Index: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h =================================================================== --- cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h +++ cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h @@ -257,7 +257,7 @@ return getAnalysisDeclContext()->getAnalysis(); } - ParentMap &getParentMap() const { + const ParentMap &getParentMap() const { return getAnalysisDeclContext()->getParentMap(); } Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -217,10 +217,10 @@ void markInteresting(SVal V); void markInteresting(const LocationContext *LC); - bool isInteresting(SymbolRef sym); - bool isInteresting(const MemRegion *R); - bool isInteresting(SVal V); - bool isInteresting(const LocationContext *LC); + bool isInteresting(SymbolRef sym) const; + bool isInteresting(const MemRegion *R) const; + bool isInteresting(SVal V) const; + bool isInteresting(const LocationContext *LC) const; /// Returns whether or not this report should be considered valid. /// @@ -469,9 +469,9 @@ ASTContext &getContext() { return D.getASTContext(); } - SourceManager &getSourceManager() { return D.getSourceManager(); } + const SourceManager &getSourceManager() { return D.getSourceManager(); } - AnalyzerOptions &getAnalyzerOptions() { return D.getAnalyzerOptions(); } + const AnalyzerOptions &getAnalyzerOptions() { return D.getAnalyzerOptions(); } virtual std::unique_ptr generatePathDiagnostics(ArrayRef consumers, @@ -519,12 +519,14 @@ /// getGraph - Get the exploded graph created by the analysis engine /// for the analyzed method or function. - ExplodedGraph &getGraph(); + const ExplodedGraph &getGraph() const; /// getStateManager - Return the state manager used by the analysis /// engine. ProgramStateManager &getStateManager(); + ProgramStateManager &getStateManager() const; + /// \p bugReports A set of bug reports within a *single* equivalence class /// /// \return A mapping from consumers to the corresponding diagnostics. @@ -566,25 +568,25 @@ GRBugReporter& getBugReporter() { return BR; } - ExplodedGraph &getGraph() { return BR.getGraph(); } + const ExplodedGraph &getGraph() const { return BR.getGraph(); } - ProgramStateManager& getStateManager() { + ProgramStateManager& getStateManager() const { return BR.getStateManager(); } - SValBuilder &getSValBuilder() { + SValBuilder &getSValBuilder() const { return getStateManager().getSValBuilder(); } - ASTContext &getASTContext() { + ASTContext &getASTContext() const { return BR.getContext(); } - SourceManager& getSourceManager() { + const SourceManager& getSourceManager() const { return BR.getSourceManager(); } - AnalyzerOptions &getAnalyzerOptions() { + const AnalyzerOptions &getAnalyzerOptions() const { return BR.getAnalyzerOptions(); } Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -74,7 +74,8 @@ /// NOTE that this function can be implemented on at most one used visitor, /// and otherwise it crahes at runtime. virtual PathDiagnosticPieceRef - getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR); + getEndPath(BugReporterContext &BRC, const ExplodedNode *N, + BugReport &BR); virtual void Profile(llvm::FoldingSetNodeID &ID) const = 0; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -919,7 +919,6 @@ }; } // namespace ento - } // namespace clang #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -103,7 +103,7 @@ return Eng.getBugReporter(); } - SourceManager &getSourceManager() { + const SourceManager &getSourceManager() { return getBugReporter().getSourceManager(); } Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -153,7 +153,11 @@ CFG &getCFG() const { return *getLocationContext()->getCFG(); } - ParentMap &getParentMap() const {return getLocationContext()->getParentMap();} + const CFGBlock *getCFGBlock() const; + + const ParentMap &getParentMap() const { + return getLocationContext()->getParentMap(); + } template T &getAnalysis() const { Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -507,6 +507,10 @@ return *svalBuilder; } + const SValBuilder &getSValBuilder() const { + return *svalBuilder; + } + SymbolManager &getSymbolManager() { return svalBuilder->getSymbolManager(); } Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1086,7 +1086,7 @@ if (!isStandardNewDelete(NE->getOperatorNew(), C.getASTContext())) return; - ParentMap &PM = C.getLocationContext()->getParentMap(); + const ParentMap &PM = C.getLocationContext()->getParentMap(); if (!PM.isConsumedExpr(NE) && treatUnusedNewEscaped(NE)) return; Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -94,7 +94,7 @@ } static void Scan(IvarUsageMap &M, const DeclContext *C, const FileID FID, - SourceManager &SM) { + const SourceManager &SM) { for (const auto *I : C->decls()) if (const auto *FD = dyn_cast(I)) { SourceLocation L = FD->getBeginLoc(); @@ -148,7 +148,7 @@ // FIXME: In the future hopefully we can just use the lexical DeclContext // to go from the ObjCImplementationDecl to the lexically "nested" // C functions. - SourceManager &SM = BR.getSourceManager(); + const SourceManager &SM = BR.getSourceManager(); Scan(M, D->getDeclContext(), SM.getFileID(D->getLocation()), SM); // Find ivars that are unused. Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp @@ -736,7 +736,7 @@ const MemRegion* FirstBinding = AllocI.R; BR.markInteresting(AllocI.InterestingMethodContext); - SourceManager& SM = BRC.getSourceManager(); + const SourceManager& SM = BRC.getSourceManager(); // Compute an actual location for the leak. Sometimes a leak doesn't // occur at an actual statement (e.g., transition between blocks; end Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -55,7 +55,7 @@ const Decl *D = nullptr; CFG *C = nullptr; - ParentMap *PM = nullptr; + const ParentMap *PM = nullptr; const LocationContext *LC = nullptr; // Iterate over ExplodedGraph for (ExplodedGraph::node_iterator I = G.nodes_begin(), E = G.nodes_end(); Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -190,8 +190,8 @@ /// Recursively scan through a path and prune out calls and macros pieces /// that aren't needed. Return true if afterwards the path contains /// "interesting stuff" which means it shouldn't be pruned from the parent path. -static bool removeUnneededCalls(PathPieces &pieces, BugReport *R, - LocationContextMap &LCM, +static bool removeUnneededCalls(PathPieces &pieces, const BugReport *R, + const LocationContextMap &LCM, bool IsInteresting = false) { bool containsSomethingInteresting = IsInteresting; const unsigned N = pieces.size(); @@ -208,7 +208,7 @@ // Check if the location context is interesting. assert(LCM.count(&call.path)); if (!removeUnneededCalls(call.path, R, LCM, - R->isInteresting(LCM[&call.path]))) + R->isInteresting(LCM.lookup(&call.path)))) continue; containsSomethingInteresting = true; @@ -353,33 +353,33 @@ class PathDiagnosticBuilder : public BugReporterContext { BugReport *R; - PathDiagnosticConsumer *PDC; + const PathDiagnosticConsumer *PDC; public: const LocationContext *LC; PathDiagnosticBuilder(GRBugReporter &br, BugReport *r, InterExplodedGraphMap &Backmap, - PathDiagnosticConsumer *pdc) + const PathDiagnosticConsumer *pdc) : BugReporterContext(br, Backmap), R(r), PDC(pdc), LC(r->getErrorNode()->getLocationContext()) {} - PathDiagnosticLocation ExecutionContinues(const ExplodedNode *N); + PathDiagnosticLocation ExecutionContinues(const ExplodedNode *N) const; PathDiagnosticLocation ExecutionContinues(llvm::raw_string_ostream &os, - const ExplodedNode *N); + const ExplodedNode *N) const; BugReport *getBugReport() { return R; } - Decl const &getCodeDecl() { return R->getErrorNode()->getCodeDecl(); } + const Decl &getCodeDecl() const { return R->getErrorNode()->getCodeDecl(); } - ParentMap& getParentMap() { return LC->getParentMap(); } + const ParentMap& getParentMap() const { return LC->getParentMap(); } - const Stmt *getParent(const Stmt *S) { + const Stmt *getParent(const Stmt *S) const { return getParentMap().getParent(S); } - PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S); + PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S) const; PathDiagnosticConsumer::PathGenerationScheme getGenerationScheme() const { return PDC ? PDC->getGenerationScheme() : PathDiagnosticConsumer::Minimal; @@ -393,7 +393,7 @@ } // namespace PathDiagnosticLocation -PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode *N) { +PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode *N) const { if (const Stmt *S = PathDiagnosticLocation::getNextStmt(N)) return PathDiagnosticLocation(S, getSourceManager(), LC); @@ -403,7 +403,7 @@ PathDiagnosticLocation PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream &os, - const ExplodedNode *N) { + const ExplodedNode *N) const { // Slow, but probably doesn't matter. if (os.str().empty()) os << ' '; @@ -454,8 +454,9 @@ } static PathDiagnosticLocation -getEnclosingStmtLocation(const Stmt *S, SourceManager &SMgr, const ParentMap &P, - const LocationContext *LC, bool allowNestedContexts) { +getEnclosingStmtLocation(const Stmt *S, const SourceManager &SMgr, + const ParentMap &P, const LocationContext *LC, + bool allowNestedContexts) { if (!S) return {}; @@ -521,7 +522,7 @@ } PathDiagnosticLocation -PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) { +PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) const { assert(S && "Null Stmt passed to getEnclosingStmtLocation"); return ::getEnclosingStmtLocation(S, getSourceManager(), getParentMap(), LC, /*allowNestedContexts=*/false); @@ -535,7 +536,7 @@ using StackDiagVector = SmallVector; static void updateStackPiecesWithMessage(PathDiagnosticPiece &P, - StackDiagVector &CallStack) { + const StackDiagVector &CallStack) { // If the piece contains a special message, add it to all the call // pieces on the active stack. if (auto *ep = dyn_cast(&P)) { @@ -563,7 +564,7 @@ const CFGBlock *Dst, const SourceManager &SM, const LocationContext *LC, - PathDiagnosticBuilder &PDB, + const PathDiagnosticBuilder &PDB, PathDiagnosticLocation &Start ) { // Figure out what case arm we took. @@ -622,7 +623,7 @@ std::shared_ptr generateDiagForGotoOP( const Stmt *S, - PathDiagnosticBuilder &PDB, + const PathDiagnosticBuilder &PDB, PathDiagnosticLocation &Start) { std::string sbuf; llvm::raw_string_ostream os(sbuf); @@ -633,13 +634,10 @@ } std::shared_ptr generateDiagForBinaryOP( - const ExplodedNode *N, - const Stmt *T, - const CFGBlock *Src, - const CFGBlock *Dst, - const SourceManager &SM, - PathDiagnosticBuilder &PDB, - const LocationContext *LC) { + const ExplodedNode *N, const Stmt *T, const CFGBlock *Src, + const CFGBlock *Dst, const SourceManager &SM, + const PathDiagnosticBuilder &PDB, const LocationContext *LC) { + const auto *B = cast(T); std::string sbuf; llvm::raw_string_ostream os(sbuf); @@ -682,7 +680,7 @@ void generateMinimalDiagForBlockEdge(const ExplodedNode *N, BlockEdge BE, const SourceManager &SM, - PathDiagnosticBuilder &PDB, + const PathDiagnosticBuilder &PDB, PathDiagnostic &PD) { const LocationContext *LC = N->getLocationContext(); const CFGBlock *Src = BE.getSrc(); @@ -916,7 +914,8 @@ return (*(Src->succ_begin()+1) == BE->getDst()); } -static bool isContainedByStmt(ParentMap &PM, const Stmt *S, const Stmt *SubS) { +static bool isContainedByStmt(const ParentMap &PM, const Stmt *S, + const Stmt *SubS) { while (SubS) { if (SubS == S) return true; @@ -925,7 +924,7 @@ return false; } -static const Stmt *getStmtBeforeCond(ParentMap &PM, const Stmt *Term, +static const Stmt *getStmtBeforeCond(const ParentMap &PM, const Stmt *Term, const ExplodedNode *N) { while (N) { Optional SP = N->getLocation().getAs(); @@ -939,7 +938,7 @@ return nullptr; } -static bool isInLoopBody(ParentMap &PM, const Stmt *S, const Stmt *Term) { +static bool isInLoopBody(const ParentMap &PM, const Stmt *S, const Stmt *Term) { const Stmt *LoopBody = nullptr; switch (Term->getStmtClass()) { case Stmt::CXXForRangeStmtClass: { @@ -1007,15 +1006,14 @@ return S; } -static const char StrEnteringLoop[] = "Entering loop body"; -static const char StrLoopBodyZero[] = "Loop body executed 0 times"; -static const char StrLoopRangeEmpty[] = - "Loop body skipped when range is empty"; -static const char StrLoopCollectionEmpty[] = - "Loop body skipped when collection is empty"; +llvm::StringLiteral StrEnteringLoop = "Entering loop body"; +llvm::StringLiteral StrLoopBodyZero = "Loop body executed 0 times"; +llvm::StringLiteral StrLoopRangeEmpty = "Loop body skipped when range is empty"; +llvm::StringLiteral StrLoopCollectionEmpty = + "Loop body skipped when collection is empty"; static std::unique_ptr -findExecutedLines(SourceManager &SM, const ExplodedNode *N); +findExecutedLines(const SourceManager &SM, const ExplodedNode *N); /// Generate diagnostics for the node \p N, /// and write it into \p PD. @@ -1210,7 +1208,7 @@ } const CFGBlock *BSrc = BE->getSrc(); - ParentMap &PM = PDB.getParentMap(); + const ParentMap &PM = PDB.getParentMap(); if (const Stmt *Term = BSrc->getTerminatorStmt()) { // Are we jumping past the loop body without ever executing the @@ -1220,7 +1218,7 @@ bool IsInLoopBody = isInLoopBody(PM, getStmtBeforeCond(PM, TermCond, N), Term); - const char *str = nullptr; + StringRef str; if (isJumpToFalseBranch(&*BE)) { if (!IsInLoopBody) { @@ -1236,7 +1234,7 @@ str = StrEnteringLoop; } - if (str) { + if (!str.empty()) { PathDiagnosticLocation L(TermCond ? TermCond : Term, SM, PDB.LC); auto PE = std::make_shared(L, str); PE->setPrunable(true); @@ -1254,7 +1252,7 @@ } static std::unique_ptr -generateEmptyDiagnosticForReport(BugReport *R, SourceManager &SM) { +generateEmptyDiagnosticForReport(const BugReport *R, const SourceManager &SM) { const BugType &BT = R->getBugType(); return llvm::make_unique( R->getBugType().getCheckName(), R->getDeclWithIssue(), @@ -1342,7 +1340,7 @@ /// This avoids a "swoosh" effect, where an edge from a top-level statement A /// points to a sub-expression B.1 that's not at the start of B. In these cases, /// we'd like to see an edge from A to B, then another one from B to B.1. -static void addContextEdges(PathPieces &pieces, SourceManager &SM, +static void addContextEdges(PathPieces &pieces, const SourceManager &SM, const ParentMap &PM, const LocationContext *LCtx) { PathPieces::iterator Prev = pieces.end(); for (PathPieces::iterator I = pieces.begin(), E = Prev; I != E; @@ -1493,7 +1491,7 @@ /// If the locations in the range are not on the same line, returns None. /// /// Note that this does not do a precise user-visible character or column count. -static Optional getLengthOnSingleLine(SourceManager &SM, +static Optional getLengthOnSingleLine(const SourceManager &SM, SourceRange Range) { SourceRange ExpansionRange(SM.getExpansionLoc(Range.getBegin()), SM.getExpansionRange(Range.getEnd()).getEnd()); @@ -1523,7 +1521,7 @@ } /// \sa getLengthOnSingleLine(SourceManager, SourceRange) -static Optional getLengthOnSingleLine(SourceManager &SM, +static Optional getLengthOnSingleLine(const SourceManager &SM, const Stmt *S) { return getLengthOnSingleLine(SM, S->getSourceRange()); } @@ -1544,7 +1542,7 @@ /// - if there is an inlined call between the edges instead of a single event. /// - if the whole statement is large enough that having subexpression arrows /// might be helpful. -static void removeContextCycles(PathPieces &Path, SourceManager &SM) { +static void removeContextCycles(PathPieces &Path, const SourceManager &SM) { for (PathPieces::iterator I = Path.begin(), E = Path.end(); I != E; ) { // Pattern match the current piece and its successor. const auto *PieceI = dyn_cast(I->get()); @@ -1599,7 +1597,7 @@ } /// Return true if X is contained by Y. -static bool lexicalContains(ParentMap &PM, const Stmt *X, const Stmt *Y) { +static bool lexicalContains(const ParentMap &PM, const Stmt *X, const Stmt *Y) { while (X) { if (X == Y) return true; @@ -1609,8 +1607,8 @@ } // Remove short edges on the same line less than 3 columns in difference. -static void removePunyEdges(PathPieces &path, SourceManager &SM, - ParentMap &PM) { +static void removePunyEdges(PathPieces &path, const SourceManager &SM, + const ParentMap &PM) { bool erased = false; for (PathPieces::iterator I = path.begin(), E = path.end(); I != E; @@ -1685,13 +1683,13 @@ } } -static bool optimizeEdges(PathPieces &path, SourceManager &SM, +static bool optimizeEdges(PathPieces &path, const SourceManager &SM, OptimizedCallsSet &OCS, - LocationContextMap &LCM) { + const LocationContextMap &LCM) { bool hasChanges = false; - const LocationContext *LC = LCM[&path]; + const LocationContext *LC = LCM.lookup(&path); assert(LC); - ParentMap &PM = LC->getParentMap(); + const ParentMap &PM = LC->getParentMap(); for (PathPieces::iterator I = path.begin(), E = path.end(); I != E; ) { // Optimize subpaths. @@ -1866,14 +1864,15 @@ /// statement had an invalid source location), this function does nothing. // FIXME: We should just generate invalid edges anyway and have the optimizer // deal with them. -static void dropFunctionEntryEdge(PathPieces &Path, LocationContextMap &LCM, - SourceManager &SM) { +static void dropFunctionEntryEdge(PathPieces &Path, + const LocationContextMap &LCM, + const SourceManager &SM) { const auto *FirstEdge = dyn_cast(Path.front().get()); if (!FirstEdge) return; - const Decl *D = LCM[&Path]->getDecl(); + const Decl *D = LCM.lookup(&Path)->getDecl(); PathDiagnosticLocation EntryLoc = PathDiagnosticLocation::createBegin(D, SM); if (FirstEdge->getStartLocation() != EntryLoc) return; @@ -1919,9 +1918,9 @@ bool GenerateDiagnostics = (ActiveScheme != PathDiagnosticConsumer::None); bool AddPathEdges = (ActiveScheme == PathDiagnosticConsumer::Extensive); - SourceManager &SM = PDB.getSourceManager(); - BugReport *R = PDB.getBugReport(); - AnalyzerOptions &Opts = PDB.getBugReporter().getAnalyzerOptions(); + const SourceManager &SM = PDB.getSourceManager(); + const BugReport *R = PDB.getBugReport(); + const AnalyzerOptions &Opts = PDB.getBugReporter().getAnalyzerOptions(); StackDiagVector CallStack; InterestingExprs IE; LocationContextMap LCM; @@ -1934,7 +1933,8 @@ assert(!EndNotes->second.empty()); LastPiece = EndNotes->second[0]; } else { - LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, ErrorNode, *R); + LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, ErrorNode, + *PDB.getBugReport()); } PD->setEndOfPath(LastPiece); } @@ -1959,8 +1959,7 @@ for (const PathDiagnosticPieceRef &Note : VisitorNotes->second) { llvm::FoldingSetNodeID ID; Note->Profile(ID); - auto P = DeduplicationSet.insert(ID); - if (!P.second) + if (!DeduplicationSet.insert(ID).second) continue; if (AddPathEdges) @@ -2122,11 +2121,11 @@ InterestingLocationContexts.insert(LC); } -bool BugReport::isInteresting(SVal V) { +bool BugReport::isInteresting(SVal V) const { return isInteresting(V.getAsRegion()) || isInteresting(V.getAsSymbol()); } -bool BugReport::isInteresting(SymbolRef sym) { +bool BugReport::isInteresting(SymbolRef sym) const { if (!sym) return false; // We don't currently consider metadata symbols to be interesting @@ -2134,7 +2133,7 @@ return InterestingSymbols.count(sym); } -bool BugReport::isInteresting(const MemRegion *R) { +bool BugReport::isInteresting(const MemRegion *R) const { if (!R) return false; R = R->getBaseRegion(); @@ -2146,7 +2145,7 @@ return false; } -bool BugReport::isInteresting(const LocationContext *LC) { +bool BugReport::isInteresting(const LocationContext *LC) const { if (!LC) return false; return InterestingLocationContexts.count(LC); @@ -2202,11 +2201,14 @@ // Methods for BugReporter and subclasses. //===----------------------------------------------------------------------===// -ExplodedGraph &GRBugReporter::getGraph() { return Eng.getGraph(); } +const ExplodedGraph &GRBugReporter::getGraph() const { return Eng.getGraph(); } ProgramStateManager& GRBugReporter::getStateManager() { return Eng.getStateManager(); } +ProgramStateManager& +GRBugReporter::getStateManager() const { return Eng.getStateManager(); } + BugReporter::~BugReporter() { FlushReports(); @@ -2984,7 +2986,7 @@ /// Insert all lines participating in the function signature \p Signature /// into \p ExecutedLines. static void populateExecutedLinesWithFunctionSignature( - const Decl *Signature, SourceManager &SM, + const Decl *Signature, const SourceManager &SM, FilesToLineNumsMap &ExecutedLines) { SourceRange SignatureSourceRange; const Stmt* Body = Signature->getBody(); @@ -3009,7 +3011,7 @@ } static void populateExecutedLinesWithStmt( - const Stmt *S, SourceManager &SM, + const Stmt *S, const SourceManager &SM, FilesToLineNumsMap &ExecutedLines) { SourceLocation Loc = S->getSourceRange().getBegin(); if (!Loc.isValid()) @@ -3023,7 +3025,7 @@ /// \return all executed lines including function signatures on the path /// starting from \p N. static std::unique_ptr -findExecutedLines(SourceManager &SM, const ExplodedNode *N) { +findExecutedLines(const SourceManager &SM, const ExplodedNode *N) { auto ExecutedLines = llvm::make_unique(); while (N) { @@ -3087,7 +3089,7 @@ // Examine the report and see if the last piece is in a header. Reset the // report location to the last piece in the main source file. - AnalyzerOptions &Opts = getAnalyzerOptions(); + const AnalyzerOptions &Opts = getAnalyzerOptions(); for (auto const &P : *Out) if (Opts.ShouldReportIssuesInMainSourceFile && !Opts.AnalyzeAll) P.second->resetDiagnosticLocationToMainFile(); Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2250,7 +2250,7 @@ SourceLocation BeginLoc = OriginalExpr->getBeginLoc(); SourceLocation EndLoc = OriginalExpr->getEndLoc(); if (BeginLoc.isMacroID() && EndLoc.isMacroID()) { - SourceManager &SM = BRC.getSourceManager(); + const SourceManager &SM = BRC.getSourceManager(); const LangOptions &LO = BRC.getASTContext().getLangOpts(); if (Lexer::isAtStartOfMacroExpansion(BeginLoc, SM, LO) && Lexer::isAtEndOfMacroExpansion(EndLoc, SM, LO)) { @@ -2587,7 +2587,7 @@ BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR) { // Here we suppress false positives coming from system headers. This list is // based on known issues. - AnalyzerOptions &Options = BRC.getAnalyzerOptions(); + const AnalyzerOptions &Options = BRC.getAnalyzerOptions(); const Decl *D = N->getLocationContext()->getDecl(); if (AnalysisDeclContext::isInStdNamespace(D)) { @@ -2654,7 +2654,7 @@ // Skip reports within the sys/queue.h macros as we do not have the ability to // reason about data structure shapes. - SourceManager &SM = BRC.getSourceManager(); + const SourceManager &SM = BRC.getSourceManager(); FullSourceLoc Loc = BR.getLocation(SM).asLocation(); while (Loc.isMacroID()) { Loc = Loc.getSpellingLoc(); Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -1035,7 +1035,7 @@ ObjCMessageKind ObjCMethodCall::getMessageKind() const { if (!Data) { // Find the parent, ignoring implicit casts. - ParentMap &PM = getLocationContext()->getParentMap(); + const ParentMap &PM = getLocationContext()->getParentMap(); const Stmt *S = PM.getParentIgnoreParenCasts(getOriginExpr()); // Check if parent is a PseudoObjectExpr. Index: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -134,7 +134,7 @@ // Do not collect nodes for non-consumed Stmt or Expr to ensure precise // diagnostic generation; specifically, so that we could anchor arrows // pointing to the beginning of statements (as written in code). - ParentMap &PM = progPoint.getLocationContext()->getParentMap(); + const ParentMap &PM = progPoint.getLocationContext()->getParentMap(); if (!PM.isConsumedExpr(Ex)) return false;