diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2021-04-28 13:15:39 -0700 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2021-04-29 01:44:16 -0700 |
commit | 30bbfda01fb6c6c56c55c6729348d9df7f68ac31 (patch) | |
tree | 65cb3737d75cdbf9132d8c16868357110d95814d /llvm/lib/IR/Attributes.cpp | |
parent | 56d923efdb692bf2d459203692b164d54f4ffe48 (diff) | |
download | llvm-30bbfda01fb6c6c56c55c6729348d9df7f68ac31.zip llvm-30bbfda01fb6c6c56c55c6729348d9df7f68ac31.tar.gz llvm-30bbfda01fb6c6c56c55c6729348d9df7f68ac31.tar.bz2 |
Improve error messages for attributes in the wrong context.
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)').
Differential revision: https://reviews.llvm.org/D101484
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 30730a4..d4bf3b1 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1693,11 +1693,23 @@ unsigned AttributeList::getNumAttrSets() const { } void AttributeList::print(raw_ostream &O) const { - O << "PAL[\n"; + O << "AttributeList[\n"; for (unsigned i = index_begin(), e = index_end(); i != e; ++i) { - if (getAttributes(i).hasAttributes()) - O << " { " << i << " => " << getAsString(i) << " }\n"; + if (!getAttributes(i).hasAttributes()) + continue; + O << " { "; + switch (i) { + case AttrIndex::ReturnIndex: + O << "return"; + break; + case AttrIndex::FunctionIndex: + O << "function"; + break; + default: + O << "arg(" << i - AttrIndex::FirstArgIndex << ")"; + } + O << " => " << getAsString(i) << " }\n"; } O << "]\n"; |