summaryrefslogtreecommitdiff
path: root/lib/VMCore/AsmWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-18 00:57:22 +0000
committerChris Lattner <sabre@nondot.org>2007-04-18 00:57:22 +0000
commit8dcd2f1a5bbb9151ec05532861be58bf3f078e63 (patch)
treea818a6045cd2aa8b73c4e019cad73e5a7c7f46f0 /lib/VMCore/AsmWriter.cpp
parent7cc6dcf6e00928db982747ce467f8c89a4d6c73e (diff)
downloadllvm-8dcd2f1a5bbb9151ec05532861be58bf3f078e63.tar.gz
llvm-8dcd2f1a5bbb9151ec05532861be58bf3f078e63.tar.bz2
llvm-8dcd2f1a5bbb9151ec05532861be58bf3f078e63.tar.xz
don't access argument list of prototypes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/AsmWriter.cpp')
-rw-r--r--lib/VMCore/AsmWriter.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 487d7e6a05..da3b1d7769 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/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...