don't access argument list of prototypes

llvm-svn: 36238
This commit is contained in:
Chris Lattner 2007-04-18 00:57:22 +00:00
parent 5976db0103
commit 82738fe254
1 changed files with 24 additions and 7 deletions

View File

@ -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...