Index: lib/AST/DeclDataCollectors.inc =================================================================== --- /dev/null +++ lib/AST/DeclDataCollectors.inc @@ -0,0 +1,104 @@ +DEF_ADD_DATA(Decl, { + addData(D->getKind()); + addData(data_collection::getMacroStack(D->getLocStart(), Context)); + addData(data_collection::getMacroStack(D->getLocEnd(), Context)); +}) + +DEF_ADD_DATA(NamedDecl, { addData(D->getQualifiedNameAsString()); }) +DEF_ADD_DATA(ValueDecl, { addData(D->getType()); }) +DEF_ADD_DATA(TypeDecl, { + if (auto *Type = D->getTypeForDecl()) + addData(Type->getCanonicalTypeInternal()); +}) +DEF_ADD_DATA(UsingDirectiveDecl, + { addData(D->getNominatedNamespace()->getName()); }) +DEF_ADD_DATA(UsingDecl, { + addData(D->isAccessDeclaration()); + addData(D->hasTypename()); +}) +DEF_ADD_DATA(AccessSpecDecl, { + CharSourceRange Range(D->getSourceRange(), false); + addData(Lexer::getSourceText(Range, Context.getSourceManager(), + Context.getLangOpts())); +}) + +DEF_ADD_DATA(TemplateDecl, { addData(D->isConcept()); }) +DEF_ADD_DATA(BuiltinTemplateDecl, { addData(D->getBuiltinTemplateKind()); }) +DEF_ADD_DATA(TemplateTemplateParmDecl, { + addData(D->isParameterPack()); + addData(D->isPackExpansion()); + addData(D->isExpandedParameterPack()); +}) +DEF_ADD_DATA(RedeclarableTemplateDecl, + { addData(D->isMemberSpecialization()); }) + +DEF_ADD_DATA(FriendDecl, { + if (D->getFriendDecl()) + addData(D->getFriendDecl()->getQualifiedNameAsString()); +}) +DEF_ADD_DATA(LinkageSpecDecl, { + addData(D->getLanguage()); + addData(D->hasBraces()); +}) +DEF_ADD_DATA(LabelDecl, { + addData(D->isGnuLocal()); + addData(D->isMSAsmLabel()); + addData(D->isResolvedMSAsmLabel()); +}) +DEF_ADD_DATA(NamespaceAliasDecl, + { addData(D->getNamespace()->getQualifiedNameAsString()); }) +DEF_ADD_DATA(NamespaceDecl, { + addData(D->isAnonymousNamespace()); + addData(D->isInline()); +}) + +DEF_ADD_DATA(FunctionDecl, { + addData(D->isDefined()); + addData(D->isThisDeclarationADefinition()); + addData(D->doesThisDeclarationHaveABody()); + addData(D->isVariadic()); + addData(D->isVirtualAsWritten()); + addData(D->isPure()); + addData(D->isTrivial()); + addData(D->isDefaulted()); + addData(D->isExplicitlyDefaulted()); + addData(D->hasImplicitReturnZero()); + addData(D->isConstexpr()); + addData(D->isDeleted()); + addData(D->isMSVCRTEntryPoint()); + addData(D->isNoReturn()); + addData(D->hasSkippedBody()); + addData(D->hasUnusedResultAttr()); + addData(D->isInlineSpecified()); + addData(D->isOutOfLine()); + addData(D->getStorageClass()); + addData(D->getLanguageLinkage()); +}) +DEF_ADD_DATA(CXXDeductionGuideDecl, { addData(D->isExplicitSpecified()); }) +DEF_ADD_DATA(CXXMethodDecl, { + addData(D->isStatic()); + addData(D->isInstance()); + addData(D->isConst()); + addData(D->isVolatile()); + addData(D->isVirtual()); + addData(D->hasInlineBody()); +}) +DEF_ADD_DATA(CXXConversionDecl, { addData(D->isExplicitSpecified()); }) +DEF_ADD_DATA(VarDecl, { + addData(D->isStaticLocal()); + addData(D->hasExternalStorage()); + addData(D->getStorageDuration()); + addData(D->getLanguageLinkage()); + addData(D->isExternC()); + addData(D->isInExternCContext()); + addData(D->isInExternCXXContext()); + addData(D->isOutOfLine()); + addData(D->isFileVarDecl()); + addData(D->getInitStyle()); + addData(D->isInlineSpecified()); + addData(D->isConstexpr()); + addData(D->isInitCapture()); +}) +DEF_ADD_DATA(ImplicitParamDecl, { addData(D->getParameterKind()); }) + +#undef DEF_ADD_DATA Index: unittests/AST/DataCollectionTest.cpp =================================================================== --- unittests/AST/DataCollectionTest.cpp +++ unittests/AST/DataCollectionTest.cpp @@ -57,7 +57,7 @@ StmtHashMatch(llvm::MD5::MD5Result &Hash) : NumFound(0), Hash(Hash) {} void run(const MatchFinder::MatchResult &Result) override { - const Stmt *S = Result.Nodes.getNodeAs("id"); + auto *S = Result.Nodes.getNodeAs("id"); if (!S) return; ++NumFound; @@ -80,7 +80,7 @@ newFrontendActionFactory(&Finder)); if (!runToolOnCode(Factory->create(), Code)) return testing::AssertionFailure() - << "Parsing error in \"" << Code.str() << "\""; + << R"(Parsing error in ")" << Code.str() << R"(")"; if (Hasher.NumFound == 0) return testing::AssertionFailure() << "Matcher didn't find any statements"; if (Hasher.NumFound > 1)