[clang-tools-extra] r326458 - [clangd] Make symbol name a required parameter for CanonicalIncludes::mapHeader

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 1 10:30:48 PST 2018


Author: ioeric
Date: Thu Mar  1 10:30:48 2018
New Revision: 326458

URL: http://llvm.org/viewvc/llvm-project?rev=326458&view=rev
Log:
[clangd] Make symbol name a required parameter for CanonicalIncludes::mapHeader

Modified:
    clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
    clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=326458&r1=326457&r2=326458&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Thu Mar  1 10:30:48 2018
@@ -35,11 +35,9 @@ void CanonicalIncludes::addSymbolMapping
 llvm::StringRef
 CanonicalIncludes::mapHeader(llvm::StringRef Header,
                              llvm::StringRef QualifiedName) const {
-  if (!QualifiedName.empty()) {
-    auto SE = SymbolMapping.find(QualifiedName);
-    if (SE != SymbolMapping.end())
-      return SE->second;
-  }
+  auto SE = SymbolMapping.find(QualifiedName);
+  if (SE != SymbolMapping.end())
+    return SE->second;
   std::lock_guard<std::mutex> Lock(RegexMutex);
   for (auto &Entry : RegexHeaderMappingTable) {
 #ifndef NDEBUG

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=326458&r1=326457&r2=326458&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h Thu Mar  1 10:30:48 2018
@@ -48,12 +48,10 @@ public:
   void addSymbolMapping(llvm::StringRef QualifiedName,
                         llvm::StringRef CanonicalPath);
 
-  /// \return \p Header itself if there is no mapping for it; otherwise, return
-  /// a canonical header name.
-  /// \p QualifiedName of a symbol declared in \p Header can be provided to
-  /// check against the symbol mapping.
+  /// Returns the canonical include for symbol with \p QualifiedName, which is
+  /// declared in \p Header
   llvm::StringRef mapHeader(llvm::StringRef Header,
-                            llvm::StringRef QualifiedName = "") const;
+                            llvm::StringRef QualifiedName) const;
 
 private:
   // A map from header patterns to header names. This needs to be mutable so




More information about the cfe-commits mailing list