From 0baf8f427978164600f65c87b022e297639cd02d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 19 Apr 2013 11:43:21 +0000 Subject: [PATCH] Attributes: Don't print trailing whitespace on the function attribute comment. llvm-svn: 179849 --- llvm/lib/IR/Attributes.cpp | 9 ++++----- llvm/test/Other/attribute-comment.ll | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 llvm/test/Other/attribute-comment.ll diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 98dcecfba6b5..44fa78e4af61 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -482,14 +482,13 @@ unsigned AttributeSetNode::getStackAlignment() const { std::string AttributeSetNode::getAsString(bool TargetIndependent, bool InAttrGrp) const { - std::string Str = ""; + std::string Str; for (SmallVectorImpl::const_iterator I = AttrList.begin(), - E = AttrList.end(); I != E; ) { + E = AttrList.end(); I != E; ++I) { if (TargetIndependent || !I->isStringAttribute()) { + if (I != AttrList.begin()) + Str += ' '; Str += I->getAsString(InAttrGrp); - if (++I != E) Str += " "; - } else { - ++I; } } return Str; diff --git a/llvm/test/Other/attribute-comment.ll b/llvm/test/Other/attribute-comment.ll new file mode 100644 index 000000000000..7354e7f765fd --- /dev/null +++ b/llvm/test/Other/attribute-comment.ll @@ -0,0 +1,9 @@ +; RUN: opt -S < %s | FileCheck %s -strict-whitespace + +; CHECK: {{^}}; Function Attrs: nounwind readnone ssp uwtable{{$}} +; CHECK-NEXT: define void @test1() #0 +define void @test1() #0 { + ret void +} + +attributes #0 = { nounwind ssp "less-precise-fpmad"="false" uwtable "no-frame-pointer-elim"="true" readnone "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }