summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-05-07 14:34:06 +0000
committerSam McCall <sam.mccall@gmail.com>2019-05-07 14:34:06 +0000
commit87ad30be5ffa6fa2acbc703e4a85a73fd1181016 (patch)
tree2fcfecb10be0b63d47f555042ac92e19176bd419 /clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
parentd6865b7d71bc4bd0d7251a1ab1979e54c57856cd (diff)
downloadbcm5719-llvm-87ad30be5ffa6fa2acbc703e4a85a73fd1181016.tar.gz
bcm5719-llvm-87ad30be5ffa6fa2acbc703e4a85a73fd1181016.zip
[Tooling] Add -x flags when inferring compile commands for files with no/invalid extension.
Summary: We treat them as headers, as the motivating case is C++ standard library. Reviewers: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61633 llvm-svn: 360153
Diffstat (limited to 'clang/lib/Tooling/InterpolatingCompilationDatabase.cpp')
-rw-r--r--clang/lib/Tooling/InterpolatingCompilationDatabase.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
index 5124340892f..8b1030f3607 100644
--- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -205,10 +205,13 @@ struct TransferableCommand {
bool TypeCertain;
auto TargetType = guessType(Filename, &TypeCertain);
// If the filename doesn't determine the language (.h), transfer with -x.
- if (TargetType != types::TY_INVALID && !TypeCertain && Type) {
- TargetType = types::onlyPrecompileType(TargetType) // header?
- ? types::lookupHeaderTypeForSourceType(*Type)
- : *Type;
+ if ((!TargetType || !TypeCertain) && Type) {
+ // Use *Type, or its header variant if the file is a header.
+ // Treat no/invalid extension as header (e.g. C++ standard library).
+ TargetType =
+ (!TargetType || types::onlyPrecompileType(TargetType)) // header?
+ ? types::lookupHeaderTypeForSourceType(*Type)
+ : *Type;
if (ClangCLMode) {
const StringRef Flag = toCLFlag(TargetType);
if (!Flag.empty())
OpenPOWER on IntegriCloud