diff options
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp | 10 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/BugReporter.cpp | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index 0f6b621bf7..cf5501a4ac 100644 --- a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -118,9 +118,12 @@ private: ASTContext &Context; bool isIntZeroExpr(const Expr *E) const { - return (E->getType()->isIntegralOrEnumerationType() - && E->isEvaluatable(Context) - && E->EvaluateAsInt(Context) == 0); + if (!E->getType()->isIntegralOrEnumerationType()) + return false; + llvm::APSInt Result; + if (E->EvaluateAsInt(Result, Context)) + return Result == 0; + return false; } void CheckExpr(const Expr *E_p) { @@ -263,4 +266,3 @@ void MallocOverflowSecurityChecker::checkASTCodeBody(const Decl *D, void ento::registerMallocOverflowSecurityChecker(CheckerManager &mgr) { mgr.registerChecker<MallocOverflowSecurityChecker>(); } - diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 9e1c12ce1f..cdc9dcf752 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -599,7 +599,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD, } if (GetRawInt) - os << LHS->EvaluateAsInt(PDB.getASTContext()); + os << LHS->EvaluateKnownConstInt(PDB.getASTContext()); os << ":' at line " << End.asLocation().getExpansionLineNumber(); |