diff options
Diffstat (limited to 'clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h')
-rw-r--r-- | clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index bd8760cf0ce0..8fd7f52585b8 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -107,6 +107,8 @@ public: return getBugReporter().getSourceManager(); } + Preprocessor &getPreprocessor() { return getBugReporter().getPreprocessor(); } + SValBuilder &getSValBuilder() { return Eng.getSValBuilder(); } @@ -173,8 +175,7 @@ public: /// @param Pred The transition will be generated from the specified Pred node /// to the newly generated node. /// @param Tag The tag to uniquely identify the creation site. - ExplodedNode *addTransition(ProgramStateRef State, - ExplodedNode *Pred, + ExplodedNode *addTransition(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag = nullptr) { return addTransitionImpl(State, false, Pred, Tag); } @@ -187,6 +188,14 @@ public: return addTransitionImpl(State ? State : getState(), true, Pred, Tag); } + /// Add a sink node to the current path of execution, halting analysis. + void addSink(ProgramStateRef State = nullptr, + const ProgramPointTag *Tag = nullptr) { + if (!State) + State = getState(); + addTransition(State, generateSink(State, getPredecessor())); + } + /// Generate a transition to a node that will be used to report /// an error. This node will be a sink. That is, it will stop exploration of /// the given path. @@ -256,10 +265,12 @@ public: /// @param IsPrunable Whether the note is prunable. It allows BugReporter /// to omit the note from the report if it would make the displayed /// bug path significantly shorter. - const NoteTag *getNoteTag(std::function<std::string(BugReport &)> &&Cb, - bool IsPrunable = false) { + const NoteTag + *getNoteTag(std::function<std::string(PathSensitiveBugReport &)> &&Cb, + bool IsPrunable = false) { return getNoteTag( - [Cb](BugReporterContext &, BugReport &BR) { return Cb(BR); }, + [Cb](BugReporterContext &, + PathSensitiveBugReport &BR) { return Cb(BR); }, IsPrunable); } @@ -272,7 +283,8 @@ public: /// bug path significantly shorter. const NoteTag *getNoteTag(std::function<std::string()> &&Cb, bool IsPrunable = false) { - return getNoteTag([Cb](BugReporterContext &, BugReport &) { return Cb(); }, + return getNoteTag([Cb](BugReporterContext &, + PathSensitiveBugReport &) { return Cb(); }, IsPrunable); } @@ -284,7 +296,9 @@ public: /// bug path significantly shorter. const NoteTag *getNoteTag(StringRef Note, bool IsPrunable = false) { return getNoteTag( - [Note](BugReporterContext &, BugReport &) { return Note; }, IsPrunable); + [Note](BugReporterContext &, + PathSensitiveBugReport &) { return std::string(Note); }, + IsPrunable); } /// Returns the word that should be used to refer to the declaration |