Simplified setting up Method's scope before generating AST for its nody.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44576 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp
index 81a18c9..b83e512 100644
--- a/Sema/SemaChecking.cpp
+++ b/Sema/SemaChecking.cpp
@@ -54,8 +54,9 @@
return true;
}
- FunctionTypeProto* proto =
- cast<FunctionTypeProto>(CurFunctionDecl->getType());
+ FunctionTypeProto* proto = CurFunctionDecl ?
+ cast<FunctionTypeProto>(CurFunctionDecl->getType()) :
+ cast<FunctionTypeProto>(ObjcGetTypeForMethodDefinition(CurMethodDecl));
if (!proto->isVariadic()) {
Diag(Fn->getLocStart(),
diag::err_va_start_used_in_non_variadic_function);
@@ -65,9 +66,10 @@
bool SecondArgIsLastNamedArgument = false;
if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Args[1])) {
if (ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
- ParmVarDecl *LastNamedArg =
- CurFunctionDecl->getParamDecl(CurFunctionDecl->getNumParams() - 1);
-
+ ParmVarDecl *LastNamedArg = CurFunctionDecl ?
+ CurFunctionDecl->getParamDecl(CurFunctionDecl->getNumParams() - 1) :
+ CurMethodDecl->getParamDecl(CurMethodDecl->getNumParams() - 1);
+
if (PV == LastNamedArg)
SecondArgIsLastNamedArgument = true;
}