11 #include "clang/AST/ASTContext.h" 12 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 void UnaryStaticAssertCheck::registerMatchers(MatchFinder *Finder) {
21 if (!getLangOpts().CPlusPlus17)
24 Finder->addMatcher(staticAssertDecl().bind(
"static_assert"),
this);
27 void UnaryStaticAssertCheck::check(
const MatchFinder::MatchResult &
Result) {
28 const auto *MatchedDecl =
29 Result.Nodes.getNodeAs<StaticAssertDecl>(
"static_assert");
30 const StringLiteral *AssertMessage = MatchedDecl->getMessage();
32 SourceLocation
Loc = MatchedDecl->getLocation();
34 if (!AssertMessage || AssertMessage->getLength() ||
35 AssertMessage->getBeginLoc().isMacroID() || Loc.isMacroID())
39 "use unary 'static_assert' when the string literal is an empty string")
40 << FixItHint::CreateRemoval(AssertMessage->getSourceRange());
SourceLocation Loc
'#' location in the include directive
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//