[cfe-commits] r125560 - in /cfe/trunk: include/clang/StaticAnalyzer/Checkers/CheckerBase.td lib/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp lib/StaticAnalyzer/Checkers/Makefile

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Feb 14 23:42:38 PST 2011


Author: akirtzidis
Date: Tue Feb 15 01:42:38 2011
New Revision: 125560

URL: http://llvm.org/viewvc/llvm-project?rev=125560&view=rev
Log:
[analyzer] Reflect changes for tablegen'ing the checkers.

-Update tablegen files for checkers, use the tablegen class name for the checker class name.
-Update ClangSACheckersProvider to not look into hidden checker packages.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
    cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
    cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/Makefile

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td?rev=125560&r1=125559&r2=125560&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td Tue Feb 15 01:42:38 2011
@@ -24,9 +24,8 @@
 class InGroup<CheckerGroup G> { CheckerGroup Group = G; }
 
 // All checkers are an indirect subclass of this.
-class Checker<string className> {
-  string      ClassName = className;
-  string      CheckerName;
+class Checker<string name = ""> {
+  string      CheckerName = name;
   string      DescFile;
   string      HelpText;
   bit         Hidden = 0;
@@ -34,7 +33,6 @@
   CheckerGroup Group;
 }
 
-class Named<string name> { string CheckerName = name; }
 class DescFile<string filename> { string DescFile = filename; }
 class HelpText<string text> { string HelpText = text; }
 class Hidden { bit Hidden = 1; }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=125560&r1=125559&r2=125560&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Tue Feb 15 01:42:38 2011
@@ -16,32 +16,27 @@
 
 let ParentPackage = Cocoa in {
 
-def : Checker<"ObjCSelfInitChecker">,
-  Named<"SelfInit">,
+def ObjCSelfInitChecker : Checker<"SelfInit">,
   HelpText<"Check that 'self' is propely initialized inside an initializer method">,
   DescFile<"ObjCSelfInitChecker.cpp">;
 
-def : Checker<"ObjCAtSyncChecker">,
-  Named<"AtSync">,
+def ObjCAtSyncChecker : Checker<"AtSync">,
   HelpText<"Check for null pointers used as mutexes for @synchronized">,
   DescFile<"ObjCAtSyncChecker.cpp">;
 
 }
 
-def : Checker<"StackAddrLeakChecker">,
+def StackAddrLeakChecker : Checker<"StackAddrLeak">,
   InPackage<Core>,
-  Named<"StackAddrLeak">,
   HelpText<"Check that addresses to stack memory are not leaked outside the function">,
   DescFile<"StackAddrLeakChecker.cpp">;
 
-def : Checker<"UnixAPIChecker">,
+def UnixAPIChecker : Checker<"API">,
   InPackage<Unix>,
-  Named<"API">,
   HelpText<"Check calls to various UNIX/Posix functions">,
   DescFile<"UnixAPIChecker.cpp">;
 
-def : Checker<"MacOSXAPIChecker">,
+def MacOSXAPIChecker : Checker<"API">,
   InPackage<MacOSX>,
-  Named<"API">,
   HelpText<"Check calls to various MacOSXAPIChecker">,
   DescFile<"MacOSXAPIChecker.cpp">;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp?rev=125560&r1=125559&r2=125560&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp Tue Feb 15 01:42:38 2011
@@ -62,6 +62,7 @@
   const char  *Name;
   const short *Members;
   const short *SubGroups;
+  bool Hidden;
 };
 
 } // end anonymous namespace.
@@ -88,6 +89,9 @@
                             bool enable,
                          llvm::DenseSet<const StaticCheckerInfoRec *> &checkers,
                             bool collectHidden) {
+  if (checkName->Hidden && !collectHidden)
+    return;
+
   if (const short *member = checkName->Members) {
     if (enable) {
       if (collectHidden || !StaticCheckerInfo[*member].Hidden)
@@ -102,14 +106,14 @@
   if (const short *subGroups = checkName->SubGroups) {
     for (; *subGroups != -1; ++subGroups)
       collectCheckers(&CheckNameTable[*subGroups], enable, checkers,
-                      /*don't enable hidden in subgroups*/ false);
+                      collectHidden && checkName->Hidden);
   }
 }
 
 static void collectCheckers(CheckerOptInfo &opt,
                        llvm::DenseSet<const StaticCheckerInfoRec *> &checkers) {
   const char *optName = opt.getName();
-  CheckNameOption key = { optName, 0, 0 };
+  CheckNameOption key = { optName, 0, 0, false };
   const CheckNameOption *found =
   std::lower_bound(CheckNameTable, CheckNameTable + CheckNameTableSize, key,
                    CheckNameOptionCompare);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Makefile?rev=125560&r1=125559&r2=125560&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Makefile (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Makefile Tue Feb 15 01:42:38 2011
@@ -19,6 +19,6 @@
 
 include $(CLANG_LEVEL)/Makefile
 
-$(ObjDir)/Checkers.inc.tmp : Checkers.td $(TBLGEN) $(ObjDir)/.dir
+$(ObjDir)/Checkers.inc.tmp : Checkers.td $(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include/clang/StaticAnalyzer/Checkers/CheckerBase.td $(TBLGEN) $(ObjDir)/.dir
 	$(Echo) "Building Clang SA Checkers tables with tblgen"
 	$(Verb) $(TableGen) -gen-clang-sa-checkers -I $(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -o $(call SYSPATH, $@) $<





More information about the cfe-commits mailing list