diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2018-11-28 11:57:13 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2018-11-28 11:57:13 +0000 |
| commit | dda6290f16075795a5700c29d1b990fff8e1261b (patch) | |
| tree | c34f2c4941666153ed851ec12163254d089b8141 /clang-tools-extra/clang-tidy | |
| parent | af860d44fe5b0146126f296df1fa2e4162b781b6 (diff) | |
| download | bcm5719-llvm-dda6290f16075795a5700c29d1b990fff8e1261b.tar.gz bcm5719-llvm-dda6290f16075795a5700c29d1b990fff8e1261b.zip | |
Fix a false-positive with cert-err58-cpp.
If a variable is declared constexpr then its initializer needs to be a constant expression, and thus, cannot throw. This check is about not throwing exceptions before main() runs, and so it doesn't apply if the initializer cannot throw. This silences the diagnostic when initializing a constexpr variable and fixes PR35457.
llvm-svn: 347745
Diffstat (limited to 'clang-tools-extra/clang-tidy')
| -rw-r--r-- | clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp b/clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp index 45f9433deab..200f9f63780 100644 --- a/clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/StaticObjectExceptionCheck.cpp @@ -26,7 +26,7 @@ void StaticObjectExceptionCheck::registerMatchers(MatchFinder *Finder) { // initializer that can throw. Finder->addMatcher( varDecl(anyOf(hasThreadStorageDuration(), hasStaticStorageDuration()), - unless(hasAncestor(functionDecl())), + unless(anyOf(isConstexpr(), hasAncestor(functionDecl()))), anyOf(hasDescendant(cxxConstructExpr(hasDeclaration( cxxConstructorDecl(unless(isNoThrow())).bind("func")))), hasDescendant(cxxNewExpr(hasDeclaration( |

