diff options
-rw-r--r-- | AST/ASTContext.cpp | 65 | ||||
-rw-r--r-- | AST/Expr.cpp | 55 | ||||
-rw-r--r-- | Analysis/GRExprEngine.cpp | 14 | ||||
-rw-r--r-- | Analysis/GRSimpleVals.cpp | 4 | ||||
-rw-r--r-- | Analysis/RValues.cpp | 7 | ||||
-rw-r--r-- | Analysis/ValueManager.cpp | 5 | ||||
-rw-r--r-- | Analysis/ValueState.cpp | 7 | ||||
-rw-r--r-- | Basic/TargetInfo.cpp | 11 | ||||
-rw-r--r-- | Basic/Targets.cpp | 47 | ||||
-rw-r--r-- | CodeGen/CGExprAgg.cpp | 6 | ||||
-rw-r--r-- | CodeGen/CGExprConstant.cpp | 16 | ||||
-rw-r--r-- | CodeGen/CGExprScalar.cpp | 13 | ||||
-rw-r--r-- | CodeGen/CodeGenFunction.cpp | 3 | ||||
-rw-r--r-- | CodeGen/CodeGenModule.cpp | 6 | ||||
-rw-r--r-- | CodeGen/CodeGenTypes.cpp | 11 | ||||
-rw-r--r-- | Driver/RewriteTest.cpp | 5 | ||||
-rw-r--r-- | Lex/LiteralSupport.cpp | 20 | ||||
-rw-r--r-- | Lex/PPExpressions.cpp | 17 | ||||
-rw-r--r-- | Sema/SemaDecl.cpp | 28 | ||||
-rw-r--r-- | Sema/SemaExpr.cpp | 38 | ||||
-rw-r--r-- | Sema/SemaStmt.cpp | 3 | ||||
-rw-r--r-- | include/clang/AST/ASTContext.h | 12 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/RValues.h | 3 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ValueManager.h | 9 | ||||
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 60 |
26 files changed, 168 insertions, 299 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index 2487abaecd..b5b28bc390 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -133,7 +133,7 @@ void ASTContext::InitBuiltinTypes() { // C99 6.2.5p2. InitBuiltinType(BoolTy, BuiltinType::Bool); // C99 6.2.5p3. - if (Target.isCharSigned(FullSourceLoc())) + if (Target.isCharSigned()) InitBuiltinType(CharTy, BuiltinType::Char_S); else InitBuiltinType(CharTy, BuiltinType::Char_U); @@ -180,7 +180,7 @@ void ASTContext::InitBuiltinTypes() { /// getTypeSize - Return the size of the specified type, in bits. This method /// does not work on incomplete types. std::pair<uint64_t, unsigned> -ASTContext::getTypeInfo(QualType T, SourceLocation L) { +ASTContext::getTypeInfo(QualType T) { T = T.getCanonicalType(); uint64_t Size; unsigned Align; @@ -195,8 +195,7 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { case Type::ConstantArray: { ConstantArrayType *CAT = cast<ConstantArrayType>(T); - std::pair<uint64_t, unsigned> EltInfo = - getTypeInfo(CAT->getElementType(), L); + std::pair<uint64_t, unsigned> EltInfo = getTypeInfo(CAT->getElementType()); Size = EltInfo.first*CAT->getSize().getZExtValue(); Align = EltInfo.second; break; @@ -204,7 +203,7 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { case Type::OCUVector: case Type::Vector: { std::pair<uint64_t, unsigned> EltInfo = - getTypeInfo(cast<VectorType>(T)->getElementType(), L); + getTypeInfo(cast<VectorType>(T)->getElementType()); Size = EltInfo.first*cast<VectorType>(T)->getNumElements(); // FIXME: Vector alignment is not the alignment of its elements. Align = EltInfo.second; @@ -220,62 +219,62 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { case BuiltinType::Void: assert(0 && "Incomplete types have no size!"); case BuiltinType::Bool: - Target.getBoolInfo(Size, Align, getFullLoc(L)); + Target.getBoolInfo(Size, Align); break; case BuiltinType::Char_S: case BuiltinType::Char_U: case BuiltinType::UChar: case BuiltinType::SChar: - Target.getCharInfo(Size, Align, getFullLoc(L)); + Target.getCharInfo(Size, Align); break; case BuiltinType::UShort: case BuiltinType::Short: - Target.getShortInfo(Size, Align, getFullLoc(L)); + Target.getShortInfo(Size, Align); break; case BuiltinType::UInt: case BuiltinType::Int: - Target.getIntInfo(Size, Align, getFullLoc(L)); + Target.getIntInfo(Size, Align); break; case BuiltinType::ULong: case BuiltinType::Long: - Target.getLongInfo(Size, Align, getFullLoc(L)); + Target.getLongInfo(Size, Align); break; case BuiltinType::ULongLong: case BuiltinType::LongLong: - Target.getLongLongInfo(Size, Align, getFullLoc(L)); + Target.getLongLongInfo(Size, Align); break; case BuiltinType::Float: - Target.getFloatInfo(Size, Align, F, getFullLoc(L)); + Target.getFloatInfo(Size, Align, F); break; case BuiltinType::Double: - Target.getDoubleInfo(Size, Align, F, getFullLoc(L)); + Target.getDoubleInfo(Size, Align, F); break; case BuiltinType::LongDouble: - Target.getLongDoubleInfo(Size, Align, F, getFullLoc(L)); + Target.getLongDoubleInfo(Size, Align, F); break; } break; } case Type::ASQual: - return getTypeInfo(QualType(cast<ASQualType>(T)->getBaseType(), 0), L); + // FIXME: Pointers into different addr spaces could have different sizes and + // alignment requirements: getPointerInfo should take an AddrSpace. + return getTypeInfo(QualType(cast<ASQualType>(T)->getBaseType(), 0)); case Type::ObjCQualifiedId: - Target.getPointerInfo(Size, Align, getFullLoc(L)); - break; case Type::Pointer: - Target.getPointerInfo(Size, Align, getFullLoc(L)); + Target.getPointerInfo(Size, Align); break; case Type::Reference: // "When applied to a reference or a reference type, the result is the size // of the referenced type." C++98 5.3.3p2: expr.sizeof. // FIXME: This is wrong for struct layout: a reference in a struct has // pointer size. - return getTypeInfo(cast<ReferenceType>(T)->getReferenceeType(), L); + return getTypeInfo(cast<ReferenceType>(T)->getReferenceeType()); case Type::Complex: { // Complex types have the same alignment as their elements, but twice the // size. std::pair<uint64_t, unsigned> EltInfo = - getTypeInfo(cast<ComplexType>(T)->getElementType(), L); + getTypeInfo(cast<ComplexType>(T)->getElementType()); Size = EltInfo.first*2; Align = EltInfo.second; break; @@ -283,11 +282,11 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { case Type::Tagged: TagType *TT = cast<TagType>(T); if (RecordType *RT = dyn_cast<RecordType>(TT)) { - const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl(), L); + const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl()); Size = Layout.getSize(); Align = Layout.getAlignment(); } else if (EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl())) { - return getTypeInfo(ED->getIntegerType(), L); + return getTypeInfo(ED->getIntegerType()); } else { assert(0 && "Unimplemented type sizes!"); } @@ -301,8 +300,7 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { /// getASTRecordLayout - Get or compute information about the layout of the /// specified record (struct/union/class), which indicates its size and field /// position information. -const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D, - SourceLocation L) { +const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) { assert(D->isDefinition() && "Cannot get layout of forward declarations!"); // Look up this layout, if already laid out, return what we have. @@ -339,7 +337,7 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D, assert (BitWidthIsICE && "Invalid BitField size expression"); FieldSize = I.getZExtValue(); - std::pair<uint64_t, unsigned> TypeInfo = getTypeInfo(FD->getType(), L); + std::pair<uint64_t, unsigned> TypeInfo = getTypeInfo(FD->getType()); uint64_t TypeSize = TypeInfo.first; if (const AlignedAttr *AA = FD->getAttr<AlignedAttr>()) @@ -372,11 +370,11 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D, FieldAlign = 8; else { const ArrayType* ATy = FD->getType()->getAsArrayType(); - FieldAlign = getTypeAlign(ATy->getElementType(), L); + FieldAlign = getTypeAlign(ATy->getElementType()); } FieldSize = 0; } else { - std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType(), L); + std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType()); FieldSize = FieldInfo.first; if (const AlignedAttr *AA = FD->getAttr<AlignedAttr>()) @@ -408,7 +406,7 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D, // Union layout just puts each member at the start of the record. for (unsigned i = 0, e = D->getNumMembers(); i != e; ++i) { const FieldDecl *FD = D->getMember(i); - std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType(), L); + std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType()); uint64_t FieldSize = FieldInfo.first; unsigned FieldAlign = FieldInfo.second; @@ -1073,16 +1071,15 @@ static bool isTypeTypedefedAsBOOL(QualType T) { /// getObjCEncodingTypeSize returns size of type for objective-c encoding /// purpose. int ASTContext::getObjCEncodingTypeSize(QualType type) { - SourceLocation Loc; - uint64_t sz = getTypeSize(type, Loc); + uint64_t sz = getTypeSize(type); // Make all integer and enum types at least as large as an int if (sz > 0 && type->isIntegralType()) - sz = std::max(sz, getTypeSize(IntTy, Loc)); + sz = std::max(sz, getTypeSize(IntTy)); // Treat arrays as pointers, since that's how they're passed in. else if (type->isArrayType()) - sz = getTypeSize(VoidPtrTy, Loc); - return sz / getTypeSize(CharTy, Loc); + sz = getTypeSize(VoidPtrTy); + return sz / getTypeSize(CharTy); } /// getObjCEncodingForMethodDecl - Return the encoded type for this method @@ -1098,7 +1095,7 @@ void ASTContext::getObjCEncodingForMethodDecl(ObjCMethodDecl *Decl, // Start with computing size of a pointer in number of bytes. // FIXME: There might(should) be a better way of doing this computation! SourceLocation Loc; - int PtrSize = getTypeSize(VoidPtrTy, Loc) / getTypeSize(CharTy, Loc); + int PtrSize = getTypeSize(VoidPtrTy) / getTypeSize(CharTy); // The first two arguments (self and _cmd) are pointers; account for // their size. int ParmOffset = 2 * PtrSize; diff --git a/AST/Expr.cpp b/AST/Expr.cpp index 1c32d7cd77..11fcc419a5 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -510,8 +510,7 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { case CallExprClass: { const CallExpr *CE = cast<CallExpr>(this); llvm::APSInt Result(32); - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), CE->getLocStart()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); if (CE->isBuiltinClassifyType(Result)) return true; if (CE->isBuiltinConstantExpr()) @@ -673,23 +672,20 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, break; case CharacterLiteralClass: { const CharacterLiteral *CL = cast<CharacterLiteral>(this); - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), CL->getLoc()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); Result = CL->getValue(); Result.setIsUnsigned(!getType()->isSignedIntegerType()); break; } case TypesCompatibleExprClass: { const TypesCompatibleExpr *TCE = cast<TypesCompatibleExpr>(this); - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), TCE->getLocStart()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2()); break; } case CallExprClass: { const CallExpr *CE = cast<CallExpr>(this); - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), CE->getLocStart()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); if (CE->isBuiltinClassifyType(Result)) break; if (Loc) *Loc = getLocStart(); @@ -723,9 +719,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, case UnaryOperator::SizeOf: case UnaryOperator::AlignOf: // Return the result in the right width. - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), - Exp->getOperatorLoc()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); // sizeof(void) and __alignof__(void) = 1 as a gcc extension. if (Exp->getSubExpr()->getType()->isVoidType()) { @@ -744,22 +738,16 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, // GCC extension: sizeof(function) = 1. Result = Exp->getOpcode() == UnaryOperator::AlignOf ? 4 : 1; } else { - unsigned CharSize = - Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc())); - + unsigned CharSize = Ctx.Target.getCharWidth(); if (Exp->getOpcode() == UnaryOperator::AlignOf) - Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(), - Exp->getOperatorLoc()) / CharSize; + Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType()) / CharSize; else - Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(), - Exp->getOperatorLoc()) / CharSize; + Result = Ctx.getTypeSize(Exp->getSubExpr()->getType()) / CharSize; } break; case UnaryOperator::LNot: { bool Val = Result == 0; - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), - Exp->getOperatorLoc()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); Result = Val; break; } @@ -780,8 +768,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, const SizeOfAlignOfTypeExpr *Exp = cast<SizeOfAlignOfTypeExpr>(this); // Return the result in the right width. - Result.zextOrTrunc( - static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc()))); + Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType()))); // sizeof(void) and __alignof__(void) = 1 as a gcc extension. if (Exp->getArgumentType()->isVoidType()) { @@ -800,17 +787,12 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, // GCC extension: sizeof(function) = 1. Result = Exp->isSizeOf() ? 1 : 4; } else { - unsigned CharSize = - Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc())); - + unsigned CharSize = Ctx.Target.getCharWidth(); if (Exp->isSizeOf()) - Result = Ctx.getTypeSize(Exp->getArgumentType(), - Exp->getOperatorLoc()) / CharSize; + Result = Ctx.getTypeSize(Exp->getArgumentType()) / CharSize; else - Result = Ctx.getTypeAlign(Exp->getArgumentType(), - Exp->getOperatorLoc()) / CharSize; + Result = Ctx.getTypeAlign(Exp->getArgumentType()) / CharSize; } - break; } case BinaryOperatorClass: { @@ -927,8 +909,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, return false; } - uint32_t DestWidth = - static_cast<uint32_t>(Ctx.getTypeSize(getType(), CastLoc)); + uint32_t DestWidth = static_cast<uint32_t>(Ctx.getTypeSize(getType())); // Handle simple integer->integer casts. if (SubExpr->getType()->isIntegerType()) { @@ -1140,7 +1121,7 @@ static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E) QualType Ty = ME->getBase()->getType(); RecordDecl *RD = Ty->getAsRecordType()->getDecl(); - const ASTRecordLayout &RL = C.getASTRecordLayout(RD, SourceLocation()); + const ASTRecordLayout &RL = C.getASTRecordLayout(RD); FieldDecl *FD = ME->getMemberDecl(); // FIXME: This is linear time. @@ -1157,7 +1138,7 @@ static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E) bool ICE = ASE->getIdx()->isIntegerConstantExpr(Idx, C); assert(ICE && "Array index is not a constant integer!"); - int64_t size = C.getTypeSize(ASE->getType(), SourceLocation()); + int64_t size = C.getTypeSize(ASE->getType()); size *= Idx.getSExtValue(); return size + evaluateOffsetOf(C, Base); @@ -1172,9 +1153,7 @@ int64_t UnaryOperator::evaluateOffsetOf(ASTContext& C) const { assert(Opc == OffsetOf && "Unary operator not offsetof!"); - unsigned CharSize = - C.Target.getCharWidth(C.getFullLoc(getOperatorLoc())); - + unsigned CharSize = C.Target.getCharWidth(); return ::evaluateOffsetOf(C, Val) / CharSize; } diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 2481f56838..4cd942b57e 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -277,8 +277,7 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) { // While most of this can be assumed (such as the signedness), having it // just computed makes sure everything makes the same assumptions end-to-end. - unsigned bits = getContext().getTypeSize(CondE->getType(), - CondE->getExprLoc()); + unsigned bits = getContext().getTypeSize(CondE->getType()); APSInt V1(bits, false); APSInt V2 = V1; @@ -716,10 +715,8 @@ void GRExprEngine::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr* Ex, uint64_t size = 1; // Handle sizeof(void) - if (T != getContext().VoidTy) { - SourceLocation Loc = Ex->getExprLoc(); - size = getContext().getTypeSize(T, Loc) / 8; - } + if (T != getContext().VoidTy) + size = getContext().getTypeSize(T) / 8; Nodify(Dst, Ex, Pred, SetRVal(Pred->getState(), Ex, @@ -949,10 +946,9 @@ void GRExprEngine::VisitSizeOfExpr(UnaryOperator* U, NodeTy* Pred, if (!T.getTypePtr()->isConstantSizeType()) return; - SourceLocation Loc = U->getExprLoc(); - uint64_t size = getContext().getTypeSize(T, Loc) / 8; + uint64_t size = getContext().getTypeSize(T) / 8; ValueState* St = Pred->getState(); - St = SetRVal(St, U, NonLVal::MakeVal(ValMgr, size, U->getType(), Loc)); + St = SetRVal(St, U, NonLVal::MakeVal(ValMgr, size, U->getType())); Nodify(Dst, U, Pred, St); } diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp index d8a3112b1a..c00800c141 100644 --- a/Analysis/GRSimpleVals.cpp +++ b/Analysis/GRSimpleVals.cpp @@ -160,7 +160,7 @@ RVal GRSimpleVals::EvalCast(ValueManager& ValMgr, NonLVal X, QualType T) { llvm::APSInt V = cast<nonlval::ConcreteInt>(X).getValue(); V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType()); - V.extOrTrunc(ValMgr.getContext().getTypeSize(T, SourceLocation())); + V.extOrTrunc(ValMgr.getContext().getTypeSize(T)); if (T->isPointerType()) return lval::ConcreteInt(ValMgr.getValue(V)); @@ -182,7 +182,7 @@ RVal GRSimpleVals::EvalCast(ValueManager& ValMgr, LVal X, QualType T) { llvm::APSInt V = cast<lval::ConcreteInt>(X).getValue(); V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType()); - V.extOrTrunc(ValMgr.getContext().getTypeSize(T, SourceLocation())); + V.extOrTrunc(ValMgr.getContext().getTypeSize(T)); return nonlval::ConcreteInt(ValMgr.getValue(V)); } diff --git a/Analysis/RValues.cpp b/Analysis/RValues.cpp index 6369da4d7f..36ea2df0e8 100644 --- a/Analysis/RValues.cpp +++ b/Analysis/RValues.cpp @@ -207,10 +207,8 @@ NonLVal LVal::NE(ValueManager& ValMgr, const LVal& R) const { // Utility methods for constructing Non-LVals. //===----------------------------------------------------------------------===// -NonLVal NonLVal::MakeVal(ValueManager& ValMgr, uint64_t X, QualType T, - SourceLocation Loc) { - - return nonlval::ConcreteInt(ValMgr.getValue(X, T, Loc)); +NonLVal NonLVal::MakeVal(ValueManager& ValMgr, uint64_t X, QualType T) { + return nonlval::ConcreteInt(ValMgr.getValue(X, T)); } NonLVal NonLVal::MakeVal(ValueManager& ValMgr, IntegerLiteral* I) { @@ -220,7 +218,6 @@ NonLVal NonLVal::MakeVal(ValueManager& ValMgr, IntegerLiteral* I) { } NonLVal NonLVal::MakeIntTruthVal(ValueManager& ValMgr, bool b) { - return nonlval::ConcreteInt(ValMgr.getTruthValue(b)); } diff --git a/Analysis/ValueManager.cpp b/Analysis/ValueManager.cpp index 2a8d23d02c..a02f3e45ef 100644 --- a/Analysis/ValueManager.cpp +++ b/Analysis/ValueManager.cpp @@ -48,10 +48,9 @@ const llvm::APSInt& ValueManager::getValue(uint64_t X, unsigned BitWidth, return getValue(V); } -const llvm::APSInt& ValueManager::getValue(uint64_t X, QualType T, - SourceLocation Loc) { +const llvm::APSInt& ValueManager::getValue(uint64_t X, QualType T) { - unsigned bits = Ctx.getTypeSize(T, Loc); + unsigned bits = Ctx.getTypeSize(T); llvm::APSInt V(bits, T->isUnsignedIntegerType()); V = X; return getValue(V); diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp index 388dba67da..f47e14bb70 100644 --- a/Analysis/ValueState.cpp +++ b/Analysis/ValueState.cpp @@ -258,8 +258,7 @@ RVal ValueStateManager::GetRVal(ValueState* St, Expr* E) { case Stmt::CharacterLiteralClass: { CharacterLiteral* C = cast<CharacterLiteral>(E); - return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(), - C->getLoc()); + return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType()); } case Stmt::IntegerLiteralClass: { @@ -271,7 +270,6 @@ RVal ValueStateManager::GetRVal(ValueState* St, Expr* E) { // subexpression that has a value. case Stmt::ImplicitCastExprClass: { - ImplicitCastExpr* C = cast<ImplicitCastExpr>(E); QualType CT = C->getType(); @@ -341,8 +339,7 @@ RVal ValueStateManager::GetBlkExprRVal(ValueState* St, Expr* E) { switch (E->getStmtClass()) { case Stmt::CharacterLiteralClass: { CharacterLiteral* C = cast<CharacterLiteral>(E); - return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(), - C->getLoc()); + return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType()); } case Stmt::IntegerLiteralClass: { diff --git a/Basic/TargetInfo.cpp b/Basic/TargetInfo.cpp index 8701b38a0f..1f0becee34 100644 --- a/Basic/TargetInfo.cpp +++ b/Basic/TargetInfo.cpp @@ -28,22 +28,19 @@ void TargetInfoImpl::ANCHOR() {} // out-of-line virtual method for class. // TargetInfoImpl. void TargetInfo::getFloatInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, - FullSourceLoc Loc) { + const llvm::fltSemantics *&Format) { Align = 32; // FIXME: implement correctly. Size = 32; Format = &llvm::APFloat::IEEEsingle; } void TargetInfo::getDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, - FullSourceLoc Loc) { + const llvm::fltSemantics *&Format) { Size = 64; // FIXME: implement correctly. Align = 32; Format = &llvm::APFloat::IEEEdouble; } void TargetInfo::getLongDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, - FullSourceLoc Loc) { + const llvm::fltSemantics *&Format) { Size = Align = 64; // FIXME: implement correctly. Format = &llvm::APFloat::IEEEdouble; //Size = 80; Align = 32; // FIXME: implement correctly. @@ -74,7 +71,7 @@ void TargetInfo::getTargetDefines(std::vector<char> &Buffer) { /// ComputeWCharWidth - Determine the width of the wchar_t type for the primary /// target, diagnosing whether this is non-portable across the secondary /// targets. -void TargetInfo::ComputeWCharInfo(FullSourceLoc Loc) { +void TargetInfo::ComputeWCharInfo() { Target->getWCharInfo(WCharWidth, WCharAlign); } diff --git a/Basic/Targets.cpp b/Basic/Targets.cpp index d170fbefb6..89125b42eb 100644 --- a/Basic/Targets.cpp +++ b/Basic/Targets.cpp @@ -722,50 +722,6 @@ public: } // end anonymous namespace. -namespace { -class LinuxTargetInfo : public DarwinTargetInfo { -public: - LinuxTargetInfo(const std::string& triple) : DarwinTargetInfo(triple) { - // Note: I have no idea if this is right, just for testing. - WCharWidth = 16; - WCharAlign = 16; - } - - virtual void getTargetDefines(std::vector<char> &Defines) const { - // TODO: linux-specific stuff. - getX86Defines(Defines, false); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - X86::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getI386VAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return X86::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - X86::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - X86::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return X86::validateAsmConstraint(c, info); - } - virtual std::string convertConstraint(const char Constraint) const { - return X86::convertConstraint(Constraint); - } - virtual const char *getClobbers() const { - return X86::getClobbers(); - } -}; -} // end anonymous namespace. - //===----------------------------------------------------------------------===// // Driver code @@ -794,9 +750,6 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { if (IsX86(T)) return new TargetInfo(new DarwinI386TargetInfo(T)); - if (T.find("bogusW16W16-") == 0) // For testing portability. - return new TargetInfo(new LinuxTargetInfo(T)); - return NULL; } diff --git a/CodeGen/CGExprAgg.cpp b/CodeGen/CGExprAgg.cpp index 493d279008..325ac2109e 100644 --- a/CodeGen/CGExprAgg.cpp +++ b/CodeGen/CGExprAgg.cpp @@ -103,8 +103,7 @@ void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) { DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); // Get size and alignment info for this aggregate. - std::pair<uint64_t, unsigned> TypeInfo = - CGF.getContext().getTypeInfo(Ty, SourceLocation()); + std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty); // FIXME: Handle variable sized types. const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth); @@ -132,8 +131,7 @@ void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr, SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp"); // Get size and alignment info for this aggregate. - std::pair<uint64_t, unsigned> TypeInfo = - CGF.getContext().getTypeInfo(Ty, SourceLocation()); + std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty); // FIXME: Handle variable sized types. const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth); diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp index 30180c1774..e2405b88f3 100644 --- a/CodeGen/CGExprConstant.cpp +++ b/CodeGen/CGExprConstant.cpp @@ -37,7 +37,8 @@ public: llvm::Constant *VisitStmt(Stmt *S) { CGM.WarnUnsupported(S, "constant expression"); - return llvm::UndefValue::get(CGM.getTypes().ConvertType(cast<Expr>(S)->getType())); + QualType T = cast<Expr>(S)->getType(); + return llvm::UndefValue::get(CGM.getTypes().ConvertType(T)); } llvm::Constant *VisitParenExpr(ParenExpr *PE) { @@ -314,8 +315,8 @@ public: assert(E->getType()->isIntegerType() && "Result type must be an integer!"); - uint32_t ResultWidth = static_cast<uint32_t>( - CGM.getContext().getTypeSize(E->getType(), SourceLocation())); + uint32_t ResultWidth = + static_cast<uint32_t>(CGM.getContext().getTypeSize(E->getType())); return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val)); } @@ -504,15 +505,15 @@ public: llvm::Constant *EmitSizeAlignOf(QualType TypeToSize, QualType RetType, bool isSizeOf) { std::pair<uint64_t, unsigned> Info = - CGM.getContext().getTypeInfo(TypeToSize, SourceLocation()); + CGM.getContext().getTypeInfo(TypeToSize); uint64_t Val = isSizeOf ? Info.first : Info.second; Val /= 8; // Return size in bytes, not bits. assert(RetType->isIntegerType() && "Result type must be an integer!"); - uint32_t ResultWidth = static_cast<uint32_t>( - CGM.getContext().getTypeSize(RetType, SourceLocation())); + uint32_t ResultWidth = + static_cast<uint32_t>(CGM.getContext().getTypeSize(RetType)); return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val)); } @@ -616,8 +617,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, QualType type = E->getType().getCanonicalType(); if (type->isIntegerType()) { - llvm::APSInt - Value(static_cast<uint32_t>(Context.getTypeSize(type, SourceLocation()))); + llvm::APSInt Value(static_cast<uint32_t>(Context.getTypeSize(type))); if (E->isIntegerConstantExpr(Value, Context)) { return llvm::ConstantInt::get(Value); } diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp index 52b022b661..892712a0d4 100644 --- a/CodeGen/CGExprScalar.cpp +++ b/CodeGen/CGExprScalar.cpp @@ -656,16 +656,14 @@ Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize, QualType RetType,bool isSizeOf){ assert(RetType->isIntegerType() && "Result type must be an integer!"); uint32_t ResultWidth = - static_cast<uint32_t>(CGF.getContext().getTypeSize(RetType, - SourceLocation())); + static_cast<uint32_t>(CGF.getContext().getTypeSize(RetType)); // sizeof(void) and __alignof__(void) = 1 as a gcc extension. if (TypeToSize->isVoidType()) return llvm::ConstantInt::get(llvm::APInt(ResultWidth, 1)); /// FIXME: This doesn't handle VLAs yet! - std::pair<uint64_t, unsigned> Info = - CGF.getContext().getTypeInfo(TypeToSize, SourceLocation()); + std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize); uint64_t Val = isSizeOf ? Info.first : Info.second; Val /= 8; // Return size in bytes, not bits. @@ -696,8 +694,8 @@ Value *ScalarExprEmitter::VisitUnaryOffsetOf(const UnaryOperator *E) assert(E->getType()->isIntegerType() && "Result type must be an integer!"); - uint32_t ResultWidth = static_cast<uint32_t>( - CGF.getContext().getTypeSize(E->getType(), SourceLocation())); + uint32_t ResultWidth = + static_cast<uint32_t>(CGF.getContext().getTypeSize(E->getType())); return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val)); } @@ -852,8 +850,7 @@ Value *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) { const QualType LHSType = E->getLHS()->getType().getCanonicalType(); const QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType(); - uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType, - SourceLocation()) / 8; + uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType) / 8; const llvm::Type *ResultType = ConvertType(E->getType()); LHS = Builder.CreatePtrToInt(LHS, ResultType, "sub.ptr.lhs.cast"); diff --git a/CodeGen/CodeGenFunction.cpp b/CodeGen/CodeGenFunction.cpp index adbb414cc0..f48d093b25 100644 --- a/CodeGen/CodeGenFunction.cpp |