From 82738fe254a288da6c34b390575bce08581888aa Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 18 Apr 2007 00:57:22 +0000 Subject: [PATCH] don't access argument list of prototypes llvm-svn: 36238 --- llvm/lib/VMCore/AsmWriter.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 487d7e6a05d0..da3b1d7769bc 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -970,13 +970,30 @@ void AssemblyWriter::printFunction(const Function *F) { // Loop over the arguments, printing them... unsigned Idx = 1; - for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); - I != E; ++I) { - // Insert commas as we go... the first arg doesn't get a comma - if (I != F->arg_begin()) Out << ", "; - printArgument(I, (Attrs ? Attrs->getParamAttrs(Idx) - : uint16_t(ParamAttr::None))); - Idx++; + if (!F->isDeclaration()) { + // If this isn't a declaration, print the argument names as well. + for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); + I != E; ++I) { + // Insert commas as we go... the first arg doesn't get a comma + if (I != F->arg_begin()) Out << ", "; + printArgument(I, (Attrs ? Attrs->getParamAttrs(Idx) + : uint16_t(ParamAttr::None))); + Idx++; + } + } else { + // Otherwise, print the types from the function type. + for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) { + // Insert commas as we go... the first arg doesn't get a comma + if (i) Out << ", "; + + // Output type... + printType(FT->getParamType(i)); + + unsigned ArgAttrs = ParamAttr::None; + if (Attrs) ArgAttrs = Attrs->getParamAttrs(i+1); + if (ArgAttrs != ParamAttr::None) + Out << ' ' << ParamAttrsList::getParamAttrsText(ArgAttrs); + } } // Finish printing arguments...