summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/conststringvar.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/conststringvar.cxx')
-rw-r--r--compilerplugins/clang/conststringvar.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/compilerplugins/clang/conststringvar.cxx b/compilerplugins/clang/conststringvar.cxx
index a6d348a8d710..f11341676dd6 100644
--- a/compilerplugins/clang/conststringvar.cxx
+++ b/compilerplugins/clang/conststringvar.cxx
@@ -65,8 +65,23 @@ public:
}
bool TraverseImplicitCastExpr(ImplicitCastExpr * expr) {
+ bool match;
+ switch (expr->getCastKind()) {
+ case CK_NoOp:
+ // OString CharPtrDetector ctor:
+ match = bool(
+ loplugin::TypeCheck(expr->getType()).Const().Pointer().Const()
+ .Char());
+ break;
+ case CK_LValueToRValue:
+ match = true;
+ break;
+ default:
+ match = false;
+ break;
+ }
bool pushed = false;
- if (expr->getCastKind() == CK_LValueToRValue) {
+ if (match) {
if (auto dr = dyn_cast<DeclRefExpr>(
expr->getSubExpr()->IgnoreParenImpCasts()))
{