Emit code for #includes in emitted C++ code all at the start of the file.
This commit is contained in:
21
cbackend.cpp
21
cbackend.cpp
@@ -1741,17 +1741,6 @@ void CWriter::writeOperandWithCast(Value* Operand, const ICmpInst &Cmp) {
|
|||||||
//
|
//
|
||||||
static void generateCompilerSpecificCode(formatted_raw_ostream& Out,
|
static void generateCompilerSpecificCode(formatted_raw_ostream& Out,
|
||||||
const TargetData *TD) {
|
const TargetData *TD) {
|
||||||
// Alloca, ...
|
|
||||||
Out << "#include <stdlib.h>\n"
|
|
||||||
<< "#include <stdint.h>\n"
|
|
||||||
<< "/* get a declaration for alloca */\n"
|
|
||||||
<< "#ifdef _MSC_VER\n"
|
|
||||||
<< "#include <malloc.h>\n"
|
|
||||||
<< "#define alloca _alloca\n"
|
|
||||||
<< "#else\n"
|
|
||||||
<< "#include <alloca.h>\n"
|
|
||||||
<< "#endif\n\n";
|
|
||||||
|
|
||||||
// We output GCC specific attributes to preserve 'linkonce'ness on globals.
|
// We output GCC specific attributes to preserve 'linkonce'ness on globals.
|
||||||
// If we aren't being compiled with GCC, just drop these attributes.
|
// If we aren't being compiled with GCC, just drop these attributes.
|
||||||
Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n"
|
Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n"
|
||||||
@@ -1976,7 +1965,6 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
Out << " DO NOT EDIT THIS FILE DIRECTLY\n";
|
Out << " DO NOT EDIT THIS FILE DIRECTLY\n";
|
||||||
Out << " *******************************************************************/\n\n";
|
Out << " *******************************************************************/\n\n";
|
||||||
|
|
||||||
// get declaration for alloca
|
|
||||||
Out << "/* Provide Declarations */\n";
|
Out << "/* Provide Declarations */\n";
|
||||||
Out << "#include <stdarg.h>\n"; // Varargs support
|
Out << "#include <stdarg.h>\n"; // Varargs support
|
||||||
Out << "#include <setjmp.h>\n"; // Unwind support
|
Out << "#include <setjmp.h>\n"; // Unwind support
|
||||||
@@ -1987,6 +1975,15 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
Out << " #define NOMINMAX\n";
|
Out << " #define NOMINMAX\n";
|
||||||
Out << " #include <windows.h>\n";
|
Out << " #include <windows.h>\n";
|
||||||
Out << "#endif // _MSC_VER\n";
|
Out << "#endif // _MSC_VER\n";
|
||||||
|
Out << "#include <stdlib.h>\n";
|
||||||
|
Out << "#include <stdint.h>\n";
|
||||||
|
Out << "/* get a declaration for alloca */\n";
|
||||||
|
Out << "#ifdef _MSC_VER\n";
|
||||||
|
Out << " #include <malloc.h>\n";
|
||||||
|
Out << " #define alloca _alloca\n";
|
||||||
|
Out << "#else\n";
|
||||||
|
Out << " #include <alloca.h>\n";
|
||||||
|
Out << "#endif\n\n";
|
||||||
|
|
||||||
Out << "#include \"" << includeName << "\"\n";
|
Out << "#include \"" << includeName << "\"\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user