diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-09-03 09:33:39 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-09-03 09:34:00 +0200 |
commit | 37a6fdf890d49a20a57aeb41021dc0ff663cc628 (patch) | |
tree | ddc85350aacd58ced61263b4e34ed585e63c2933 /compilerplugins | |
parent | convert Link<> to typed (diff) | |
download | core-37a6fdf890d49a20a57aeb41021dc0ff663cc628.tar.gz core-37a6fdf890d49a20a57aeb41021dc0ff663cc628.zip |
loplugin:stringconstant also for cases using char const v[] = "..."
Change-Id: Iba38686620624178a7be39d703389402bbcea4cb
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/stringconstant.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 5c675a8ae022..2688542fcda5 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -781,6 +781,16 @@ bool StringConstant::isStringConstant( { return false; } + DeclRefExpr const * dre = dyn_cast<DeclRefExpr>(expr); + if (dre != nullptr) { + VarDecl const * var = dyn_cast<VarDecl>(dre->getDecl()); + if (var != nullptr) { + Expr const * init = var->getAnyInitializer(); + if (init != nullptr) { + expr = init->IgnoreParenImpCasts(); + } + } + } StringLiteral const * lit = dyn_cast<StringLiteral>(expr); if (lit != nullptr) { if (!lit->isAscii()) { |