From 48e9d4af39fc9c6be5dd6e6bd4fc89e3401fe144 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 5 Jan 2012 12:21:11 -0800 Subject: [PATCH] Emit code for #includes in emitted C++ code all at the start of the file. --- cbackend.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cbackend.cpp b/cbackend.cpp index 41190117..cf606672 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -1741,17 +1741,6 @@ void CWriter::writeOperandWithCast(Value* Operand, const ICmpInst &Cmp) { // static void generateCompilerSpecificCode(formatted_raw_ostream& Out, const TargetData *TD) { - // Alloca, ... - Out << "#include \n" - << "#include \n" - << "/* get a declaration for alloca */\n" - << "#ifdef _MSC_VER\n" - << "#include \n" - << "#define alloca _alloca\n" - << "#else\n" - << "#include \n" - << "#endif\n\n"; - // We output GCC specific attributes to preserve 'linkonce'ness on globals. // If we aren't being compiled with GCC, just drop these attributes. 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 << " *******************************************************************/\n\n"; - // get declaration for alloca Out << "/* Provide Declarations */\n"; Out << "#include \n"; // Varargs support Out << "#include \n"; // Unwind support @@ -1987,6 +1975,15 @@ bool CWriter::doInitialization(Module &M) { Out << " #define NOMINMAX\n"; Out << " #include \n"; Out << "#endif // _MSC_VER\n"; + Out << "#include \n"; + Out << "#include \n"; + Out << "/* get a declaration for alloca */\n"; + Out << "#ifdef _MSC_VER\n"; + Out << " #include \n"; + Out << " #define alloca _alloca\n"; + Out << "#else\n"; + Out << " #include \n"; + Out << "#endif\n\n"; Out << "#include \"" << includeName << "\"\n";