summaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-10-01 14:08:51 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-10-01 14:08:51 +0000
commit72b874999130a839ead5de40379240b6a6da5b5d (patch)
tree386c332b20524b29560deff2d7020d72c0e49f78 /lib/Sema
parentf791ec4bdc69fc17f0d9bbf3a13c5dd88b666c97 (diff)
downloadclang-72b874999130a839ead5de40379240b6a6da5b5d.tar.gz
[clang] Make handling of unnamed template params similar to function params
Summary: Clang uses the location identifier should be inserted for declarator decls when a decl is unnamed. But for type template and template template paramaters it uses the location of "typename/class" keyword, which makes it hard for tooling to insert/change parameter names. This change tries to unify these two cases by making template parameter parsing and sourcerange operations similar to function params/declarator decls. Reviewers: ilya-biryukov Subscribers: arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68143 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaTemplate.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 5633582d67..199103e36f 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1005,15 +1005,10 @@ NamedDecl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
assert(S->isTemplateParamScope() &&
"Template type parameter not in template parameter scope!");
- SourceLocation Loc = ParamNameLoc;
- if (!ParamName)
- Loc = KeyLoc;
-
bool IsParameterPack = EllipsisLoc.isValid();
- TemplateTypeParmDecl *Param
- = TemplateTypeParmDecl::Create(Context, Context.getTranslationUnitDecl(),
- KeyLoc, Loc, Depth, Position, ParamName,
- Typename, IsParameterPack);
+ TemplateTypeParmDecl *Param = TemplateTypeParmDecl::Create(
+ Context, Context.getTranslationUnitDecl(), KeyLoc, ParamNameLoc, Depth,
+ Position, ParamName, Typename, IsParameterPack);
Param->setAccess(AS_public);
if (Param->isParameterPack())
@@ -1044,7 +1039,7 @@ NamedDecl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
assert(DefaultTInfo && "expected source information for type");
// Check for unexpanded parameter packs.
- if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
+ if (DiagnoseUnexpandedParameterPack(ParamNameLoc, DefaultTInfo,
UPPC_DefaultArgument))
return Param;