aboutsummaryrefslogtreecommitdiffstats
path: root/include/clang/StaticAnalyzer/Core/CheckerManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/StaticAnalyzer/Core/CheckerManager.h')
-rw-r--r--include/clang/StaticAnalyzer/Core/CheckerManager.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 6cc4baa1687f..38a9aaf72c27 100644
--- a/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -90,21 +90,23 @@ enum PointerEscapeKind {
PSK_EscapeOther
};
-// This wrapper is used to ensure that only StringRefs originating from the
-// CheckerRegistry are used as check names. We want to make sure all check
-// name strings have a lifetime that keeps them alive at least until the path
-// diagnostics have been processed.
-class CheckName {
+/// This wrapper is used to ensure that only StringRefs originating from the
+/// CheckerRegistry are used as check names. We want to make sure all checker
+/// name strings have a lifetime that keeps them alive at least until the path
+/// diagnostics have been processed, since they are expected to be constexpr
+/// string literals (most likely generated by TblGen).
+class CheckerNameRef {
friend class ::clang::ento::CheckerRegistry;
StringRef Name;
- explicit CheckName(StringRef Name) : Name(Name) {}
+ explicit CheckerNameRef(StringRef Name) : Name(Name) {}
public:
- CheckName() = default;
+ CheckerNameRef() = default;
StringRef getName() const { return Name; }
+ operator StringRef() const { return Name; }
};
enum class ObjCMessageVisitKind {
@@ -117,7 +119,7 @@ class CheckerManager {
ASTContext &Context;
const LangOptions LangOpts;
AnalyzerOptions &AOptions;
- CheckName CurrentCheckName;
+ CheckerNameRef CurrentCheckerName;
public:
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions)
@@ -125,8 +127,8 @@ public:
~CheckerManager();
- void setCurrentCheckName(CheckName name) { CurrentCheckName = name; }
- CheckName getCurrentCheckName() const { return CurrentCheckName; }
+ void setCurrentCheckerName(CheckerNameRef name) { CurrentCheckerName = name; }
+ CheckerNameRef getCurrentCheckerName() const { return CurrentCheckerName; }
bool hasPathSensitiveCheckers() const;
@@ -162,7 +164,7 @@ public:
assert(!ref && "Checker already registered, use getChecker!");
CHECKER *checker = new CHECKER(std::forward<AT>(Args)...);
- checker->Name = CurrentCheckName;
+ checker->Name = CurrentCheckerName;
CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
CHECKER::_register(checker, *this);
ref = checker;