[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

Christopher Sauer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 14 01:37:32 PST 2023


cpsauer updated this revision to Diff 489208.
cpsauer added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

@nridge, I took a shot at the change you suggested. Confirming that this what you were thinking of, removing `inferTargetAndDriverMode` from database load and replacing it with a call to the underlying `addTargetAndModeForProgramName` in the `CommandMangler` after the `SystemIncludeExtractor` is invoked?
Note that I also saw a parallel call to `inferTargetAndDriverMode` in `JSONCompilationDatabasePlugin`, which seemed like it might cause the same problem, so I eliminated the call in there, too. I then culled the dead code, since there weren't other call sites for the `addTargetAndModeForProgramName` wrappings. Could I ask you to sanity check that? I know that's a more general tooling library; I was having trouble determining whether other tooling needed the target inference or not.  
Also, @ArcsinX, could I get your take? Do you think this would fix the layering issue you raised?

We're definitely stretching my (currently quite limited) understanding of how clangd's implementation fits together, so I think I'll need to ask for help/guidance if that looks wrong.

Thanks again, guys!
-CS


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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138546.489208.patch
Type: text/x-patch
Size: 12459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230114/552bcda0/attachment-0001.bin>


More information about the cfe-commits mailing list