[clang-tools-extra] the message in a static_assert is not always a string literal
authorCorentin Jabot <corentinjabot@gmail.com>
Thu, 20 Jul 2023 07:17:56 +0000 (09:17 +0200)
committerCorentin Jabot <corentinjabot@gmail.com>
Thu, 20 Jul 2023 07:23:08 +0000 (09:23 +0200)
Fixes build failure introduce by 47ccfd7.

clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp

index 81b2156..c90d2e4 100644 (file)
@@ -21,7 +21,8 @@ void UnaryStaticAssertCheck::registerMatchers(MatchFinder *Finder) {
 void UnaryStaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *MatchedDecl =
       Result.Nodes.getNodeAs<StaticAssertDecl>("static_assert");
-  const StringLiteral *AssertMessage = MatchedDecl->getMessage();
+  const auto *AssertMessage =
+      dyn_cast_if_present<StringLiteral>(MatchedDecl->getMessage());
 
   SourceLocation Loc = MatchedDecl->getLocation();