[PATCH] Refactor attribute arguments
eli.friedman at gmail.com
Mon Jul 22 14:30:04 PDT 2013
On Mon, Jul 22, 2013 at 11:13 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> And then I promptly attached the wrong patch. Sorry. Correct patch
> attached here.
> On Mon, Jul 22, 2013 at 2:09 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> There was already a helper method named
>> checkFunctionOrMethodArgumentIndex whcih would perform semantic
>> checking for attributes. This patch refactors alloc_size, nonnull,
>> format_args and the ownership attributes to use the helper method
>> instead of the copy and pasted code.
>> No functional changes intended, but there are some new test cases to
>> test coverage.
@@ -3082,8 +2964,14 @@
+ // We cannot use the ArgIdx returned from checkFunctionOrMethodArgumentIndex
+ // because that has corrected for the implicit this parameter, and is zero-
+ // based. The attribute expects what the user wrote explicitly.
+ llvm::APSInt Val;
+ IdxExpr->EvaluateAsInt(Val, S.Context);
- FormatArgAttr(Attr.getRange(), S.Context, Idx.getZExtValue(),
+ FormatArgAttr(Attr.getRange(), S.Context, Val.getZExtValue(),
Are you sure? We have tests in test/SemaCXX/attr-format.cpp which
seem to say this is wrong.
More information about the cfe-commits