summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-12-19 22:22:01 +0100
committerKadir Cetinkaya <kadircet@google.com>2019-12-20 11:10:36 +0100
commitc2377eae286bbe616267bef772ee736b030dd007 (patch)
tree0fe97afeef4533fd328a5a2ea2b432fbf136146b /clang/lib
parent29bd2194979c50097edb39a4beb714bff8c153a1 (diff)
downloadbcm5719-llvm-c2377eae286bbe616267bef772ee736b030dd007.tar.gz
bcm5719-llvm-c2377eae286bbe616267bef772ee736b030dd007.zip
[clang][Tooling] Prefer -x over -std when interpolating
Summary: Currently interpolation logic prefers -std over -x. But the latter is a more strong signal, so this patch inverts the order and only makes use of -std if -x didn't exist. Fixes https://github.com/clangd/clangd/issues/185 Thanks @sammccall for tracking this down! Reviewers: sammccall Subscribers: ilya-biryukov, usaxena95, cfe-commits, sammccall Tags: #clang Differential Revision: https://reviews.llvm.org/D71727
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Tooling/InterpolatingCompilationDatabase.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
index 59b66abe65e..2cc819a498c 100644
--- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,7 +191,8 @@ struct TransferableCommand {
OldArgs.data() + OldPos, OldArgs.data() + Pos);
}
- if (Std != LangStandard::lang_unspecified) // -std take precedence over -x
+ // Make use of -std iff -x was missing.
+ if (Type == types::TY_INVALID && Std != LangStandard::lang_unspecified)
Type = toType(LangStandard::getLangStandardForKind(Std).getLanguage());
Type = foldType(*Type);
// The contract is to store None instead of TY_INVALID.
OpenPOWER on IntegriCloud