10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
19 void UnaryStaticAssertCheck::registerMatchers(MatchFinder *Finder) {
20 Finder->addMatcher(staticAssertDecl().bind(
"static_assert"),
this);
23 void UnaryStaticAssertCheck::check(
const MatchFinder::MatchResult &Result) {
24 const auto *MatchedDecl =
25 Result.Nodes.getNodeAs<StaticAssertDecl>(
"static_assert");
26 const StringLiteral *AssertMessage = MatchedDecl->getMessage();
28 SourceLocation
Loc = MatchedDecl->getLocation();
30 if (!AssertMessage || AssertMessage->getLength() ||
31 AssertMessage->getBeginLoc().isMacroID() ||
Loc.isMacroID())
35 "use unary 'static_assert' when the string literal is an empty string")
36 << FixItHint::CreateRemoval(AssertMessage->getSourceRange());