summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-17 20:33:28 +0000
committerChris Lattner <sabre@nondot.org>2009-10-17 20:33:28 +0000
commitec3a1565f69d8ae3fd2772e9b0f83237d98e5ebf (patch)
tree5eb2dbc3c9e19f1499ea8e0fd4969c7034841afd /clang/lib
parent867f67301b7c35135d04e437eb186f5a4e6b9826 (diff)
downloadbcm5719-llvm-ec3a1565f69d8ae3fd2772e9b0f83237d98e5ebf.tar.gz
bcm5719-llvm-ec3a1565f69d8ae3fd2772e9b0f83237d98e5ebf.zip
teach getCorrespondingUnsignedType how to handle vectors of integers,
fixing PR4838. llvm-svn: 84353
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp16
-rw-r--r--clang/lib/Sema/SemaExpr.cpp12
2 files changed, 18 insertions, 10 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 507baeab27a..1b77bbe1dbd 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3930,7 +3930,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
unsigned ASTContext::getIntWidth(QualType T) {
if (T == BoolTy)
return 1;
- if (FixedWidthIntType* FWIT = dyn_cast<FixedWidthIntType>(T)) {
+ if (FixedWidthIntType *FWIT = dyn_cast<FixedWidthIntType>(T)) {
return FWIT->getWidth();
}
// For builtin types, just use the standard type sizing method
@@ -3939,10 +3939,18 @@ unsigned ASTContext::getIntWidth(QualType T) {
QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
assert(T->isSignedIntegerType() && "Unexpected type");
- if (const EnumType* ETy = T->getAs<EnumType>())
+
+ // Turn <4 x signed int> -> <4 x unsigned int>
+ if (const VectorType *VTy = T->getAs<VectorType>())
+ return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
+ VTy->getNumElements());
+
+ // For enums, we return the unsigned version of the base type.
+ if (const EnumType *ETy = T->getAs<EnumType>())
T = ETy->getDecl()->getIntegerType();
- const BuiltinType* BTy = T->getAs<BuiltinType>();
- assert (BTy && "Unexpected signed integer type");
+
+ const BuiltinType *BTy = T->getAs<BuiltinType>();
+ assert(BTy && "Unexpected signed integer type");
switch (BTy->getKind()) {
case BuiltinType::Char_S:
case BuiltinType::SChar:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 67058860d6d..b69e1fbcd6c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3753,16 +3753,16 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) {
// Check if the pointee types are compatible ignoring the sign.
// We explicitly check for char so that we catch "char" vs
// "unsigned char" on systems where "char" is unsigned.
- if (lhptee->isCharType()) {
+ if (lhptee->isCharType())
lhptee = Context.UnsignedCharTy;
- } else if (lhptee->isSignedIntegerType()) {
+ else if (lhptee->isSignedIntegerType())
lhptee = Context.getCorrespondingUnsignedType(lhptee);
- }
- if (rhptee->isCharType()) {
+
+ if (rhptee->isCharType())
rhptee = Context.UnsignedCharTy;
- } else if (rhptee->isSignedIntegerType()) {
+ else if (rhptee->isSignedIntegerType())
rhptee = Context.getCorrespondingUnsignedType(rhptee);
- }
+
if (lhptee == rhptee) {
// Types are compatible ignoring the sign. Qualifier incompatibility
// takes priority over sign incompatibility because the sign
OpenPOWER on IntegriCloud