Adjust order of GetPlatformClangArguments

This commit is contained in:
Fangrui Song 2018-03-11 21:48:05 -07:00
parent 89d45fb48a
commit 3a752a3c8f
6 changed files with 13 additions and 10 deletions

View File

@ -69,11 +69,7 @@ std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Create(
std::vector<CXUnsavedFile>& unsaved_files, std::vector<CXUnsavedFile>& unsaved_files,
unsigned flags) { unsigned flags) {
std::vector<const char*> args; std::vector<const char*> args;
for (const std::string& a : arguments) for (auto& arg : arguments)
args.push_back(a.c_str());
std::vector<std::string> platform_args = GetPlatformClangArguments();
for (const auto& arg : platform_args)
args.push_back(arg.c_str()); args.push_back(arg.c_str());
CXTranslationUnit cx_tu; CXTranslationUnit cx_tu;

View File

@ -42,7 +42,7 @@ void CopyFileTo(const std::string& destination, const std::string& source);
bool IsSymLink(const std::string& path); bool IsSymLink(const std::string& path);
// Returns any clang arguments that are specific to the current platform. // Returns any clang arguments that are specific to the current platform.
std::vector<std::string> GetPlatformClangArguments(); std::vector<const char*> GetPlatformClangArguments();
// Free any unused memory and return it to the system. // Free any unused memory and return it to the system.
void FreeUnusedMemory(); void FreeUnusedMemory();

View File

@ -259,7 +259,7 @@ bool IsSymLink(const std::string& path) {
return lstat(path.c_str(), &buf) == 0 && S_ISLNK(buf.st_mode); return lstat(path.c_str(), &buf) == 0 && S_ISLNK(buf.st_mode);
} }
std::vector<std::string> GetPlatformClangArguments() { std::vector<const char*> GetPlatformClangArguments() {
return {}; return {};
} }

View File

@ -129,12 +129,13 @@ bool IsSymLink(const std::string& path) {
return false; return false;
} }
std::vector<std::string> GetPlatformClangArguments() { std::vector<const char*> GetPlatformClangArguments() {
// //
// Found by executing // Found by executing
// //
// $ clang++ -E -x c++ - -v // $ clang++ -E -x c++ - -v
// //
// https://clang.llvm.org/docs/MSVCCompatibility.html
// clang-format off // clang-format off
return { return {

View File

@ -27,6 +27,8 @@
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
extern bool gTestOutputMode;
struct CompileCommandsEntry { struct CompileCommandsEntry {
std::string directory; std::string directory;
std::string file; std::string file;
@ -193,6 +195,12 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
if (!AnyStartsWith(args, "-working-directory")) if (!AnyStartsWith(args, "-working-directory"))
result.args.emplace_back("-working-directory=" + entry.directory); result.args.emplace_back("-working-directory=" + entry.directory);
if (!gTestOutputMode) {
std::vector<const char*> platform = GetPlatformClangArguments();
for (auto arg: platform)
result.args.push_back(arg);
}
bool next_flag_is_path = false; bool next_flag_is_path = false;
bool add_next_flag_to_quote_dirs = false; bool add_next_flag_to_quote_dirs = false;
bool add_next_flag_to_angle_dirs = false; bool add_next_flag_to_angle_dirs = false;

View File

@ -10,9 +10,7 @@
#include <stdexcept> #include <stdexcept>
namespace {
bool gTestOutputMode = false; bool gTestOutputMode = false;
} // namespace
//// Elementary types //// Elementary types