[PATCH] D46579: [llvm-rc] Handle C preprocessor output

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 05:49:57 PDT 2018


mstorsjo created this revision.
mstorsjo added reviewers: zturner, amccarth, mnbvmar.
Herald added a subscriber: mgorny.

When preprocessing resource scripts (which can easily be done outside of llvm-rc), included headers can leave behind C declarations (despite preprocessing with -DRC_INVOKED), that can't be parsed by a resource compiler.

This is handled in rc.exe (verified experimentally), GNU windres and wrc (clearly visible in the source) by parsing the preprocessor output line markers and ignoring content from files named *.h.

In addition to this filtering, strip out any other preprocessor directive that are left behind (like pragmas) which also can't be handled by the tokenizer.

The added test uses both standard #line markers (supported by rc.exe) and GNU style extended line markers, thus this test doesn't pass with rc.exe, but passes with GNU windres.


Repository:
  rL LLVM

https://reviews.llvm.org/D46579

Files:
  test/tools/llvm-rc/Inputs/cpp-output.rc
  test/tools/llvm-rc/cpp-output.test
  tools/llvm-rc/CMakeLists.txt
  tools/llvm-rc/ResourceScriptCppFilter.cpp
  tools/llvm-rc/ResourceScriptCppFilter.h
  tools/llvm-rc/llvm-rc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46579.145674.patch
Type: text/x-patch
Size: 7800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/ff557069/attachment.bin>


More information about the llvm-commits mailing list