[clang-tools-extra] [clangd] Remove potential prefix from enum value names (PR #83412)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 15 06:40:20 PDT 2024


================
@@ -125,25 +123,42 @@ llvm::Error ScopifyEnum::addClassKeywordToDeclarations() {
 }
 
 llvm::Error ScopifyEnum::scopifyEnumValues() {
-  std::string PrefixToInsert(D->getName());
-  PrefixToInsert += "::";
+  StringRef EnumName(D->getName());
+  bool StripPrefix = true;
+  for (auto E : D->enumerators()) {
+    if (!E->getName().starts_with(EnumName)) {
+      StripPrefix = false;
+      break;
+    }
+  }
   for (auto E : D->enumerators()) {
----------------
5chmidti wrote:

This is not in your changed lines, but please change this `auto` to `const EnumConstantDecl *` as well.

https://github.com/llvm/llvm-project/pull/83412


More information about the cfe-commits mailing list