This is an archive of the discontinued LLVM Phabricator instance.

Fix bugs in EOL marking in command line tokenizers
ClosedPublic

Authored by rnk on Nov 5 2020, 10:33 AM.

Details

Summary

Add unit tests for this behavior, since the integration test for
clang-cl did not catch these bugs.

Fixes PR47604

Diff Detail

Event Timeline

rnk created this revision.Nov 5 2020, 10:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 5 2020, 10:33 AM
rnk requested review of this revision.Nov 5 2020, 10:33 AM
MaskRay added inline comments.Nov 5 2020, 10:43 AM
llvm/lib/Support/CommandLine.cpp
872

Nit: full stop.

llvm/unittests/Support/CommandLineTest.cpp
250

Could you add some comments what nullptr is used for?

As another interesting test, does -Xclang\nfoo work?

rnk added inline comments.Nov 5 2020, 10:59 AM
llvm/lib/Support/CommandLine.cpp
872

Fixed here and above

llvm/unittests/Support/CommandLineTest.cpp
250

Comments added. As far as -Xclang\nfoo goes, this code produces the expected result: "-Xclang", nullptr, "foo". I'll adjust the test a bit, but I think it already covers this case. As for what clang does with that, I expect it doesn't work, but I don't think it's important to make it work. -Xclang is clang's own option, and if it doesn't support being split across newlines, that's our choice, as long as we don't crash.

rnk updated this revision to Diff 303193.Nov 5 2020, 10:59 AM
  • comments
MaskRay accepted this revision.Nov 5 2020, 11:06 AM

Thanks!

llvm/unittests/Support/CommandLineTest.cpp
258

typo: as -> else

This revision is now accepted and ready to land.Nov 5 2020, 11:06 AM
This revision was landed with ongoing or failed builds.Nov 5 2020, 1:04 PM
This revision was automatically updated to reflect the committed changes.