diff options
author | Adam Balogh <adam.balogh@ericsson.com> | 2018-07-13 13:44:44 +0000 |
---|---|---|
committer | Adam Balogh <adam.balogh@ericsson.com> | 2018-07-13 13:44:44 +0000 |
commit | bf966f523755c9f72886e90a98c15eae8d248cd8 (patch) | |
tree | 1c888c86ea410bc482db28f780b0c72d9722445f /clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp | |
parent | c48aefb63bb307e1c5e843a05b01a55509c3528b (diff) | |
download | bcm5719-llvm-bf966f523755c9f72886e90a98c15eae8d248cd8.tar.gz bcm5719-llvm-bf966f523755c9f72886e90a98c15eae8d248cd8.zip |
[Analyzer] alpha.unix.cstring.OutOfBounds checker enable/disable fix
It was not possible to disable alpha.unix.cstring.OutOfBounds checker's reports
since unix.Malloc checker always implicitly enabled the filter. Moreover if the
checker was disabled from command line (-analyzer-disable-checker ..) the out
of bounds warnings were nevertheless emitted under different checker names such
as unix.cstring.NullArg, or unix.Malloc.
This patch fixes the case sot that Malloc checker only enables implicitly the
underlying modeling of strcpy, memcpy etc. but not the warning messages that
would have been emmitted by alpha.unix.cstring.OutOfBounds
Patch by: Dániel Krupp
Differential Revision: https://reviews.llvm.org/D48831
llvm-svn: 337000
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index a51bc062e19..278452ec994 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -305,10 +305,10 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C, ProgramStateRef StOutBound = state->assumeInBound(Idx, Size, false); if (StOutBound && !StInBound) { // These checks are either enabled by the CString out-of-bounds checker - // explicitly or the "basic" CStringNullArg checker support that Malloc - // checker enables. - assert(Filter.CheckCStringOutOfBounds || Filter.CheckCStringNullArg); - + // explicitly or implicitly by the Malloc checker. + // In the latter case we only do modeling but do not emit warning. + if (!Filter.CheckCStringOutOfBounds) + return nullptr; // Emit a bug report. if (warningMsg) { emitOutOfBoundsBug(C, StOutBound, S, warningMsg); @@ -1039,7 +1039,7 @@ bool CStringChecker::memsetAux(const Expr *DstBuffer, const Expr *CharE, std::tie(StateWholeReg, StateNotWholeReg) = State->assume(svalBuilder.evalEQ(State, Extent, *SizeNL)); - // With the semantic of 'memset()', we should convert the CharVal to + // With the semantic of 'memset()', we should convert the CharVal to // unsigned char. CharVal = svalBuilder.evalCast(CharVal, Ctx.UnsignedCharTy, Ctx.IntTy); @@ -2418,5 +2418,5 @@ void CStringChecker::checkDeadSymbols(SymbolReaper &SR, REGISTER_CHECKER(CStringNotNullTerm) void ento::registerCStringCheckerBasic(CheckerManager &Mgr) { - registerCStringNullArg(Mgr); + Mgr.registerChecker<CStringChecker>(); } |