17#include "llvm/Support/Path.h"
18#include "llvm/Support/raw_ostream.h"
33 Loc =
SM.getExpansionLoc(Loc);
37 OS << llvm::sys::path::filename(FE->
getName());
46 OS <<
'@' << Decomposed.second;
55 return attr->getDefinedIn();
62 SmallVectorImpl<char> &Buf;
63 llvm::raw_svector_ostream Out;
65 const LangOptions &LangOpts;
66 bool IgnoreResults =
false;
67 bool generatedLoc =
false;
69 llvm::DenseMap<const Type *, unsigned> TypeSubstitutions;
72 USRGenerator(ASTContext *Ctx, SmallVectorImpl<char> &Buf,
73 const LangOptions &LangOpts)
74 : Buf(Buf), Out(Buf), Context(Ctx), LangOpts(LangOpts) {
79 bool ignoreResults()
const {
return IgnoreResults; }
82 void VisitDeclContext(
const DeclContext *D);
83 void VisitFieldDecl(
const FieldDecl *D);
84 void VisitFunctionDecl(
const FunctionDecl *D);
85 void VisitNamedDecl(
const NamedDecl *D);
86 void VisitNamespaceDecl(
const NamespaceDecl *D);
87 void VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D);
88 void VisitFunctionTemplateDecl(
const FunctionTemplateDecl *D);
89 void VisitClassTemplateDecl(
const ClassTemplateDecl *D);
90 void VisitObjCContainerDecl(
const ObjCContainerDecl *CD,
91 const ObjCCategoryDecl *CatD =
nullptr);
92 void VisitObjCMethodDecl(
const ObjCMethodDecl *MD);
93 void VisitObjCPropertyDecl(
const ObjCPropertyDecl *D);
94 void VisitObjCPropertyImplDecl(
const ObjCPropertyImplDecl *D);
95 void VisitTagDecl(
const TagDecl *D);
96 void VisitTypedefDecl(
const TypedefDecl *D);
97 void VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *D);
98 void VisitVarDecl(
const VarDecl *D);
99 void VisitBindingDecl(
const BindingDecl *D);
100 void VisitNonTypeTemplateParmDecl(
const NonTypeTemplateParmDecl *D);
101 void VisitTemplateTemplateParmDecl(
const TemplateTemplateParmDecl *D);
102 void VisitUnresolvedUsingValueDecl(
const UnresolvedUsingValueDecl *D);
103 void VisitUnresolvedUsingTypenameDecl(
const UnresolvedUsingTypenameDecl *D);
104 void VisitConceptDecl(
const ConceptDecl *D);
106 void VisitLinkageSpecDecl(
const LinkageSpecDecl *D) {
107 IgnoreResults =
true;
110 void VisitUsingDirectiveDecl(
const UsingDirectiveDecl *D) {
111 IgnoreResults =
true;
114 void VisitUsingDecl(
const UsingDecl *D) {
118 bool EmittedDeclName = !EmitDeclName(D);
119 assert(EmittedDeclName &&
"EmitDeclName can not fail for UsingDecls");
120 (void)EmittedDeclName;
123 bool ShouldGenerateLocation(
const NamedDecl *D);
125 bool isLocal(
const NamedDecl *D) {
129 void GenExtSymbolContainer(
const NamedDecl *D);
133 bool GenLoc(
const Decl *D,
bool IncludeOffset);
142 void GenObjCClass(StringRef cls, StringRef ExtSymDefinedIn,
143 StringRef CategoryContextExtSymbolDefinedIn) {
145 CategoryContextExtSymbolDefinedIn);
149 void GenObjCCategory(StringRef cls, StringRef cat, StringRef clsExt,
155 void GenObjCProperty(StringRef prop,
bool isClassProp) {
160 void GenObjCProtocol(StringRef prot, StringRef ext) {
164 void VisitType(QualType T);
165 void VisitTemplateParameterList(
const TemplateParameterList *Params);
167 void VisitTemplateArgument(
const TemplateArgument &Arg);
169 void VisitMSGuidDecl(
const MSGuidDecl *D);
173 bool EmitDeclName(
const NamedDecl *D);
181bool USRGenerator::EmitDeclName(
const NamedDecl *D) {
189bool USRGenerator::ShouldGenerateLocation(
const NamedDecl *D) {
201void USRGenerator::VisitDeclContext(
const DeclContext *DC) {
202 if (
const NamedDecl *D = dyn_cast<NamedDecl>(DC))
208void USRGenerator::VisitFieldDecl(
const FieldDecl *D) {
215 Out << (isa<ObjCIvarDecl>(D) ?
"@" :
"@FI@");
216 if (EmitDeclName(D)) {
218 IgnoreResults =
true;
223void USRGenerator::VisitFunctionDecl(
const FunctionDecl *D) {
224 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
228 IgnoreResults =
true;
232 const unsigned StartSize = Buf.size();
234 if (Buf.size() == StartSize)
235 GenExtSymbolContainer(D);
237 bool IsTemplate =
false;
241 VisitTemplateParameterList(FunTmpl->getTemplateParameters());
245 PrintingPolicy Policy(LangOpts);
248 Policy.SuppressTemplateArgsInCXXConstructors =
true;
251 if ((!LangOpts.CPlusPlus || D->
isExternC()) &&
252 !D->
hasAttr<OverloadableAttr>())
257 if (
const TemplateArgumentList *SpecArgs =
259 for (
const auto &Arg : SpecArgs->asArray()) {
261 VisitTemplateArgument(Arg);
263 }
else if (
const ASTTemplateArgumentListInfo *SpecArgsWritten =
265 for (
const auto &ArgLoc : SpecArgsWritten->arguments()) {
267 VisitTemplateArgument(ArgLoc.getArgument());
275 if (
const auto *FPT = CanonicalType->
getAs<FunctionProtoType>()) {
276 for (QualType PT : FPT->param_types()) {
293 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
297 if (
unsigned quals = MD->getMethodQualifiers().getCVRUQualifiers())
298 Out << (char)(
'0' + quals);
299 switch (MD->getRefQualifier()) {
312void USRGenerator::VisitNamedDecl(
const NamedDecl *D) {
316 if (EmitDeclName(D)) {
321 IgnoreResults =
true;
325void USRGenerator::VisitVarDecl(
const VarDecl *D) {
329 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
336 VisitTemplateParameterList(VarTmpl->getTemplateParameters());
337 }
else if (
const VarTemplatePartialSpecializationDecl *PartialSpec =
338 dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
340 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
351 IgnoreResults =
true;
356 if (
const VarTemplateSpecializationDecl *Spec =
357 dyn_cast<VarTemplateSpecializationDecl>(D)) {
358 const TemplateArgumentList &Args = Spec->getTemplateArgs();
360 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
362 VisitTemplateArgument(Args.
get(I));
367void USRGenerator::VisitBindingDecl(
const BindingDecl *D) {
368 if (isLocal(D) && GenLoc(D,
true))
373void USRGenerator::VisitNonTypeTemplateParmDecl(
374 const NonTypeTemplateParmDecl *D) {
378void USRGenerator::VisitTemplateTemplateParmDecl(
379 const TemplateTemplateParmDecl *D) {
383void USRGenerator::VisitNamespaceDecl(
const NamespaceDecl *D) {
394void USRGenerator::VisitFunctionTemplateDecl(
const FunctionTemplateDecl *D) {
398void USRGenerator::VisitClassTemplateDecl(
const ClassTemplateDecl *D) {
402void USRGenerator::VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D) {
411 if (
auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->
getDeclContext()))
412 return ICD->getCategoryDecl();
416void USRGenerator::VisitObjCMethodDecl(
const ObjCMethodDecl *D) {
418 if (
const ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
425 IgnoreResults =
true;
429 VisitObjCContainerDecl(ID, CD);
438void USRGenerator::VisitObjCContainerDecl(
const ObjCContainerDecl *D,
439 const ObjCCategoryDecl *CatD) {
442 llvm_unreachable(
"Invalid ObjC container.");
443 case Decl::ObjCInterface:
444 case Decl::ObjCImplementation:
448 case Decl::ObjCCategory: {
456 IgnoreResults =
true;
462 Out <<
"objc(ext)" <<
ID->getName() <<
'@';
465 GenObjCCategory(
ID->getName(), CD->
getName(),
471 case Decl::ObjCCategoryImpl: {
479 IgnoreResults =
true;
482 GenObjCCategory(
ID->getName(), CD->
getName(),
487 case Decl::ObjCProtocol: {
495void USRGenerator::VisitObjCPropertyDecl(
const ObjCPropertyDecl *D) {
505void USRGenerator::VisitObjCPropertyImplDecl(
const ObjCPropertyImplDecl *D) {
507 VisitObjCPropertyDecl(PD);
511 IgnoreResults =
true;
514void USRGenerator::VisitTagDecl(
const TagDecl *D) {
518 GenLoc(D, isLocal(D)))
521 GenExtSymbolContainer(D);
526 bool AlreadyStarted =
false;
527 if (
const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
528 if (ClassTemplateDecl *ClassTmpl =
CXXRecord->getDescribedClassTemplate()) {
529 AlreadyStarted =
true;
532 case TagTypeKind::Interface:
533 case TagTypeKind::Class:
534 case TagTypeKind::Struct:
537 case TagTypeKind::Union:
540 case TagTypeKind::Enum:
541 llvm_unreachable(
"enum template");
543 VisitTemplateParameterList(ClassTmpl->getTemplateParameters());
544 }
else if (
const ClassTemplatePartialSpecializationDecl *PartialSpec =
545 dyn_cast<ClassTemplatePartialSpecializationDecl>(
547 AlreadyStarted =
true;
550 case TagTypeKind::Interface:
551 case TagTypeKind::Class:
552 case TagTypeKind::Struct:
555 case TagTypeKind::Union:
558 case TagTypeKind::Enum:
559 llvm_unreachable(
"enum partial specialization");
561 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
565 if (!AlreadyStarted) {
567 case TagTypeKind::Interface:
568 case TagTypeKind::Class:
569 case TagTypeKind::Struct:
572 case TagTypeKind::Union:
575 case TagTypeKind::Enum:
582 assert(Buf.size() > 0);
583 const unsigned off = Buf.size() - 1;
585 if (EmitDeclName(D)) {
594 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
597 auto enum_range = ED->enumerators();
598 if (enum_range.begin() != enum_range.end()) {
599 Out <<
'@' << **enum_range.begin();
607 if (
const ClassTemplateSpecializationDecl *Spec =
608 dyn_cast<ClassTemplateSpecializationDecl>(D)) {
609 const TemplateArgumentList &Args = Spec->getTemplateArgs();
611 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
613 VisitTemplateArgument(Args.
get(I));
618void USRGenerator::VisitTypedefDecl(
const TypedefDecl *D) {
619 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
622 if (
const NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
628void USRGenerator::VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *D) {
632void USRGenerator::GenExtSymbolContainer(
const NamedDecl *D) {
634 if (!Container.empty())
635 Out <<
"@M@" << Container;
638bool USRGenerator::GenLoc(
const Decl *D,
bool IncludeOffset) {
640 return IgnoreResults;
645 IgnoreResults =
true;
656 return IgnoreResults;
671void USRGenerator::VisitType(QualType T) {
675 ASTContext &Ctx = *Context;
688 Out << ((char)(
'0' + qVal));
692 if (
const PackExpansionType *Expansion = T->
getAs<PackExpansionType>()) {
694 T = Expansion->getPattern();
697 if (
const BuiltinType *BT = T->
getAs<BuiltinType>()) {
698 switch (BT->getKind()) {
699 case BuiltinType::Void:
702 case BuiltinType::Bool:
705 case BuiltinType::UChar:
708 case BuiltinType::Char8:
711 case BuiltinType::Char16:
714 case BuiltinType::Char32:
717 case BuiltinType::UShort:
720 case BuiltinType::UInt:
723 case BuiltinType::ULong:
726 case BuiltinType::ULongLong:
729 case BuiltinType::UInt128:
732 case BuiltinType::Char_U:
733 case BuiltinType::Char_S:
736 case BuiltinType::SChar:
739 case BuiltinType::WChar_S:
740 case BuiltinType::WChar_U:
743 case BuiltinType::Short:
746 case BuiltinType::Int:
749 case BuiltinType::Long:
752 case BuiltinType::LongLong:
755 case BuiltinType::Int128:
758 case BuiltinType::Float16:
759 case BuiltinType::Half:
762 case BuiltinType::Float:
765 case BuiltinType::Double:
768 case BuiltinType::LongDouble:
771 case BuiltinType::Float128:
774 case BuiltinType::NullPtr:
777#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
778 case BuiltinType::Id: \
779 Out << "@BT@" << #Suffix << "_" << #ImgType; \
781#include "clang/Basic/OpenCLImageTypes.def"
782#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
783 case BuiltinType::Id: \
784 Out << "@BT@" << #ExtType; \
786#include "clang/Basic/OpenCLExtensionTypes.def"
787 case BuiltinType::OCLEvent:
788 Out <<
"@BT@OCLEvent";
790 case BuiltinType::OCLClkEvent:
791 Out <<
"@BT@OCLClkEvent";
793 case BuiltinType::OCLQueue:
794 Out <<
"@BT@OCLQueue";
796 case BuiltinType::OCLReserveID:
797 Out <<
"@BT@OCLReserveID";
799 case BuiltinType::OCLSampler:
800 Out <<
"@BT@OCLSampler";
802#define SVE_TYPE(Name, Id, SingletonId) \
803 case BuiltinType::Id: \
804 Out << "@BT@" << #Name; \
806#include "clang/Basic/AArch64ACLETypes.def"
807#define PPC_VECTOR_TYPE(Name, Id, Size) \
808 case BuiltinType::Id: \
809 Out << "@BT@" << #Name; \
811#include "clang/Basic/PPCTypes.def"
812#define RVV_TYPE(Name, Id, SingletonId) \
813 case BuiltinType::Id: \
814 Out << "@BT@" << Name; \
816#include "clang/Basic/RISCVVTypes.def"
817#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
818#include "clang/Basic/WebAssemblyReferenceTypes.def"
819#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
820 case BuiltinType::Id: \
821 Out << "@BT@" << #Name; \
823#include "clang/Basic/AMDGPUTypes.def"
824#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
825 case BuiltinType::Id: \
826 Out << "@BT@" << #Name; \
828#include "clang/Basic/HLSLIntangibleTypes.def"
829 case BuiltinType::ShortAccum:
830 Out <<
"@BT@ShortAccum";
832 case BuiltinType::Accum:
835 case BuiltinType::LongAccum:
836 Out <<
"@BT@LongAccum";
838 case BuiltinType::UShortAccum:
839 Out <<
"@BT@UShortAccum";
841 case BuiltinType::UAccum:
844 case BuiltinType::ULongAccum:
845 Out <<
"@BT@ULongAccum";
847 case BuiltinType::ShortFract:
848 Out <<
"@BT@ShortFract";
850 case BuiltinType::Fract:
853 case BuiltinType::LongFract:
854 Out <<
"@BT@LongFract";
856 case BuiltinType::UShortFract:
857 Out <<
"@BT@UShortFract";
859 case BuiltinType::UFract:
862 case BuiltinType::ULongFract:
863 Out <<
"@BT@ULongFract";
865 case BuiltinType::SatShortAccum:
866 Out <<
"@BT@SatShortAccum";
868 case BuiltinType::SatAccum:
869 Out <<
"@BT@SatAccum";
871 case BuiltinType::SatLongAccum:
872 Out <<
"@BT@SatLongAccum";
874 case BuiltinType::SatUShortAccum:
875 Out <<
"@BT@SatUShortAccum";
877 case BuiltinType::SatUAccum:
878 Out <<
"@BT@SatUAccum";
880 case BuiltinType::SatULongAccum:
881 Out <<
"@BT@SatULongAccum";
883 case BuiltinType::SatShortFract:
884 Out <<
"@BT@SatShortFract";
886 case BuiltinType::SatFract:
887 Out <<
"@BT@SatFract";
889 case BuiltinType::SatLongFract:
890 Out <<
"@BT@SatLongFract";
892 case BuiltinType::SatUShortFract:
893 Out <<
"@BT@SatUShortFract";
895 case BuiltinType::SatUFract:
896 Out <<
"@BT@SatUFract";
898 case BuiltinType::SatULongFract:
899 Out <<
"@BT@SatULongFract";
901 case BuiltinType::BFloat16:
904 case BuiltinType::Ibm128:
905 Out <<
"@BT@__ibm128";
907 case BuiltinType::ObjCId:
910 case BuiltinType::ObjCClass:
913 case BuiltinType::ObjCSel:
916#define BUILTIN_TYPE(Id, SingletonId)
917#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
918#include "clang/AST/BuiltinTypes.def"
919 case BuiltinType::Dependent:
922 IgnoreResults =
true;
930 auto [Substitution, Inserted] =
931 TypeSubstitutions.try_emplace(T.
getTypePtr(), TypeSubstitutions.size());
933 Out <<
'S' << Substitution->second <<
'_';
937 if (
const PointerType *PT = T->
getAs<PointerType>()) {
942 if (
const ObjCObjectPointerType *OPT = T->
getAs<ObjCObjectPointerType>()) {
947 if (
const RValueReferenceType *RT = T->
getAs<RValueReferenceType>()) {
952 if (
const ReferenceType *RT = T->
getAs<ReferenceType>()) {
957 if (
const FunctionProtoType *FT = T->
getAs<FunctionProtoType>()) {
959 VisitType(FT->getReturnType());
961 for (
const auto &I : FT->param_types()) {
966 if (FT->isVariadic())
970 if (
const BlockPointerType *BT = T->
getAs<BlockPointerType>()) {
975 if (
const ComplexType *CT = T->
getAs<ComplexType>()) {
977 T = CT->getElementType();
980 if (
const TagType *TT = T->
getAs<TagType>()) {
981 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TT)) {
982 T = ICNT->getDecl()->getCanonicalTemplateSpecializationType(Ctx);
985 VisitTagDecl(TT->getDecl());
989 if (
const ObjCInterfaceType *OIT = T->
getAs<ObjCInterfaceType>()) {
991 VisitObjCInterfaceDecl(OIT->getDecl());
994 if (
const ObjCObjectType *OIT = T->
getAs<ObjCObjectType>()) {
996 VisitType(OIT->getBaseType());
997 for (
auto *Prot : OIT->getProtocols())
998 VisitObjCProtocolDecl(Prot);
1001 if (
const TemplateTypeParmType *TTP =
1003 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
1006 if (
const TemplateSpecializationType *Spec =
1007 T->
getAs<TemplateSpecializationType>()) {
1009 VisitTemplateName(Spec->getTemplateName());
1010 Out << Spec->template_arguments().size();
1011 for (
const auto &Arg : Spec->template_arguments())
1012 VisitTemplateArgument(Arg);
1015 if (
const DependentNameType *DNT = T->
getAs<DependentNameType>()) {
1018 Out <<
':' << DNT->getIdentifier()->getName();
1021 if (
const auto *VT = T->
getAs<VectorType>()) {
1023 Out << VT->getNumElements();
1024 T = VT->getElementType();
1027 if (
const auto *
const AT = dyn_cast<ArrayType>(T)) {
1029 switch (AT->getSizeModifier()) {
1030 case ArraySizeModifier::Static:
1033 case ArraySizeModifier::Star:
1036 case ArraySizeModifier::Normal:
1040 if (
const auto *
const CAT = dyn_cast<ConstantArrayType>(T))
1041 Out << CAT->getSize();
1043 T = AT->getElementType();
1053void USRGenerator::VisitTemplateParameterList(
1054 const TemplateParameterList *Params) {
1057 Out <<
'>' << Params->
size();
1058 for (TemplateParameterList::const_iterator P = Params->
begin(),
1059 PEnd = Params->
end();
1069 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
1070 if (NTTP->isParameterPack())
1073 VisitType(NTTP->getType());
1085void USRGenerator::VisitTemplateName(
TemplateName Name) {
1087 if (TemplateTemplateParmDecl *TTP =
1088 dyn_cast<TemplateTemplateParmDecl>(
Template)) {
1089 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
1100void USRGenerator::VisitTemplateArgument(
const TemplateArgument &Arg) {
1126 VisitTemplateArgument(P);
1150void USRGenerator::VisitUnresolvedUsingValueDecl(
1151 const UnresolvedUsingValueDecl *D) {
1152 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1160void USRGenerator::VisitUnresolvedUsingTypenameDecl(
1161 const UnresolvedUsingTypenameDecl *D) {
1162 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1170void USRGenerator::VisitConceptDecl(
const ConceptDecl *D) {
1171 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1178void USRGenerator::VisitMSGuidDecl(
const MSGuidDecl *D) {
1181 D->NamedDecl::printName(Out);
1189 StringRef CatSymDefinedIn,
1191 if (ClsSymDefinedIn.empty() && CatSymDefinedIn.empty())
1193 if (CatSymDefinedIn.empty()) {
1194 OS <<
"@M@" << ClsSymDefinedIn <<
'@';
1197 OS <<
"@CM@" << CatSymDefinedIn <<
'@';
1198 if (ClsSymDefinedIn != CatSymDefinedIn) {
1199 OS << ClsSymDefinedIn <<
'@';
1204 StringRef Cls, raw_ostream &OS, StringRef ExtSymDefinedIn,
1205 StringRef CategoryContextExtSymbolDefinedIn) {
1207 CategoryContextExtSymbolDefinedIn, OS);
1208 OS <<
"objc(cs)" << Cls;
1213 StringRef ClsSymDefinedIn,
1214 StringRef CatSymDefinedIn) {
1216 OS <<
"objc(cy)" << Cls <<
'@' << Cat;
1224 bool IsInstanceMethod,
1226 OS << (IsInstanceMethod ?
"(im)" :
"(cm)") << Sel;
1231 OS << (isClassProp ?
"(cpy)" :
"(py)") << Prop;
1235 StringRef ExtSymDefinedIn) {
1236 if (!ExtSymDefinedIn.empty())
1237 OS <<
"@M@" << ExtSymDefinedIn <<
'@';
1238 OS <<
"objc(pl)" << Prot;
1242 StringRef ExtSymDefinedIn) {
1243 if (!ExtSymDefinedIn.empty())
1244 OS <<
"@M@" << ExtSymDefinedIn;
1245 OS <<
"@E@" << EnumName;
1250 OS <<
'@' << EnumConstantName;
1270 if (
auto *ExternalSymAttr = CD->
getAttr<ExternalSourceSymbolAttr>()) {
1271 if (!ExternalSymAttr->getUSR().empty()) {
1272 llvm::raw_svector_ostream Out(Buf);
1273 Out << ExternalSymAttr->getUSR();
1279 return UG.ignoreResults();
1294 if (MacroName.empty())
1297 llvm::raw_svector_ostream Out(Buf);
1301 bool ShouldGenerateLocation = Loc.
isValid() && !
SM.isInSystemHeader(Loc);
1304 if (ShouldGenerateLocation)
1321 T = T.getCanonicalType();
1323 USRGenerator UG(&Ctx, Buf, LangOpts);
1325 return UG.ignoreResults();
1350 OS <<
"@M@" << ModName;
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...
static void combineClassAndCategoryExtContainers(StringRef ClsSymDefinedIn, StringRef CatSymDefinedIn, raw_ostream &OS)
static bool printLoc(llvm::raw_ostream &OS, SourceLocation Loc, const SourceManager &SM, bool IncludeOffset)
static const ObjCCategoryDecl * getCategoryContext(const NamedDecl *D)
static void printQualifier(llvm::raw_ostream &Out, const LangOptions &LangOpts, NestedNameSpecifier NNS)
static StringRef GetExternalSourceContainer(const NamedDecl *D)
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
const LangOptions & getLangOpts() const
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
A simple visitor class that helps create declaration visitors.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
ASTContext & getASTContext() const LLVM_READONLY
ExternalSourceSymbolAttr * getExternalSourceSymbolAttr() const
Looks on this and related declarations for an applicable external source symbol attribute.
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
bool isEmpty() const
Evaluates true when this declaration name is empty.
StringRef getName() const
The name of this FileEntry.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
QualType getReturnType() const
bool isVariadic() const
Whether this function is variadic.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
StringRef getName() const
Return the actual identifier string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Record the location of a macro definition.
SourceLocation getLocation() const
Retrieve the location of the macro name in the definition.
const IdentifierInfo * getName() const
Retrieve the name of the macro being defined.
Module * Parent
The parent of this module.
std::string Name
The name of this module.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool isExternallyVisible() const
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
void AddStructuralValue(const APValue &)
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
bool IsClassExtension() const
const ObjCInterfaceDecl * getClassInterface() const
Selector getSelector() const
bool isInstanceMethod() const
ObjCInterfaceDecl * getClassInterface()
bool isClassProperty() const
ObjCPropertyDecl * getPropertyDecl() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getCanonicalType() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isEmbeddedInDeclarator() const
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
TypedefNameDecl * getTypedefNameForAnonDecl() const
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
TagKind getTagKind() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isExtVectorType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR for a top-level module name, including the USR prefix.
static StringRef getUSRSpacePrefix()
void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class category.
bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS)
Generate a USR for a module, including the USR prefix.
bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR fragment for a module name.
bool generateUSRForMacro(const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
Generate a USR for a macro, including the USR prefix.
void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS)
Generate a USR fragment for an Objective-C property.
void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS)
Generate a USR fragment for an enum constant.
void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS)
Generate a USR fragment for an Objective-C instance variable.
void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
Generate a USR fragment for an Objective-C method.
bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf)
Generates a USR for a type.
void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class.
void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate USR fragment for a global (non-nested) enum.
void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C protocol.
bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS)
Generate a USR fragment for a module.
bool generateUSRForDecl(const Decl *D, SmallVectorImpl< char > &Buf)
Generate a USR for a Decl, including the USR prefix.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
std::pair< FileID, unsigned > FileIDAndOffset
@ Template
We are parsing a template declaration.
U cast(CodeGen::Address addr)
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned ConstantArraySizeAsWritten
Whether we should print the sizes of constant array expressions as written in the sources.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
@ Plain
E.g., (anonymous enum)/(unnamed struct)/etc.
unsigned AnonymousTagNameStyle