17#include "llvm/Support/Path.h"
18#include "llvm/Support/raw_ostream.h"
33 if (
SM.getExpansionLoc(Loc) ==
SM.getSpellingLoc(Loc)) {
37 OS <<
'@' <<
SM.getDecomposedLoc(Loc).second;
42 OS <<
'@' <<
SM.getDecomposedLoc(
SM.getExpansionLoc(Loc)).second;
43 OS <<
'@' <<
SM.getDecomposedLoc(
SM.getSpellingLoc(Loc)).second;
55 Loc =
SM.getExpansionLoc(Loc);
59 OS << llvm::sys::path::filename(FE->
getName());
77 return attr->getDefinedIn();
84 SmallVectorImpl<char> &Buf;
85 llvm::raw_svector_ostream Out;
87 const LangOptions &LangOpts;
88 bool IgnoreResults =
false;
93 bool GeneratedFilename =
false;
95 llvm::DenseMap<const Type *, unsigned> TypeSubstitutions;
98 USRGenerator(ASTContext *Ctx, SmallVectorImpl<char> &Buf,
99 const LangOptions &LangOpts)
100 : Buf(Buf), Out(Buf), Context(Ctx), LangOpts(LangOpts) {
105 bool ignoreResults()
const {
return IgnoreResults; }
108 void VisitDeclContext(
const DeclContext *D);
109 void VisitFieldDecl(
const FieldDecl *D);
110 void VisitFunctionDecl(
const FunctionDecl *D);
111 void VisitNamedDecl(
const NamedDecl *D);
112 void VisitNamespaceDecl(
const NamespaceDecl *D);
113 void VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D);
114 void VisitFunctionTemplateDecl(
const FunctionTemplateDecl *D);
115 void VisitClassTemplateDecl(
const ClassTemplateDecl *D);
116 void VisitObjCContainerDecl(
const ObjCContainerDecl *CD,
117 const ObjCCategoryDecl *CatD =
nullptr);
118 void VisitObjCMethodDecl(
const ObjCMethodDecl *MD);
119 void VisitObjCPropertyDecl(
const ObjCPropertyDecl *D);
120 void VisitObjCPropertyImplDecl(
const ObjCPropertyImplDecl *D);
121 void VisitTagDecl(
const TagDecl *D);
122 void VisitTypedefDecl(
const TypedefDecl *D);
123 void VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *D);
124 void VisitVarDecl(
const VarDecl *D);
125 void VisitBindingDecl(
const BindingDecl *D);
126 void VisitNonTypeTemplateParmDecl(
const NonTypeTemplateParmDecl *D);
127 void VisitTemplateTemplateParmDecl(
const TemplateTemplateParmDecl *D);
128 void VisitUnresolvedUsingValueDecl(
const UnresolvedUsingValueDecl *D);
129 void VisitUnresolvedUsingTypenameDecl(
const UnresolvedUsingTypenameDecl *D);
130 void VisitConceptDecl(
const ConceptDecl *D);
132 void VisitLinkageSpecDecl(
const LinkageSpecDecl *D) {
133 IgnoreResults =
true;
136 void VisitUsingDirectiveDecl(
const UsingDirectiveDecl *D) {
137 IgnoreResults =
true;
140 void VisitUsingDecl(
const UsingDecl *D) {
144 bool EmittedDeclName = !EmitDeclName(D);
145 assert(EmittedDeclName &&
"EmitDeclName can not fail for UsingDecls");
146 (void)EmittedDeclName;
149 bool ShouldGenerateLocation(
const NamedDecl *D);
151 bool isLocal(
const NamedDecl *D) {
155 void GenExtSymbolContainer(
const NamedDecl *D);
159 bool GenLoc(
const Decl *D,
bool IncludeOffset);
168 void GenObjCClass(StringRef cls, StringRef ExtSymDefinedIn,
169 StringRef CategoryContextExtSymbolDefinedIn) {
171 CategoryContextExtSymbolDefinedIn);
175 void GenObjCCategory(StringRef cls, StringRef cat, StringRef clsExt,
181 void GenObjCProperty(StringRef prop,
bool isClassProp) {
186 void GenObjCProtocol(StringRef prot, StringRef ext) {
190 void VisitType(QualType T);
191 void VisitTemplateParameterList(
const TemplateParameterList *Params);
193 void VisitTemplateArgument(
const TemplateArgument &Arg);
195 void VisitMSGuidDecl(
const MSGuidDecl *D);
199 bool EmitDeclName(
const NamedDecl *D);
207bool USRGenerator::EmitDeclName(
const NamedDecl *D) {
215bool USRGenerator::ShouldGenerateLocation(
const NamedDecl *D) {
227void USRGenerator::VisitDeclContext(
const DeclContext *DC) {
228 if (
const NamedDecl *D = dyn_cast<NamedDecl>(DC))
234void USRGenerator::VisitFieldDecl(
const FieldDecl *D) {
241 Out << (isa<ObjCIvarDecl>(D) ?
"@" :
"@FI@");
242 if (EmitDeclName(D)) {
244 IgnoreResults =
true;
249void USRGenerator::VisitFunctionDecl(
const FunctionDecl *D) {
250 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
254 IgnoreResults =
true;
258 const unsigned StartSize = Buf.size();
260 if (Buf.size() == StartSize)
261 GenExtSymbolContainer(D);
263 bool IsTemplate =
false;
267 VisitTemplateParameterList(FunTmpl->getTemplateParameters());
271 PrintingPolicy Policy(LangOpts);
274 Policy.SuppressTemplateArgsInCXXConstructors =
true;
277 if ((!LangOpts.CPlusPlus || D->
isExternC()) &&
278 !D->
hasAttr<OverloadableAttr>())
283 if (
const TemplateArgumentList *SpecArgs =
285 for (
const auto &Arg : SpecArgs->asArray()) {
287 VisitTemplateArgument(Arg);
289 }
else if (
const ASTTemplateArgumentListInfo *SpecArgsWritten =
291 for (
const auto &ArgLoc : SpecArgsWritten->arguments()) {
293 VisitTemplateArgument(ArgLoc.getArgument());
301 if (
const auto *FPT = CanonicalType->
getAs<FunctionProtoType>()) {
302 for (QualType PT : FPT->param_types()) {
319 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
323 if (
unsigned quals = MD->getMethodQualifiers().getCVRUQualifiers())
324 Out << (char)(
'0' + quals);
325 switch (MD->getRefQualifier()) {
338void USRGenerator::VisitNamedDecl(
const NamedDecl *D) {
342 if (EmitDeclName(D)) {
347 IgnoreResults =
true;
351void USRGenerator::VisitVarDecl(
const VarDecl *D) {
355 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
362 VisitTemplateParameterList(VarTmpl->getTemplateParameters());
363 }
else if (
const VarTemplatePartialSpecializationDecl *PartialSpec =
364 dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
366 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
377 IgnoreResults =
true;
382 if (
const VarTemplateSpecializationDecl *Spec =
383 dyn_cast<VarTemplateSpecializationDecl>(D)) {
384 const TemplateArgumentList &Args = Spec->getTemplateArgs();
386 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
388 VisitTemplateArgument(Args.
get(I));
393void USRGenerator::VisitBindingDecl(
const BindingDecl *D) {
394 if (isLocal(D) && GenLoc(D,
true))
399void USRGenerator::VisitNonTypeTemplateParmDecl(
400 const NonTypeTemplateParmDecl *D) {
404void USRGenerator::VisitTemplateTemplateParmDecl(
405 const TemplateTemplateParmDecl *D) {
409void USRGenerator::VisitNamespaceDecl(
const NamespaceDecl *D) {
420void USRGenerator::VisitFunctionTemplateDecl(
const FunctionTemplateDecl *D) {
424void USRGenerator::VisitClassTemplateDecl(
const ClassTemplateDecl *D) {
428void USRGenerator::VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D) {
437 if (
auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->
getDeclContext()))
438 return ICD->getCategoryDecl();
442void USRGenerator::VisitObjCMethodDecl(
const ObjCMethodDecl *D) {
444 if (
const ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
451 IgnoreResults =
true;
455 VisitObjCContainerDecl(ID, CD);
464void USRGenerator::VisitObjCContainerDecl(
const ObjCContainerDecl *D,
465 const ObjCCategoryDecl *CatD) {
468 llvm_unreachable(
"Invalid ObjC container.");
469 case Decl::ObjCInterface:
470 case Decl::ObjCImplementation:
474 case Decl::ObjCCategory: {
482 IgnoreResults =
true;
488 Out <<
"objc(ext)" <<
ID->getName() <<
'@';
491 GenObjCCategory(
ID->getName(), CD->
getName(),
497 case Decl::ObjCCategoryImpl: {
505 IgnoreResults =
true;
508 GenObjCCategory(
ID->getName(), CD->
getName(),
513 case Decl::ObjCProtocol: {
521void USRGenerator::VisitObjCPropertyDecl(
const ObjCPropertyDecl *D) {
531void USRGenerator::VisitObjCPropertyImplDecl(
const ObjCPropertyImplDecl *D) {
533 VisitObjCPropertyDecl(PD);
537 IgnoreResults =
true;
540void USRGenerator::VisitTagDecl(
const TagDecl *D) {
544 GenLoc(D, isLocal(D)))
547 GenExtSymbolContainer(D);
552 bool AlreadyStarted =
false;
553 if (
const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
554 if (ClassTemplateDecl *ClassTmpl =
CXXRecord->getDescribedClassTemplate()) {
555 AlreadyStarted =
true;
558 case TagTypeKind::Interface:
559 case TagTypeKind::Class:
560 case TagTypeKind::Struct:
563 case TagTypeKind::Union:
566 case TagTypeKind::Enum:
567 llvm_unreachable(
"enum template");
569 VisitTemplateParameterList(ClassTmpl->getTemplateParameters());
570 }
else if (
const ClassTemplatePartialSpecializationDecl *PartialSpec =
571 dyn_cast<ClassTemplatePartialSpecializationDecl>(
573 AlreadyStarted =
true;
576 case TagTypeKind::Interface:
577 case TagTypeKind::Class:
578 case TagTypeKind::Struct:
581 case TagTypeKind::Union:
584 case TagTypeKind::Enum:
585 llvm_unreachable(
"enum partial specialization");
587 VisitTemplateParameterList(PartialSpec->getTemplateParameters());
591 if (!AlreadyStarted) {
593 case TagTypeKind::Interface:
594 case TagTypeKind::Class:
595 case TagTypeKind::Struct:
598 case TagTypeKind::Union:
601 case TagTypeKind::Enum:
608 assert(Buf.size() > 0);
609 const unsigned off = Buf.size() - 1;
611 if (EmitDeclName(D)) {
620 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
623 auto enum_range = ED->enumerators();
624 if (enum_range.begin() != enum_range.end()) {
625 Out <<
'@' << **enum_range.begin();
633 if (
const ClassTemplateSpecializationDecl *Spec =
634 dyn_cast<ClassTemplateSpecializationDecl>(D)) {
635 const TemplateArgumentList &Args = Spec->getTemplateArgs();
637 for (
unsigned I = 0, N = Args.
size(); I != N; ++I) {
639 VisitTemplateArgument(Args.
get(I));
644void USRGenerator::VisitTypedefDecl(
const TypedefDecl *D) {
645 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
648 if (
const NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
654void USRGenerator::VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *D) {
658void USRGenerator::GenExtSymbolContainer(
const NamedDecl *D) {
660 if (!Container.empty())
661 Out <<
"@M@" << Container;
664bool USRGenerator::GenLoc(
const Decl *D,
bool IncludeOffset) {
667 IgnoreResults =
true;
671 if (!IncludeOffset && GeneratedFilename)
672 return IgnoreResults;
674 bool PrintErr =
false;
678 if (!GeneratedFilename) {
679 GeneratedFilename =
true;
686 IgnoreResults = IgnoreResults || PrintErr;
687 return IgnoreResults;
702void USRGenerator::VisitType(QualType T) {
706 ASTContext &Ctx = *Context;
719 Out << ((char)(
'0' + qVal));
723 if (
const PackExpansionType *Expansion = T->
getAs<PackExpansionType>()) {
725 T = Expansion->getPattern();
728 if (
const BuiltinType *BT = T->
getAs<BuiltinType>()) {
729 switch (BT->getKind()) {
730 case BuiltinType::Void:
733 case BuiltinType::Bool:
736 case BuiltinType::UChar:
739 case BuiltinType::Char8:
742 case BuiltinType::Char16:
745 case BuiltinType::Char32:
748 case BuiltinType::UShort:
751 case BuiltinType::UInt:
754 case BuiltinType::ULong:
757 case BuiltinType::ULongLong:
760 case BuiltinType::UInt128:
763 case BuiltinType::Char_U:
764 case BuiltinType::Char_S:
767 case BuiltinType::SChar:
770 case BuiltinType::WChar_S:
771 case BuiltinType::WChar_U:
774 case BuiltinType::Short:
777 case BuiltinType::Int:
780 case BuiltinType::Long:
783 case BuiltinType::LongLong:
786 case BuiltinType::Int128:
789 case BuiltinType::Float16:
790 case BuiltinType::Half:
793 case BuiltinType::Float:
796 case BuiltinType::Double:
799 case BuiltinType::LongDouble:
802 case BuiltinType::Float128:
805 case BuiltinType::NullPtr:
808#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
809 case BuiltinType::Id: \
810 Out << "@BT@" << #Suffix << "_" << #ImgType; \
812#include "clang/Basic/OpenCLImageTypes.def"
813#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
814 case BuiltinType::Id: \
815 Out << "@BT@" << #ExtType; \
817#include "clang/Basic/OpenCLExtensionTypes.def"
818 case BuiltinType::OCLEvent:
819 Out <<
"@BT@OCLEvent";
821 case BuiltinType::OCLClkEvent:
822 Out <<
"@BT@OCLClkEvent";
824 case BuiltinType::OCLQueue:
825 Out <<
"@BT@OCLQueue";
827 case BuiltinType::OCLReserveID:
828 Out <<
"@BT@OCLReserveID";
830 case BuiltinType::OCLSampler:
831 Out <<
"@BT@OCLSampler";
833#define SVE_TYPE(Name, Id, SingletonId) \
834 case BuiltinType::Id: \
835 Out << "@BT@" << #Name; \
837#include "clang/Basic/AArch64ACLETypes.def"
838#define PPC_VECTOR_TYPE(Name, Id, Size) \
839 case BuiltinType::Id: \
840 Out << "@BT@" << #Name; \
842#include "clang/Basic/PPCTypes.def"
843#define RVV_TYPE(Name, Id, SingletonId) \
844 case BuiltinType::Id: \
845 Out << "@BT@" << Name; \
847#include "clang/Basic/RISCVVTypes.def"
848#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
849#include "clang/Basic/WebAssemblyReferenceTypes.def"
850#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
851 case BuiltinType::Id: \
852 Out << "@BT@" << #Name; \
854#include "clang/Basic/AMDGPUTypes.def"
855#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
856 case BuiltinType::Id: \
857 Out << "@BT@" << #Name; \
859#include "clang/Basic/HLSLIntangibleTypes.def"
860 case BuiltinType::ShortAccum:
861 Out <<
"@BT@ShortAccum";
863 case BuiltinType::Accum:
866 case BuiltinType::LongAccum:
867 Out <<
"@BT@LongAccum";
869 case BuiltinType::UShortAccum:
870 Out <<
"@BT@UShortAccum";
872 case BuiltinType::UAccum:
875 case BuiltinType::ULongAccum:
876 Out <<
"@BT@ULongAccum";
878 case BuiltinType::ShortFract:
879 Out <<
"@BT@ShortFract";
881 case BuiltinType::Fract:
884 case BuiltinType::LongFract:
885 Out <<
"@BT@LongFract";
887 case BuiltinType::UShortFract:
888 Out <<
"@BT@UShortFract";
890 case BuiltinType::UFract:
893 case BuiltinType::ULongFract:
894 Out <<
"@BT@ULongFract";
896 case BuiltinType::SatShortAccum:
897 Out <<
"@BT@SatShortAccum";
899 case BuiltinType::SatAccum:
900 Out <<
"@BT@SatAccum";
902 case BuiltinType::SatLongAccum:
903 Out <<
"@BT@SatLongAccum";
905 case BuiltinType::SatUShortAccum:
906 Out <<
"@BT@SatUShortAccum";
908 case BuiltinType::SatUAccum:
909 Out <<
"@BT@SatUAccum";
911 case BuiltinType::SatULongAccum:
912 Out <<
"@BT@SatULongAccum";
914 case BuiltinType::SatShortFract:
915 Out <<
"@BT@SatShortFract";
917 case BuiltinType::SatFract:
918 Out <<
"@BT@SatFract";
920 case BuiltinType::SatLongFract:
921 Out <<
"@BT@SatLongFract";
923 case BuiltinType::SatUShortFract:
924 Out <<
"@BT@SatUShortFract";
926 case BuiltinType::SatUFract:
927 Out <<
"@BT@SatUFract";
929 case BuiltinType::SatULongFract:
930 Out <<
"@BT@SatULongFract";
932 case BuiltinType::BFloat16:
935 case BuiltinType::Ibm128:
936 Out <<
"@BT@__ibm128";
938 case BuiltinType::ObjCId:
941 case BuiltinType::ObjCClass:
944 case BuiltinType::ObjCSel:
947#define BUILTIN_TYPE(Id, SingletonId)
948#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
949#include "clang/AST/BuiltinTypes.def"
950 case BuiltinType::Dependent:
953 IgnoreResults =
true;
961 auto [Substitution, Inserted] =
962 TypeSubstitutions.try_emplace(T.
getTypePtr(), TypeSubstitutions.size());
964 Out <<
'S' << Substitution->second <<
'_';
968 if (
const PointerType *PT = T->
getAs<PointerType>()) {
973 if (
const ObjCObjectPointerType *OPT = T->
getAs<ObjCObjectPointerType>()) {
978 if (
const RValueReferenceType *RT = T->
getAs<RValueReferenceType>()) {
983 if (
const ReferenceType *RT = T->
getAs<ReferenceType>()) {
988 if (
const FunctionProtoType *FT = T->
getAs<FunctionProtoType>()) {
990 VisitType(FT->getReturnType());
992 for (
const auto &I : FT->param_types()) {
997 if (FT->isVariadic())
1001 if (
const BlockPointerType *BT = T->
getAs<BlockPointerType>()) {
1006 if (
const ComplexType *CT = T->
getAs<ComplexType>()) {
1008 T = CT->getElementType();
1011 if (
const TagType *TT = T->
getAs<TagType>()) {
1012 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TT)) {
1013 T = ICNT->getDecl()->getCanonicalTemplateSpecializationType(Ctx);
1016 VisitTagDecl(TT->getDecl());
1020 if (
const ObjCInterfaceType *OIT = T->
getAs<ObjCInterfaceType>()) {
1022 VisitObjCInterfaceDecl(OIT->getDecl());
1025 if (
const ObjCObjectType *OIT = T->
getAs<ObjCObjectType>()) {
1027 VisitType(OIT->getBaseType());
1028 for (
auto *Prot : OIT->getProtocols())
1029 VisitObjCProtocolDecl(Prot);
1032 if (
const TemplateTypeParmType *TTP =
1034 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
1037 if (
const TemplateSpecializationType *Spec =
1038 T->
getAs<TemplateSpecializationType>()) {
1040 VisitTemplateName(Spec->getTemplateName());
1041 Out << Spec->template_arguments().size();
1042 for (
const auto &Arg : Spec->template_arguments())
1043 VisitTemplateArgument(Arg);
1046 if (
const DependentNameType *DNT = T->
getAs<DependentNameType>()) {
1049 Out <<
':' << DNT->getIdentifier()->getName();
1052 if (
const auto *VT = T->
getAs<VectorType>()) {
1054 Out << VT->getNumElements();
1055 T = VT->getElementType();
1058 if (
const auto *
const AT = dyn_cast<ArrayType>(T)) {
1060 switch (AT->getSizeModifier()) {
1061 case ArraySizeModifier::Static:
1064 case ArraySizeModifier::Star:
1067 case ArraySizeModifier::Normal:
1071 if (
const auto *
const CAT = dyn_cast<ConstantArrayType>(T))
1072 Out << CAT->getSize();
1074 T = AT->getElementType();
1084void USRGenerator::VisitTemplateParameterList(
1085 const TemplateParameterList *Params) {
1088 Out <<
'>' << Params->
size();
1089 for (TemplateParameterList::const_iterator P = Params->
begin(),
1090 PEnd = Params->
end();
1100 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
1101 if (NTTP->isParameterPack())
1104 VisitType(NTTP->getType());
1116void USRGenerator::VisitTemplateName(
TemplateName Name) {
1118 if (TemplateTemplateParmDecl *TTP =
1119 dyn_cast<TemplateTemplateParmDecl>(
Template)) {
1120 Out <<
't' << TTP->getDepth() <<
'.' << TTP->getIndex();
1131void USRGenerator::VisitTemplateArgument(
const TemplateArgument &Arg) {
1157 VisitTemplateArgument(P);
1181void USRGenerator::VisitUnresolvedUsingValueDecl(
1182 const UnresolvedUsingValueDecl *D) {
1183 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1191void USRGenerator::VisitUnresolvedUsingTypenameDecl(
1192 const UnresolvedUsingTypenameDecl *D) {
1193 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1201void USRGenerator::VisitConceptDecl(
const ConceptDecl *D) {
1202 if (ShouldGenerateLocation(D) && GenLoc(D, isLocal(D)))
1209void USRGenerator::VisitMSGuidDecl(
const MSGuidDecl *D) {
1212 D->NamedDecl::printName(Out);
1220 StringRef CatSymDefinedIn,
1222 if (ClsSymDefinedIn.empty() && CatSymDefinedIn.empty())
1224 if (CatSymDefinedIn.empty()) {
1225 OS <<
"@M@" << ClsSymDefinedIn <<
'@';
1228 OS <<
"@CM@" << CatSymDefinedIn <<
'@';
1229 if (ClsSymDefinedIn != CatSymDefinedIn) {
1230 OS << ClsSymDefinedIn <<
'@';
1235 StringRef Cls, raw_ostream &OS, StringRef ExtSymDefinedIn,
1236 StringRef CategoryContextExtSymbolDefinedIn) {
1238 CategoryContextExtSymbolDefinedIn, OS);
1239 OS <<
"objc(cs)" << Cls;
1244 StringRef ClsSymDefinedIn,
1245 StringRef CatSymDefinedIn) {
1247 OS <<
"objc(cy)" << Cls <<
'@' << Cat;
1255 bool IsInstanceMethod,
1257 OS << (IsInstanceMethod ?
"(im)" :
"(cm)") << Sel;
1262 OS << (isClassProp ?
"(cpy)" :
"(py)") << Prop;
1266 StringRef ExtSymDefinedIn) {
1267 if (!ExtSymDefinedIn.empty())
1268 OS <<
"@M@" << ExtSymDefinedIn <<
'@';
1269 OS <<
"objc(pl)" << Prot;
1273 StringRef ExtSymDefinedIn) {
1274 if (!ExtSymDefinedIn.empty())
1275 OS <<
"@M@" << ExtSymDefinedIn;
1276 OS <<
"@E@" << EnumName;
1281 OS <<
'@' << EnumConstantName;
1301 if (
auto *ExternalSymAttr = CD->
getAttr<ExternalSourceSymbolAttr>()) {
1302 if (!ExternalSymAttr->getUSR().empty()) {
1303 llvm::raw_svector_ostream Out(Buf);
1304 Out << ExternalSymAttr->getUSR();
1310 return UG.ignoreResults();
1325 if (MacroName.empty())
1328 llvm::raw_svector_ostream Out(Buf);
1332 bool ShouldGenerateLocation = Loc.
isValid() && !
SM.isInSystemHeader(Loc);
1335 if (ShouldGenerateLocation)
1352 T = T.getCanonicalType();
1354 USRGenerator UG(&Ctx, Buf, LangOpts);
1356 return UG.ignoreResults();
1381 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)
Print Loc including both the file and offset, if IncludeOffset is true.
static const ObjCCategoryDecl * getCategoryContext(const NamedDecl *D)
static void printQualifier(llvm::raw_ostream &Out, const LangOptions &LangOpts, NestedNameSpecifier NNS)
static bool printLocOffset(llvm::raw_ostream &OS, SourceLocation Loc, const SourceManager &SM)
Print only the offset part of Loc.
static StringRef GetExternalSourceContainer(const NamedDecl *D)
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