This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Add compiler utility class for LIT tests
ClosedPublic

Authored by EricWF on Jan 16 2015, 12:59 PM.

Details

Summary

This adds a compiler utility class that handles generating compile commands and running them. Instead of having to pass the compiler path and 3 groups of flags between the configuration and the test format this allows us to just pass the compiler object.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 18312.Jan 16 2015, 12:59 PM
EricWF retitled this revision from to [libcxx] Add compiler utility class for LIT tests.
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: danalbert, jroelofs.
EricWF added a subscriber: Unknown Object (MLST).
jroelofs accepted this revision.Jan 16 2015, 1:08 PM
jroelofs edited edge metadata.

This looks really nice!

This revision is now accepted and ready to land.Jan 16 2015, 1:08 PM
EricWF updated this revision to Diff 18317.Jan 16 2015, 1:29 PM
EricWF edited edge metadata.

Merged with master and fixed newline in target triple.

EricWF closed this revision.Jan 16 2015, 1:36 PM
danalbert edited edge metadata.Jan 16 2015, 2:12 PM

I tried pretty hard to find a way that this wouldn't work under msvc, but it looks like it all should be fine. It won't pass along the compiler information for msvc, but it will still work.

Mostly LGTM, but I left some nits.

test/libcxx/test/compiler.py
5

I probably would have put this directly in the libcxx module rather than libcxx.test, but nbd.

13

This should maybe be just None, since you want it to abort if try to use it before it's initialized (and bool((None, None, None)) == True).

20

Isn't this an error? Should probably raise an exception...

48

I'm not a fan of using one argument to accept multiple types that don't conform to the same interface (or behave like the same duck, as it were). Just require that infiles is a list. The argument name is plural, after all.

102

parsed_macros = {}

107

macro, value = l.split()

Address @danalbert's comments.

test/libcxx/test/compiler.py
5

I think that's a good change.

13

Oop, didn't think of that. Thanks.

20

Perhaps dumpMacros() should throw an exception if the return code is non-zero, but I don't think it makes sense for _initTypeAndVersion() to throw because then CXXCompiler wouldn't work with compilers that didn't support the dump macro command.

Any suggestion on the type of the exception?

48

I'm not a big fan either but I think its the best option. I really hate forcing the transformation from string -> list at every call site, I think that makes the the calling code less clear. Even if we only accept a list of files we still have to diagnose being passed a string. Requiring a list is almost the same amount of work as just accepting it.

If this were C++ I would almost certainly have two overloads for both a single file and for a list of files. Accepting both types is quite useful for the user and I don't believe it makes the code unclear.

What problems do you envision this code causing?

107

value can contain spaces. We only want to split on the first space, not all of them.