diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index b5b28bc390..5dd7d9aeeb 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -260,9 +260,15 @@ ASTContext::getTypeInfo(QualType T) { // alignment requirements: getPointerInfo should take an AddrSpace. return getTypeInfo(QualType(cast(T)->getBaseType(), 0)); case Type::ObjCQualifiedId: - case Type::Pointer: - Target.getPointerInfo(Size, Align); + Size = Target.getPointerWidth(0); + Align = Target.getPointerAlign(0); break; + case Type::Pointer: { + unsigned AS = cast(T)->getPointeeType().getAddressSpace(); + Size = Target.getPointerWidth(AS); + Align = Target.getPointerAlign(AS); + 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. diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index 554fc3fbeb..d2b6047525 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -339,9 +339,7 @@ llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys, llvm::Function *CodeGenModule::getMemCpyFn() { if (MemCpyFn) return MemCpyFn; llvm::Intrinsic::ID IID; - uint64_t Size; unsigned Align; - Context.Target.getPointerInfo(Size, Align); - switch (Size) { + switch (Context.Target.getPointerWidth(0)) { default: assert(0 && "Unknown ptr width"); case 32: IID = llvm::Intrinsic::memcpy_i32; break; case 64: IID = llvm::Intrinsic::memcpy_i64; break; @@ -352,9 +350,7 @@ llvm::Function *CodeGenModule::getMemCpyFn() { llvm::Function *CodeGenModule::getMemSetFn() { if (MemSetFn) return MemSetFn; llvm::Intrinsic::ID IID; - uint64_t Size; unsigned Align; - Context.Target.getPointerInfo(Size, Align); - switch (Size) { + switch (Context.Target.getPointerWidth(0)) { default: assert(0 && "Unknown ptr width"); case 32: IID = llvm::Intrinsic::memset_i32; break; case 64: IID = llvm::Intrinsic::memset_i64; break; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index ec6030135a..4fb50bca91 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -64,12 +64,10 @@ public: return true; } - /// getPointerWidth - Return the width of pointers on this target, we - /// currently assume one pointer type. - void getPointerInfo(uint64_t &Size, unsigned &Align) const { - Size = 32; // FIXME: implement correctly. - Align = 32; - } + /// getPointerWidth - Return the width of pointers on this target, for the + /// specified address space. FIXME: implement correctly. + uint64_t getPointerWidth(unsigned AddrSpace) const { return 32; } + uint64_t getPointerAlign(unsigned AddrSpace) const { return 32; } /// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target, /// in bits. @@ -119,13 +117,9 @@ public: void getLongDoubleInfo(uint64_t &Size, unsigned &Align, const llvm::fltSemantics *&Format) const; - /// getWCharInfo - Return the size of wchar_t in bits. - /// - void getWCharInfo(uint64_t &Size, unsigned &Align) const { - Size = WCharWidth; - Align = WCharAlign; - } - + unsigned getWCharWidth() const { return WCharWidth; } + unsigned getWCharAlign() const { return WCharAlign; } + /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this /// target, in bits. unsigned getIntMaxTWidth() const { @@ -182,20 +176,14 @@ public: } unsigned getCharWidth(bool isWide = false) const { - uint64_t Size; unsigned Align; if (isWide) - getWCharInfo(Size, Align); - else - getCharInfo(Size, Align); - return static_cast(Size); - } - - unsigned getWCharWidth() const { + return WCharWidth; uint64_t Size; unsigned Align; - getWCharInfo(Size, Align); + getCharInfo(Size, Align); return static_cast(Size); } + unsigned getIntWidth() const { uint64_t Size; unsigned Align; getIntInfo(Size, Align);