[PATCH] D15921: [analyzer] Utility to match function calls.

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 6 11:22:42 PST 2016


zaks.anna added inline comments.

================
Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:309
@@ -286,1 +308,3 @@
 
+  /// \brief Returns true if the CallEvent is call to a function that matches
+  /// the CallDescription.
----------------
"is call" -> "is a call"

================
Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:41
@@ +40,3 @@
+                              const CallDescription &CD) {
+  assert(Call.getKind() != CE_ObjCMessage);
+  if (!CD.II)
----------------
Please, add && "ObjC Methods are not supported"

================
Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:47
@@ +46,3 @@
+    return false;
+  return Call.getCalleeIdentifier() == CD.II;
+}
----------------
You can micro optimize by checking if the identifier matches first (and only checking arguments later); in most cases it won't.

================
Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:57
@@ +56,3 @@
+    return false;
+  return Call.getSelector() == getASTContext().Selectors.getSelector(0, &CD.II);
+}
----------------
This will only match against the first part of the ObjC method name. Also, this is not tested. I am Ok with adding the ObjC support later and adding an assert above to error out if this is used for ObjC.


http://reviews.llvm.org/D15921





More information about the cfe-commits mailing list