]> granicus.if.org Git - clang/commitdiff
Make the VLASizeChecker implementation private, and its creation only known to GRExpr...
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 21:51:50 +0000 (21:51 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Nov 2009 21:51:50 +0000 (21:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86292 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h [deleted file]
lib/Analysis/GRExprEngineInternalChecks.cpp
lib/Analysis/GRExprEngineInternalChecks.h
lib/Analysis/VLASizeChecker.cpp

diff --git a/include/clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h b/include/clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h
deleted file mode 100644 (file)
index b339b3d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//=== VLASizeChecker.h - Undefined dereference checker ----------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines two VLASizeCheckers, a builtin check in GRExprEngine that 
-// performs checks for declaration of VLA of undefined or zero size.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Analysis/PathSensitive/Checker.h"
-
-namespace clang {
-
-class UndefSizedVLAChecker : public Checker {
-  BugType *BT;
-
-public:
-  UndefSizedVLAChecker() : BT(0) {}
-  static void *getTag();
-  ExplodedNode *CheckType(QualType T, ExplodedNode *Pred, 
-                          const GRState *state, Stmt *S, GRExprEngine &Eng);
-};
-
-class ZeroSizedVLAChecker : public Checker {
-  BugType *BT;
-
-public:
-  ZeroSizedVLAChecker() : BT(0) {}
-  static void *getTag();
-  ExplodedNode *CheckType(QualType T, ExplodedNode *Pred, 
-                          const GRState *state, Stmt *S, GRExprEngine &Eng);
-};
-
-}
index 3daf3c8ef59cad4e1a2299c3f2d581ac47d5f53d..41ad018dcf80c8f77d9f3ca82e933ce2db5c812d 100644 (file)
@@ -21,7 +21,6 @@
 #include "clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h"
 #include "clang/Analysis/PathSensitive/Checkers/UndefinedAssignmentChecker.h"
 #include "clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h"
-#include "clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/Compiler.h"
@@ -397,13 +396,6 @@ void GRExprEngine::RegisterInternalChecks() {
   BR.Register(new NilReceiverStructRet(this));
   BR.Register(new NilReceiverLargerThanVoidPtrRet(this));
 
-  RegisterDivZeroChecker(*this);
-  RegisterReturnStackAddressChecker(*this);
-  RegisterReturnUndefChecker(*this);
-  
-  // Note that this must be registered after ReturnStackAddressChecker.
-  RegisterReturnPointerRangeChecker(*this);
-
   // The following checks do not need to have their associated BugTypes
   // explicitly registered with the BugReporter.  If they issue any BugReports,
   // their associated BugType will get registered with the BugReporter
@@ -415,6 +407,12 @@ void GRExprEngine::RegisterInternalChecks() {
   registerCheck(new BadCallChecker());
   registerCheck(new UndefDerefChecker());
   registerCheck(new NullDerefChecker());
-  registerCheck(new UndefSizedVLAChecker());
-  registerCheck(new ZeroSizedVLAChecker());
+  
+  RegisterVLASizeChecker(*this);
+  RegisterDivZeroChecker(*this);
+  RegisterReturnStackAddressChecker(*this);
+  RegisterReturnUndefChecker(*this);
+
+  // Note that this must be registered after ReturnStackAddressChecker.
+  RegisterReturnPointerRangeChecker(*this);
 }
index ae239ca23c9f1d1b7a1b87edbfeec6796bb22cf6..42753b94fd3330b8c0e0b1c9ed9bef8c4151a6c9 100644 (file)
@@ -23,6 +23,7 @@ void RegisterDivZeroChecker(GRExprEngine &Eng);
 void RegisterReturnPointerRangeChecker(GRExprEngine &Eng);
 void RegisterReturnStackAddressChecker(GRExprEngine &Eng);  
 void RegisterReturnUndefChecker(GRExprEngine &Eng);
+void RegisterVLASizeChecker(GRExprEngine &Eng);
   
 } // end clang namespace
 #endif
index 6184a77cf39104df2628705972bd17257a5d6afc..49e19434cb7ef4fb19b76331c2d329428a69cf2b 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h"
+#include "GRExprEngineInternalChecks.h"
+#include "clang/Analysis/PathSensitive/Checker.h"
 #include "clang/Analysis/PathSensitive/GRExprEngine.h"
 #include "clang/Analysis/PathSensitive/BugReporter.h"
 
 using namespace clang;
 
+namespace {
+class VISIBILITY_HIDDEN UndefSizedVLAChecker : public Checker {
+  BugType *BT;
+  
+public:
+  UndefSizedVLAChecker() : BT(0) {}
+  static void *getTag();
+  ExplodedNode *CheckType(QualType T, ExplodedNode *Pred, 
+                          const GRState *state, Stmt *S, GRExprEngine &Eng);
+};
+
+class VISIBILITY_HIDDEN ZeroSizedVLAChecker : public Checker {
+  BugType *BT;
+  
+public:
+  ZeroSizedVLAChecker() : BT(0) {}
+  static void *getTag();
+  ExplodedNode *CheckType(QualType T, ExplodedNode *Pred, 
+                          const GRState *state, Stmt *S, GRExprEngine &Eng);
+};
+} // end anonymous namespace
+
+void clang::RegisterVLASizeChecker(GRExprEngine &Eng) {
+  Eng.registerCheck(new UndefSizedVLAChecker());
+  Eng.registerCheck(new ZeroSizedVLAChecker());
+}
+
 void *UndefSizedVLAChecker::getTag() {
   static int x = 0;
   return &x;