diff options
author | Kristof Umann <dkszelethus@gmail.com> | 2019-08-13 18:48:08 +0000 |
---|---|---|
committer | Kristof Umann <dkszelethus@gmail.com> | 2019-08-13 18:48:08 +0000 |
commit | fedc6539be61a7e21bd23b17db9d8d27f1201ee3 (patch) | |
tree | f7eeb9894343c68f410ca531eb0d36128faaca87 /include | |
parent | 8ac879c039dc6e6fd4a5984416d5acaf8b5a7764 (diff) | |
download | clang-fedc6539be61a7e21bd23b17db9d8d27f1201ee3.tar.gz |
[analyzer][NFC] Refactoring BugReporter.cpp P4.: If it can be const, make it const
When I'm new to a file/codebase, I personally find C++'s strong static type
system to be a great aid. BugReporter.cpp is still painful to read however:
function calls are made with mile long parameter lists, seemingly all of them
taken with a non-const reference/pointer. This patch fixes nothing but this:
make a few things const, and hammer it until it compiles.
Differential Revision: https://reviews.llvm.org/D65382
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
7 files changed, 28 insertions, 18 deletions
diff --git a/include/clang/Analysis/AnalysisDeclContext.h b/include/clang/Analysis/AnalysisDeclContext.h index d5445d3ce5..9faa78cde8 100644 --- a/include/clang/Analysis/AnalysisDeclContext.h +++ b/include/clang/Analysis/AnalysisDeclContext.h @@ -257,7 +257,7 @@ public: return getAnalysisDeclContext()->getAnalysis<T>(); } - ParentMap &getParentMap() const { + const ParentMap &getParentMap() const { return getAnalysisDeclContext()->getParentMap(); } diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 9a16f23461..f73fd29805 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -217,10 +217,10 @@ public: 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 @@ public: 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<DiagnosticForConsumerMapTy> generatePathDiagnostics(ArrayRef<PathDiagnosticConsumer *> consumers, @@ -519,12 +519,14 @@ public: /// 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 @@ public: 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(); } diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h index ecd5ed0ca3..0e2346174a 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -74,7 +74,8 @@ public: /// 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; diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index f982595600..7ccf569a68 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -919,7 +919,6 @@ public: }; } // namespace ento - } // namespace clang #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index 981133e669..1d2e554ec2 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -103,7 +103,7 @@ public: return Eng.getBugReporter(); } - SourceManager &getSourceManager() { + const SourceManager &getSourceManager() { return getBugReporter().getSourceManager(); } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h index 52ae92e70d..864266e77e 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -153,7 +153,11 @@ public: CFG &getCFG() const { return *getLocationContext()->getCFG(); } - ParentMap &getParentMap() const {return getLocationContext()->getParentMap();} + const CFGBlock *getCFGBlock() const; + + const ParentMap &getParentMap() const { + return getLocationContext()->getParentMap(); + } template <typename T> T &getAnalysis() const { diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index d38058f9af..07920790c8 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -507,6 +507,10 @@ public: return *svalBuilder; } + const SValBuilder &getSValBuilder() const { + return *svalBuilder; + } + SymbolManager &getSymbolManager() { return svalBuilder->getSymbolManager(); } |