From f5612b76bcbc8290b44f0e3deb677ee6ff0a95b8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 23 Apr 2003 19:09:22 +0000 Subject: [PATCH] Fix the super obnoxious "cast to pointer from integer of different size" warnings git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5881 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 17 +++++++++-------- lib/Target/CBackend/Writer.cpp | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index dfe5ec2f58a..f9ddc7d8c41 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -946,13 +946,8 @@ void CWriter::visitBranchInst(BranchInst &I) { void CWriter::visitBinaryOperator(Instruction &I) { // binary instructions, shift instructions, setCond instructions. - if (isa(I.getType())) { - Out << "("; - printType(Out, I.getType()); - Out << ")"; - } + assert(!isa(I.getType())); - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(0)); switch (I.getOpcode()) { @@ -975,14 +970,20 @@ void CWriter::visitBinaryOperator(Instruction &I) { default: std::cerr << "Invalid operator type!" << I; abort(); } - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(1)); } void CWriter::visitCastInst(CastInst &I) { Out << "("; - printType(Out, I.getType(), string(""),/*ignoreName*/false, /*namedContext*/false); + printType(Out, I.getType(), string(""),/*ignoreName*/false, + /*namedContext*/false); Out << ")"; + if (isa(I.getType())&&I.getOperand(0)->getType()->isIntegral() || + isa(I.getOperand(0)->getType())&&I.getType()->isIntegral()) { + // Avoid "cast to pointer from integer of different size" warnings + Out << "(long)"; + } + writeOperand(I.getOperand(0)); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index dfe5ec2f58a..f9ddc7d8c41 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -946,13 +946,8 @@ void CWriter::visitBranchInst(BranchInst &I) { void CWriter::visitBinaryOperator(Instruction &I) { // binary instructions, shift instructions, setCond instructions. - if (isa(I.getType())) { - Out << "("; - printType(Out, I.getType()); - Out << ")"; - } + assert(!isa(I.getType())); - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(0)); switch (I.getOpcode()) { @@ -975,14 +970,20 @@ void CWriter::visitBinaryOperator(Instruction &I) { default: std::cerr << "Invalid operator type!" << I; abort(); } - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(1)); } void CWriter::visitCastInst(CastInst &I) { Out << "("; - printType(Out, I.getType(), string(""),/*ignoreName*/false, /*namedContext*/false); + printType(Out, I.getType(), string(""),/*ignoreName*/false, + /*namedContext*/false); Out << ")"; + if (isa(I.getType())&&I.getOperand(0)->getType()->isIntegral() || + isa(I.getOperand(0)->getType())&&I.getType()->isIntegral()) { + // Avoid "cast to pointer from integer of different size" warnings + Out << "(long)"; + } + writeOperand(I.getOperand(0)); }