diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2021-04-28 13:15:39 -0700 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2021-04-28 13:17:43 -0700 |
commit | 191570989ba291c639034906eeb6a0bae9ed47e9 (patch) | |
tree | 76743dd05a77562f148c14d41bf8ca69bb0514fd /llvm/unittests/IR/AttributesTest.cpp | |
parent | 0cc3e10f5e291d85d5c5047ee783340a8694a249 (diff) | |
download | llvm-cleaner-attribute-errors.tar.gz |
Improve error messages for attributes in the wrong context.cleaner-attribute-errors
verifyFunctionAttrs has a comment that the value V is printed in error messages. The recently added errors for attributes didn't print V. Make them print V.
Change the stringification of AttributeList. Firstly they started with 'PAL[' which stood for ParamAttrsList. Change that to 'AttributeList[' matching its current name AttributeList. Print out semantic meaning of the index instead of the raw index value (i.e. 'return', 'function' or 'arg(n)').
Diffstat (limited to 'llvm/unittests/IR/AttributesTest.cpp')
-rw-r--r-- | llvm/unittests/IR/AttributesTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/unittests/IR/AttributesTest.cpp b/llvm/unittests/IR/AttributesTest.cpp index 03b4cef404f5..f260f0f9bf86 100644 --- a/llvm/unittests/IR/AttributesTest.cpp +++ b/llvm/unittests/IR/AttributesTest.cpp @@ -217,4 +217,39 @@ TEST(Attributes, HasParentContext) { } } +TEST(Attributes, AttributeListPrinting) { + LLVMContext C; + + { + std::string S; + raw_string_ostream OS(S); + AttributeList AL; + AL.addAttribute(C, AttributeList::FunctionIndex, Attribute::AlwaysInline) + .print(OS); + EXPECT_EQ(S, "AttributeList[\n" + " { function => alwaysinline }\n" + "]\n"); + } + + { + std::string S; + raw_string_ostream OS(S); + AttributeList AL; + AL.addAttribute(C, AttributeList::ReturnIndex, Attribute::SExt).print(OS); + EXPECT_EQ(S, "AttributeList[\n" + " { return => signext }\n" + "]\n"); + } + + { + std::string S; + raw_string_ostream OS(S); + AttributeList AL; + AL.addParamAttribute(C, 5, Attribute::ZExt).print(OS); + EXPECT_EQ(S, "AttributeList[\n" + " { arg(5) => zeroext }\n" + "]\n"); + } +} + } // end anonymous namespace |