diff options
author | Sam McCall <sam.mccall@gmail.com> | 2019-05-07 14:34:06 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-05-07 14:34:06 +0000 |
commit | 865e584f54b58c624ba6133153799ecb98f3ae4e (patch) | |
tree | 6638a30eb07d9e91ba70b7672a533c3ac2ad8cb9 /lib/Tooling | |
parent | 96177dc49e3cc8d175f80b0469e6b09837858a97 (diff) | |
download | clang-865e584f54b58c624ba6133153799ecb98f3ae4e.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling')
-rw-r--r-- | lib/Tooling/InterpolatingCompilationDatabase.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Tooling/InterpolatingCompilationDatabase.cpp b/lib/Tooling/InterpolatingCompilationDatabase.cpp index 5124340892..8b1030f360 100644 --- a/lib/Tooling/InterpolatingCompilationDatabase.cpp +++ b/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()) |