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!");
152 return OS << *ClassRec->getDecl();
162 return OS << *Rec->getDecl();
171 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
173 #include "clang/Basic/OperatorKinds.def"
176 assert(OpName &&
"not an overloaded operator");
179 if (OpName[0] >=
'a' && OpName[0] <=
'z')
191 return OS << *Rec->getDecl();
198 return OS <<
"<using-directive>";
201 llvm_unreachable(
"Unexpected declaration name kind");
207 switch (getStoredNameKind()) {
212 case StoredDeclarationNameExtra:
213 switch (getExtra()->ExtraKindOrNumArgs) {
231 if (getExtra()->ExtraKindOrNumArgs <
240 llvm_unreachable(
"This should be unreachable!");
250 llvm::raw_string_ostream OS(Result);
257 return CXXName->Type;
279 void *DeclarationName::getFETokenInfoAsVoidSlow()
const {
282 llvm_unreachable(
"Handled by getFETokenInfo()");
293 return getAsCXXLiteralOperatorIdName()->
FETokenInfo;
296 llvm_unreachable(
"Declaration name has no FETokenInfo");
321 llvm_unreachable(
"Declaration name has no FETokenInfo");
330 uintptr_t Ptr =
reinterpret_cast<uintptr_t
>(&UDirExtra);
331 Ptr |= StoredDeclarationNameExtra;
337 llvm::errs() << *
this <<
'\n';
340 DeclarationNameTable::DeclarationNameTable(
const ASTContext &
C) : Ctx(C) {
341 CXXSpecialNamesImpl =
new llvm::FoldingSet<CXXSpecialName>;
342 CXXLiteralOperatorNames =
new llvm::FoldingSet<CXXLiteralOperatorIdName>;
354 llvm::FoldingSet<CXXSpecialName> *SpecialNames =
355 static_cast<llvm::FoldingSet<CXXSpecialName>*
>(CXXSpecialNamesImpl);
356 llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
357 =
static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*
>
358 (CXXLiteralOperatorNames);
384 "Kind must be a C++ special name kind");
385 llvm::FoldingSet<CXXSpecialName> *SpecialNames
386 =
static_cast<llvm::FoldingSet<CXXSpecialName>*
>(CXXSpecialNamesImpl);
392 assert(!Ty.
hasQualifiers() &&
"Constructor type must be unqualified");
396 assert(!Ty.
hasQualifiers() &&
"Destructor type must be unqualified");
406 llvm::FoldingSetNodeID
ID;
407 ID.AddInteger(EKind);
410 void *InsertPos =
nullptr;
411 if (
CXXSpecialName *Name = SpecialNames->FindNodeOrInsertPos(ID, InsertPos))
416 SpecialName->
Type = Ty;
419 SpecialNames->InsertNode(SpecialName, InsertPos);
430 llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
431 =
static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*
>
432 (CXXLiteralOperatorNames);
434 llvm::FoldingSetNodeID
ID;
437 void *InsertPos =
nullptr;
439 LiteralNames->FindNodeOrInsertPos(ID, InsertPos))
444 LiteralName->
ID = II;
447 LiteralNames->InsertNode(LiteralName, InsertPos);
492 return TInfo->getType()->containsUnexpandedParameterPack();
496 llvm_unreachable(
"All name kinds handled.");
514 return TInfo->getType()->isInstantiationDependentType();
518 llvm_unreachable(
"All name kinds handled.");
523 llvm::raw_string_ostream OS(Result);
556 llvm_unreachable(
"Unexpected declaration name kind");
578 return TInfo->getTypeLoc().getEndLoc();
589 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.
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
std::string getAsString() const
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
IdentifierInfo * getAsIdentifierInfo() const
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...
void Profile(llvm::FoldingSetNodeID &ID)
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)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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:").
Function object that provides a total ordering on QualType values.
ID
Defines the set of possible language-specific address spaces.
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)
Defines the clang::TypeLoc interface and its subclasses.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isDependentType() const
QualType getCXXNameType() const
struct CXXOpName CXXOperatorName
The result type of a method or function.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
OverloadedOperatorKind getCXXOverloadedOperator() const
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.
Selector getObjCSelector() const
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
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
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
void setFETokenInfo(void *T)
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
static DeclarationName getUsingDirectiveName()
getUsingDirectiveName - Return name for all using-directives.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.