forked from OSchip/llvm-project
Correct various uses of 'argument' that in fact refer to function parameters
Cleanup only. llvm-svn: 199773
This commit is contained in:
parent
111d3485af
commit
601b22c377
|
@ -2887,7 +2887,7 @@ CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
|
||||||
CINDEX_LINKAGE CXType clang_getResultType(CXType T);
|
CINDEX_LINKAGE CXType clang_getResultType(CXType T);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the number of non-variadic arguments associated with a
|
* \brief Retrieve the number of non-variadic parameters associated with a
|
||||||
* function type.
|
* function type.
|
||||||
*
|
*
|
||||||
* If a non-function type is passed in, -1 is returned.
|
* If a non-function type is passed in, -1 is returned.
|
||||||
|
@ -2895,7 +2895,7 @@ CINDEX_LINKAGE CXType clang_getResultType(CXType T);
|
||||||
CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
|
CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the type of an argument of a function type.
|
* \brief Retrieve the type of a parameter of a function type.
|
||||||
*
|
*
|
||||||
* If a non-function type is passed in or the function does not have enough
|
* If a non-function type is passed in or the function does not have enough
|
||||||
* parameters, an invalid type is returned.
|
* parameters, an invalid type is returned.
|
||||||
|
|
|
@ -6950,11 +6950,8 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
|
||||||
if (lproto && rproto) { // two C99 style function prototypes
|
if (lproto && rproto) { // two C99 style function prototypes
|
||||||
assert(!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec() &&
|
assert(!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec() &&
|
||||||
"C++ shouldn't be here");
|
"C++ shouldn't be here");
|
||||||
unsigned lproto_nargs = lproto->getNumParams();
|
// Compatible functions must have the same number of parameters
|
||||||
unsigned rproto_nargs = rproto->getNumParams();
|
if (lproto->getNumParams() != rproto->getNumParams())
|
||||||
|
|
||||||
// Compatible functions must have the same number of arguments
|
|
||||||
if (lproto_nargs != rproto_nargs)
|
|
||||||
return QualType();
|
return QualType();
|
||||||
|
|
||||||
// Variadic and non-variadic functions aren't compatible
|
// Variadic and non-variadic functions aren't compatible
|
||||||
|
@ -6967,28 +6964,29 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
|
||||||
if (LangOpts.ObjCAutoRefCount &&
|
if (LangOpts.ObjCAutoRefCount &&
|
||||||
!FunctionTypesMatchOnNSConsumedAttrs(rproto, lproto))
|
!FunctionTypesMatchOnNSConsumedAttrs(rproto, lproto))
|
||||||
return QualType();
|
return QualType();
|
||||||
|
|
||||||
// Check argument compatibility
|
// Check parameter type compatibility
|
||||||
SmallVector<QualType, 10> types;
|
SmallVector<QualType, 10> types;
|
||||||
for (unsigned i = 0; i < lproto_nargs; i++) {
|
for (unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
|
||||||
QualType largtype = lproto->getParamType(i).getUnqualifiedType();
|
QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
|
||||||
QualType rargtype = rproto->getParamType(i).getUnqualifiedType();
|
QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
|
||||||
QualType argtype = mergeFunctionParameterTypes(
|
QualType paramType = mergeFunctionParameterTypes(
|
||||||
largtype, rargtype, OfBlockPointer, Unqualified);
|
lParamType, rParamType, OfBlockPointer, Unqualified);
|
||||||
if (argtype.isNull()) return QualType();
|
if (paramType.isNull())
|
||||||
|
return QualType();
|
||||||
|
|
||||||
if (Unqualified)
|
if (Unqualified)
|
||||||
argtype = argtype.getUnqualifiedType();
|
paramType = paramType.getUnqualifiedType();
|
||||||
|
|
||||||
types.push_back(argtype);
|
types.push_back(paramType);
|
||||||
if (Unqualified) {
|
if (Unqualified) {
|
||||||
largtype = largtype.getUnqualifiedType();
|
lParamType = lParamType.getUnqualifiedType();
|
||||||
rargtype = rargtype.getUnqualifiedType();
|
rParamType = rParamType.getUnqualifiedType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCanonicalType(argtype) != getCanonicalType(largtype))
|
if (getCanonicalType(paramType) != getCanonicalType(lParamType))
|
||||||
allLTypes = false;
|
allLTypes = false;
|
||||||
if (getCanonicalType(argtype) != getCanonicalType(rargtype))
|
if (getCanonicalType(paramType) != getCanonicalType(rParamType))
|
||||||
allRTypes = false;
|
allRTypes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7012,20 +7010,19 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
|
||||||
// The only types actually affected are promotable integer
|
// The only types actually affected are promotable integer
|
||||||
// types and floats, which would be passed as a different
|
// types and floats, which would be passed as a different
|
||||||
// type depending on whether the prototype is visible.
|
// type depending on whether the prototype is visible.
|
||||||
unsigned proto_nargs = proto->getNumParams();
|
for (unsigned i = 0, n = proto->getNumParams(); i < n; ++i) {
|
||||||
for (unsigned i = 0; i < proto_nargs; ++i) {
|
QualType paramTy = proto->getParamType(i);
|
||||||
QualType argTy = proto->getParamType(i);
|
|
||||||
|
|
||||||
// Look at the converted type of enum types, since that is the type used
|
// Look at the converted type of enum types, since that is the type used
|
||||||
// to pass enum values.
|
// to pass enum values.
|
||||||
if (const EnumType *Enum = argTy->getAs<EnumType>()) {
|
if (const EnumType *Enum = paramTy->getAs<EnumType>()) {
|
||||||
argTy = Enum->getDecl()->getIntegerType();
|
paramTy = Enum->getDecl()->getIntegerType();
|
||||||
if (argTy.isNull())
|
if (paramTy.isNull())
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argTy->isPromotableIntegerType() ||
|
if (paramTy->isPromotableIntegerType() ||
|
||||||
getCanonicalType(argTy).getUnqualifiedType() == FloatTy)
|
getCanonicalType(paramTy).getUnqualifiedType() == FloatTy)
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7346,10 +7343,8 @@ bool ASTContext::FunctionTypesMatchOnNSConsumedAttrs(
|
||||||
FunctionProtoType::ExtProtoInfo ToEPI =
|
FunctionProtoType::ExtProtoInfo ToEPI =
|
||||||
ToFunctionType->getExtProtoInfo();
|
ToFunctionType->getExtProtoInfo();
|
||||||
if (FromEPI.ConsumedParameters && ToEPI.ConsumedParameters)
|
if (FromEPI.ConsumedParameters && ToEPI.ConsumedParameters)
|
||||||
for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams();
|
for (unsigned i = 0, n = FromFunctionType->getNumParams(); i != n; ++i) {
|
||||||
ArgIdx != NumArgs; ++ArgIdx) {
|
if (FromEPI.ConsumedParameters[i] != ToEPI.ConsumedParameters[i])
|
||||||
if (FromEPI.ConsumedParameters[ArgIdx] !=
|
|
||||||
ToEPI.ConsumedParameters[ArgIdx])
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -186,13 +186,12 @@ static bool isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT) {
|
||||||
return isSafeToConvert(RD, CGT, AlreadyChecked);
|
return isSafeToConvert(RD, CGT, AlreadyChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// isFuncParamTypeConvertible - Return true if the specified type in a
|
||||||
/// isFuncTypeArgumentConvertible - Return true if the specified type in a
|
/// function parameter or result position can be converted to an IR type at this
|
||||||
/// function argument or result position can be converted to an IR type at this
|
|
||||||
/// point. This boils down to being whether it is complete, as well as whether
|
/// point. This boils down to being whether it is complete, as well as whether
|
||||||
/// we've temporarily deferred expanding the type because we're in a recursive
|
/// we've temporarily deferred expanding the type because we're in a recursive
|
||||||
/// context.
|
/// context.
|
||||||
bool CodeGenTypes::isFuncTypeArgumentConvertible(QualType Ty) {
|
bool CodeGenTypes::isFuncParamTypeConvertible(QualType Ty) {
|
||||||
// If this isn't a tagged type, we can convert it!
|
// If this isn't a tagged type, we can convert it!
|
||||||
const TagType *TT = Ty->getAs<TagType>();
|
const TagType *TT = Ty->getAs<TagType>();
|
||||||
if (TT == 0) return true;
|
if (TT == 0) return true;
|
||||||
|
@ -217,17 +216,17 @@ bool CodeGenTypes::isFuncTypeArgumentConvertible(QualType Ty) {
|
||||||
|
|
||||||
|
|
||||||
/// Code to verify a given function type is complete, i.e. the return type
|
/// Code to verify a given function type is complete, i.e. the return type
|
||||||
/// and all of the argument types are complete. Also check to see if we are in
|
/// and all of the parameter types are complete. Also check to see if we are in
|
||||||
/// a RS_StructPointer context, and if so whether any struct types have been
|
/// a RS_StructPointer context, and if so whether any struct types have been
|
||||||
/// pended. If so, we don't want to ask the ABI lowering code to handle a type
|
/// pended. If so, we don't want to ask the ABI lowering code to handle a type
|
||||||
/// that cannot be converted to an IR type.
|
/// that cannot be converted to an IR type.
|
||||||
bool CodeGenTypes::isFuncTypeConvertible(const FunctionType *FT) {
|
bool CodeGenTypes::isFuncTypeConvertible(const FunctionType *FT) {
|
||||||
if (!isFuncTypeArgumentConvertible(FT->getResultType()))
|
if (!isFuncParamTypeConvertible(FT->getResultType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
|
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
|
||||||
for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
|
for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
|
||||||
if (!isFuncTypeArgumentConvertible(FPT->getParamType(i)))
|
if (!isFuncParamTypeConvertible(FPT->getParamType(i)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -493,7 +492,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// While we're converting the argument types for a function, we don't want
|
// While we're converting the parameter types for a function, we don't want
|
||||||
// to recursively convert any pointed-to structs. Converting directly-used
|
// to recursively convert any pointed-to structs. Converting directly-used
|
||||||
// structs is ok though.
|
// structs is ok though.
|
||||||
if (!RecordsBeingLaidOut.insert(Ty)) {
|
if (!RecordsBeingLaidOut.insert(Ty)) {
|
||||||
|
|
|
@ -136,8 +136,8 @@ public:
|
||||||
/// be converted to an LLVM type (i.e. doesn't depend on an incomplete tag
|
/// be converted to an LLVM type (i.e. doesn't depend on an incomplete tag
|
||||||
/// type).
|
/// type).
|
||||||
bool isFuncTypeConvertible(const FunctionType *FT);
|
bool isFuncTypeConvertible(const FunctionType *FT);
|
||||||
bool isFuncTypeArgumentConvertible(QualType Ty);
|
bool isFuncParamTypeConvertible(QualType Ty);
|
||||||
|
|
||||||
/// GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable,
|
/// GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable,
|
||||||
/// given a CXXMethodDecl. If the method to has an incomplete return type,
|
/// given a CXXMethodDecl. If the method to has an incomplete return type,
|
||||||
/// and/or incomplete argument types, this will return the opaque type.
|
/// and/or incomplete argument types, this will return the opaque type.
|
||||||
|
|
|
@ -67,10 +67,10 @@ static bool hasFunctionProto(const Decl *D) {
|
||||||
return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
|
return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getFunctionOrMethodNumArgs - Return number of function or method
|
/// getFunctionOrMethodNumParams - Return number of function or method
|
||||||
/// arguments. It is an error to call this on a K&R function (use
|
/// parameters. It is an error to call this on a K&R function (use
|
||||||
/// hasFunctionProto first).
|
/// hasFunctionProto first).
|
||||||
static unsigned getFunctionOrMethodNumArgs(const Decl *D) {
|
static unsigned getFunctionOrMethodNumParams(const Decl *D) {
|
||||||
if (const FunctionType *FnTy = D->getFunctionType())
|
if (const FunctionType *FnTy = D->getFunctionType())
|
||||||
return cast<FunctionProtoType>(FnTy)->getNumParams();
|
return cast<FunctionProtoType>(FnTy)->getNumParams();
|
||||||
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
|
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
|
||||||
|
@ -78,7 +78,7 @@ static unsigned getFunctionOrMethodNumArgs(const Decl *D) {
|
||||||
return cast<ObjCMethodDecl>(D)->param_size();
|
return cast<ObjCMethodDecl>(D)->param_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QualType getFunctionOrMethodArgType(const Decl *D, unsigned Idx) {
|
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) {
|
||||||
if (const FunctionType *FnTy = D->getFunctionType())
|
if (const FunctionType *FnTy = D->getFunctionType())
|
||||||
return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
|
return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
|
||||||
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
|
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
|
||||||
|
@ -208,16 +208,15 @@ static bool checkAttrMutualExclusion(Sema &S, Decl *D,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Check if IdxExpr is a valid argument index for a function or
|
/// \brief Check if IdxExpr is a valid parameter index for a function or
|
||||||
/// instance method D. May output an error.
|
/// instance method D. May output an error.
|
||||||
///
|
///
|
||||||
/// \returns true if IdxExpr is a valid index.
|
/// \returns true if IdxExpr is a valid index.
|
||||||
static bool checkFunctionOrMethodArgumentIndex(Sema &S, const Decl *D,
|
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D,
|
||||||
const AttributeList &Attr,
|
const AttributeList &Attr,
|
||||||
unsigned AttrArgNum,
|
unsigned AttrArgNum,
|
||||||
const Expr *IdxExpr,
|
const Expr *IdxExpr,
|
||||||
uint64_t &Idx)
|
uint64_t &Idx) {
|
||||||
{
|
|
||||||
assert(isFunctionOrMethod(D));
|
assert(isFunctionOrMethod(D));
|
||||||
|
|
||||||
// In C++ the implicit 'this' function parameter also counts.
|
// In C++ the implicit 'this' function parameter also counts.
|
||||||
|
@ -225,8 +224,8 @@ static bool checkFunctionOrMethodArgumentIndex(Sema &S, const Decl *D,
|
||||||
bool HP = hasFunctionProto(D);
|
bool HP = hasFunctionProto(D);
|
||||||
bool HasImplicitThisParam = isInstanceMethod(D);
|
bool HasImplicitThisParam = isInstanceMethod(D);
|
||||||
bool IV = HP && isFunctionOrMethodVariadic(D);
|
bool IV = HP && isFunctionOrMethodVariadic(D);
|
||||||
unsigned NumArgs = (HP ? getFunctionOrMethodNumArgs(D) : 0) +
|
unsigned NumParams =
|
||||||
HasImplicitThisParam;
|
(HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
|
||||||
|
|
||||||
llvm::APSInt IdxInt;
|
llvm::APSInt IdxInt;
|
||||||
if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() ||
|
if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() ||
|
||||||
|
@ -238,7 +237,7 @@ static bool checkFunctionOrMethodArgumentIndex(Sema &S, const Decl *D,
|
||||||
}
|
}
|
||||||
|
|
||||||
Idx = IdxInt.getLimitedValue();
|
Idx = IdxInt.getLimitedValue();
|
||||||
if (Idx < 1 || (!IV && Idx > NumArgs)) {
|
if (Idx < 1 || (!IV && Idx > NumParams)) {
|
||||||
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
|
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
|
||||||
<< Attr.getName() << AttrArgNum << IdxExpr->getSourceRange();
|
<< Attr.getName() << AttrArgNum << IdxExpr->getSourceRange();
|
||||||
return false;
|
return false;
|
||||||
|
@ -1193,13 +1192,13 @@ static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
for (unsigned i = 0; i < Attr.getNumArgs(); ++i) {
|
for (unsigned i = 0; i < Attr.getNumArgs(); ++i) {
|
||||||
Expr *Ex = Attr.getArgAsExpr(i);
|
Expr *Ex = Attr.getArgAsExpr(i);
|
||||||
uint64_t Idx;
|
uint64_t Idx;
|
||||||
if (!checkFunctionOrMethodArgumentIndex(S, D, Attr, i + 1, Ex, Idx))
|
if (!checkFunctionOrMethodParameterIndex(S, D, Attr, i + 1, Ex, Idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Is the function argument a pointer type?
|
// Is the function argument a pointer type?
|
||||||
// FIXME: Should also highlight argument in decl in the diagnostic.
|
// FIXME: Should also highlight argument in decl in the diagnostic.
|
||||||
if (!attrNonNullArgCheck(S, getFunctionOrMethodArgType(D, Idx),
|
if (!attrNonNullArgCheck(S, getFunctionOrMethodParamType(D, Idx), Attr,
|
||||||
Attr, Ex->getSourceRange()))
|
Ex->getSourceRange()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
NonNullArgs.push_back(Idx);
|
NonNullArgs.push_back(Idx);
|
||||||
|
@ -1208,8 +1207,8 @@ static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
// If no arguments were specified to __attribute__((nonnull)) then all pointer
|
// If no arguments were specified to __attribute__((nonnull)) then all pointer
|
||||||
// arguments have a nonnull attribute.
|
// arguments have a nonnull attribute.
|
||||||
if (NonNullArgs.empty()) {
|
if (NonNullArgs.empty()) {
|
||||||
for (unsigned i = 0, e = getFunctionOrMethodNumArgs(D); i != e; ++i) {
|
for (unsigned i = 0, e = getFunctionOrMethodNumParams(D); i != e; ++i) {
|
||||||
QualType T = getFunctionOrMethodArgType(D, i).getNonReferenceType();
|
QualType T = getFunctionOrMethodParamType(D, i).getNonReferenceType();
|
||||||
possibleTransparentUnionPointerType(T);
|
possibleTransparentUnionPointerType(T);
|
||||||
if (T->isAnyPointerType() || T->isBlockPointerType())
|
if (T->isAnyPointerType() || T->isBlockPointerType())
|
||||||
NonNullArgs.push_back(i);
|
NonNullArgs.push_back(i);
|
||||||
|
@ -1298,11 +1297,11 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
|
||||||
for (unsigned i = 1; i < AL.getNumArgs(); ++i) {
|
for (unsigned i = 1; i < AL.getNumArgs(); ++i) {
|
||||||
Expr *Ex = AL.getArgAsExpr(i);
|
Expr *Ex = AL.getArgAsExpr(i);
|
||||||
uint64_t Idx;
|
uint64_t Idx;
|
||||||
if (!checkFunctionOrMethodArgumentIndex(S, D, AL, i, Ex, Idx))
|
if (!checkFunctionOrMethodParameterIndex(S, D, AL, i, Ex, Idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Is the function argument a pointer type?
|
// Is the function argument a pointer type?
|
||||||
QualType T = getFunctionOrMethodArgType(D, Idx);
|
QualType T = getFunctionOrMethodParamType(D, Idx);
|
||||||
int Err = -1; // No error
|
int Err = -1; // No error
|
||||||
switch (K) {
|
switch (K) {
|
||||||
case OwnershipAttr::Takes:
|
case OwnershipAttr::Takes:
|
||||||
|
@ -2363,12 +2362,12 @@ static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
|
/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
|
||||||
static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
Expr *IdxExpr = Attr.getArgAsExpr(0);
|
Expr *IdxExpr = Attr.getArgAsExpr(0);
|
||||||
uint64_t ArgIdx;
|
uint64_t Idx;
|
||||||
if (!checkFunctionOrMethodArgumentIndex(S, D, Attr, 1, IdxExpr, ArgIdx))
|
if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// make sure the format string is really a string
|
// make sure the format string is really a string
|
||||||
QualType Ty = getFunctionOrMethodArgType(D, ArgIdx);
|
QualType Ty = getFunctionOrMethodParamType(D, Idx);
|
||||||
|
|
||||||
bool not_nsstring_type = !isNSStringType(Ty, S.Context);
|
bool not_nsstring_type = !isNSStringType(Ty, S.Context);
|
||||||
if (not_nsstring_type &&
|
if (not_nsstring_type &&
|
||||||
|
@ -2393,7 +2392,7 @@ static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We cannot use the ArgIdx returned from checkFunctionOrMethodArgumentIndex
|
// We cannot use the Idx returned from checkFunctionOrMethodParameterIndex
|
||||||
// because that has corrected for the implicit this parameter, and is zero-
|
// because that has corrected for the implicit this parameter, and is zero-
|
||||||
// based. The attribute expects what the user wrote explicitly.
|
// based. The attribute expects what the user wrote explicitly.
|
||||||
llvm::APSInt Val;
|
llvm::APSInt Val;
|
||||||
|
@ -2509,7 +2508,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
// In C++ the implicit 'this' function parameter also counts, and they are
|
// In C++ the implicit 'this' function parameter also counts, and they are
|
||||||
// counted from one.
|
// counted from one.
|
||||||
bool HasImplicitThisParam = isInstanceMethod(D);
|
bool HasImplicitThisParam = isInstanceMethod(D);
|
||||||
unsigned NumArgs = getFunctionOrMethodNumArgs(D) + HasImplicitThisParam;
|
unsigned NumArgs = getFunctionOrMethodNumParams(D) + HasImplicitThisParam;
|
||||||
|
|
||||||
IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
|
IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
|
||||||
StringRef Format = II->getName();
|
StringRef Format = II->getName();
|
||||||
|
@ -2559,7 +2558,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the format string is really a string
|
// make sure the format string is really a string
|
||||||
QualType Ty = getFunctionOrMethodArgType(D, ArgIdx);
|
QualType Ty = getFunctionOrMethodParamType(D, ArgIdx);
|
||||||
|
|
||||||
if (Kind == CFStringFormat) {
|
if (Kind == CFStringFormat) {
|
||||||
if (!isCFStringType(Ty, S.Context)) {
|
if (!isCFStringType(Ty, S.Context)) {
|
||||||
|
@ -3271,19 +3270,19 @@ static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D,
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ArgumentIdx;
|
uint64_t ArgumentIdx;
|
||||||
if (!checkFunctionOrMethodArgumentIndex(S, D, Attr, 2, Attr.getArgAsExpr(1),
|
if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 2, Attr.getArgAsExpr(1),
|
||||||
ArgumentIdx))
|
ArgumentIdx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64_t TypeTagIdx;
|
uint64_t TypeTagIdx;
|
||||||
if (!checkFunctionOrMethodArgumentIndex(S, D, Attr, 3, Attr.getArgAsExpr(2),
|
if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 3, Attr.getArgAsExpr(2),
|
||||||
TypeTagIdx))
|
TypeTagIdx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool IsPointer = (Attr.getName()->getName() == "pointer_with_type_tag");
|
bool IsPointer = (Attr.getName()->getName() == "pointer_with_type_tag");
|
||||||
if (IsPointer) {
|
if (IsPointer) {
|
||||||
// Ensure that buffer has a pointer type.
|
// Ensure that buffer has a pointer type.
|
||||||
QualType BufferTy = getFunctionOrMethodArgType(D, ArgumentIdx);
|
QualType BufferTy = getFunctionOrMethodParamType(D, ArgumentIdx);
|
||||||
if (!BufferTy->isPointerType()) {
|
if (!BufferTy->isPointerType()) {
|
||||||
S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only)
|
S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only)
|
||||||
<< Attr.getName();
|
<< Attr.getName();
|
||||||
|
|
|
@ -554,8 +554,8 @@ CXType clang_getArgType(CXType X, unsigned i) {
|
||||||
return MakeCXType(QualType(), GetTU(X));
|
return MakeCXType(QualType(), GetTU(X));
|
||||||
|
|
||||||
if (const FunctionProtoType *FD = T->getAs<FunctionProtoType>()) {
|
if (const FunctionProtoType *FD = T->getAs<FunctionProtoType>()) {
|
||||||
unsigned numArgs = FD->getNumParams();
|
unsigned numParams = FD->getNumParams();
|
||||||
if (i >= numArgs)
|
if (i >= numParams)
|
||||||
return MakeCXType(QualType(), GetTU(X));
|
return MakeCXType(QualType(), GetTU(X));
|
||||||
|
|
||||||
return MakeCXType(FD->getParamType(i), GetTU(X));
|
return MakeCXType(FD->getParamType(i), GetTU(X));
|
||||||
|
|
Loading…
Reference in New Issue