10#include "clang/ASTMatchers/ASTMatchFinder.h"
11#include "clang/Lex/Lexer.h"
20 AST_POLYMORPHIC_SUPPORTED_TYPES(TypeLoc,
22 const SourceLocation Loc = Node.getBeginLoc();
23 return Loc.isValid() && !Loc.isMacroID();
28 if (
const auto QualLoc = Node.getAs<QualifiedTypeLoc>())
29 TL = QualLoc.getUnqualifiedLoc();
31 const auto BuiltinLoc = TL.getAs<BuiltinTypeLoc>();
35 if (
const auto *BT = BuiltinLoc.getTypePtr())
36 return BT->getKind() == BuiltinType::LongDouble;
42 dyn_cast_if_present<BuiltinType>(Node.getType().getTypePtr()))
43 return BT->getKind() == BuiltinType::LongDouble;
52 Finder->addMatcher(typeLoc(loc(realFloatingPointType()),
53 isValidAndNotInMacro(), isLongDoubleType())
54 .bind(
"longDoubleTypeLoc"),
56 Finder->addMatcher(floatLiteral(isValidAndNotInMacro(), isLongDoubleLiteral())
57 .bind(
"longDoubleFloatLiteral"),
62 if (
const auto *TL = Result.Nodes.getNodeAs<TypeLoc>(
"longDoubleTypeLoc")) {
63 diag(TL->getBeginLoc(),
"%0 type is not portable and should not be used")
68 Result.Nodes.getNodeAs<FloatingLiteral>(
"longDoubleFloatLiteral")) {
69 diag(FL->getBeginLoc(),
"%0 type from literal suffix 'L' is not portable "
70 "and should not be used")
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
void registerMatchers(ast_matchers::MatchFinder *Finder) override
AST_POLYMORPHIC_MATCHER(isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc, NestedNameSpecifierLoc))
Matches AST nodes that were found within Abseil files.
AST_MATCHER(BinaryOperator, isRelationalOperator)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//