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/lib/IR/Attributes.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/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 30730a4374a5..324e6f183334 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()) { + 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"; |