[analyzer] Inline StringSet that's defined in a header
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 13 Jul 2020 21:50:00 +0000 (23:50 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 13 Jul 2020 21:51:05 +0000 (23:51 +0200)
That's just asking for ODR violations. Also drop a call to lower()
that's not needed.

clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp

index 89b8965..ec43a23 100644 (file)
@@ -20,13 +20,6 @@ namespace clang {
 namespace ento {
 namespace smartptr {
 
-/// Set of STL smart pointer class which we are trying to model.
-const llvm::StringSet<> StdSmartPtrs = {
-    "shared_ptr",
-    "unique_ptr",
-    "weak_ptr",
-};
-
 /// Returns true if the event call is on smart pointer.
 bool isStdSmartPtrCall(const CallEvent &Call);
 
index 91f2890..bcc7d41 100644 (file)
@@ -73,7 +73,8 @@ bool isStdSmartPtrCall(const CallEvent &Call) {
     return false;
 
   if (RecordDecl->getDeclName().isIdentifier()) {
-    return smartptr::StdSmartPtrs.count(RecordDecl->getName().lower());
+    StringRef Name = RecordDecl->getName();
+    return Name == "shared_ptr" || Name == "unique_ptr" || Name == "weak_ptr";
   }
   return false;
 }