[PATCH] D78848: [clangd] Disable delayed template parsing in the main file

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 26 05:50:31 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d7637dc460a: [clangd] Disable delayed template parsing in the main file (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78848/new/

https://reviews.llvm.org/D78848

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp


Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -175,6 +175,17 @@
                         AllOf(DeclNamed("foo"), WithTemplateArgs("<bool>"))}));
 }
 
+TEST(ParsedASTTest, IgnoresDelayedTemplateParsing) {
+  auto TU = TestTU::withCode(R"cpp(
+    template <typename T> void xxx() {
+      int yyy = 0;
+    }
+  )cpp");
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+  auto AST = TU.build();
+  EXPECT_EQ(Decl::Var, findUnqualifiedDecl(AST, "yyy").getKind());
+}
+
 TEST(ParsedASTTest, TokensAfterPreamble) {
   TestTU TU;
   TU.AdditionalFiles["foo.h"] = R"(
Index: clang-tools-extra/clangd/ParsedAST.cpp
===================================================================
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -256,6 +256,9 @@
   // Recovery expression currently only works for C++.
   if (CI->getLangOpts()->CPlusPlus)
     CI->getLangOpts()->RecoveryAST = Opts.BuildRecoveryAST;
+  // This is on-by-default in windows to allow parsing SDK headers, but it
+  // breaks many features. Disable it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
 
   StoreDiags ASTDiags;
   std::string Content = std::string(Buffer->getBuffer());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78848.260165.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200426/9d4584dd/attachment.bin>


More information about the cfe-commits mailing list