forked from OSchip/llvm-project
Handle typedef function declarations correctly, such as
typedef int (*Myfunc)(int); Myfunc func; Reviewed by chandlerc llvm-svn: 107450
This commit is contained in:
parent
4ca8ddaceb
commit
19ebcd0f28
|
@ -977,17 +977,23 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
|
||||||
TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
|
TRY_TO(TraverseNestedNameSpecifier(D->getQualifier()));
|
||||||
|
|
||||||
// Visit the function type itself, which can be either
|
// Visit the function type itself, which can be either
|
||||||
// FunctionNoProtoType or FunctionProtoType.
|
// FunctionNoProtoType or FunctionProtoType, or a typedef. If it's
|
||||||
|
// not a Function*ProtoType, then it can't have a body or arguments,
|
||||||
|
// so we have to do less work.
|
||||||
Type *FuncType = D->getType().getTypePtr();
|
Type *FuncType = D->getType().getTypePtr();
|
||||||
if (FunctionNoProtoType *FuncNoProto =
|
if (FunctionProtoType *FuncProto = dyn_cast<FunctionProtoType>(FuncType)) {
|
||||||
|
// Don't call Traverse*, or the result type and parameter types
|
||||||
|
// will be double counted.
|
||||||
|
TRY_TO(WalkUpFromFunctionProtoType(FuncProto));
|
||||||
|
} else if (FunctionNoProtoType *FuncNoProto =
|
||||||
dyn_cast<FunctionNoProtoType>(FuncType)) {
|
dyn_cast<FunctionNoProtoType>(FuncType)) {
|
||||||
// Don't call Traverse*, or the result type will be double
|
// Don't call Traverse*, or the result type will be double
|
||||||
// counted.
|
// counted.
|
||||||
TRY_TO(WalkUpFromFunctionNoProtoType(FuncNoProto));
|
TRY_TO(WalkUpFromFunctionNoProtoType(FuncNoProto));
|
||||||
} else {
|
} else { // a typedef type, or who knows what
|
||||||
// Don't call Traverse*, or the result type and parameter types
|
TRY_TO(TraverseType(D->getType()));
|
||||||
// will be double counted.
|
assert(!D->isThisDeclarationADefinition() && "Unexpected function type");
|
||||||
TRY_TO(WalkUpFromFunctionProtoType(dyn_cast<FunctionProtoType>(FuncType)));
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY_TO(TraverseType(D->getResultType()));
|
TRY_TO(TraverseType(D->getResultType()));
|
||||||
|
|
Loading…
Reference in New Issue