From cf135cbc77bf8638bdbfeb1160ef42ce1bf02404 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 2 Jun 2003 03:10:53 +0000 Subject: Fix bug: CBackend/2003-06-01-NullPointerType.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6526 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 9 +++++---- lib/Target/CBackend/Writer.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index a12afa7958..954266163b 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -435,7 +435,9 @@ void CWriter::printConstant(Constant *CPV) { case Type::PointerTyID: if (isa(CPV)) { - Out << "(NULL)"; + Out << "(("; + printType(Out, CPV->getType()); + Out << ")/*NULL*/0)"; break; } else if (ConstantPointerRef *CPR = dyn_cast(CPV)) { writeOperand(CPR->getValue()); @@ -545,9 +547,8 @@ void CWriter::printModule(Module *M) { Out << "#include \n"; Out << "#include \n"; - // Provide a definition for null if one does not already exist, - // and for `bool' if not compiling with a C++ compiler. - Out << "#ifndef NULL\n#define NULL 0\n#endif\n\n" + // Provide a definition for `bool' if not compiling with a C++ compiler. + Out << "\n" << "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n" << "\n\n/* Support for floating point constants */\n" diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index a12afa7958..954266163b 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -435,7 +435,9 @@ void CWriter::printConstant(Constant *CPV) { case Type::PointerTyID: if (isa(CPV)) { - Out << "(NULL)"; + Out << "(("; + printType(Out, CPV->getType()); + Out << ")/*NULL*/0)"; break; } else if (ConstantPointerRef *CPR = dyn_cast(CPV)) { writeOperand(CPR->getValue()); @@ -545,9 +547,8 @@ void CWriter::printModule(Module *M) { Out << "#include \n"; Out << "#include \n"; - // Provide a definition for null if one does not already exist, - // and for `bool' if not compiling with a C++ compiler. - Out << "#ifndef NULL\n#define NULL 0\n#endif\n\n" + // Provide a definition for `bool' if not compiling with a C++ compiler. + Out << "\n" << "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n" << "\n\n/* Support for floating point constants */\n" -- cgit v1.2.3-70-g09d2