diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-25 06:03:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-25 06:03:53 +0000 |
commit | 1ad9b28e3217c2349a04f3d3bf14f9c73a99afa7 (patch) | |
tree | ffdc08bb7cee5a8da948446790ee8f57c411a638 /lib/Sema/SemaDecl.cpp | |
parent | 11ddb7dc22bb398a6727318729680630bfcefaae (diff) |
rename getNumParmVarDeclsFromType back to getNumParams(),
remove a special case that was apparently for typeof() and
generalize the code in SemaDecl that handles typedefs to
handle any sugar type (including typedef, typeof, etc).
Improve comment to make it more clear what is going on.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d34b20780e..8dd4356046 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2153,8 +2153,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, } NewFD->setParams(Context, &Params[0], Params.size()); - } else if (isa<TypedefType>(R)) { - // When we're declaring a function with a typedef, as in the + } else if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) { + // When we're declaring a function with a typedef, typeof, etc as in the // following example, we'll need to synthesize (unnamed) // parameters for use in the declaration. // @@ -2162,20 +2162,19 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // typedef void fn(int); // fn f; // @endcode - if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) { - // Synthesize a parameter for each argument type. - llvm::SmallVector<ParmVarDecl*, 16> Params; - for (FunctionProtoType::arg_type_iterator ArgType = FT->arg_type_begin(); - ArgType != FT->arg_type_end(); ++ArgType) { - ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, - SourceLocation(), 0, - *ArgType, VarDecl::None, 0); - Param->setImplicit(); - Params.push_back(Param); - } - - NewFD->setParams(Context, &Params[0], Params.size()); + + // Synthesize a parameter for each argument type. + llvm::SmallVector<ParmVarDecl*, 16> Params; + for (FunctionProtoType::arg_type_iterator AI = FT->arg_type_begin(), + AE = FT->arg_type_end(); AI != AE; ++AI) { + ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, + SourceLocation(), 0, + *AI, VarDecl::None, 0); + Param->setImplicit(); + Params.push_back(Param); } + + NewFD->setParams(Context, &Params[0], Params.size()); } // If name lookup finds a previous declaration that is not in the |