Skip to content

Commit

Permalink
Merge pull request #402 from immunant/kkysen/first-compile-command-pe…
Browse files Browse the repository at this point in the history
…r-src

rewriter: warn on multiple compile commands per src and truncate to first one (reopened #398)
  • Loading branch information
kkysen authored Oct 1, 2024
2 parents 89bac1a + 5ebdf79 commit 14dcd2e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/rewriter/SourceRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,14 @@ std::optional<Pkey> pkey_from_commands(std::function<std::optional<std::vector<C
return {};
}

if (comp_cmds.size() != 1) {
llvm::errs() << "warning: multiple compile commands for a single source file" << '\n'
<< " truncating to first compile command" << '\n'
<< " may not work properly" << '\n';
comp_cmds.resize(1);
}
assert(comp_cmds.size() == 1);

auto cc_cmd = *comp_cmd_with_pkey;

auto pkey_define = std::find_if(cc_cmd.CommandLine.begin(),
Expand Down

0 comments on commit 14dcd2e

Please sign in to comment.