[cfe-commits] Add cpp frontend
Douglas Gregor
dgregor at apple.com
Sun Mar 6 10:24:35 PST 2011
On Mar 6, 2011, at 9:51 AM, Joerg Sonnenberger wrote:
> Anyone for review? This would be quite useful to have in 2.9 as a
> standalone cpp (even in "modern" mode) is used by a number of programs.
>
> Joerg
>
> On Sat, Mar 05, 2011 at 01:19:59PM +0100, Joerg Sonnenberger wrote:
>> Hi all,
>> the attached patch recognizes getting called as cpp and act accordingly.
>> This differs from clang -E in the handling of missing input files. cpp
>> assumes that stdin is used in that case. Patch is based on an earlier
>> version from rdivacky.
>>
>> Joerg
>
>> Index: include/clang/Driver/Driver.h
>> ===================================================================
>> --- include/clang/Driver/Driver.h (revision 126955)
>> +++ include/clang/Driver/Driver.h (working copy)
>> @@ -102,6 +102,9 @@
>> /// Whether the driver should follow g++ like behavior.
>> unsigned CCCIsCXX : 1;
>>
>> + /// Whether the driver is just the preprocessor
>> + unsigned CCCIsCPP : 1;
>> +
>> /// Echo commands while executing (in -v style).
>> unsigned CCCEcho : 1;
>>
>> @@ -221,7 +224,7 @@
>> /// \param TC - The default host tool chain.
>> /// \param Args - The input arguments.
>> /// \param Actions - The list to store the resulting actions onto.
>> - void BuildActions(const ToolChain &TC, const ArgList &Args,
>> + void BuildActions(const ToolChain &TC, const InputArgList &Args,
>> ActionList &Actions) const;
>>
>> /// BuildUniversalActions - Construct the list of actions to perform
>> @@ -230,7 +233,7 @@
>> /// \param TC - The default host tool chain.
>> /// \param Args - The input arguments.
>> /// \param Actions - The list to store the resulting actions onto.
>> - void BuildUniversalActions(const ToolChain &TC, const ArgList &Args,
>> + void BuildUniversalActions(const ToolChain &TC, const InputArgList &Args,
>> ActionList &Actions) const;
>>
>> /// BuildJobs - Bind actions to concrete tools and translate
>> Index: tools/driver/driver.cpp
>> ===================================================================
>> --- tools/driver/driver.cpp (revision 126955)
>> +++ tools/driver/driver.cpp (working copy)
>> @@ -342,6 +342,11 @@
>> TheDriver.CCCIsCXX = true;
>> }
>>
>> + if (llvm::StringRef(ProgName).endswith("cpp") ||
>> + llvm::StringRef(ProgName).rsplit('-').first.endswith("cpp")) {
>> + TheDriver.CCCIsCPP = true;
>> + }
Why is this an "endswith" check rather than equality comparison? I suspect that we just want to match "cpp" or "cpp-version".
Even as "cpp", we're still going to outright reject "-traditional". Is that still the right thing to do?
Anyway, this looks okay to me, but I'd love to hear Daniel's opinion on this.
- Doug
More information about the cfe-commits
mailing list