29 #include "llvm/ADT/FoldingSet.h" 30 #include "llvm/Support/Casting.h" 31 #include "llvm/Support/Compiler.h" 32 #include "llvm/Support/ErrorHandling.h" 33 #include "llvm/Support/raw_ostream.h" 39 using namespace clang;
42 return (A < B ? -1 : (A > B ? 1 : 0));
69 return LHSSelector.getAsIdentifierInfo()->
getName().compare(
70 RHSSelector.getAsIdentifierInfo()->
getName());
73 for (
unsigned I = 0, N =
std::min(LN, RN); I != N; ++I) {
115 llvm_unreachable(
"Invalid DeclarationName Kind!");
125 OS << *ClassRec->getDecl();
130 OS << *InjTy->getDecl();
134 ClassType.
print(OS, Policy);
158 OS <<
"<deduction guide for ";
163 case DeclarationName::CXXOperatorName: { 164 const char *OpName = getOperatorSpelling(getCXXOverloadedOperator()); 165 assert(OpName && "not an overloaded operator"); 168 if (OpName[0] >= 'a' && OpName[0] <= 'z
') 174 case DeclarationName::CXXLiteralOperatorName: 175 OS << "operator\"\"" << getCXXLiteralIdentifier()->getName(); 178 case DeclarationName::CXXConversionFunctionName: { 180 QualType Type = getCXXNameType(); 181 if (const RecordType *Rec = Type->getAs<RecordType>()) { 182 OS << *Rec->getDecl(); 185 // We know we're printing
C++ here, ensure we
print 'bool' properly.
188 Type.print(OS, CXXPolicy);
192 OS <<
"<using-directive>";
196 llvm_unreachable(
"Unexpected declaration name kind");
216 if (TD && TD->getDeclContext()->isDependentContext())
224 llvm::raw_string_ostream OS(Result);
229 void *DeclarationName::getFETokenInfoSlow()
const {
232 llvm_unreachable(
"case Identifier already handled by getFETokenInfo!");
236 return castAsCXXSpecialNameExtra()->FETokenInfo;
238 return castAsCXXOperatorIdName()->FETokenInfo;
240 return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
242 return castAsCXXLiteralOperatorIdName()->FETokenInfo;
244 llvm_unreachable(
"DeclarationName has no FETokenInfo!");
248 void DeclarationName::setFETokenInfoSlow(
void *T) {
251 llvm_unreachable(
"case Identifier already handled by setFETokenInfo!");
255 castAsCXXSpecialNameExtra()->FETokenInfo = T;
258 castAsCXXOperatorIdName()->FETokenInfo = T;
261 castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
264 castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
267 llvm_unreachable(
"DeclarationName has no FETokenInfo!");
272 llvm::errs() << *
this <<
'\n';
278 CXXOperatorNames[Op].
Kind = static_cast<OverloadedOperatorKind>(Op);
285 llvm::FoldingSetNodeID
ID;
286 ID.AddPointer(Template);
288 void *InsertPos =
nullptr;
289 if (
auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
293 CXXDeductionGuideNames.InsertNode(Name, InsertPos);
301 llvm::FoldingSetNodeID
ID;
303 void *InsertPos =
nullptr;
304 if (
auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
305 return {Name, DeclarationName::StoredCXXConstructorName};
309 CXXConstructorNames.InsertNode(SpecialName, InsertPos);
310 return {SpecialName, DeclarationName::StoredCXXConstructorName};
317 llvm::FoldingSetNodeID
ID;
319 void *InsertPos =
nullptr;
320 if (
auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
321 return {Name, DeclarationName::StoredCXXDestructorName};
325 CXXDestructorNames.InsertNode(SpecialName, InsertPos);
326 return {SpecialName, DeclarationName::StoredCXXDestructorName};
332 llvm::FoldingSetNodeID
ID;
334 void *InsertPos =
nullptr;
336 CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
337 return {Name, DeclarationName::StoredCXXConversionFunctionName};
341 CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
342 return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356 llvm_unreachable(
"Invalid kind in getCXXSpecialName!");
362 llvm::FoldingSetNodeID
ID;
365 void *InsertPos =
nullptr;
366 if (
auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
370 CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
382 NamedType.TInfo =
nullptr;
402 switch (Name.getNameKind()) {
417 return TInfo->getType()->containsUnexpandedParameterPack();
419 return Name.getCXXNameType()->containsUnexpandedParameterPack();
421 llvm_unreachable(
"All name kinds handled.");
425 switch (Name.getNameKind()) {
440 return TInfo->getType()->isInstantiationDependentType();
442 return Name.getCXXNameType()->isInstantiationDependentType();
444 llvm_unreachable(
"All name kinds handled.");
449 llvm::raw_string_ostream OS(Result);
455 switch (Name.getNameKind()) {
480 OS << TInfo->getType().getAsString(PP);
485 llvm_unreachable(
"Unexpected declaration name kind");
489 switch (Name.getNameKind()) {
495 unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
500 unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
508 return TInfo->getTypeLoc().getEndLoc();
519 llvm_unreachable(
"Unexpected declaration name kind");
Defines the clang::ASTContext interface.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
A (possibly-)qualified type.
NameKind
The kind of the name stored in this DeclarationName.
C Language Family Type Representation.
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
Defines the C++ template declaration subclasses.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
A container of type source information.
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
const T * getAs() const
Member-template getAs<specific type>'.
Describes how types, statements, expressions, and declarations should be printed. ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
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 SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
NameKind getNameKind() const
Determine what kind of name this is.
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...
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
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.
Allows QualTypes to be sorted and hence used in maps and sets.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
Defines the clang::LangOptions interface.
static void printCXXConstructorDestructorName(QualType ClassType, raw_ostream &OS, PrintingPolicy Policy)
std::string getAsString() const
Retrieve the human-readable string for this name.
Defines an enumeration for C++ overloaded operators.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
Defines the clang::TypeLoc interface and its subclasses.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
unsigned getNumArgs() const
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Encodes a location in the source.
unsigned SuppressScope
Suppresses printing of scope specifiers.
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
The injected class name of a C++ class template or class template partial specialization.
StringRef getName() const
Return the actual identifier string.
Dataflow Directional Tag Classes.
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
The base class of all kinds of template declarations (e.g., class, function, etc.).
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...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Defines the clang::SourceLocation class and associated facilities.
static int compare(DeclarationName LHS, DeclarationName RHS)
void print(raw_ostream &OS, const PrintingPolicy &Policy)
Contains the actual identifier that makes up the name of a C++ literal operator.
__DEVICE__ int min(int __a, int __b)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...