[PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 27 05:22:03 PDT 2016


NoQ created this revision.
NoQ added a reviewer: zaks.anna.
NoQ added subscribers: dcoughlin, xazax.hun, a.sidorin, cfe-commits.

The `-analyze-function` option is very useful when debugging test failures, especially when printing or viewing exploded graphs - with this option you no longer need to delete or comment out other test cases.

But because this option accepts unqualified identifiers, it is hard to use this option in C++ tests (in which you often need to test a particular method of a particular class, but there's no way to specify the class, eg. D22374).

This patch changes `-analyze-function` to accept qualified names. Because `-analyzer-display-progress` has recently been changed to display qualified names, you can use `-analyzer-display-progress` to quickly lookup the exact name you need to put into `-analyze-function`.

Yeah, i agree it's a good idea to update the debugging tricks doc, just as soon as i get to it :)

https://reviews.llvm.org/D22856

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/analyzeOneFunction.m

Index: test/Analysis/analyzeOneFunction.m
===================================================================
--- test/Analysis/analyzeOneFunction.m
+++ test/Analysis/analyzeOneFunction.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyze-function="Test1::myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===================================================================
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -569,14 +569,8 @@
 }
 
 static std::string getFunctionName(const Decl *D) {
-  if (const ObjCMethodDecl *ID = dyn_cast<ObjCMethodDecl>(D)) {
-    return ID->getSelector().getAsString();
-  }
-  if (const FunctionDecl *ND = dyn_cast<FunctionDecl>(D)) {
-    IdentifierInfo *II = ND->getIdentifier();
-    if (II)
-      return II->getName();
-  }
+  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
+    return ND->getQualifiedNameAsString();
   return "";
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22856.65710.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160727/4a3cd000/attachment.bin>


More information about the cfe-commits mailing list