[clang-tools-extra] r222751 - clang-tidy: Add override before the first attribute.

Daniel Jasper djasper at google.com
Tue Nov 25 04:32:48 PST 2014


Not sure it adds that much value, but done in r222755.

On Tue, Nov 25, 2014 at 12:38 PM, Alexander Kornienko <alexfh at google.com>
wrote:

>
>
> On Tue, Nov 25, 2014 at 11:45 AM, Daniel Jasper <djasper at google.com>
> wrote:
>
>> Author: djasper
>> Date: Tue Nov 25 04:45:23 2014
>> New Revision: 222751
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=222751&view=rev
>> Log:
>> clang-tidy: Add override before the first attribute.
>>
>> Apparently attributes aren't sorted by source location.
>>
>> Modified:
>>     clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp
>>     clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp?rev=222751&r1=222750&r2=222751&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp (original)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp Tue Nov 25
>> 04:45:23 2014
>> @@ -98,8 +98,10 @@ void UseOverride::check(const MatchFinde
>>      if (Method->hasAttrs()) {
>>        for (const clang::Attr *A : Method->getAttrs()) {
>>          if (!A->isImplicit()) {
>> -          InsertLoc = Sources.getExpansionLoc(A->getLocation());
>> -          break;
>> +          SourceLocation Loc = Sources.getExpansionLoc(A->getLocation());
>> +          if (!InsertLoc.isValid() ||
>> +              Sources.isBeforeInTranslationUnit(Loc, InsertLoc))
>> +            InsertLoc = Loc;
>>          }
>>        }
>>      }
>>
>> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp?rev=222751&r1=222750&r2=222751&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
>> (original)
>> +++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp Tue Nov
>> 25 04:45:23 2014
>> @@ -9,6 +9,7 @@
>>  #define NOT_OVERRIDE
>>
>>  #define MUST_USE_RESULT __attribute__((warn_unused_result))
>> +#define UNUSED __attribute__((unused))
>>
>>  struct MUST_USE_RESULT MustUseResultObject {};
>>
>> @@ -24,7 +25,7 @@ struct Base {
>>
>>    virtual void j() const;
>>    virtual MustUseResultObject k();
>> -  virtual bool l() MUST_USE_RESULT;
>> +  virtual bool l() MUST_USE_RESULT UNUSED;
>>
>
> Maybe add a test with the reversed order of attributes?
>
>
>>
>>    virtual void m();
>>  };
>> @@ -71,9 +72,9 @@ public:
>>    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
>>    // CHECK-FIXES: {{^  MustUseResultObject k\(\) override;}}
>>
>> -  virtual bool l() MUST_USE_RESULT; // Has an explicit attribute
>> +  virtual bool l() MUST_USE_RESULT UNUSED;
>>    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
>> -  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT;}}
>> +  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT UNUSED;}}
>>
>>    virtual void m() override final;
>>    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
>> @@ -117,9 +118,9 @@ public:
>>    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
>>    // CHECK-FIXES: {{^  void j\(\) const final;}}
>>
>> -  virtual bool l() final MUST_USE_RESULT;
>> +  virtual bool l() final MUST_USE_RESULT UNUSED;
>>    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Annotate this
>> -  // CHECK-FIXES: {{^  bool l\(\) final MUST_USE_RESULT;}}
>> +  // CHECK-FIXES: {{^  bool l\(\) final MUST_USE_RESULT UNUSED;}}
>>  };
>>
>>  struct InlineDefinitions : public Base {
>> @@ -152,9 +153,9 @@ public:
>>    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
>>    // CHECK-FIXES: {{^  MustUseResultObject k\(\) override {}}}
>>
>> -  virtual bool l() MUST_USE_RESULT {} // Has an explicit attribute
>> +  virtual bool l() MUST_USE_RESULT UNUSED {}
>>    // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
>> -  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT {}}}
>> +  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT UNUSED {}}}
>>  };
>>
>>  struct Macros : public Base {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> Alexander Kornienko | Software Engineer | alexfh at google.com | Google
> Germany, Munich
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141125/95a4338f/attachment.html>


More information about the cfe-commits mailing list