summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-07-17 08:56:55 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-07-17 08:56:55 +0000
commit01f56862982c958ad73b4d4b60f0c59d8f383b23 (patch)
tree9d822b6510f317859745fc38c996278100d0638f /clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp
parent80c2289a03f8a993b2377993a873242a62116c58 (diff)
downloadbcm5719-llvm-01f56862982c958ad73b4d4b60f0c59d8f383b23.tar.gz
bcm5719-llvm-01f56862982c958ad73b4d4b60f0c59d8f383b23.zip
[clang-tidy] MemsetZeroLenghtChecker: Don't crash trying to evaluate dependent values.
llvm-svn: 213238
Diffstat (limited to 'clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp b/clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp
index b9b776e0b5c..7e60a529aef 100644
--- a/clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/MemsetZeroLengthCheck.cpp
@@ -59,11 +59,13 @@ void MemsetZeroLengthCheck::check(const MatchFinder::MatchResult &Result) {
// Try to evaluate the second argument so we can also find values that are not
// just literals.
llvm::APSInt Value1, Value2;
- if (!Arg2->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
+ if (Arg2->isValueDependent() ||
+ !Arg2->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
return;
// If both arguments evaluate to zero emit a warning without fix suggestions.
- if (Arg1->EvaluateAsInt(Value1, *Result.Context) &&
+ if (!Arg1->isValueDependent() &&
+ Arg1->EvaluateAsInt(Value1, *Result.Context) &&
(Value1 == 0 || Value1.isNegative())) {
diag(Call->getLocStart(), "memset of size zero");
return;
OpenPOWER on IntegriCloud