This is an archive of the discontinued LLVM Phabricator instance.

[Tooling] Infer driver mode and target for FixedCompilationDatabase
AbandonedPublic

Authored by de1acr0ix on Dec 27 2019, 6:57 PM.

Details

Reviewers
klimek
Summary

When creating FixedCompilationDatabase from command line, compiler
command is often provided. This commit tries to infer driver mode and
target from that so that clang tools does not need to specify them
explicitly.

Event Timeline

de1acr0ix created this revision.Dec 27 2019, 6:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 27 2019, 6:57 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
de1acr0ix planned changes to this revision.Dec 27 2019, 9:17 PM

I realized an obvious problem: if the first argument is "-cc" or something compiler option ends with a possible driver mode suffix it would be treated as compiler binary name.

de1acr0ix updated this revision to Diff 235496.EditedDec 28 2019, 7:51 PM

Check if argv[0] is an option before inferring - anything starting with dash or slash (but without a second slash) will be treated as compiler option.

de1acr0ix abandoned this revision.Dec 29 2019, 3:21 PM

It is impossible to handle the case that positional argument starts with a source file with a driver mode suffix in file name stem, such as "somecpp.cpp".