[PATCH] Updated warnings in Consumed Analysis code

Aaron Ballman aaron.ballman at gmail.com
Wed Aug 21 15:10:03 PDT 2013


Oddly, the patch does not apply cleanly for me.  When I apply it, I
get compile errors in handleTestsUnconsumedAttr, which ultimately
looks like:

static void handleTestsUnconsumedAttr(Sema &S, Decl *D,
                                      const AttributeList &Attr) {
  if (!checkAttributeNumArgs(S, Attr, 0)) return;

  if (!isa<CXXMethodDecl>(D)) {
    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
      Attr.getName() << ExpectedMethod;
    return;
  }

  if (!checkAttributeNumArgs(S, Attr, 0)) return;

  if (!isa<CXXMethodDecl>(D)) {
    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
      Attr.getName() << ExpectedMethod;
    return;
  }

  if (!checkAttributeNumArgs(S, Attr, 0)) return;

  if (!isa<CXXMethodDecl>(D)) {
    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
      Attr.getName() << ExpectedMethod;
    return;
  }

  S.ExtVectorDecls.push_back(TD);
}

I think maybe some of the offsets are wonky in the patch file.  I
manually made the changes outlined in the patch and committed in
r188940.

Thanks!

~Aaron

On Wed, Aug 21, 2013 at 5:40 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> LGTM.
>
> -Eli
>
>
> On Wed, Aug 21, 2013 at 2:32 PM, Christian Wailes <chriswailes at google.com>
> wrote:
>>
>> Hi dblaikie, delesley, aaron.ballman,
>>
>> A warning was added to clang that duplicated, word for world, the text
>> from another warning.  This warning was removed, and code was changed to use
>> the existing warning.
>>
>> http://llvm-reviews.chandlerc.com/D1467
>>
>> Files:
>>   include/clang/Basic/DiagnosticSemaKinds.td
>>   lib/Sema/SemaDeclAttr.cpp
>>
>> Index: include/clang/Basic/DiagnosticSemaKinds.td
>> ===================================================================
>> --- include/clang/Basic/DiagnosticSemaKinds.td
>> +++ include/clang/Basic/DiagnosticSemaKinds.td
>> @@ -2189,9 +2189,6 @@
>>  def warn_use_of_temp_while_consumed : Warning<
>>    "invocation of method '%0' on a temporary object while it is in the "
>>    "'consumed' state">, InGroup<Consumed>, DefaultIgnore;
>> -def warn_uniqueness_attribute_wrong_decl_type : Warning<
>> -  "%0 attribute only applies to methods">,
>> -  InGroup<Consumed>, DefaultIgnore;
>>
>>  // ConsumedStrict warnings
>>  def warn_use_in_unknown_state : Warning<
>> Index: lib/Sema/SemaDeclAttr.cpp
>> ===================================================================
>> --- lib/Sema/SemaDeclAttr.cpp
>> +++ lib/Sema/SemaDeclAttr.cpp
>> @@ -1003,8 +1003,8 @@
>>    if (!checkAttributeNumArgs(S, Attr, 0)) return;
>>
>>    if (!(isa<CXXMethodDecl>(D) || isa<CXXConstructorDecl>(D))) {
>> -    S.Diag(Attr.getLoc(),
>> diag::warn_uniqueness_attribute_wrong_decl_type) <<
>> -      Attr.getName();
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
>> +      Attr.getName() << ExpectedMethod;
>>      return;
>>    }
>>
>> @@ -1019,8 +1019,8 @@
>>    if (!checkAttributeNumArgs(S, Attr, 0)) return;
>>
>>    if (!isa<CXXMethodDecl>(D)) {
>> -    S.Diag(Attr.getLoc(),
>> diag::warn_uniqueness_attribute_wrong_decl_type) <<
>> -      Attr.getName();
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
>> +      Attr.getName() << ExpectedMethod;
>>      return;
>>    }
>>
>> @@ -1035,8 +1035,8 @@
>>    if (!checkAttributeNumArgs(S, Attr, 0)) return;
>>
>>    if (!isa<CXXMethodDecl>(D)) {
>> -    S.Diag(Attr.getLoc(),
>> diag::warn_uniqueness_attribute_wrong_decl_type) <<
>> -      Attr.getName();
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
>> +      Attr.getName() << ExpectedMethod;
>>      return;
>>    }
>>
>> @@ -1051,8 +1051,8 @@
>>    if (!checkAttributeNumArgs(S, Attr, 0)) return;
>>
>>    if (!isa<CXXMethodDecl>(D)) {
>> -    S.Diag(Attr.getLoc(),
>> diag::warn_uniqueness_attribute_wrong_decl_type) <<
>> -      Attr.getName();
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
>> +      Attr.getName() << ExpectedMethod;
>>      return;
>>    }
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>



More information about the cfe-commits mailing list