[clang] 724afa5 - [analyzer] Inline StringSet that's defined in a header

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 13 14:51:14 PDT 2020


Author: Benjamin Kramer
Date: 2020-07-13T23:51:05+02:00
New Revision: 724afa5a331372ff1684f2bffa6976887490cbaf

URL: https://github.com/llvm/llvm-project/commit/724afa5a331372ff1684f2bffa6976887490cbaf
DIFF: https://github.com/llvm/llvm-project/commit/724afa5a331372ff1684f2bffa6976887490cbaf.diff

LOG: [analyzer] Inline StringSet that's defined in a header

That's just asking for ODR violations. Also drop a call to lower()
that's not needed.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
index 89b8965e4c9a..ec43a23e30a9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
@@ -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);
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 91f289078814..bcc7d4103c1c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -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;
 }


        


More information about the cfe-commits mailing list