Skip to content

Commit a8124ee

Browse files
committed
[clangd] Add missing readonly modifier for const generic parameters
Fixes clangd/clangd#1222. As discussed there, we saw no reason to keep this check. Differential Revision: https://reviews.llvm.org/D135892
1 parent b75bde6 commit a8124ee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ kindForType(const Type *TP, const HeuristicResolver *Resolver) {
164164

165165
// Whether T is const in a loose sense - is a variable with this type readonly?
166166
bool isConst(QualType T) {
167-
if (T.isNull() || T->isDependentType())
167+
if (T.isNull())
168168
return false;
169169
T = T.getNonReferenceType();
170170
if (T.isConstQualified())

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,17 @@ sizeof...($TemplateParameter[[Elements]]);
855855
const char *$LocalVariable_decl_readonly[[s]] = $LocalVariable_readonly_static[[__func__]];
856856
}
857857
)cpp",
858+
// Issue 1022: readonly modifier for generic parameter
859+
R"cpp(
860+
template <typename $TemplateParameter_decl[[T]]>
861+
auto $Function_decl[[foo]](const $TemplateParameter[[T]] $Parameter_decl_readonly[[template_type]],
862+
const $TemplateParameter[[auto]] $Parameter_decl_readonly[[auto_type]],
863+
const int $Parameter_decl_readonly[[explicit_type]]) {
864+
return $Parameter_readonly[[template_type]]
865+
+ $Parameter_readonly[[auto_type]]
866+
+ $Parameter_readonly[[explicit_type]];
867+
}
868+
)cpp",
858869
// Explicit template specialization
859870
R"cpp(
860871
struct $Class_decl[[Base]]{};

0 commit comments

Comments
 (0)