Go to the documentation of this file.
30 #include "llvm/ADT/FoldingSet.h"
31 #include "llvm/Support/Casting.h"
32 #include "llvm/Support/Compiler.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include "llvm/Support/raw_ostream.h"
40 using namespace clang;
43 return (A < B ? -1 : (A > B ? 1 : 0));
70 return LHSSelector.getAsIdentifierInfo()->
getName().compare(
71 RHSSelector.getAsIdentifierInfo()->
getName());
74 for (
unsigned I = 0, N =
std::min(LN, RN); I != N; ++I) {
116 llvm_unreachable(
"Invalid DeclarationName Kind!");
126 OS << *ClassRec->getDecl();
131 OS << *InjTy->getDecl();
135 ClassType.
print(OS, Policy);
143 StringRef Name = II->getName();
146 if (II->isMangledOpenMPVariantName()) {
147 std::pair<StringRef, StringRef> NameContextPair =
149 OS << NameContextPair.first <<
"["
171 OS <<
"<deduction guide for ";
176 case DeclarationName::CXXOperatorName: {
177 const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178 assert(OpName && "not an overloaded operator");
181 if (OpName[0] >= 'a
' && OpName[0] <= 'z
')
187 case DeclarationName::CXXLiteralOperatorName:
188 OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
191 case DeclarationName::CXXConversionFunctionName: {
193 QualType Type = getCXXNameType();
194 if (const RecordType *Rec = Type->getAs<RecordType>()) {
195 OS << *Rec->getDecl();
198 // We know we're printing
C++ here, ensure we
print 'bool' properly.
201 Type.print(OS, CXXPolicy);
205 OS <<
"<using-directive>";
209 llvm_unreachable(
"Unexpected declaration name kind");
222 bool DeclarationName::isDependentName()
const {
229 if (TD && TD->getDeclContext()->isDependentContext())
237 llvm::raw_string_ostream OS(Result);
242 void *DeclarationName::getFETokenInfoSlow()
const {
245 llvm_unreachable(
"case Identifier already handled by getFETokenInfo!");
249 return castAsCXXSpecialNameExtra()->FETokenInfo;
251 return castAsCXXOperatorIdName()->FETokenInfo;
253 return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
255 return castAsCXXLiteralOperatorIdName()->FETokenInfo;
257 llvm_unreachable(
"DeclarationName has no FETokenInfo!");
261 void DeclarationName::setFETokenInfoSlow(
void *T) {
264 llvm_unreachable(
"case Identifier already handled by setFETokenInfo!");
268 castAsCXXSpecialNameExtra()->FETokenInfo = T;
271 castAsCXXOperatorIdName()->FETokenInfo = T;
274 castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
277 castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
280 llvm_unreachable(
"DeclarationName has no FETokenInfo!");
285 llvm::errs() << *
this <<
'\n';
298 llvm::FoldingSetNodeID
ID;
299 ID.AddPointer(Template);
301 void *InsertPos =
nullptr;
302 if (
auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(
ID, InsertPos))
306 CXXDeductionGuideNames.InsertNode(Name, InsertPos);
314 llvm::FoldingSetNodeID
ID;
316 void *InsertPos =
nullptr;
317 if (
auto *Name = CXXConstructorNames.FindNodeOrInsertPos(
ID, InsertPos))
318 return {Name, DeclarationName::StoredCXXConstructorName};
322 CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323 return {SpecialName, DeclarationName::StoredCXXConstructorName};
330 llvm::FoldingSetNodeID
ID;
332 void *InsertPos =
nullptr;
333 if (
auto *Name = CXXDestructorNames.FindNodeOrInsertPos(
ID, InsertPos))
334 return {Name, DeclarationName::StoredCXXDestructorName};
338 CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339 return {SpecialName, DeclarationName::StoredCXXDestructorName};
345 llvm::FoldingSetNodeID
ID;
347 void *InsertPos =
nullptr;
349 CXXConversionFunctionNames.FindNodeOrInsertPos(
ID, InsertPos))
350 return {Name, DeclarationName::StoredCXXConversionFunctionName};
354 CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355 return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
369 llvm_unreachable(
"Invalid kind in getCXXSpecialName!");
375 llvm::FoldingSetNodeID
ID;
378 void *InsertPos =
nullptr;
379 if (
auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(
ID, InsertPos))
383 CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
388 switch (Name.getNameKind()) {
395 setNamedTypeLoc(
nullptr);
429 return TInfo->getType()->containsUnexpandedParameterPack();
433 llvm_unreachable(
"All name kinds handled.");
452 return TInfo->getType()->isInstantiationDependentType();
456 llvm_unreachable(
"All name kinds handled.");
461 llvm::raw_string_ostream OS(Result);
482 Name.
print(OS, Policy);
496 OS << TInfo->getType().getAsString(Policy);
498 Name.
print(OS, Policy);
501 llvm_unreachable(
"Unexpected declaration name kind");
520 return TInfo->getTypeLoc().getEndLoc();
531 llvm_unreachable(
"Unexpected declaration name kind");
SourceLocation getCXXOperatorNameEndLoc() const
Return the end location of the getCXXOperatorNameRange() range.
unsigned SuppressScope
Suppresses printing of scope specifiers.
A trivial tuple used to represent a source range.
Encodes a location in the source.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
A (possibly-)qualified type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
Describes how types, statements, expressions, and declarations should be printed.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
The name of a declaration.
TypeSourceInfo * getNamedTypeInfo() const
Returns the source type info.
The base class of the type hierarchy.
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
static int compare(DeclarationName LHS, DeclarationName RHS)
__DEVICE__ int min(int __a, int __b)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
std::string getAsString() const
Retrieve the human-readable string for this name.
SourceLocation getCXXLiteralOperatorNameLoc() const
Return the location of the literal operator name (without the operator keyword).
unsigned getNumArgs() const
const T * getAs() const
Member-template getAs<specific type>'.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static int compareInt(unsigned A, unsigned B)
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
@ NUM_OVERLOADED_OPERATORS
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ CXXConversionFunctionName
static constexpr StringRef getOpenMPVariantManglingSeparatorStr()
OpenMP variants are mangled early based on their OpenMP context selector.
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool isNull() const
Return true if this QualType doesn't point to a type yet.
NameKind
The kind of the name stored in this DeclarationName.
The injected class name of a C++ class template or class template partial specialization.
void adjustForCPlusPlus()
Adjust this printing policy for cases where it's known that we're printing C++ code (for instance,...
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
NameKind getNameKind() const
Determine what kind of name this is.
StringRef getName() const
Return the actual identifier string.
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
Smart pointer class that efficiently represents Objective-C method names.
static void printCXXConstructorDestructorName(QualType ClassType, raw_ostream &OS, PrintingPolicy Policy)
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
A container of type source information.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
Function object that provides a total ordering on QualType values.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Contains the actual identifier that makes up the name of a C++ literal operator.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...