[PATCH] D45512: [Tooling] Correct the "-std" compile command option.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 11 01:42:35 PDT 2018
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a subscriber: klimek.
"-std c++11" is not valid in compiler, we have to use "-std=c++11".
Test in vscode with this patch, code completion for header works as expected.
Repository:
rC Clang
https://reviews.llvm.org/D45512
Files:
lib/Tooling/InterpolatingCompilationDatabase.cpp
unittests/Tooling/CompilationDatabaseTest.cpp
Index: unittests/Tooling/CompilationDatabaseTest.cpp
===================================================================
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -711,9 +711,9 @@
// .h is ambiguous, so we add explicit language flags
EXPECT_EQ(getCommand("foo.h"),
- "clang -D dir/foo.cpp -x c++-header -std c++17");
+ "clang -D dir/foo.cpp -x c++-header -std=c++17");
// and don't add -x if the inferred language is correct.
- EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+ EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
// respect -x if it's already there.
EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
// prefer a worse match with the right language
Index: lib/Tooling/InterpolatingCompilationDatabase.cpp
===================================================================
--- lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,9 +191,9 @@
// --std flag may only be transferred if the language is the same.
// We may consider "translating" these, e.g. c++11 -> c11.
if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) {
- Result.CommandLine.push_back("-std");
Result.CommandLine.push_back(
- LangStandard::getLangStandardForKind(Std).getName());
+ "-std=" +
+ std::string(LangStandard::getLangStandardForKind(Std).getName()));
}
Result.CommandLine.push_back(Filename);
return Result;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45512.141959.patch
Type: text/x-patch
Size: 1612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180411/f4db0700/attachment.bin>
More information about the cfe-commits
mailing list