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

Conversion operators contain invalid MemberLocs which causes 
SemanticHighlighting to emit a lot of error logs in large files as they can 
occur fairly often (for example converting StringRef to std string).
As the only thing happening was a lot of error logs being emited there doesn't 
really seem to be any way to test this (no erroneous tokens are added). But 
emiting as many logs as were being emited is not wanted.

Can't really be patched elsewhere. RecursiveASTVisitor should still traverse 
the expr as it can contain other "non-implicit" decls/exprs that must be 
visited (for example DeclRefs). A potential fix could be to special case the 
TraverseMemberExpr function to not Walk* the Expr if it has an invalid 
MemberLoc. But that would change the behaviour of RecursiveASTVisitor to be 
unexpected. (and to change the behaviour to be this for all exprs would change 
the contract of RecursiveASTVisitor to much)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65928

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -52,6 +52,11 @@
       // When calling the destructor manually like: AAA::~A(); The ~ is a
       // MemberExpr. Other methods should still be highlighted though.
       return true;
+    if (ME->getMemberLoc().isInvalid())
+      // If the member is a conversion operator the loc will be invalid. This
+      // causes the addToken function to emit a lot of error logs about trying
+      // to add a token with an invalid range.
+      return true;
     addToken(ME->getMemberLoc(), MD);
     return true;
   }


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -52,6 +52,11 @@
       // When calling the destructor manually like: AAA::~A(); The ~ is a
       // MemberExpr. Other methods should still be highlighted though.
       return true;
+    if (ME->getMemberLoc().isInvalid())
+      // If the member is a conversion operator the loc will be invalid. This
+      // causes the addToken function to emit a lot of error logs about trying
+      // to add a token with an invalid range.
+      return true;
     addToken(ME->getMemberLoc(), MD);
     return true;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to