[PATCH] D143197: [clangd] Fix bugs in main-file include patching for stale preambles
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 8 07:28:23 PST 2023
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang-tools-extra/clangd/Preamble.cpp:691
+ // it's coming from baseline preamble.
+ if (It->second)
+ PatchedInc = *It->second;
----------------
if It->second is null, then all the `#includes` of this header from the baseline preamble were in disabled sections, so it's *very* likely this one is too.
I think we're better not pushing onto PP.PreambleIncludes at all in this case, rather than pushing an unresolved one - this is how the MainFileIncludes looks like when an `#include` is in a disabled section and there's no patching happening.
================
Comment at: clang-tools-extra/clangd/unittests/PreambleTests.cpp:236
+TEST(PreamblePatchTest, IncludesArePreserved) {
+ llvm::StringLiteral Baseline = "//error-ok\n#include <foo>\n#include <bar>\n";
+ auto Modified = Baseline + "#define FOO\n";
----------------
rawstrings?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143197/new/
https://reviews.llvm.org/D143197
More information about the cfe-commits
mailing list