eandrews created this revision. eandrews added reviewers: aaron.ballman, tahonermann. Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware. Herald added a reviewer: NoQ. Herald added a project: All. eandrews requested review of this revision.
Fix static analyzer concerns about dereferencing null values https://reviews.llvm.org/D157118 Files: clang/lib/AST/StmtPrinter.cpp clang/lib/Analysis/PathDiagnostic.cpp Index: clang/lib/Analysis/PathDiagnostic.cpp =================================================================== --- clang/lib/Analysis/PathDiagnostic.cpp +++ clang/lib/Analysis/PathDiagnostic.cpp @@ -584,6 +584,7 @@ PathDiagnosticLocation::createBegin(const Stmt *S, const SourceManager &SM, LocationOrAnalysisDeclContext LAC) { + assert(S && "Statement cannot be null"); return PathDiagnosticLocation(getValidSourceLocation(S, LAC), SM, SingleLocK); } Index: clang/lib/AST/StmtPrinter.cpp =================================================================== --- clang/lib/AST/StmtPrinter.cpp +++ clang/lib/AST/StmtPrinter.cpp @@ -175,6 +175,7 @@ /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and /// with no newline after the }. void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) { + assert(Node && "Compound statement cannot be null"); OS << "{" << NL; PrintFPPragmas(Node); for (auto *I : Node->body())
Index: clang/lib/Analysis/PathDiagnostic.cpp =================================================================== --- clang/lib/Analysis/PathDiagnostic.cpp +++ clang/lib/Analysis/PathDiagnostic.cpp @@ -584,6 +584,7 @@ PathDiagnosticLocation::createBegin(const Stmt *S, const SourceManager &SM, LocationOrAnalysisDeclContext LAC) { + assert(S && "Statement cannot be null"); return PathDiagnosticLocation(getValidSourceLocation(S, LAC), SM, SingleLocK); } Index: clang/lib/AST/StmtPrinter.cpp =================================================================== --- clang/lib/AST/StmtPrinter.cpp +++ clang/lib/AST/StmtPrinter.cpp @@ -175,6 +175,7 @@ /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and /// with no newline after the }. void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) { + assert(Node && "Compound statement cannot be null"); OS << "{" << NL; PrintFPPragmas(Node); for (auto *I : Node->body())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits