summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-05-12 13:30:32 +0200
committerNoel Grandin <noel@peralex.com>2015-05-13 12:21:19 +0200
commit274c836cf82ce3929141e03a28cfb840f4c724cb (patch)
treeed3c87ed3ac37ba67187c8977ee24746c9626b70
parentbe316c62086bd59b097f1db13034752833c3febe (diff)
check for static fields that needs to be wrapped in VclPtr
Change-Id: I6135cfd9aa70f90d58150733b6b48525e5c347c8
-rw-r--r--compilerplugins/clang/vclwidgets.cxx33
1 files changed, 19 insertions, 14 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index a09f8dbbd73d..22d722cd7417 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -228,23 +228,10 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
if (ignoreLocation(pVarDecl)) {
return true;
}
- const RecordType *recordType = pVarDecl->getType()->getAs<RecordType>();
- if (recordType == nullptr) {
- return true;
- }
- const CXXRecordDecl *recordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl());
- if (recordDecl == nullptr) {
+ if ( isa<ParmVarDecl>(pVarDecl) || pVarDecl->isLocalVarDecl() ) {
return true;
}
- // check if this field is derived from Window
- if (isDerivedFromWindow(recordDecl)) {
- report(
- DiagnosticsEngine::Warning,
- "OutputDevice subclass allocated on stack, should be allocated via VclPtr or via *.",
- pVarDecl->getLocation())
- << pVarDecl->getSourceRange();
- }
if ( !startsWith(pVarDecl->getType().getAsString(), "std::vector<vcl::Window *>")
&& !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, Size>")
&& !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, class Size>")
@@ -270,6 +257,24 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
"OutputDevice subclass should be wrapped in VclPtr. " + pVarDecl->getType().getAsString(),
pVarDecl->getLocation())
<< pVarDecl->getSourceRange();
+ return true;
+ }
+
+ const RecordType *recordType = pVarDecl->getType()->getAs<RecordType>();
+ if (recordType == nullptr) {
+ return true;
+ }
+ const CXXRecordDecl *recordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl());
+ if (recordDecl == nullptr) {
+ return true;
+ }
+ // check if this field is derived from Window
+ if (isDerivedFromWindow(recordDecl)) {
+ report(
+ DiagnosticsEngine::Warning,
+ "OutputDevice subclass allocated on stack, should be allocated via VclPtr or via *.",
+ pVarDecl->getLocation())
+ << pVarDecl->getSourceRange();
}
return true;
}