[PATCH] D68027: [clangd] Change constness of parameters to findExplicitRefs

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 07:37:19 PDT 2019


kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Recursive AST requires non-const ast nodes, but it doesn't really
mutate them. In addition to that, in clangd we mostly have const ast nodes. So
it makes sense to move the const_cast into callee rather than having it at every
caller in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68027

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h


Index: clang-tools-extra/clangd/FindTarget.h
===================================================================
--- clang-tools-extra/clangd/FindTarget.h
+++ clang-tools-extra/clangd/FindTarget.h
@@ -101,9 +101,9 @@
 /// qualifiers.
 /// FIXME: currently this does not report references to overloaded operators.
 /// FIXME: extend to report location information about declaration names too.
-void findExplicitReferences(Stmt *S,
+void findExplicitReferences(const Stmt *S,
                             llvm::function_ref<void(ReferenceLoc)> Out);
-void findExplicitReferences(Decl *D,
+void findExplicitReferences(const Decl *D,
                             llvm::function_ref<void(ReferenceLoc)> Out);
 
 /// Similar to targetDecl(), however instead of applying a filter, all possible
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -616,15 +616,15 @@
 };
 } // namespace
 
-void findExplicitReferences(Stmt *S,
+void findExplicitReferences(const Stmt *S,
                             llvm::function_ref<void(ReferenceLoc)> Out) {
   assert(S);
-  ExplicitReferenceColletor(Out).TraverseStmt(S);
+  ExplicitReferenceColletor(Out).TraverseStmt(const_cast<Stmt *>(S));
 }
-void findExplicitReferences(Decl *D,
+void findExplicitReferences(const Decl *D,
                             llvm::function_ref<void(ReferenceLoc)> Out) {
   assert(D);
-  ExplicitReferenceColletor(Out).TraverseDecl(D);
+  ExplicitReferenceColletor(Out).TraverseDecl(const_cast<Decl *>(D));
 }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclRelation R) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68027.221767.patch
Type: text/x-patch
Size: 1700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190925/06da166c/attachment-0001.bin>


More information about the cfe-commits mailing list