mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-15 09:56:02 +00:00

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 all of rc.exe, by parsing the preprocessor output line markers and ignoring content from files named *.h and *.c, documented at [1]. In addition to this filtering, strip out any other preprocessor directive that is 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. (Windres on the other hand doesn't filter out files named *.c, only *.h.) Differential Revision: https://reviews.llvm.org/D46579 [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331903 91177308-0d34-0410-b5e6-96231b3b80d8
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
//===-- ResourceScriptCppFilter.h ------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===---------------------------------------------------------------------===//
|
|
//
|
|
// This filters the input to llvm-rc for preprocessor markers, removing
|
|
// preprocessing directives that a preprocessor can output or leave behind.
|
|
//
|
|
// It also filters out any contribution from files named *.h or *.c, based
|
|
// on preprocessor line markers. When preprocessing RC files, the included
|
|
// headers can leave behind C declarations, that RC doesn't understand.
|
|
// Rc.exe simply discards anything that comes from files named *.h or *.h.
|
|
//
|
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx
|
|
//
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_LLVMRC_RESOURCESCRIPTCPPFILTER_H
|
|
#define LLVM_TOOLS_LLVMRC_RESOURCESCRIPTCPPFILTER_H
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include <string>
|
|
|
|
namespace llvm {
|
|
|
|
std::string filterCppOutput(StringRef Input);
|
|
|
|
} // namespace llvm
|
|
|
|
#endif
|