diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/Basic/TargetInfo.cpp | 2 | ||||
-rw-r--r-- | clang/CodeGen/CGDecl.cpp | 4 | ||||
-rw-r--r-- | clang/CodeGen/CGExpr.cpp | 13 | ||||
-rw-r--r-- | clang/CodeGen/CGStmt.cpp | 2 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenFunction.cpp | 8 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenFunction.h | 6 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenTypes.cpp | 27 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenTypes.h | 6 |
9 files changed, 32 insertions, 38 deletions
diff --git a/clang/Basic/TargetInfo.cpp b/clang/Basic/TargetInfo.cpp index a565536fd6f..008e99b9149 100644 --- a/clang/Basic/TargetInfo.cpp +++ b/clang/Basic/TargetInfo.cpp @@ -26,7 +26,7 @@ void TargetInfoImpl::ANCHOR() {} // out-of-line virtual method for class. /// non-portable. void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) { NonPortable = true; - if (Diag) Diag->Report(Loc, DiagKind); + if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind); } /// GetTargetDefineMap - Get the set of target #defines in an associative diff --git a/clang/CodeGen/CGDecl.cpp b/clang/CodeGen/CGDecl.cpp index 1013dd4e8f5..15f8610ed0c 100644 --- a/clang/CodeGen/CGDecl.cpp +++ b/clang/CodeGen/CGDecl.cpp @@ -72,7 +72,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const BlockVarDecl &D) { llvm::Value *DeclPtr; if (Ty->isConstantSizeType()) { // A normal fixed sized variable becomes an alloca in the entry block. - const llvm::Type *LTy = ConvertType(Ty, D.getLocation()); + const llvm::Type *LTy = ConvertType(Ty); // TODO: Alignment DeclPtr = new llvm::AllocaInst(LTy, 0, D.getName(), AllocaInsertPt); } else { @@ -97,7 +97,7 @@ void CodeGenFunction::EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg) { DeclPtr = Arg; } else { // A fixed sized first class variable becomes an alloca in the entry block. - const llvm::Type *LTy = ConvertType(Ty, D.getLocation()); + const llvm::Type *LTy = ConvertType(Ty); if (LTy->isFirstClassType()) { // TODO: Alignment DeclPtr = new llvm::AllocaInst(LTy, 0, std::string(D.getName())+".addr", diff --git a/clang/CodeGen/CGExpr.cpp b/clang/CodeGen/CGExpr.cpp index 1de2ab87e90..a8ad1f47e93 100644 --- a/clang/CodeGen/CGExpr.cpp +++ b/clang/CodeGen/CGExpr.cpp @@ -41,7 +41,7 @@ llvm::Value *CodeGenFunction::EvaluateExprAsBool(const Expr *E) { /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to /// the type specified by DstTy, following the rules of C99 6.3. RValue CodeGenFunction::EmitConversion(RValue Val, QualType ValTy, - QualType DstTy, SourceLocation Loc) { + QualType DstTy) { ValTy = ValTy.getCanonicalType(); DstTy = DstTy.getCanonicalType(); if (ValTy == DstTy) return Val; @@ -54,7 +54,7 @@ RValue CodeGenFunction::EmitConversion(RValue Val, QualType ValTy, // Handle pointer conversions next: pointers can only be converted to/from // other pointers and integers. if (isa<PointerType>(DstTy)) { - const llvm::Type *DestTy = ConvertType(DstTy, Loc); + const llvm::Type *DestTy = ConvertType(DstTy); // The source value may be an integer, or a pointer. assert(Val.isScalar() && "Can only convert from integer or pointer"); @@ -66,7 +66,7 @@ RValue CodeGenFunction::EmitConversion(RValue Val, QualType ValTy, if (isa<PointerType>(ValTy)) { // Must be an ptr to int cast. - const llvm::Type *DestTy = ConvertType(DstTy, Loc); + const llvm::Type *DestTy = ConvertType(DstTy); assert(isa<llvm::IntegerType>(DestTy) && "not ptr->int?"); return RValue::get(Builder.CreateIntToPtr(Val.getVal(), DestTy, "conv")); } @@ -78,7 +78,7 @@ RValue CodeGenFunction::EmitConversion(RValue Val, QualType ValTy, // We know that these are representable as scalars in LLVM, convert to LLVM // types since they are easier to reason about. llvm::Value *SrcVal = Val.getVal(); - const llvm::Type *DestTy = ConvertType(DstTy, Loc); + const llvm::Type *DestTy = ConvertType(DstTy); if (SrcVal->getType() == DestTy) return Val; llvm::Value *Result; @@ -417,7 +417,7 @@ RValue CodeGenFunction::EmitCastExpr(const CastExpr *E) { if (E->getType()->isVoidType()) return RValue::getAggregate(0); - return EmitConversion(Src, SrcTy, E->getType(), E->getLParenLoc()); + return EmitConversion(Src, SrcTy, E->getType()); } RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) { @@ -941,8 +941,7 @@ RValue CodeGenFunction::EmitBinaryAssign(const BinaryOperator *E) { RValue RHS = EmitExprWithUsualUnaryConversions(E->getRHS(), RHSTy); // Convert the RHS to the type of the LHS. - // FIXME: I'm not thrilled about having to call getLocStart() here... :( - RHS = EmitConversion(RHS, RHSTy, E->getType(), E->getLocStart()); + RHS = EmitConversion(RHS, RHSTy, E->getType()); // Store the value into the LHS. EmitStoreThroughLValue(RHS, LHS, E->getType()); diff --git a/clang/CodeGen/CGStmt.cpp b/clang/CodeGen/CGStmt.cpp index d874e513614..e2dfacae188 100644 --- a/clang/CodeGen/CGStmt.cpp +++ b/clang/CodeGen/CGStmt.cpp @@ -263,7 +263,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) { Builder.CreateRet(llvm::UndefValue::get(RetTy)); } else { // Do implicit conversions to the returned type. - RetVal = EmitConversion(RetVal, RV->getType(), FnRetTy, SourceLocation()); + RetVal = EmitConversion(RetVal, RV->getType(), FnRetTy); if (RetVal.isScalar()) { // FIXME: Pass return loc in! diff --git a/clang/CodeGen/CodeGenFunction.cpp b/clang/CodeGen/CodeGenFunction.cpp index 3c4a68baeac..b315ab40b4f 100644 --- a/clang/CodeGen/CodeGenFunction.cpp +++ b/clang/CodeGen/CodeGenFunction.cpp @@ -39,13 +39,13 @@ llvm::BasicBlock *CodeGenFunction::getBasicBlockForLabel(const LabelStmt *S) { } -const llvm::Type *CodeGenFunction::ConvertType(QualType T, SourceLocation Loc) { - return CGM.getTypes().ConvertType(T, Loc); +const llvm::Type *CodeGenFunction::ConvertType(QualType T) { + return CGM.getTypes().ConvertType(T); } void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { - LLVMIntTy = ConvertType(getContext().IntTy, FD->getLocation()); - LLVMPointerWidth = Target.getPointerWidth(FD->getLocation()); + LLVMIntTy = ConvertType(getContext().IntTy); + LLVMPointerWidth = Target.getPointerWidth(SourceLocation()); CurFn = cast<llvm::Function>(CGM.GetAddrOfGlobalDecl(FD)); CurFuncDecl = FD; diff --git a/clang/CodeGen/CodeGenFunction.h b/clang/CodeGen/CodeGenFunction.h index 683cdfbd491..ad7deea46a1 100644 --- a/clang/CodeGen/CodeGenFunction.h +++ b/clang/CodeGen/CodeGenFunction.h @@ -27,7 +27,6 @@ namespace clang { class Decl; class FunctionDecl; class TargetInfo; - class SourceLocation; class QualType; class FunctionTypeProto; @@ -152,7 +151,7 @@ public: void GenerateCode(const FunctionDecl *FD); - const llvm::Type *ConvertType(QualType T, SourceLocation Loc); + const llvm::Type *ConvertType(QualType T); /// getBasicBlockForLabel - Return the LLVM basicblock that the specified /// label maps to. @@ -172,8 +171,7 @@ public: /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to /// the type specified by DstTy, following the rules of C99 6.3. - RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy, - SourceLocation Loc); + RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy); /// ConvertScalarValueToBool - Convert the specified expression value to a /// boolean (i1) truth value. This is equivalent to "Val == 0". diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp index 4f7834ed55a..cdc3e63026d 100644 --- a/clang/CodeGen/CodeGenModule.cpp +++ b/clang/CodeGen/CodeGenModule.cpp @@ -33,7 +33,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalDecl(const Decl *D) { if (Entry) return Entry; QualType ASTTy = cast<ValueDecl>(D)->getType(); - const llvm::Type *Ty = getTypes().ConvertType(ASTTy, D->getLocation()); + const llvm::Type *Ty = getTypes().ConvertType(ASTTy); if (isa<FunctionDecl>(D)) { const llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty); // FIXME: param attributes for sext/zext etc. diff --git a/clang/CodeGen/CodeGenTypes.cpp b/clang/CodeGen/CodeGenTypes.cpp index 34c42fbcc6e..63f3600b94c 100644 --- a/clang/CodeGen/CodeGenTypes.cpp +++ b/clang/CodeGen/CodeGenTypes.cpp @@ -21,7 +21,7 @@ using namespace CodeGen; /// ConvertType - Convert the specified type to its LLVM form. -const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { +const llvm::Type *CodeGenTypes::ConvertType(QualType T) { // FIXME: Cache these, move the CodeGenModule, expand, etc. const clang::Type &Ty = *T.getCanonicalType(); @@ -35,7 +35,7 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { case BuiltinType::Char_U: case BuiltinType::SChar: case BuiltinType::UChar: - return llvm::IntegerType::get(Target.getCharWidth(Loc)); + return llvm::IntegerType::get(Target.getCharWidth(SourceLocation())); case BuiltinType::Bool: // FIXME: This is very strange. We want scalars to be i1, but in memory @@ -44,19 +44,19 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { case BuiltinType::Short: case BuiltinType::UShort: - return llvm::IntegerType::get(Target.getShortWidth(Loc)); + return llvm::IntegerType::get(Target.getShortWidth(SourceLocation())); case BuiltinType::Int: case BuiltinType::UInt: - return llvm::IntegerType::get(Target.getIntWidth(Loc)); + return llvm::IntegerType::get(Target.getIntWidth(SourceLocation())); case BuiltinType::Long: case BuiltinType::ULong: - return llvm::IntegerType::get(Target.getLongWidth(Loc)); + return llvm::IntegerType::get(Target.getLongWidth(SourceLocation())); case BuiltinType::LongLong: case BuiltinType::ULongLong: - return llvm::IntegerType::get(Target.getLongLongWidth(Loc)); + return llvm::IntegerType::get(Target.getLongLongWidth(SourceLocation())); case BuiltinType::Float: return llvm::Type::FloatTy; case BuiltinType::Double: return llvm::Type::DoubleTy; @@ -83,11 +83,11 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { } case Type::Pointer: { const PointerType &P = cast<PointerType>(Ty); - return llvm::PointerType::get(ConvertType(P.getPointeeType(), Loc)); + return llvm::PointerType::get(ConvertType(P.getPointeeType())); } case Type::Reference: { const ReferenceType &R = cast<ReferenceType>(Ty); - return llvm::PointerType::get(ConvertType(R.getReferenceeType(), Loc)); + return llvm::PointerType::get(ConvertType(R.getReferenceeType())); } case Type::Array: { @@ -98,7 +98,7 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { llvm::APSInt Size(32); if (A.getSize() && A.getSize()->isIntegerConstantExpr(Size)) { - const llvm::Type *EltTy = ConvertType(A.getElementType(), Loc); + const llvm::Type *EltTy = ConvertType(A.getElementType()); return llvm::ArrayType::get(EltTy, Size.getZExtValue()); } else { assert(0 && "FIXME: VLAs not implemented yet!"); @@ -112,13 +112,13 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { if (FP.getResultType()->isVoidType()) ResultType = llvm::Type::VoidTy; // Result of function uses llvm void. else - ResultType = ConvertType(FP.getResultType(), Loc); + ResultType = ConvertType(FP.getResultType()); // FIXME: Convert argument types. bool isVarArg; std::vector<const llvm::Type*> ArgTys; if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(&FP)) { - DecodeArgumentTypes(*FTP, ArgTys, Loc); + DecodeArgumentTypes(*FTP, ArgTys); isVarArg = FTP->isVariadic(); } else { isVarArg = true; @@ -136,10 +136,9 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T, SourceLocation Loc) { } void CodeGenTypes::DecodeArgumentTypes(const FunctionTypeProto &FTP, - std::vector<const llvm::Type*> & - ArgTys, SourceLocation Loc) { + std::vector<const llvm::Type*> &ArgTys) { for (unsigned i = 0, e = FTP.getNumArgs(); i != e; ++i) { - const llvm::Type *Ty = ConvertType(FTP.getArgType(i), Loc); + const llvm::Type *Ty = ConvertType(FTP.getArgType(i)); if (Ty->isFirstClassType()) ArgTys.push_back(Ty); else diff --git a/clang/CodeGen/CodeGenTypes.h b/clang/CodeGen/CodeGenTypes.h index 0a6551faa71..dd322a19ec8 100644 --- a/clang/CodeGen/CodeGenTypes.h +++ b/clang/CodeGen/CodeGenTypes.h @@ -23,7 +23,6 @@ namespace llvm { namespace clang { class TargetInfo; class QualType; - class SourceLocation; class FunctionTypeProto; namespace CodeGen { @@ -38,10 +37,9 @@ public: TargetInfo &getTarget() const { return Target; } - const llvm::Type *ConvertType(QualType T, SourceLocation Loc); + const llvm::Type *ConvertType(QualType T); void DecodeArgumentTypes(const FunctionTypeProto &FTP, - std::vector<const llvm::Type*> &ArgTys, - SourceLocation Loc); + std::vector<const llvm::Type*> &ArgTys); }; } // end namespace CodeGen } // end namespace clang |