[cfe-commits] r58187 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/AST/Builtins.cpp lib/AST/TypeSerialization.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Sun Oct 26 09:43:14 PDT 2008
Author: akirtzidis
Date: Sun Oct 26 11:43:14 2008
New Revision: 58187
URL: http://llvm.org/viewvc/llvm-project?rev=58187&view=rev
Log:
Don't give a default argument to ASTContext::getFunctionType for the TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call.
-Remove the default argument.
-Update all call sites of ASTContext::getFunctionType.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Builtins.cpp
cfe/trunk/lib/AST/TypeSerialization.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Sun Oct 26 11:43:14 2008
@@ -1750,7 +1750,7 @@
Context->CharTy.getQualifiedType(QualType::Const)));
QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(),
&ArgTys[0], ArgTys.size(),
- false /*isVariadic*/);
+ false /*isVariadic*/, 0);
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SelGetUidIdent, getFuncType,
@@ -1765,7 +1765,7 @@
Context->CharTy.getQualifiedType(QualType::Const)));
QualType getFuncType = Context->getFunctionType(Context->getObjCProtoType(),
&ArgTys[0], ArgTys.size(),
- false /*isVariadic*/);
+ false /*isVariadic*/, 0);
GetProtocolFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SelGetProtoIdent, getFuncType,
@@ -1793,7 +1793,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- false);
+ false, 0);
SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1812,7 +1812,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- true /*isVariadic*/);
+ true /*isVariadic*/, 0);
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1834,7 +1834,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- true /*isVariadic*/);
+ true /*isVariadic*/, 0);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1853,7 +1853,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- true /*isVariadic*/);
+ true /*isVariadic*/, 0);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1877,7 +1877,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- true /*isVariadic*/);
+ true /*isVariadic*/, 0);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1896,7 +1896,7 @@
ArgTys.push_back(argT);
QualType msgSendType = Context->getFunctionType(Context->DoubleTy,
&ArgTys[0], ArgTys.size(),
- true /*isVariadic*/);
+ true /*isVariadic*/, 0);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
@@ -1911,7 +1911,7 @@
Context->CharTy.getQualifiedType(QualType::Const)));
QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- false /*isVariadic*/);
+ false /*isVariadic*/, 0);
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType,
@@ -1926,7 +1926,7 @@
Context->CharTy.getQualifiedType(QualType::Const)));
QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
&ArgTys[0], ArgTys.size(),
- false /*isVariadic*/);
+ false /*isVariadic*/, 0);
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType,
@@ -2284,7 +2284,7 @@
QualType castType = Context->getFunctionType(returnType,
&ArgTypes[0], ArgTypes.size(),
// If we don't have a method decl, force a variadic cast.
- Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true);
+ Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0);
castType = Context->getPointerType(castType);
cast = new ExplicitCastExpr(castType, cast, SourceLocation());
@@ -2310,7 +2310,7 @@
// Now do the "normal" pointer to function cast.
castType = Context->getFunctionType(returnType,
&ArgTypes[0], ArgTypes.size(),
- Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false);
+ Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0);
castType = Context->getPointerType(castType);
cast = new ExplicitCastExpr(castType, cast, SourceLocation());
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sun Oct 26 11:43:14 2008
@@ -209,7 +209,7 @@
/// list. isVariadic indicates whether the argument list includes '...'.
QualType getFunctionType(QualType ResultTy, const QualType *ArgArray,
unsigned NumArgs, bool isVariadic,
- unsigned TypeQuals = 0);
+ unsigned TypeQuals);
/// getTypeDeclType - Return the unique reference to the type for
/// the specified type declaration.
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Oct 26 11:43:14 2008
@@ -913,7 +913,7 @@
Canonical = getFunctionType(getCanonicalType(ResultTy),
&CanonicalArgs[0], NumArgs,
- isVariadic);
+ isVariadic, TypeQuals);
// Get the new insert position for the node we care about.
FunctionTypeProto *NewIP =
@@ -1947,6 +1947,9 @@
if (lproto->isVariadic() != rproto->isVariadic())
return QualType();
+ if (lproto->getTypeQuals() != rproto->getTypeQuals())
+ return QualType();
+
// Check argument compatibility
llvm::SmallVector<QualType, 10> types;
for (unsigned i = 0; i < lproto_nargs; i++) {
@@ -1963,7 +1966,7 @@
if (allLTypes) return lhs;
if (allRTypes) return rhs;
return getFunctionType(retType, types.begin(), types.size(),
- lproto->isVariadic());
+ lproto->isVariadic(), lproto->getTypeQuals());
}
if (lproto) allRTypes = false;
@@ -1988,7 +1991,8 @@
if (allLTypes) return lhs;
if (allRTypes) return rhs;
return getFunctionType(retType, proto->arg_type_begin(),
- proto->getNumArgs(), lproto->isVariadic());
+ proto->getNumArgs(), lproto->isVariadic(),
+ lproto->getTypeQuals());
}
if (allLTypes) return lhs;
Modified: cfe/trunk/lib/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Builtins.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Builtins.cpp (original)
+++ cfe/trunk/lib/AST/Builtins.cpp Sun Oct 26 11:43:14 2008
@@ -203,5 +203,5 @@
if (ArgTypes.size() == 0 && TypeStr[0] == '.')
return Context.getFunctionTypeNoProto(ResType);
return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
- TypeStr[0] == '.');
+ TypeStr[0] == '.', 0);
}
Modified: cfe/trunk/lib/AST/TypeSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeSerialization.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeSerialization.cpp (original)
+++ cfe/trunk/lib/AST/TypeSerialization.cpp Sun Oct 26 11:43:14 2008
@@ -194,6 +194,7 @@
void FunctionTypeProto::EmitImpl(Serializer& S) const {
S.Emit(getResultType());
S.EmitBool(isVariadic());
+ S.EmitInt(getTypeQuals());
S.EmitInt(getNumArgs());
for (arg_type_iterator I=arg_type_begin(), E=arg_type_end(); I!=E; ++I)
@@ -203,6 +204,7 @@
Type* FunctionTypeProto::CreateImpl(ASTContext& Context, Deserializer& D) {
QualType ResultType = QualType::ReadVal(D);
bool isVariadic = D.ReadBool();
+ unsigned TypeQuals = D.ReadInt();
unsigned NumArgs = D.ReadInt();
llvm::SmallVector<QualType,15> Args;
@@ -211,7 +213,7 @@
Args.push_back(QualType::ReadVal(D));
return Context.getFunctionType(ResultType,&*Args.begin(),
- NumArgs,isVariadic).getTypePtr();
+ NumArgs,isVariadic,TypeQuals).getTypePtr();
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Oct 26 11:43:14 2008
@@ -3033,7 +3033,7 @@
BlockTy = Context.getFunctionTypeNoProto(RetTy);
else
BlockTy = Context.getFunctionType(RetTy, &ArgTypes[0], ArgTypes.size(),
- BSI->isVariadic);
+ BSI->isVariadic, 0);
BlockTy = Context.getBlockPointerType(BlockTy);
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=58187&r1=58186&r2=58187&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sun Oct 26 11:43:14 2008
@@ -513,7 +513,7 @@
// Strip the cv-quals from the type.
T = Context.getFunctionType(FnTy->getResultType(), FnTy->arg_type_begin(),
- FnTy->getNumArgs(), FnTy->isVariadic());
+ FnTy->getNumArgs(), FnTy->isVariadic(), 0);
}
}
@@ -556,7 +556,7 @@
ArgTys.push_back(ArgTy);
}
T = Context.getFunctionType(T, &ArgTys[0], ArgTys.size(),
- MDecl->isVariadic());
+ MDecl->isVariadic(), 0);
return T;
}
More information about the cfe-commits
mailing list