[clang-tools-extra] a8124ee - [clangd] Add missing readonly modifier for const generic parameters

Tom Praschan via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 13 10:09:34 PDT 2022


Author: Tom Praschan
Date: 2022-10-13T21:09:25+02:00
New Revision: a8124eea9df513a5565805b480c227fa88751359

URL: https://github.com/llvm/llvm-project/commit/a8124eea9df513a5565805b480c227fa88751359
DIFF: https://github.com/llvm/llvm-project/commit/a8124eea9df513a5565805b480c227fa88751359.diff

LOG: [clangd] Add missing readonly modifier for const generic parameters

Fixes https://github.com/clangd/clangd/issues/1222. As discussed there, we saw no reason to keep this check.

Differential Revision: https://reviews.llvm.org/D135892

Added: 
    

Modified: 
    clang-tools-extra/clangd/SemanticHighlighting.cpp
    clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 5b6fcf923e3f..2375d6f7dd35 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -164,7 +164,7 @@ kindForType(const Type *TP, const HeuristicResolver *Resolver) {
 
 // Whether T is const in a loose sense - is a variable with this type readonly?
 bool isConst(QualType T) {
-  if (T.isNull() || T->isDependentType())
+  if (T.isNull())
     return false;
   T = T.getNonReferenceType();
   if (T.isConstQualified())

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index e851bea5e632..6011aca7fa39 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -855,6 +855,17 @@ sizeof...($TemplateParameter[[Elements]]);
             const char *$LocalVariable_decl_readonly[[s]] = $LocalVariable_readonly_static[[__func__]];
         }
       )cpp",
+      // Issue 1022: readonly modifier for generic parameter
+      R"cpp(
+        template <typename $TemplateParameter_decl[[T]]>
+        auto $Function_decl[[foo]](const $TemplateParameter[[T]] $Parameter_decl_readonly[[template_type]], 
+                                   const $TemplateParameter[[auto]] $Parameter_decl_readonly[[auto_type]], 
+                                   const int $Parameter_decl_readonly[[explicit_type]]) {
+            return $Parameter_readonly[[template_type]] 
+                 + $Parameter_readonly[[auto_type]] 
+                 + $Parameter_readonly[[explicit_type]];
+        }
+      )cpp",
       // Explicit template specialization
       R"cpp(
         struct $Class_decl[[Base]]{};


        


More information about the cfe-commits mailing list