This is an archive of the discontinued LLVM Phabricator instance.

[clang][cli] Generate and round-trip preprocessor options
ClosedPublic

Authored by jansvoboda11 on Jan 25 2021, 8:08 AM.

Details

Summary

This patch implements generation of remaining preprocessor options and tests it by performing parse-generate-parse round trip.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Jan 25 2021, 8:08 AM
jansvoboda11 requested review of this revision.Jan 25 2021, 8:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2021, 8:08 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 retitled this revision from [WIP][clang][cli] Generate and round-trip preprocessor options to [clang][cli] Generate and round-trip preprocessor options.Jan 28 2021, 9:36 AM
jansvoboda11 edited the summary of this revision. (Show Details)
dexonsmith accepted this revision.Jan 28 2021, 12:06 PM

LGTM.

clang/lib/Frontend/CompilerInvocation.cpp
3189

Can we name this differently, so it's obvious which is being called without looking at the argument list? I suggest ParsePreprocessorArgsImpl for this one, since it's doing the actual parsing.

3325–3326

Have you considered just defining the lambdas inline in the call to RoundTrip? I'm fine either way, but the way clang-format tends to clean this up seems pretty readable to me, and the names don't really add much value since they match the functions being called. Up to you.

This revision is now accepted and ready to land.Jan 28 2021, 12:06 PM
jansvoboda11 added inline comments.Jan 29 2021, 5:49 AM
clang/lib/Frontend/CompilerInvocation.cpp
3189

I thought about it and decided to keep it the same. We'd be renaming it back to ParsePreprocessorArgs in a few weeks, when we round-trip the whole CompilerInvocation at once and the need for the fine-grained interposed functions disappears.

3325–3326

In this case, where one of the lambdas contains a long comment, I suggest keeping it separate. It's easier to read that way.

jansvoboda11 edited the summary of this revision. (Show Details)

Rename variable

Rebase, rename parse function

jansvoboda11 edited the summary of this revision. (Show Details)Feb 8 2021, 12:34 AM
This revision was landed with ongoing or failed builds.Feb 8 2021, 12:35 AM
This revision was automatically updated to reflect the committed changes.