Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Don't store -fsyntax-only in compilation entries
Browse files Browse the repository at this point in the history
There is a FIXME about the usage of -fsyntax-only in clang::createInvocationFromCommandLine
  • Loading branch information
MaskRay committed Feb 15, 2018
1 parent af14a10 commit 368b266
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/clang_translation_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Create(
if (error_code != CXError_Success && cx_tu)
EmitDiagnostics(filepath, args, cx_tu);

// We sometimes dump the command to logs and ask the user to run it. Include
// -fsyntax-only so they don't do a full compile.
auto make_msg = [&]() {
return "Please try running the following, identify which flag causes the "
"issue, and report a bug. cquery will then filter the flag for you "
" automatically:\n$ " + StringJoin(args, " ");
" automatically:\n$ " + StringJoin(args, " ") + " -fsyntax-only";
};

switch (error_code) {
Expand Down
23 changes: 8 additions & 15 deletions src/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
if (!AnyStartsWith(result.args, "-Wno-unknown-warning-option"))
result.args.push_back("-Wno-unknown-warning-option");

// We sometimes dump the command to logs and ask the user to run it. Include
// -fsyntax-only so they don't do a full compile.
if (!AnyStartsWith(result.args, "-fsyntax-only"))
result.args.push_back("-fsyntax-only");

// Using -fparse-all-comments enables documentation in the indexer and in
// code completion.
if (init_opts->index.comments > 1 &&
Expand Down Expand Up @@ -603,28 +598,28 @@ TEST_SUITE("Project") {
/* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-lstdc++", "&/dir/myfile.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option", "-fsyntax-only", "-fparse-all-comments"});
"-Wno-unknown-warning-option", "-fparse-all-comments"});

CheckFlags(
/* raw */ {"clang.exe"},
/* expected */
{"clang.exe", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fsyntax-only", "-fparse-all-comments"});
"-fparse-all-comments"});

CheckFlags(
/* raw */ {"goma", "clang"},
/* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fsyntax-only", "-fparse-all-comments"});
"-fparse-all-comments"});

CheckFlags(
/* raw */ {"goma", "clang", "--foo"},
/* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14", "--foo",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fsyntax-only", "-fparse-all-comments"});
"-fparse-all-comments"});
}

TEST_CASE("Windows path normalization") {
Expand All @@ -633,15 +628,15 @@ TEST_SUITE("Project") {
/* expected */
{"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14",
"&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option", "-fsyntax-only", "-fparse-all-comments"});
"-Wno-unknown-warning-option", "-fparse-all-comments"});

CheckFlags(
"E:/workdir", "E:/workdir/bar.cc",
/* raw */ {"clang", "E:/workdir/bar.cc"},
/* expected */
{"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14",
"&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option", "-fsyntax-only", "-fparse-all-comments"});
"-Wno-unknown-warning-option", "-fparse-all-comments"});
}

TEST_CASE("Path in args") {
Expand All @@ -651,7 +646,7 @@ TEST_SUITE("Project") {
/* expected */
{"cc", "-working-directory", "/home/user", "-xc", "-std=gnu11", "-O0",
"&/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option", "-fsyntax-only", "-fparse-all-comments"});
"-Wno-unknown-warning-option", "-fparse-all-comments"});
}

TEST_CASE("Implied binary") {
Expand All @@ -661,7 +656,7 @@ TEST_SUITE("Project") {
/* expected */
{"clang++", "-working-directory", "/home/user", "-xc++", "-std=c++14",
"-DDONT_IGNORE_ME", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option", "-fsyntax-only", "-fparse-all-comments"});
"-Wno-unknown-warning-option", "-fparse-all-comments"});
}

// Checks flag parsing for a random chromium file in comparison to what
Expand Down Expand Up @@ -1012,7 +1007,6 @@ TEST_SUITE("Project") {
"lock_screen_sanity_unittest.cc",
"-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option",
"-fsyntax-only",
"-fparse-all-comments"});
}

Expand Down Expand Up @@ -1338,7 +1332,6 @@ TEST_SUITE("Project") {
"&/w/c/s/out/Release/../../apps/app_lifetime_monitor.cc",
"-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option",
"-fsyntax-only",
"-fparse-all-comments"});
}

Expand Down

0 comments on commit 368b266

Please sign in to comment.