Skip to content

Commit dc17429

Browse files
authored
[clang] improved preservation of template keyword (llvm#133610)
1 parent 3c7a0e6 commit dc17429

File tree

66 files changed

+612
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+612
-720
lines changed

clang-tools-extra/clangd/AST.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ getQualification(ASTContext &Context, const DeclContext *DestContext,
119119
// There can't be any more tag parents after hitting a namespace.
120120
assert(!ReachedNS);
121121
(void)ReachedNS;
122-
NNS = NestedNameSpecifier::Create(Context, nullptr, false,
123-
TD->getTypeForDecl());
122+
NNS = NestedNameSpecifier::Create(Context, nullptr, TD->getTypeForDecl());
124123
} else if (auto *NSD = llvm::dyn_cast<NamespaceDecl>(CurContext)) {
125124
ReachedNS = true;
126125
NNS = NestedNameSpecifier::Create(Context, nullptr, NSD);

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,6 @@ bool allowIndex(CodeCompletionContext &CC) {
14671467
return true;
14681468
case NestedNameSpecifier::Super:
14691469
case NestedNameSpecifier::TypeSpec:
1470-
case NestedNameSpecifier::TypeSpecWithTemplate:
14711470
// Unresolved inside a template.
14721471
case NestedNameSpecifier::Identifier:
14731472
return false;

clang-tools-extra/clangd/DumpAST.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ class DumpVisitor : public RecursiveASTVisitor<DumpVisitor> {
157157
NNS_KIND(Identifier);
158158
NNS_KIND(Namespace);
159159
NNS_KIND(TypeSpec);
160-
NNS_KIND(TypeSpecWithTemplate);
161160
NNS_KIND(Global);
162161
NNS_KIND(Super);
163162
NNS_KIND(NamespaceAlias);

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ struct TargetFinder {
500500
}
501501
return;
502502
case NestedNameSpecifier::TypeSpec:
503-
case NestedNameSpecifier::TypeSpecWithTemplate:
504503
add(QualType(NNS->getAsType(), 0), Flags);
505504
return;
506505
case NestedNameSpecifier::Global:

clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
144144
case NestedNameSpecifier::Global:
145145
return true;
146146
case NestedNameSpecifier::TypeSpec:
147-
case NestedNameSpecifier::TypeSpecWithTemplate:
148147
case NestedNameSpecifier::Super:
149148
case NestedNameSpecifier::Identifier:
150149
return false;

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ Improvements to Clang's diagnostics
275275
- Diagnostics on chained comparisons (``a < b < c``) are now an error by default. This can be disabled with
276276
``-Wno-error=parentheses``.
277277
- Clang now better preserves the sugared types of pointers to member.
278+
- Clang now better preserves the presence of the template keyword with dependent
279+
prefixes.
280+
- When printing types for diagnostics, clang now doesn't suppress the scopes of
281+
template arguments contained within nested names.
278282
- The ``-Wshift-bool`` warning has been added to warn about shifting a boolean. (#GH28334)
279283
- Fixed diagnostics adding a trailing ``::`` when printing some source code
280284
constructs, like base classes.

clang/include/clang/AST/ASTContext.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,15 +1837,14 @@ class ASTContext : public RefCountedBase<ASTContext> {
18371837
TagDecl *OwnedTagDecl = nullptr) const;
18381838
QualType getDependentNameType(ElaboratedTypeKeyword Keyword,
18391839
NestedNameSpecifier *NNS,
1840-
const IdentifierInfo *Name,
1841-
QualType Canon = QualType()) const;
1840+
const IdentifierInfo *Name) const;
18421841

18431842
QualType getDependentTemplateSpecializationType(
1844-
ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
1845-
const IdentifierInfo *Name, ArrayRef<TemplateArgumentLoc> Args) const;
1843+
ElaboratedTypeKeyword Keyword, const DependentTemplateStorage &Name,
1844+
ArrayRef<TemplateArgumentLoc> Args) const;
18461845
QualType getDependentTemplateSpecializationType(
1847-
ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
1848-
const IdentifierInfo *Name, ArrayRef<TemplateArgument> Args) const;
1846+
ElaboratedTypeKeyword Keyword, const DependentTemplateStorage &Name,
1847+
ArrayRef<TemplateArgument> Args, bool IsCanonical = false) const;
18491848

18501849
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const;
18511850

@@ -2393,11 +2392,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
23932392
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
23942393
bool TemplateKeyword,
23952394
TemplateName Template) const;
2395+
TemplateName
2396+
getDependentTemplateName(const DependentTemplateStorage &Name) const;
23962397

2397-
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
2398-
const IdentifierInfo *Name) const;
2399-
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
2400-
OverloadedOperatorKind Operator) const;
24012398
TemplateName
24022399
getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
24032400
unsigned Index,

clang/include/clang/AST/ASTImporter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ class TypeSourceInfo;
446446
/// returns nullptr only if the FromId was nullptr.
447447
IdentifierInfo *Import(const IdentifierInfo *FromId);
448448

449+
/// Import the given identifier or overloaded operator from the "from"
450+
/// context into the "to" context.
451+
///
452+
/// \returns The equivalent identifier or overloaded operator in the "to"
453+
/// context.
454+
IdentifierOrOverloadedOperator
455+
Import(IdentifierOrOverloadedOperator FromIO);
456+
449457
/// Import the given Objective-C selector from the "from"
450458
/// context into the "to" context.
451459
///

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ class ASTNodeTraverser
396396
// FIXME: Provide a NestedNameSpecifier visitor.
397397
NestedNameSpecifier *Qualifier = T->getQualifier();
398398
if (NestedNameSpecifier::SpecifierKind K = Qualifier->getKind();
399-
K == NestedNameSpecifier::TypeSpec ||
400-
K == NestedNameSpecifier::TypeSpecWithTemplate)
399+
K == NestedNameSpecifier::TypeSpec)
401400
Visit(Qualifier->getAsType());
402401
if (T->isSugared())
403402
Visit(T->getMostRecentCXXRecordDecl()->getTypeForDecl());

clang/include/clang/AST/AbstractBasicReader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,8 @@ class DataStreamBasicReader : public BasicReaderBase<Impl> {
279279
continue;
280280

281281
case NestedNameSpecifier::TypeSpec:
282-
case NestedNameSpecifier::TypeSpecWithTemplate:
283282
cur = NestedNameSpecifier::Create(ctx, cur,
284-
kind == NestedNameSpecifier::TypeSpecWithTemplate,
285-
asImpl().readQualType().getTypePtr());
283+
asImpl().readQualType().getTypePtr());
286284
continue;
287285

288286
case NestedNameSpecifier::Global:

0 commit comments

Comments
 (0)