Author: Haojian Wu
Date: 2023-02-04T00:08:45+01:00
New Revision: d46d44e3c4a6f1f980f595386fc7ddd03c1f3fcd

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

LOG: [Tooling/Inclusion] qualifed_name() => qualifiedName(), NFC

Added: 
    

Modified: 
    clang/include/clang/Tooling/Inclusions/StandardLibrary.h
    clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
    clang/unittests/Tooling/StandardLibraryTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h 
b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
index 60509a9cebcab..830cbd5873bc6 100644
--- a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
+++ b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
@@ -75,11 +75,11 @@ class Symbol {
   named(llvm::StringRef Scope, llvm::StringRef Name, Lang Language = 
Lang::CXX);
 
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) 
{
-    return OS << S.qualified_name();
+    return OS << S.qualifiedName();
   }
   llvm::StringRef scope() const;
   llvm::StringRef name() const;
-  llvm::StringRef qualified_name() const;
+  llvm::StringRef qualifiedName() const;
   // The preferred header for this symbol (e.g. the suggested insertion).
   Header header() const;
   // Some symbols may be provided by multiple headers.

diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index add8414eaf091..23e4ee0054cd1 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -32,6 +32,11 @@ struct SymbolHeaderMapping {
     const char *Data;  // std::vector
     unsigned ScopeLen; // ~~~~~
     unsigned NameLen;  //      ~~~~~~
+    StringRef scope() const { return StringRef(Data, ScopeLen); }
+    StringRef name() const { return StringRef(Data + ScopeLen, NameLen); }
+    StringRef qualifiedName() const {
+      return StringRef(Data, ScopeLen + NameLen);
+    }
   } *SymbolNames = nullptr;
   // Symbol name -> Symbol::ID, within a namespace.
   llvm::DenseMap<llvm::StringRef, NSSymbolMap *> *NamespaceSymbols = nullptr;
@@ -162,16 +167,13 @@ std::vector<Symbol> Symbol::all(Lang L) {
   return Result;
 }
 llvm::StringRef Symbol::scope() const {
-  auto &S = getMappingPerLang(Language)->SymbolNames[ID];
-  return StringRef(S.Data, S.ScopeLen);
+  return getMappingPerLang(Language)->SymbolNames[ID].scope();
 }
 llvm::StringRef Symbol::name() const {
-  auto &S = getMappingPerLang(Language)->SymbolNames[ID];
-  return StringRef(S.Data + S.ScopeLen, S.NameLen);
+  return getMappingPerLang(Language)->SymbolNames[ID].name();
 }
-llvm::StringRef Symbol::qualified_name() const {
-  auto &S = getMappingPerLang(Language)->SymbolNames[ID];
-  return StringRef(S.Data, S.ScopeLen + S.NameLen);
+llvm::StringRef Symbol::qualifiedName() const {
+  return getMappingPerLang(Language)->SymbolNames[ID].qualifiedName();
 }
 std::optional<Symbol> Symbol::named(llvm::StringRef Scope, llvm::StringRef 
Name,
                                     Lang L) {

diff  --git a/clang/unittests/Tooling/StandardLibraryTest.cpp 
b/clang/unittests/Tooling/StandardLibraryTest.cpp
index 136b7b80dc4fb..dee34ab233e64 100644
--- a/clang/unittests/Tooling/StandardLibraryTest.cpp
+++ b/clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -47,7 +47,7 @@ TEST(StdlibTest, All) {
   EXPECT_TRUE(Vector);
   EXPECT_EQ(Vector->scope(), "std::");
   EXPECT_EQ(Vector->name(), "vector");
-  EXPECT_EQ(Vector->qualified_name(), "std::vector");
+  EXPECT_EQ(Vector->qualifiedName(), "std::vector");
   EXPECT_EQ(llvm::to_string(*Vector), "std::vector");
   EXPECT_FALSE(stdlib::Symbol::named("std::", "dongle"));
   EXPECT_FALSE(stdlib::Symbol::named("clang::", "ASTContext"));


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to