17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/StringRef.h"
36 bool WithGlobalNsPrefix);
48 const NamespaceDecl *Namesp,
49 bool WithGlobalNsPrefix);
63 bool FullyQualify,
bool WithGlobalNsPrefix);
67 bool FullyQualified,
bool WithGlobalNsPrefix);
70 const ASTContext &Ctx, NestedNameSpecifier *scope,
bool WithGlobalNsPrefix);
74 bool WithGlobalNsPrefix) {
81 assert(ArgTDecl !=
nullptr);
87 Ctx, NNS, WithGlobalNsPrefix);
96 Ctx, ArgTDecl,
true, WithGlobalNsPrefix);
108 bool WithGlobalNsPrefix) {
109 bool Changed =
false;
134 bool WithGlobalNsPrefix) {
138 assert(!isa<DependentTemplateSpecializationType>(TypePtr));
141 if (
const auto *TST = dyn_cast<const TemplateSpecializationType>(TypePtr)) {
142 bool MightHaveChanged =
false;
150 Ctx, Arg, WithGlobalNsPrefix);
151 FQArgs.push_back(Arg);
156 if (MightHaveChanged) {
158 TST->getTemplateName(), FQArgs,
159 TST->getCanonicalTypeInternal());
165 }
else if (
const auto *TSTRecord = dyn_cast<const RecordType>(TypePtr)) {
170 if (
const auto *TSTDecl =
171 dyn_cast<ClassTemplateSpecializationDecl>(TSTRecord->getDecl())) {
174 bool MightHaveChanged =
false;
176 for (
unsigned int I = 0,
E = TemplateArgs.
size();
I !=
E; ++
I) {
181 Ctx, Arg, WithGlobalNsPrefix);
182 FQArgs.push_back(Arg);
187 if (MightHaveChanged) {
191 TSTRecord->getCanonicalTypeInternal());
204 bool WithGlobalNsPrefix) {
206 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
207 while (NS && NS->isInline()) {
211 if (NS->getDeclName()) {
215 }
else if (
const auto *TD = dyn_cast<TagDecl>(DC)) {
217 }
else if (
const auto *TDD = dyn_cast<TypedefNameDecl>(DC)) {
219 Ctx, TDD, FullyQualify, WithGlobalNsPrefix);
229 bool WithGlobalNsPrefix) {
251 Ctx, Scope->
getPrefix(), WithGlobalNsPrefix);
259 TD = TagDeclType->getDecl();
267 }
else if (
const auto *TDD = dyn_cast<TypedefType>(Type)) {
275 llvm_unreachable(
"bad NNS kind");
282 bool FullyQualified,
bool WithGlobalNsPrefix) {
285 const DeclContext *DC = Decl->getDeclContext()->getRedeclContext();
286 const auto *Outer = dyn_cast_or_null<NamedDecl>(DC);
287 const auto *OuterNS = dyn_cast_or_null<NamespaceDecl>(DC);
288 if (Outer && !(OuterNS && OuterNS->isAnonymousNamespace())) {
289 if (
const auto *CxxDecl = dyn_cast<CXXRecordDecl>(DC)) {
291 CxxDecl->getDescribedClassTemplate()) {
302 if (ClassTempl->spec_begin() != ClassTempl->spec_end()) {
303 Decl = *(ClassTempl->spec_begin());
312 }
else if (
const auto *TD = dyn_cast<TagDecl>(Outer)) {
314 Ctx, TD, FullyQualified, WithGlobalNsPrefix);
315 }
else if (dyn_cast<TranslationUnitDecl>(Outer)) {
334 bool FullyQualified,
bool WithGlobalNsPrefix) {
335 if (!TypePtr)
return nullptr;
339 if (
const auto *TDT = dyn_cast<TypedefType>(TypePtr)) {
340 Decl = TDT->getDecl();
341 }
else if (
const auto *TagDeclType = dyn_cast<TagType>(TypePtr)) {
342 Decl = TagDeclType->getDecl();
343 }
else if (
const auto *TST = dyn_cast<TemplateSpecializationType>(TypePtr)) {
344 Decl = TST->getTemplateName().getAsTemplateDecl();
349 if (!Decl)
return nullptr;
352 Ctx, Decl, FullyQualified, WithGlobalNsPrefix);
357 bool WithGlobalNsPrefix) {
358 while (Namespace && Namespace->
isInline()) {
360 Namespace = dyn_cast<
NamespaceDecl>(Namespace->getDeclContext());
362 if (!Namespace)
return nullptr;
364 bool FullyQualified =
true;
367 createOuterNNS(Ctx, Namespace, FullyQualified, WithGlobalNsPrefix),
374 bool WithGlobalNsPrefix) {
385 bool WithGlobalNsPrefix) {
402 bool IsLValueRefTy = isa<LValueReferenceType>(QT.
getTypePtr());
420 while (isa<SubstTemplateTypeParmType>(QT.
getTypePtr())) {
437 if (
const auto *ETypeInput = dyn_cast<ElaboratedType>(QT.
getTypePtr())) {
438 QT = ETypeInput->getNamedType();
440 Keyword = ETypeInput->getKeyword();
449 if (isa<const TemplateSpecializationType>(QT.
getTypePtr()) ||
459 if (Prefix || Keyword !=
ETK_None) {
468 bool WithGlobalNsPrefix) {
471 Policy.AnonymousTagLocations =
false;
472 Policy.PolishForDeclaration =
true;
473 Policy.SuppressUnwrittenScope =
true;
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
static NestedNameSpecifier * createNestedNameSpecifierForScopeOf(const ASTContext &Ctx, const Decl *decl, bool FullyQualified, bool WithGlobalNsPrefix)
Create a nested name specifier for the declaring context of the type.
A (possibly-)qualified type.
static bool getFullyQualifiedTemplateName(const ASTContext &Ctx, TemplateName &TName, bool WithGlobalNsPrefix)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
static NestedNameSpecifier * createNestedNameSpecifier(const ASTContext &Ctx, const NamespaceDecl *Namesp, bool WithGlobalNsPrefix)
Create a NestedNameSpecifier for Namesp and its enclosing scopes.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Defines the C++ template declaration subclasses.
std::string getAsString() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
The base class of the type hierarchy.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
An identifier, stored as an IdentifierInfo*.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NamespaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this namespace.
A namespace, stored as a NamespaceDecl*.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents the result of substituting a type for a template type parameter.
The collection of all-type qualifiers we support.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
static QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix)
Generates a QualType that can be used to name the same type if used at the end of the current transla...
bool isInline() const
Returns true if this is an inline namespace declaration.
TypeDecl - Represents a declaration of a type.
bool SuppressScope
Suppresses printing of scope specifiers.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
detail::InMemoryDirectory::const_iterator I
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
const Type * getTypeForDecl() const
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
static const Type * getFullyQualifiedTemplateType(const ASTContext &Ctx, const Type *TypePtr, bool WithGlobalNsPrefix)
ArgKind getKind() const
Return the kind of stored template argument.
Represents a C++ template name within the type system.
A namespace alias, stored as a NamespaceAliasDecl*.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
A type, stored as a Type*.
const clang::PrintingPolicy & getPrintingPolicy() const
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
const TemplateArgument * iterator
TagDecl - Represents the declaration of a struct/union/class/enum.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
static NestedNameSpecifier * createOuterNNS(const ASTContext &Ctx, const Decl *D, bool FullyQualify, bool WithGlobalNsPrefix)
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
detail::InMemoryDirectory::const_iterator E
A type that was preceded by the 'template' keyword, stored as a Type*.
const T * getAs() const
Member-template getAs<specific type>'.
std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Get the fully qualified name for a type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
The template argument is a type.
static bool getFullyQualifiedTemplateArgument(const ASTContext &Ctx, TemplateArgument &Arg, bool WithGlobalNsPrefix)
A template argument list.
The template argument is a template name that was provided for a template template parameter...
Declaration of a class template.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
static NestedNameSpecifier * getFullyQualifiedNestedNameSpecifier(const ASTContext &Ctx, NestedNameSpecifier *scope, bool WithGlobalNsPrefix)
Return a fully qualified version of this name specifier.
NamedDecl - This represents a decl with a name.
No keyword precedes the qualified type name.
The global specifier '::'. There is no stored value.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.