This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Move -extra-arg handling to CommonOptionsProvider
ClosedPublic

Authored by alexfh on Oct 31 2014, 10:27 PM.

Details

Summary

Handle -extra-arg and -extra-arg-before options in the
CommonOptionsProvider so they can be used in all clang tools. Adjust arguments
in a CompilationDatabase wrapper instead of adding ArgumentsAdjuster to the
tool.

Diff Detail

Event Timeline

alexfh updated this revision to Diff 15667.Oct 31 2014, 10:27 PM
alexfh retitled this revision from to [clang-tidy] Move -extra-arg handling to CommonOptionsProvider.
alexfh updated this object.
alexfh edited the test plan for this revision. (Show Details)
alexfh added reviewers: klimek, djasper.
alexfh added a subscriber: Unknown Object (MLST).
klimek added inline comments.Nov 2 2014, 8:41 PM
lib/Tooling/CommonOptionsParser.cpp
138–139

It seems to me like we'd want either this to take an ArgumentAdjuster instead of hard-coding to the args-before / args-after case?

alexfh added inline comments.Nov 2 2014, 8:46 PM
lib/Tooling/CommonOptionsParser.cpp
138–139

This would make sense, if we make this compilation database wrapper public. But for this specific case the total amount of code is not larger than what would be needed for the ArgumentsAdjuster-based variant.

klimek added inline comments.Nov 2 2014, 8:59 PM
lib/Tooling/CommonOptionsParser.cpp
138–139

Well, if the code is not much larger, I'd go with the variant that fits the names better... Or do you have a specific reason for not handing in an argument adjuster? To me it was just unexpected when reading the code...

alexfh added inline comments.Nov 3 2014, 6:45 AM
lib/Tooling/CommonOptionsParser.cpp
138–139

I'd like to see ArgumentsAdjuster replaced with an appropriate std::function eventually. As for the name of the compilation database wrapper, I'd better change it to something closer to the implementation, than vice versa. How about ExtraArgumentsInserterCompilations? Or CompilationsWithExtraArguments?

klimek added inline comments.Nov 3 2014, 7:14 AM
lib/Tooling/CommonOptionsParser.cpp
138–139

I'm not convinced that renaming is better - can you provide an argument on why you prefer the current implementation (you said the more composable implementation would be ~ the same length).

alexfh updated this revision to Diff 15724.Nov 3 2014, 11:35 AM

Make ArgumentsAdjustingCompilations more generic by using ArgumentsAdjusters.

The previous version looks marginally better to me due to slightly less
code, but this one turned out to be better than I expected. Which one do
you prefer?

klimek accepted this revision.Nov 4 2014, 12:43 AM
klimek edited edge metadata.

LG. I prefer the current version.

lib/Tooling/CommonOptionsParser.cpp
82

Do we also have to adjust here?

This revision is now accepted and ready to land.Nov 4 2014, 12:43 AM
alexfh added inline comments.Nov 4 2014, 1:00 AM
lib/Tooling/CommonOptionsParser.cpp
82

I think, it's used only in tests, but I see no reason not to adjust the commands here.

alexfh updated this revision to Diff 15749.Nov 4 2014, 1:01 AM
alexfh edited edge metadata.

Adjust arguments in getAllCompileCommands().

alexfh closed this revision.Nov 4 2014, 1:02 AM