[clang-tools-extra] bf9921a - [clangd] Disable predefined macros in tests. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon May 9 05:45:02 PDT 2022
Author: Sam McCall
Date: 2022-05-09T14:44:51+02:00
New Revision: bf9921adb9304b90f21f087c1ea2ef178d9c57dd
URL: https://github.com/llvm/llvm-project/commit/bf9921adb9304b90f21f087c1ea2ef178d9c57dd
DIFF: https://github.com/llvm/llvm-project/commit/bf9921adb9304b90f21f087c1ea2ef178d9c57dd.diff
LOG: [clangd] Disable predefined macros in tests. NFC
These aren't needed. With them the generated predefines buffer is 13KB.
For every TestTU, we must:
- generate the buffer (3 times: parsing preamble, scanning preamble, main file)
- parse the buffer (again 3 times)
- serialize all the macros it defines in the PCH
- compress the buffer itself to write it into the PCH
- decompress it from the PCH
Avoiding this reduces unit test time by ~25%.
Differential Revision: https://reviews.llvm.org/D125172
Added:
Modified:
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index 77d4e289cf264..c4e9095ac5aa1 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -386,9 +386,9 @@ TEST(IncludeCleaner, VirtualBuffers) {
using flags::FLAGS_FOO;
- // CLI will come from a define, __llvm__ is a built-in. In both cases, they
+ // CLI will come from a define, __cplusplus is a built-in. In both cases, they
// come from non-existent files.
- int y = CLI + __llvm__;
+ int y = CLI + __cplusplus;
int concat(a, b) = 42;
)cpp";
diff --git a/clang-tools-extra/clangd/unittests/TestTU.cpp b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 1de663ac9caf2..78a8406c79110 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -40,7 +40,9 @@ ParseInputs TestTU::inputs(MockFS &FS) const {
ParseInputs Inputs;
Inputs.FeatureModules = FeatureModules;
auto &Argv = Inputs.CompileCommand.CommandLine;
- Argv = {"clang"};
+ // In tests, omit predefined macros (__GNUC__ etc) for a 25% speedup.
+ // There are hundreds, and we'd generate, parse, serialize, and re-parse them!
+ Argv = {"clang", "-Xclang", "-undef"};
// FIXME: this shouldn't need to be conditional, but it breaks a
// GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
if (!HeaderCode.empty()) {
More information about the cfe-commits
mailing list