aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngineInternalChecks.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-09-02 07:09:39 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-09-02 07:09:39 +0000
commit904e1e30f945dc11d9a6b08314db6e5bdb07e3ec (patch)
tree2ccca8b30134afe79356c583626bca1b7b460b2a /lib/Analysis/GRExprEngineInternalChecks.cpp
parenta97d54c165ca6b6e57b9f333059a84c2188dd591 (diff)
Still use BadArg bugtype in the checker. This saves us implement registerInitialVisitors
in the BugReport. When all internal bug checking logic are moved to checkers, BuiltinBug will not reference GRExprEngine, and FlushReports() will be not necessary, since all bugs are emitted into the equivalent classes immediately. For now just add a ctor with no arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r--lib/Analysis/GRExprEngineInternalChecks.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp
index 33546ea224..91b7cf3db6 100644
--- a/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -67,6 +67,8 @@ public:
BuiltinBug(GRExprEngine *eng, const char* n)
: BugType(n, "Logic errors"), Eng(*eng), desc(n) {}
+
+ const std::string &getDescription() const { return desc; }
virtual void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) = 0;
@@ -246,15 +248,13 @@ public:
: BuiltinBugReport(bt, shortDesc, desc, n), Arg(arg) {}
const Stmt *getArg() const { return Arg; }
-
- void registerInitialVisitors(BugReporterContext& BRC,
- const ExplodedNode* N) {
- registerTrackNullOrUndefValue(BRC, getArg(), N);
- }
};
class VISIBILITY_HIDDEN BadArg : public BuiltinBug {
public:
+ BadArg() : BuiltinBug(0, "Uninitialized argument",
+ "Pass-by-value argument in function call is undefined.") {}
+
BadArg(GRExprEngine* eng) : BuiltinBug(eng,"Uninitialized argument",
"Pass-by-value argument in function call is undefined.") {}
@@ -262,14 +262,6 @@ public:
: BuiltinBug(eng,"Uninitialized argument", d) {}
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
- for (GRExprEngine::UndefArgsTy::iterator I = Eng.undef_arg_begin(),
- E = Eng.undef_arg_end(); I!=E; ++I) {
- // Generate a report for this bug.
- ArgReport *report = new ArgReport(*this, desc.c_str(), I->first,
- I->second);
- report->addRange(I->second->getSourceRange());
- BR.EmitReport(report);
- }
}
void registerInitialVisitors(BugReporterContext& BRC,
@@ -639,7 +631,7 @@ namespace {
class VISIBILITY_HIDDEN CheckUndefinedArg
: public CheckerVisitor<CheckUndefinedArg> {
- BugType *BT;
+ BadArg *BT;
public:
CheckUndefinedArg() : BT(0) {}
@@ -659,10 +651,9 @@ void CheckUndefinedArg::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE){
if (C.getState()->getSVal(*I).isUndef()) {
if (ExplodedNode *ErrorNode = C.generateNode(CE, C.getState(), true)) {
if (!BT)
- BT = new BugType("Uninitialized argument.", "Logic errors");
+ BT = new BadArg();
// Generate a report for this bug.
- ArgReport *Report = new ArgReport(*BT,
- "Pass-by-value argument in function call is undefined.",
+ ArgReport *Report = new ArgReport(*BT, BT->getDescription().c_str(),
ErrorNode, *I);
Report->addRange((*I)->getSourceRange());
C.EmitReport(Report);