clang-tidy: Add override before the first attribute.

Apparently attributes aren't sorted by source location.

llvm-svn: 222751
This commit is contained in:
Daniel Jasper 2014-11-25 10:45:23 +00:00
parent 1cbac4e94f
commit 4525be4ebc
2 changed files with 12 additions and 9 deletions

View File

@ -98,8 +98,10 @@ void UseOverride::check(const MatchFinder::MatchResult &Result) {
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;
}
}
}

View File

@ -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;
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 {