diff options
author | Noel <noelgrandin@gmail.com> | 2020-11-02 15:37:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-02 17:39:10 +0100 |
commit | 28be7b98070b7475cc675e76f075c941133cb790 (patch) | |
tree | 3237d5ca81cd7cc835a1200f5ae41e1008174b13 /compilerplugins | |
parent | 3940cf7d716f3e469f47d3c831a799e58edf2eb8 (diff) |
create common macro and method for logging unknown attributes
instead of repeating the code everywhere
Change-Id: Idb94054b392ed256e64259cdb17d1522bf3c52b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105184
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/sallogareas.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index e0d6d160101f..bb256c6d7431 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -75,18 +75,23 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call ) if( ignoreLocation( call )) return true; const FunctionDecl* func = call->getDirectCallee(); - if( !func ) + if( !func || !func->getIdentifier()) return true; - if( !( func->getNumParams() == 5 && func->getIdentifier() != NULL - && ( func->getName() == "sal_detail_log" || func->getName() == "log" || func->getName() == "DbgUnhandledException")) ) + auto name = func->getName(); + if( !( name == "sal_detail_log" || name == "log" || name == "DbgUnhandledException" || name == "XMLOFF_WARN_UNKNOWN") ) return true; auto tc = loplugin::DeclCheck(func); enum class LogCallKind { Sal, DbgUnhandledException}; LogCallKind kind; int areaArgIndex; - if( tc.Function("sal_detail_log") || tc.Function("log").Namespace("detail").Namespace("sal").GlobalNamespace() ) + if( tc.Function("XMLOFF_WARN_UNKNOWN") ) + { + kind = LogCallKind::Sal; // fine + areaArgIndex = 0; + } + else if( tc.Function("sal_detail_log") || tc.Function("log").Namespace("detail").Namespace("sal").GlobalNamespace() ) { kind = LogCallKind::Sal; // fine areaArgIndex = 1; @@ -121,6 +126,8 @@ bool SalLogAreas::VisitCallExpr( const CallExpr* call ) if( loplugin::DeclCheck(inFunction).Function("log").Namespace("detail").Namespace("sal").GlobalNamespace() || loplugin::DeclCheck(inFunction).Function("sal_detail_logFormat").GlobalNamespace() ) return true; // These functions only forward to sal_detail_log, so ok. + if( loplugin::DeclCheck(inFunction).Function("XMLOFF_WARN_UNKNOWN").GlobalNamespace()) + return true; if( call->getArg( areaArgIndex )->isNullPointerConstant( compiler.getASTContext(), Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull ) { // If the area argument is a null pointer, that is allowed only for SAL_DEBUG. |