[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 2 16:27:29 PDT 2018

NoQ added inline comments.

Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:68
     : IILockGuard(nullptr), IIUniqueLock(nullptr),
-      LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"),
-      FgetsFn("fgets"), ReadFn("read"), RecvFn("recv"),
-      PthreadLockFn("pthread_mutex_lock"),
-      PthreadTryLockFn("pthread_mutex_trylock"),
-      PthreadUnlockFn("pthread_mutex_unlock"),
-      MtxLock("mtx_lock"),
-      MtxTimedLock("mtx_timedlock"),
-      MtxTryLock("mtx_trylock"),
-      MtxUnlock("mtx_unlock"),
+      LockFn({"lock"}), UnlockFn({"unlock"}), SleepFn({"sleep"}), GetcFn({"getc"}),
+      FgetsFn({"fgets"}), ReadFn({"read"}), RecvFn({"recv"}),
I wish the old syntax for simple C functions was preserved.

This could be accidentally achieved by using `ArrayRef<StringRef>` instead of `std::vector<StringRef>` for your constructor's argument.

Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:273-280
+    std::string Regex = "^::(.*)?";
+    Regex += llvm::join(CD.QualifiedName, "(.*)?::(.*)?") + "(.*)?$";
+    auto Matches = match(namedDecl(matchesName(Regex)).bind("Regex"), *ND,
+                         LCtx->getAnalysisDeclContext()->getASTContext());
+    if (Matches.empty())
Uhm, i think we don't need to flatten the class name to a string and then regex to do this.

We can just unwrap the declaration and see if the newly unwrapped layer matches the expected name on every step, until all expected names have been found.

  rC Clang


More information about the cfe-commits mailing list