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