21 #include "llvm/ADT/DenseMap.h"
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());
71 void Profile(llvm::FoldingSetNodeID &FSID) {
77 return (A < B ? -1 : (A > B ? 1 : 0));
88 if (!LII)
return RII ? -1 : 0;
100 for (
unsigned I = 0, N =
std::min(LN, RN);
I != N; ++
I) {
103 case -1:
return true;
104 case 1:
return false;
133 llvm_unreachable(
"Invalid DeclarationName Kind!");
143 OS << *ClassRec->getDecl();
148 OS << *InjTy->getDecl();
152 ClassType.
print(OS, Policy);
180 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
182 #include "clang/Basic/OperatorKinds.def"
185 assert(OpName &&
"not an overloaded operator");
188 if (OpName[0] >=
'a' && OpName[0] <=
'z')
202 OS << *Rec->getDecl();
208 Type.
print(OS, CXXPolicy);
212 OS <<
"<using-directive>";
216 llvm_unreachable(
"Unexpected declaration name kind");
228 switch (getStoredNameKind()) {
233 case StoredDeclarationNameExtra:
234 switch (getExtra()->ExtraKindOrNumArgs) {
252 if (getExtra()->ExtraKindOrNumArgs <
261 llvm_unreachable(
"This should be unreachable!");
271 llvm::raw_string_ostream OS(Result);
278 return CXXName->Type;
300 void *DeclarationName::getFETokenInfoAsVoidSlow()
const {
303 llvm_unreachable(
"Handled by getFETokenInfo()");
314 return getAsCXXLiteralOperatorIdName()->
FETokenInfo;
317 llvm_unreachable(
"Declaration name has no FETokenInfo");
342 llvm_unreachable(
"Declaration name has no FETokenInfo");
352 Ptr |= StoredDeclarationNameExtra;
358 llvm::errs() << *
this <<
'\n';
361 DeclarationNameTable::DeclarationNameTable(
const ASTContext &C) : Ctx(C) {
362 CXXSpecialNamesImpl =
new llvm::FoldingSet<CXXSpecialName>;
363 CXXLiteralOperatorNames =
new llvm::FoldingSet<CXXLiteralOperatorIdName>;
375 llvm::FoldingSet<CXXSpecialName> *SpecialNames =
376 static_cast<llvm::FoldingSet<CXXSpecialName>*
>(CXXSpecialNamesImpl);
377 llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
378 =
static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*
>
379 (CXXLiteralOperatorNames);
405 "Kind must be a C++ special name kind");
406 llvm::FoldingSet<CXXSpecialName> *SpecialNames
407 =
static_cast<llvm::FoldingSet<CXXSpecialName>*
>(CXXSpecialNamesImpl);
413 assert(!Ty.
hasQualifiers() &&
"Constructor type must be unqualified");
417 assert(!Ty.
hasQualifiers() &&
"Destructor type must be unqualified");
427 llvm::FoldingSetNodeID
ID;
428 ID.AddInteger(EKind);
431 void *InsertPos =
nullptr;
437 SpecialName->
Type = Ty;
440 SpecialNames->InsertNode(SpecialName, InsertPos);
451 llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
452 =
static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*
>
453 (CXXLiteralOperatorNames);
455 llvm::FoldingSetNodeID
ID;
458 void *InsertPos =
nullptr;
460 LiteralNames->FindNodeOrInsertPos(ID, InsertPos))
465 LiteralName->
ID = II;
468 LiteralNames->InsertNode(LiteralName, InsertPos);
513 return TInfo->getType()->containsUnexpandedParameterPack();
517 llvm_unreachable(
"All name kinds handled.");
535 return TInfo->getType()->isInstantiationDependentType();
539 llvm_unreachable(
"All name kinds handled.");
544 llvm::raw_string_ostream OS(Result);
577 llvm_unreachable(
"Unexpected declaration name kind");
599 return TInfo->getTypeLoc().getEndLoc();
610 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.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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...
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
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
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
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.
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.
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.