summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp4
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-static-assert.cpp6
2 files changed, 9 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
index c56262b90cf..ed9367c8a21 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
@@ -39,11 +39,13 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
anything())).bind("assertExprRoot"),
IsAlwaysFalse);
+ auto NonConstexprFunctionCall =
+ callExpr(hasDeclaration(functionDecl(unless(isConstexpr()))));
auto Condition = expr(anyOf(
expr(ignoringParenCasts(anyOf(
AssertExprRoot,
unaryOperator(hasUnaryOperand(ignoringParenCasts(AssertExprRoot)))))),
- anything()));
+ anything()), unless(findAll(NonConstexprFunctionCall)));
Finder->addMatcher(
stmt(anyOf(conditionalOperator(hasCondition(Condition.bind("condition"))),
diff --git a/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp b/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp
index 5a40c304173..8375531e2b2 100644
--- a/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp
@@ -20,6 +20,9 @@ void abort() {}
constexpr bool myfunc(int a, int b) { return a * b == 0; }
+typedef __SIZE_TYPE__ size_t;
+extern "C" size_t strlen(const char *s);
+
class A {
public:
bool method() { return true; }
@@ -120,5 +123,8 @@ int main() {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
// CHECK-FIXES: {{^ }}static_assert(10==5 , "Report me!");
+ assert(strlen("12345") == 5);
+ // CHECK-FIXES: {{^ }}assert(strlen("12345") == 5);
+
return 0;
}
OpenPOWER on IntegriCloud