diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-03-27 08:44:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-03-27 10:57:46 +0100 |
commit | be0655364cf3fff09195d6ce9d50e5b60b98ff18 (patch) | |
tree | 2cf78d3f4f5ed29ee9835f535e4fb9e94e4d8029 /compilerplugins | |
parent | 7047f46695689564b1a69679e3a4e5a8c20aa3a3 (diff) |
Improve loplugin:typedefparam error reporting
Change-Id: I2ed4c20ab909b79fca794fb04259018fbfcb1db5
Reviewed-on: https://gerrit.libreoffice.org/69787
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/test/typedefparam.cxx | 4 | ||||
-rw-r--r-- | compilerplugins/clang/typedefparam.cxx | 13 |
2 files changed, 8 insertions, 9 deletions
diff --git a/compilerplugins/clang/test/typedefparam.cxx b/compilerplugins/clang/test/typedefparam.cxx index ed2f8d7017a3..63609347dda8 100644 --- a/compilerplugins/clang/test/typedefparam.cxx +++ b/compilerplugins/clang/test/typedefparam.cxx @@ -18,7 +18,7 @@ class Foo }; void Foo::bar(sal_uLong) -// expected-error@-1 {{function param 0 at definition site does not match function param at declaration site, 'sal_uLong' (aka 'unsigned long') vs 'sal_uIntPtr' (aka 'unsigned long') [loplugin:typedefparam]}} +// expected-error@-1 {{function param 1 at definition site does not match function param at declaration site, 'sal_uLong' (aka 'unsigned long') vs 'sal_uIntPtr' (aka 'unsigned long') [loplugin:typedefparam]}} { } @@ -73,7 +73,7 @@ struct Struct2 : public Struct1 virtual sal_uLong foo1() override; // expected-error@-1 {{method return type does not match overridden method 'sal_uLong' (aka 'unsigned long') vs 'sal_uIntPtr' (aka 'unsigned long') [loplugin:typedefparam]}} virtual void foo2(sal_uLong) override; - // expected-error@-1 {{method param 0 does not match overridden method param 'sal_uLong' (aka 'unsigned long') vs 'sal_uIntPtr' (aka 'unsigned long') [loplugin:typedefparam]}} + // expected-error@-1 {{method param 1 does not match overridden method param 'sal_uLong' (aka 'unsigned long') vs 'sal_uIntPtr' (aka 'unsigned long') [loplugin:typedefparam]}} }; }; diff --git a/compilerplugins/clang/typedefparam.cxx b/compilerplugins/clang/typedefparam.cxx index e4ed07da4e13..fe6ebba78f0f 100644 --- a/compilerplugins/clang/typedefparam.cxx +++ b/compilerplugins/clang/typedefparam.cxx @@ -56,11 +56,10 @@ bool TypedefParam::VisitFunctionDecl(FunctionDecl const* functionDecl) report(DiagnosticsEngine::Warning, "function param %0 at definition site does not match function param at " "declaration site, %1 vs %2", - compat::getBeginLoc(functionDecl)) - << i << thisParam->getType() << canonicalParam->getType() + thisParam->getLocation()) + << (i + 1) << thisParam->getType() << canonicalParam->getType() << functionDecl->getSourceRange(); - report(DiagnosticsEngine::Note, "declaration site here", - compat::getBeginLoc(canonicalDecl)) + report(DiagnosticsEngine::Note, "declaration site here", canonicalParam->getLocation()) << canonicalDecl->getSourceRange(); } } @@ -112,11 +111,11 @@ bool TypedefParam::VisitCXXMethodDecl(CXXMethodDecl const* methodDecl) report(DiagnosticsEngine::Warning, "method param %0 does not match overridden method param " "%1 vs %2", - compat::getBeginLoc(methodDecl)) - << i << parmVarDecl->getType() << superParmVarDecl->getType() + parmVarDecl->getLocation()) + << (i + 1) << parmVarDecl->getType() << superParmVarDecl->getType() << methodDecl->getSourceRange(); report(DiagnosticsEngine::Note, "super-class method here", - compat::getBeginLoc(superMethodDecl)) + superParmVarDecl->getLocation()) << superMethodDecl->getSourceRange(); } ++i; |