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,
150 StringRef clsExt, StringRef catExt) {
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()) {
307void USRGenerator::VisitNamedDecl(
const NamedDecl *D) {
311 if (EmitDeclName(D)) {
316 IgnoreResults =
true;
320void USRGenerator::VisitVarDecl(
const VarDecl *D) {
324 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
331 VisitTemplateParameterList(VarTmpl->getTemplateParameters());
332 }
else if (
const VarTemplatePartialSpecializationDecl *PartialSpec
333 = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
335 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
346 IgnoreResults =
true;
351 if (
const VarTemplateSpecializationDecl *Spec
352 = dyn_cast<VarTemplateSpecializationDecl>(D)) {
353 const TemplateArgumentList &Args = Spec->getTemplateArgs();
355 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
357 VisitTemplateArgument(Args.
get(I));
362void USRGenerator::VisitBindingDecl(
const BindingDecl *D) {
363 if (isLocal(D) && GenLoc(D,
true))
368void USRGenerator::VisitNonTypeTemplateParmDecl(
369 const NonTypeTemplateParmDecl *D) {
373void USRGenerator::VisitTemplateTemplateParmDecl(
374 const TemplateTemplateParmDecl *D) {
378void USRGenerator::VisitNamespaceDecl(
const NamespaceDecl *D) {
389void USRGenerator::VisitFunctionTemplateDecl(
const FunctionTemplateDecl *D) {
393void USRGenerator::VisitClassTemplateDecl(
const ClassTemplateDecl *D) {
397void USRGenerator::VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D) {
406 if (
auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->
getDeclContext()))
407 return ICD->getCategoryDecl();
411void USRGenerator::VisitObjCMethodDecl(
const ObjCMethodDecl *D) {
413 if (
const ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
421 IgnoreResults =
true;
425 VisitObjCContainerDecl(ID, CD);
434void USRGenerator::VisitObjCContainerDecl(
const ObjCContainerDecl *D,
435 const ObjCCategoryDecl *CatD) {
438 llvm_unreachable(
"Invalid ObjC container.");
439 case Decl::ObjCInterface:
440 case Decl::ObjCImplementation:
444 case Decl::ObjCCategory: {
452 IgnoreResults =
true;
458 Out <<
"objc(ext)" <<
ID->getName() <<
'@';
462 GenObjCCategory(
ID->getName(), CD->
getName(),
468 case Decl::ObjCCategoryImpl: {
476 IgnoreResults =
true;
479 GenObjCCategory(
ID->getName(), CD->
getName(),
484 case Decl::ObjCProtocol: {
492void USRGenerator::VisitObjCPropertyDecl(
const ObjCPropertyDecl *D) {
502void USRGenerator::VisitObjCPropertyImplDecl(
const ObjCPropertyImplDecl *D) {
504 VisitObjCPropertyDecl(PD);
508 IgnoreResults =
true;
511void USRGenerator::VisitTagDecl(
const TagDecl *D) {
515 ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
518 GenExtSymbolContainer(D);
523 bool AlreadyStarted =
false;
524 if (
const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
525 if (ClassTemplateDecl *ClassTmpl =
CXXRecord->getDescribedClassTemplate()) {
526 AlreadyStarted =
true;
529 case TagTypeKind::Interface:
530 case TagTypeKind::Class:
531 case TagTypeKind::Struct:
534 case TagTypeKind::Union:
537 case TagTypeKind::Enum:
538 llvm_unreachable(
"enum template");
540 VisitTemplateParameterList(ClassTmpl->getTemplateParameters());
541 }
else if (
const ClassTemplatePartialSpecializationDecl *PartialSpec
542 = dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord)) {
543 AlreadyStarted =
true;
546 case TagTypeKind::Interface:
547 case TagTypeKind::Class:
548 case TagTypeKind::Struct:
551 case TagTypeKind::Union:
554 case TagTypeKind::Enum:
555 llvm_unreachable(
"enum partial specialization");
557 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
561 if (!AlreadyStarted) {
563 case TagTypeKind::Interface:
564 case TagTypeKind::Class:
565 case TagTypeKind::Struct:
568 case TagTypeKind::Union:
571 case TagTypeKind::Enum:
578 assert(Buf.size() > 0);
579 const unsigned off = Buf.size() - 1;
581 if (EmitDeclName(D)) {
590 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
593 auto enum_range = ED->enumerators();
594 if (enum_range.begin() != enum_range.end()) {
595 Out <<
'@' << **enum_range.begin();
603 if (
const ClassTemplateSpecializationDecl *Spec
604 = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
605 const TemplateArgumentList &Args = Spec->getTemplateArgs();
607 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
609 VisitTemplateArgument(Args.
get(I));
614void USRGenerator::VisitTypedefDecl(
const TypedefDecl *D) {
615 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
618 if (
const NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
624void USRGenerator::VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *D) {
628void USRGenerator::GenExtSymbolContainer(
const NamedDecl *D) {
630 if (!Container.empty())
631 Out <<
"@M@" << Container;
634bool USRGenerator::GenLoc(
const Decl *D,
bool IncludeOffset) {
636 return IgnoreResults;
641 IgnoreResults =
true;
652 return IgnoreResults;
666void USRGenerator::VisitType(QualType
T) {
670 ASTContext &Ctx = *Context;
674 Qualifiers Q =
T.getQualifiers();
683 Out << ((char) (
'0' + qVal));
687 if (
const PackExpansionType *Expansion =
T->
getAs<PackExpansionType>()) {
689 T = Expansion->getPattern();
692 if (
const BuiltinType *BT =
T->
getAs<BuiltinType>()) {
693 switch (BT->getKind()) {
694 case BuiltinType::Void:
696 case BuiltinType::Bool:
698 case BuiltinType::UChar:
700 case BuiltinType::Char8:
702 case BuiltinType::Char16:
704 case BuiltinType::Char32:
706 case BuiltinType::UShort:
708 case BuiltinType::UInt:
710 case BuiltinType::ULong:
712 case BuiltinType::ULongLong:
714 case BuiltinType::UInt128:
716 case BuiltinType::Char_U:
717 case BuiltinType::Char_S:
719 case BuiltinType::SChar:
721 case BuiltinType::WChar_S:
722 case BuiltinType::WChar_U:
724 case BuiltinType::Short:
726 case BuiltinType::Int:
728 case BuiltinType::Long:
730 case BuiltinType::LongLong:
732 case BuiltinType::Int128:
734 case BuiltinType::Float16:
735 case BuiltinType::Half:
737 case BuiltinType::Float:
739 case BuiltinType::Double:
741 case BuiltinType::LongDouble:
743 case BuiltinType::Float128:
745 case BuiltinType::NullPtr:
747#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
748 case BuiltinType::Id: \
749 Out << "@BT@" << #Suffix << "_" << #ImgType; break;
750#include "clang/Basic/OpenCLImageTypes.def"
751#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
752 case BuiltinType::Id: \
753 Out << "@BT@" << #ExtType; break;
754#include "clang/Basic/OpenCLExtensionTypes.def"
755 case BuiltinType::OCLEvent:
756 Out <<
"@BT@OCLEvent";
break;
757 case BuiltinType::OCLClkEvent:
758 Out <<
"@BT@OCLClkEvent";
break;
759 case BuiltinType::OCLQueue:
760 Out <<
"@BT@OCLQueue";
break;
761 case BuiltinType::OCLReserveID:
762 Out <<
"@BT@OCLReserveID";
break;
763 case BuiltinType::OCLSampler:
764 Out <<
"@BT@OCLSampler";
break;
765#define SVE_TYPE(Name, Id, SingletonId) \
766 case BuiltinType::Id: \
767 Out << "@BT@" << #Name; \
769#include "clang/Basic/AArch64ACLETypes.def"
770#define PPC_VECTOR_TYPE(Name, Id, Size) \
771 case BuiltinType::Id: \
772 Out << "@BT@" << #Name; break;
773#include "clang/Basic/PPCTypes.def"
774#define RVV_TYPE(Name, Id, SingletonId) \
775 case BuiltinType::Id: \
776 Out << "@BT@" << Name; break;
777#include "clang/Basic/RISCVVTypes.def"
778#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
779#include "clang/Basic/WebAssemblyReferenceTypes.def"
780#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
781 case BuiltinType::Id: \
782 Out << "@BT@" << #Name; \
784#include "clang/Basic/AMDGPUTypes.def"
785#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
786 case BuiltinType::Id: \
787 Out << "@BT@" << #Name; \
789#include "clang/Basic/HLSLIntangibleTypes.def"
790 case BuiltinType::ShortAccum:
791 Out <<
"@BT@ShortAccum";
break;
792 case BuiltinType::Accum:
793 Out <<
"@BT@Accum";
break;
794 case BuiltinType::LongAccum:
795 Out <<
"@BT@LongAccum";
break;
796 case BuiltinType::UShortAccum:
797 Out <<
"@BT@UShortAccum";
break;
798 case BuiltinType::UAccum:
799 Out <<
"@BT@UAccum";
break;
800 case BuiltinType::ULongAccum:
801 Out <<
"@BT@ULongAccum";
break;
802 case BuiltinType::ShortFract:
803 Out <<
"@BT@ShortFract";
break;
804 case BuiltinType::Fract:
805 Out <<
"@BT@Fract";
break;
806 case BuiltinType::LongFract:
807 Out <<
"@BT@LongFract";
break;
808 case BuiltinType::UShortFract:
809 Out <<
"@BT@UShortFract";
break;
810 case BuiltinType::UFract:
811 Out <<
"@BT@UFract";
break;
812 case BuiltinType::ULongFract:
813 Out <<
"@BT@ULongFract";
break;
814 case BuiltinType::SatShortAccum:
815 Out <<
"@BT@SatShortAccum";
break;
816 case BuiltinType::SatAccum:
817 Out <<
"@BT@SatAccum";
break;
818 case BuiltinType::SatLongAccum:
819 Out <<
"@BT@SatLongAccum";
break;
820 case BuiltinType::SatUShortAccum:
821 Out <<
"@BT@SatUShortAccum";
break;
822 case BuiltinType::SatUAccum:
823 Out <<
"@BT@SatUAccum";
break;
824 case BuiltinType::SatULongAccum:
825 Out <<
"@BT@SatULongAccum";
break;
826 case BuiltinType::SatShortFract:
827 Out <<
"@BT@SatShortFract";
break;
828 case BuiltinType::SatFract:
829 Out <<
"@BT@SatFract";
break;
830 case BuiltinType::SatLongFract:
831 Out <<
"@BT@SatLongFract";
break;
832 case BuiltinType::SatUShortFract:
833 Out <<
"@BT@SatUShortFract";
break;
834 case BuiltinType::SatUFract:
835 Out <<
"@BT@SatUFract";
break;
836 case BuiltinType::SatULongFract:
837 Out <<
"@BT@SatULongFract";
break;
838 case BuiltinType::BFloat16:
839 Out <<
"@BT@__bf16";
break;
840 case BuiltinType::Ibm128:
841 Out <<
"@BT@__ibm128";
break;
842 case BuiltinType::ObjCId:
844 case BuiltinType::ObjCClass:
846 case BuiltinType::ObjCSel:
848#define BUILTIN_TYPE(Id, SingletonId)
849#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
850#include "clang/AST/BuiltinTypes.def"
851 case BuiltinType::Dependent:
854 IgnoreResults =
true;
862 auto [Substitution, Inserted] =
863 TypeSubstitutions.try_emplace(
T.getTypePtr(), TypeSubstitutions.size());
865 Out <<
'S' << Substitution->second <<
'_';
869 if (
const PointerType *PT =
T->
getAs<PointerType>()) {
874 if (
const ObjCObjectPointerType *OPT =
T->
getAs<ObjCObjectPointerType>()) {
879 if (
const RValueReferenceType *RT =
T->
getAs<RValueReferenceType>()) {
884 if (
const ReferenceType *RT =
T->
getAs<ReferenceType>()) {
889 if (
const FunctionProtoType *FT =
T->
getAs<FunctionProtoType>()) {
891 VisitType(FT->getReturnType());
893 for (
const auto &I : FT->param_types()) {
898 if (FT->isVariadic())
902 if (
const BlockPointerType *BT =
T->
getAs<BlockPointerType>()) {
907 if (
const ComplexType *CT =
T->
getAs<ComplexType>()) {
909 T = CT->getElementType();
912 if (
const TagType *TT =
T->
getAs<TagType>()) {
913 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TT)) {
914 T = ICNT->getOriginalDecl()->getCanonicalTemplateSpecializationType(
918 VisitTagDecl(TT->getOriginalDecl());
922 if (
const ObjCInterfaceType *OIT =
T->
getAs<ObjCInterfaceType>()) {
924 VisitObjCInterfaceDecl(OIT->getDecl());
927 if (
const ObjCObjectType *OIT =
T->
getAs<ObjCObjectType>()) {
929 VisitType(OIT->getBaseType());
930 for (
auto *Prot : OIT->getProtocols())
931 VisitObjCProtocolDecl(Prot);
934 if (
const TemplateTypeParmType *TTP =
936 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
939 if (
const TemplateSpecializationType *Spec
940 =
T->
getAs<TemplateSpecializationType>()) {
942 VisitTemplateName(Spec->getTemplateName());
943 Out << Spec->template_arguments().size();
944 for (
const auto &Arg : Spec->template_arguments())
945 VisitTemplateArgument(Arg);
948 if (
const DependentNameType *DNT =
T->
getAs<DependentNameType>()) {
951 Out <<
':' << DNT->getIdentifier()->getName();
954 if (
const auto *VT =
T->
getAs<VectorType>()) {
956 Out << VT->getNumElements();
957 T = VT->getElementType();
960 if (
const auto *
const AT = dyn_cast<ArrayType>(
T)) {
962 switch (AT->getSizeModifier()) {
963 case ArraySizeModifier::Static:
966 case ArraySizeModifier::Star:
969 case ArraySizeModifier::Normal:
973 if (
const auto *
const CAT = dyn_cast<ConstantArrayType>(
T))
974 Out << CAT->getSize();
976 T = AT->getElementType();
986void USRGenerator::VisitTemplateParameterList(
987 const TemplateParameterList *Params) {
990 Out <<
'>' << Params->
size();
991 for (TemplateParameterList::const_iterator P = Params->
begin(),
992 PEnd = Params->
end();
1002 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
1003 if (NTTP->isParameterPack())
1006 VisitType(NTTP->getType());
1018void USRGenerator::VisitTemplateName(
TemplateName Name) {
1020 if (TemplateTemplateParmDecl *TTP
1021 = dyn_cast<TemplateTemplateParmDecl>(
Template)) {
1022 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
1033void USRGenerator::VisitTemplateArgument(
const TemplateArgument &Arg) {
1059 VisitTemplateArgument(P);
1083void USRGenerator::VisitUnresolvedUsingValueDecl(
const UnresolvedUsingValueDecl *D) {
1084 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1092void USRGenerator::VisitUnresolvedUsingTypenameDecl(
const UnresolvedUsingTypenameDecl *D) {
1093 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1101void USRGenerator::VisitConceptDecl(
const ConceptDecl *D) {
1102 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1109void USRGenerator::VisitMSGuidDecl(
const MSGuidDecl *D) {
1112 D->NamedDecl::printName(Out);
1120 StringRef CatSymDefinedIn,
1122 if (ClsSymDefinedIn.empty() && CatSymDefinedIn.empty())
1124 if (CatSymDefinedIn.empty()) {
1125 OS <<
"@M@" << ClsSymDefinedIn <<
'@';
1128 OS <<
"@CM@" << CatSymDefinedIn <<
'@';
1129 if (ClsSymDefinedIn != CatSymDefinedIn) {
1130 OS << ClsSymDefinedIn <<
'@';
1135 StringRef ExtSymDefinedIn,
1136 StringRef CategoryContextExtSymbolDefinedIn) {
1138 CategoryContextExtSymbolDefinedIn, OS);
1139 OS <<
"objc(cs)" << Cls;
1144 StringRef ClsSymDefinedIn,
1145 StringRef CatSymDefinedIn) {
1147 OS <<
"objc(cy)" << Cls <<
'@' << Cat;
1155 bool IsInstanceMethod,
1157 OS << (IsInstanceMethod ?
"(im)" :
"(cm)") << Sel;
1162 OS << (isClassProp ?
"(cpy)" :
"(py)") << Prop;
1166 StringRef ExtSymDefinedIn) {
1167 if (!ExtSymDefinedIn.empty())
1168 OS <<
"@M@" << ExtSymDefinedIn <<
'@';
1169 OS <<
"objc(pl)" << Prot;
1173 StringRef ExtSymDefinedIn) {
1174 if (!ExtSymDefinedIn.empty())
1175 OS <<
"@M@" << ExtSymDefinedIn;
1176 OS <<
"@E@" << EnumName;
1181 OS <<
'@' << EnumConstantName;
1201 if (
auto *ExternalSymAttr = CD->
getAttr<ExternalSourceSymbolAttr>()) {
1202 if (!ExternalSymAttr->getUSR().empty()) {
1203 llvm::raw_svector_ostream Out(Buf);
1204 Out << ExternalSymAttr->getUSR();
1210 return UG.ignoreResults();
1226 if (MacroName.empty())
1229 llvm::raw_svector_ostream Out(Buf);
1233 bool ShouldGenerateLocation = Loc.
isValid() && !
SM.isInSystemHeader(Loc);
1236 if (ShouldGenerateLocation)
1253 T =
T.getCanonicalType();
1255 USRGenerator UG(&Ctx, Buf, LangOpts);
1257 return UG.ignoreResults();
1282 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()
CanQualType getCanonicalType(QualType T) const
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.
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
const FunctionProtoType * T
@ 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 AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g.,...
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.