[PATCH] D143559: [Tooling/Inclusion] Use the StdSpecialSymbolMap.inc in the stdlib

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 8 00:50:06 PST 2023


hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Remove a special-case in clangd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143559

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/unittests/Tooling/StandardLibraryTest.cpp


Index: clang/unittests/Tooling/StandardLibraryTest.cpp
===================================================================
--- clang/unittests/Tooling/StandardLibraryTest.cpp
+++ clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -62,6 +62,14 @@
               ElementsAre(stdlib::Header::named("<istream>"),
                           stdlib::Header::named("<iostream>"),
                           stdlib::Header::named("<iosfwd>")));
+  EXPECT_THAT(stdlib::Symbol::named("std::", "size_t")->headers(),
+              ElementsAre(stdlib::Header::named("<cstddef>"),
+                          stdlib::Header::named("<cstdlib>"),
+                          stdlib::Header::named("<cstring>"),
+                          stdlib::Header::named("<cwchar>"),
+                          stdlib::Header::named("<cuchar>"),
+                          stdlib::Header::named("<ctime>"),
+                          stdlib::Header::named("<cstdio>")));
 
   EXPECT_THAT(stdlib::Header::all(), Contains(*VectorH));
   EXPECT_THAT(stdlib::Symbol::all(), Contains(*Vector));
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===================================================================
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -62,6 +62,7 @@
     break;
   case Lang::CXX:
 #include "StdSymbolMap.inc"
+#include "StdSpecialSymbolMap.inc"
     break;
   }
 #undef SYMBOL
@@ -130,6 +131,7 @@
     break;
   case Lang::CXX:
 #include "StdSymbolMap.inc"
+#include "StdSpecialSymbolMap.inc"
     break;
   }
 #undef SYMBOL
Index: clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
+++ clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
@@ -51,6 +51,7 @@
   EXPECT_EQ("<cstdio>", CI.mapSymbol("std::", "printf", Language));
   // std::move is ambiguous, currently always mapped to <utility>
   EXPECT_EQ("<utility>", CI.mapSymbol("std::", "move", Language));
+  EXPECT_EQ("<cstddef>", CI.mapSymbol("std::", "size_t", Language));
   // Unknown std symbols aren't mapped.
   EXPECT_EQ("", CI.mapSymbol("std::", "notathing", Language));
   // iosfwd declares some symbols it doesn't own.
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===================================================================
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -716,8 +716,6 @@
   // There are two std::move()s, this is by far the most common.
   if (Scope == "std::" && Name == "move")
     return "<utility>";
-  if (Scope == "std::" && Name == "size_t")
-    return "<cstddef>";
   if (auto StdSym = tooling::stdlib::Symbol::named(Scope, Name, Lang))
     return StdSym->header().name();
   return "";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143559.495752.patch
Type: text/x-patch
Size: 2913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230208/1e364474/attachment.bin>


More information about the cfe-commits mailing list