[cfe-dev] Language not recognized: 'c++-module-cpp-output'

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Sun Jun 4 02:38:12 PDT 2017


Richard Smith <richard at metafoo.co.uk> writes:

> I think you misunderstood my question. What difference do you expect the -x
> c++-cpp-output / -x c++-module-cpp-output flag to make, compared to passing
> -x c++ / -x c++-module for the same input file? What do you think that flag
> does?

I believe that -x *cpp-output tells the compiler that what's being
compiled has previously gone through -E. At least that's the GCC's
semantics.

It is also now clear that this semantics is pretty useless since it
looses information and that's why we have -frewrite-includes and
-fdirectives-only.

Now if you ask me what I would like -x *cpp-output to mean, it would
be this: The input can still contain comments and line continuations
but no macro expansions/conditions or #include directives.

My understanding is that the preprocessor is essentially a tokenizer
for the compiler frontend. So in this model a compiler could
substitute a "full preprocessor" with a simpler and maybe faster
tokenizer.

For what it's worth, I've implemented such a tokenizer in build2[1]
and it turned out not too hairy. We use[2] it to extract module
information from translation units.

Its performance is about the same as Clang's full preprocessor (-E)
which I think is not bad considering I haven't done any optimization
work and it uses std::istream to read the data.

[1] https://git.build2.org/cgit/build2/tree/build2/cc/lexer.hxx
    https://git.build2.org/cgit/build2/tree/build2/cc/lexer.cxx

[2] https://git.build2.org/cgit/build2/tree/build2/cc/parser.hxx
    https://git.build2.org/cgit/build2/tree/build2/cc/parser.cxx

Boris



More information about the cfe-dev mailing list