Kaydet (Commit) 274c836c authored tarafından Noel Grandin's avatar Noel Grandin

check for static fields that needs to be wrapped in VclPtr

Change-Id: I6135cfd9aa70f90d58150733b6b48525e5c347c8
üst be316c62
...@@ -228,23 +228,10 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) { ...@@ -228,23 +228,10 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
if (ignoreLocation(pVarDecl)) { if (ignoreLocation(pVarDecl)) {
return true; return true;
} }
const RecordType *recordType = pVarDecl->getType()->getAs<RecordType>(); if ( isa<ParmVarDecl>(pVarDecl) || pVarDecl->isLocalVarDecl() ) {
if (recordType == nullptr) {
return true;
}
const CXXRecordDecl *recordDecl = dyn_cast<CXXRecordDecl>(recordType->getDecl());
if (recordDecl == nullptr) {
return true; 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 *>") 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 *, Size>")
&& !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, class Size>") && !startsWith(pVarDecl->getType().getAsString(), "std::map<vcl::Window *, class Size>")
...@@ -270,6 +257,24 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) { ...@@ -270,6 +257,24 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
"OutputDevice subclass should be wrapped in VclPtr. " + pVarDecl->getType().getAsString(), "OutputDevice subclass should be wrapped in VclPtr. " + pVarDecl->getType().getAsString(),
pVarDecl->getLocation()) pVarDecl->getLocation())
<< pVarDecl->getSourceRange(); << 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; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment