22 #include "llvm/ADT/FoldingSet.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/raw_ostream.h"
25 using namespace clang;
43 ID.AddPointer(
Type.getAsOpaquePtr());
49 public llvm::FoldingSetNode {
87 void Profile(llvm::FoldingSetNodeID &FSID) {
93 return (A < B ? -1 : (A > B ? 1 : 0));
104 if (!LII)
return RII ? -1 : 0;
118 return LHSSelector.getAsIdentifierInfo()->
getName().compare(
119 RHSSelector.getAsIdentifierInfo()->
getName());
122 for (
unsigned I = 0, N =
std::min(LN, RN);
I != N; ++
I) {
161 llvm_unreachable(
"Invalid DeclarationName Kind!");
171 OS << *ClassRec->getDecl();
176 OS << *InjTy->getDecl();
180 ClassType.
print(OS, Policy);
206 OS <<
"<deduction guide for ";
211 case DeclarationName::CXXOperatorName: {
212 static const char* const OperatorNames[NUM_OVERLOADED_OPERATORS] = {
214 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
216 #include "clang/Basic/OperatorKinds.def"
218 const char *OpName = OperatorNames[N.getCXXOverloadedOperator()];
219 assert(OpName && "not an overloaded operator");
222 if (OpName[0] >= 'a
' && OpName[0] <= 'z
')
228 case DeclarationName::CXXLiteralOperatorName:
229 OS << "operator\"\"" << N.getCXXLiteralIdentifier()->getName();
232 case DeclarationName::CXXConversionFunctionName: {
234 QualType Type = N.getCXXNameType();
235 if (const RecordType *Rec = Type->getAs<RecordType>()) {
236 OS << *Rec->getDecl();
239 // We know we're printing C++ here, ensure we
print 'bool' properly.
242 Type.print(OS, CXXPolicy);
246 OS <<
"<using-directive>";
250 llvm_unreachable(
"Unexpected declaration name kind");
262 switch (getStoredNameKind()) {
267 case StoredDeclarationNameExtra:
268 switch (getExtra()->ExtraKindOrNumArgs) {
289 if (getExtra()->ExtraKindOrNumArgs <
298 llvm_unreachable(
"This should be unreachable!");
308 if (TD && TD->getDeclContext()->isDependentContext())
316 llvm::raw_string_ostream OS(Result);
323 return CXXName->Type;
329 if (
auto *Guide = getAsCXXDeductionGuideNameExtra())
330 return Guide->Template;
351 void *DeclarationName::getFETokenInfoAsVoidSlow()
const {
354 llvm_unreachable(
"Handled by getFETokenInfo()");
362 return getAsCXXDeductionGuideNameExtra()->
FETokenInfo;
368 return getAsCXXLiteralOperatorIdName()->
FETokenInfo;
371 llvm_unreachable(
"Declaration name has no FETokenInfo");
388 getAsCXXDeductionGuideNameExtra()->
FETokenInfo = T;
400 llvm_unreachable(
"Declaration name has no FETokenInfo");
410 Ptr |= StoredDeclarationNameExtra;
416 llvm::errs() << *
this <<
'\n';
419 DeclarationNameTable::DeclarationNameTable(
const ASTContext &C) : Ctx(C) {
420 CXXSpecialNamesImpl =
new llvm::FoldingSet<CXXSpecialName>;
421 CXXLiteralOperatorNames =
new llvm::FoldingSet<CXXLiteralOperatorIdName>;
422 CXXDeductionGuideNames =
new llvm::FoldingSet<CXXDeductionGuideNameExtra>;
435 static_cast<llvm::FoldingSet<CXXSpecialName> *
>(CXXSpecialNamesImpl);
437 static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName> *
>(
438 CXXLiteralOperatorNames);
439 auto *DeductionGuideNames =
440 static_cast<llvm::FoldingSet<CXXDeductionGuideNameExtra> *
>(
441 CXXDeductionGuideNames);
445 delete DeductionGuideNames;
462 auto *DeductionGuideNames =
463 static_cast<llvm::FoldingSet<CXXDeductionGuideNameExtra> *
>(
464 CXXDeductionGuideNames);
466 llvm::FoldingSetNodeID
ID;
467 ID.AddPointer(Template);
469 void *InsertPos =
nullptr;
470 if (
auto *
Name = DeductionGuideNames->FindNodeOrInsertPos(ID, InsertPos))
475 Name->Template = Template;
476 Name->FETokenInfo =
nullptr;
478 DeductionGuideNames->InsertNode(
Name, InsertPos);
492 "Kind must be a C++ special name kind");
493 llvm::FoldingSet<CXXSpecialName> *SpecialNames
494 =
static_cast<llvm::FoldingSet<CXXSpecialName>*
>(CXXSpecialNamesImpl);
500 assert(!Ty.
hasQualifiers() &&
"Constructor type must be unqualified");
504 assert(!Ty.
hasQualifiers() &&
"Destructor type must be unqualified");
514 llvm::FoldingSetNodeID
ID;
515 ID.AddInteger(EKind);
518 void *InsertPos =
nullptr;
524 SpecialName->
Type = Ty;
527 SpecialNames->InsertNode(SpecialName, InsertPos);
538 llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
539 =
static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*
>
540 (CXXLiteralOperatorNames);
542 llvm::FoldingSetNodeID
ID;
545 void *InsertPos =
nullptr;
547 LiteralNames->FindNodeOrInsertPos(ID, InsertPos))
552 LiteralName->
ID = II;
555 LiteralNames->InsertNode(LiteralName, InsertPos);
602 return TInfo->getType()->containsUnexpandedParameterPack();
606 llvm_unreachable(
"All name kinds handled.");
625 return TInfo->getType()->isInstantiationDependentType();
629 llvm_unreachable(
"All name kinds handled.");
634 llvm::raw_string_ostream OS(Result);
665 OS << TInfo->getType().getAsString(PP);
670 llvm_unreachable(
"Unexpected declaration name kind");
693 return TInfo->getTypeLoc().getEndLoc();
704 llvm_unreachable(
"Unexpected declaration name kind");
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
Defines the clang::ASTContext interface.
Smart pointer class that efficiently represents Objective-C method names.
CXXSpecialName - Records the type associated with one of the "special" kinds of declaration names in ...
A (possibly-)qualified type.
NameKind
NameKind - The kind of name this object contains.
QualType Type
Type - The type associated with this declaration name.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
SourceLocation getEndLoc() const
getEndLoc - Retrieve the location of the last token.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
C Language Family Type Representation.
Defines the C++ template declaration subclasses.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
A container of type source information.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Describes how types, statements, expressions, and declarations should be printed. ...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
CXXOperatorIdName - Contains extra information for the name of an overloaded operator in C++...
void Profile(llvm::FoldingSetNodeID &ID)
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static int compare(DeclarationName LHS, DeclarationName RHS)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
static int compareInt(unsigned A, unsigned B)
void print(raw_ostream &OS, const PrintingPolicy &Policy)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool SuppressScope
Suppresses printing of scope specifiers.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
detail::InMemoryDirectory::const_iterator I
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
Function object that provides a total ordering on QualType values.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Allows QualTypes to be sorted and hence used in maps and sets.
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
StringRef getName() const
Return the actual identifier string.
void Profile(llvm::FoldingSetNodeID &FSID)
unsigned getNumArgs() const
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
void setFETokenInfo(void *T)
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
Defines the clang::TypeLoc interface and its subclasses.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
The result type of a method or function.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void * FETokenInfo
FETokenInfo - Extra information associated with this operator name that can be used by the front end...
Encodes a location in the source.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
std::ostream & operator<<(std::ostream &ss, const StringRef str)
void * FETokenInfo
FETokenInfo - Extra information associated with this operator name that can be used by the front end...
The injected class name of a C++ class template or class template partial specialization.
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
DeclarationName - The name of a declaration.
void adjustForCPlusPlus()
Adjust this printing policy for cases where it's known that we're printing C++ code (for instance...
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
bool hasQualifiers() const
Determines whether this type has any qualifiers.
DeclarationName()
DeclarationName - Used to create an empty selector.
Not an overloaded operator.
struct CXXLitOpName CXXLiteralOperatorName
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
CXXLiteralOperatorName - Contains the actual identifier that makes up the name.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setFETokenInfo(void *T)
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
static void printCXXConstructorDestructorName(QualType ClassType, raw_ostream &OS, PrintingPolicy Policy)
void * FETokenInfo
FETokenInfo - Extra information associated with this declaration name that can be used by the front e...
static DeclarationName getUsingDirectiveName()
getUsingDirectiveName - Return name for all using-directives.
bool isNull() const
Return true if this QualType doesn't point to a type yet.