summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-17 15:07:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-17 20:40:01 +0200
commit476fb5d26ea766ae1aa3238e2967480857872d29 (patch)
tree31ff870497f7e6ca29747f157f687fe9d2557533 /compilerplugins
parent254c20f025e2b1b93751489b82bef3a20231866a (diff)
Revert "simplify sharedplugin PostTraverse calls"
This reverts commit ff55ad1aceb10b900254c8ad3629775b7789d60a, Lubos prefers it the way it was. Change-Id: I68edc21c438b6aa2fc819245dd9a3d590af3a278 Reviewed-on: https://gerrit.libreoffice.org/75790 Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/dbgunhandledexception.cxx8
-rw-r--r--compilerplugins/clang/indentation.cxx14
-rw-r--r--compilerplugins/clang/literaltoboolconversion.cxx7
-rw-r--r--compilerplugins/clang/passparamsbyref.cxx7
-rw-r--r--compilerplugins/clang/sharedvisitor/generator.cxx4
-rw-r--r--compilerplugins/clang/sharedvisitor/sharedvisitor.cxx24
-rw-r--r--compilerplugins/clang/unicodetochar.cxx15
-rw-r--r--compilerplugins/clang/unreffun.cxx5
8 files changed, 53 insertions, 31 deletions
diff --git a/compilerplugins/clang/dbgunhandledexception.cxx b/compilerplugins/clang/dbgunhandledexception.cxx
index 0b0cb41edc2e..81d6126fb3af 100644
--- a/compilerplugins/clang/dbgunhandledexception.cxx
+++ b/compilerplugins/clang/dbgunhandledexception.cxx
@@ -34,7 +34,7 @@ public:
bool VisitCallExpr(CallExpr const* call);
bool TraverseCXXCatchStmt(CXXCatchStmt*);
bool PreTraverseCXXCatchStmt(CXXCatchStmt*);
- void PostTraverseCXXCatchStmt(CXXCatchStmt*);
+ bool PostTraverseCXXCatchStmt(CXXCatchStmt*, bool traverseOk);
private:
std::stack<CXXCatchStmt const*> currCatchStmt;
@@ -56,10 +56,11 @@ bool DbgUnhandledException::PreTraverseCXXCatchStmt(CXXCatchStmt* catchStmt)
return true;
}
-void DbgUnhandledException::PostTraverseCXXCatchStmt(CXXCatchStmt* catchStmt)
+bool DbgUnhandledException::PostTraverseCXXCatchStmt(CXXCatchStmt* catchStmt, bool)
{
assert(currCatchStmt.top() == catchStmt);
currCatchStmt.pop();
+ return true;
}
bool DbgUnhandledException::TraverseCXXCatchStmt(CXXCatchStmt* catchStmt)
@@ -67,7 +68,8 @@ bool DbgUnhandledException::TraverseCXXCatchStmt(CXXCatchStmt* catchStmt)
if (!PreTraverseCXXCatchStmt(catchStmt))
return false;
bool ret = RecursiveASTVisitor::TraverseCXXCatchStmt(catchStmt);
- PostTraverseCXXCatchStmt(catchStmt);
+ if (!PostTraverseCXXCatchStmt(catchStmt, ret))
+ return false;
return ret;
}
diff --git a/compilerplugins/clang/indentation.cxx b/compilerplugins/clang/indentation.cxx
index b544138f9f5d..eaa795e6765a 100644
--- a/compilerplugins/clang/indentation.cxx
+++ b/compilerplugins/clang/indentation.cxx
@@ -65,7 +65,7 @@ public:
bool VisitCompoundStmt(CompoundStmt const*);
bool PreTraverseSwitchStmt(SwitchStmt*);
- void PostTraverseSwitchStmt(SwitchStmt*);
+ bool PostTraverseSwitchStmt(SwitchStmt*, bool);
bool TraverseSwitchStmt(SwitchStmt*);
bool VisitSwitchStmt(SwitchStmt const*);
@@ -79,14 +79,18 @@ bool Indentation::PreTraverseSwitchStmt(SwitchStmt* switchStmt)
return true;
}
-void Indentation::PostTraverseSwitchStmt(SwitchStmt*) { switchStmtBodies.pop_back(); }
+bool Indentation::PostTraverseSwitchStmt(SwitchStmt*, bool)
+{
+ switchStmtBodies.pop_back();
+ return true;
+}
bool Indentation::TraverseSwitchStmt(SwitchStmt* switchStmt)
{
PreTraverseSwitchStmt(switchStmt);
- FilteringPlugin::TraverseSwitchStmt(switchStmt);
- PostTraverseSwitchStmt(switchStmt);
- return true;
+ auto ret = FilteringPlugin::TraverseSwitchStmt(switchStmt);
+ PostTraverseSwitchStmt(switchStmt, ret);
+ return ret;
}
bool Indentation::VisitCompoundStmt(CompoundStmt const* compoundStmt)
diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx
index 9e9b0b391523..6bfef41b6cc0 100644
--- a/compilerplugins/clang/literaltoboolconversion.cxx
+++ b/compilerplugins/clang/literaltoboolconversion.cxx
@@ -31,7 +31,7 @@ public:
bool VisitImplicitCastExpr(ImplicitCastExpr const * expr);
bool PreTraverseLinkageSpecDecl(LinkageSpecDecl * decl);
- void PostTraverseLinkageSpecDecl(LinkageSpecDecl * decl);
+ bool PostTraverseLinkageSpecDecl(LinkageSpecDecl * decl, bool);
bool TraverseLinkageSpecDecl(LinkageSpecDecl * decl);
private:
@@ -64,15 +64,16 @@ bool LiteralToBoolConversion::PreTraverseLinkageSpecDecl(LinkageSpecDecl *) {
return true;
}
-void LiteralToBoolConversion::PostTraverseLinkageSpecDecl(LinkageSpecDecl *) {
+bool LiteralToBoolConversion::PostTraverseLinkageSpecDecl(LinkageSpecDecl *, bool) {
assert(externCContexts_ != 0);
--externCContexts_;
+ return true;
}
bool LiteralToBoolConversion::TraverseLinkageSpecDecl(LinkageSpecDecl * decl) {
PreTraverseLinkageSpecDecl(decl);
bool ret = RecursiveASTVisitor::TraverseLinkageSpecDecl(decl);
- PostTraverseLinkageSpecDecl(decl);
+ PostTraverseLinkageSpecDecl(decl, ret);
return ret;
}
diff --git a/compilerplugins/clang/passparamsbyref.cxx b/compilerplugins/clang/passparamsbyref.cxx
index af28388c4e79..7de7133f3aed 100644
--- a/compilerplugins/clang/passparamsbyref.cxx
+++ b/compilerplugins/clang/passparamsbyref.cxx
@@ -44,7 +44,7 @@ public:
// LValueToRValue ImplicitCastExprs when determining whether a param is
// bound to a reference:
bool PreTraverseFunctionDecl(FunctionDecl *);
- void PostTraverseFunctionDecl(FunctionDecl *);
+ bool PostTraverseFunctionDecl(FunctionDecl *, bool);
bool TraverseFunctionDecl(FunctionDecl *);
bool PreTraverseImplicitCastExpr(ImplicitCastExpr *);
bool TraverseImplicitCastExpr(ImplicitCastExpr *);
@@ -83,7 +83,7 @@ bool PassParamsByRef::PreTraverseFunctionDecl(FunctionDecl* functionDecl)
return true;
}
-void PassParamsByRef::PostTraverseFunctionDecl(FunctionDecl* functionDecl)
+bool PassParamsByRef::PostTraverseFunctionDecl(FunctionDecl* functionDecl, bool)
{
mbInsideFunctionDecl = false;
@@ -132,6 +132,7 @@ void PassParamsByRef::PostTraverseFunctionDecl(FunctionDecl* functionDecl)
<< can->getSourceRange();
}
}
+ return true;
}
bool PassParamsByRef::TraverseFunctionDecl(FunctionDecl* functionDecl)
@@ -140,7 +141,7 @@ bool PassParamsByRef::TraverseFunctionDecl(FunctionDecl* functionDecl)
if (PreTraverseFunctionDecl(functionDecl))
{
ret = RecursiveASTVisitor::TraverseFunctionDecl(functionDecl);
- PostTraverseFunctionDecl(functionDecl);
+ PostTraverseFunctionDecl(functionDecl, ret);
}
return ret;
}
diff --git a/compilerplugins/clang/sharedvisitor/generator.cxx b/compilerplugins/clang/sharedvisitor/generator.cxx
index 3eeb74b26c77..b12939516d16 100644
--- a/compilerplugins/clang/sharedvisitor/generator.cxx
+++ b/compilerplugins/clang/sharedvisitor/generator.cxx
@@ -318,7 +318,9 @@ void generateVisitor( PluginType type )
output << " if( " << plugin.variableName << " != nullptr ";
output << ")\n";
output << " {\n";
- output << " " << plugin.variableName << "->Post" << traverse.name << "( arg );\n";
+ output << " if( !" << plugin.variableName << "->Post" << traverse.name << "( arg, ret ))\n";
+ // This will disable the plugin for the rest of the run.
+ output << " save" << plugin.className << " = nullptr;\n";
output << " }\n";
}
output << " " << plugin.variableName << " = save" << plugin.className << ";\n";
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index 33db9d878021..1552f2661f32 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -1246,7 +1246,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr( arg );
if( unicodeToChar != nullptr )
{
- unicodeToChar->PostTraverseCStyleCastExpr( arg );
+ if( !unicodeToChar->PostTraverseCStyleCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
}
unicodeToChar = saveUnicodeToChar;
return ret;
@@ -1274,7 +1275,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseCXXCatchStmt( arg );
if( dbgUnhandledException != nullptr )
{
- dbgUnhandledException->PostTraverseCXXCatchStmt( arg );
+ if( !dbgUnhandledException->PostTraverseCXXCatchStmt( arg, ret ))
+ saveDbgUnhandledException = nullptr;
}
dbgUnhandledException = saveDbgUnhandledException;
return ret;
@@ -1290,7 +1292,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr( arg );
if( unicodeToChar != nullptr )
{
- unicodeToChar->PostTraverseCXXFunctionalCastExpr( arg );
+ if( !unicodeToChar->PostTraverseCXXFunctionalCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
}
unicodeToChar = saveUnicodeToChar;
return ret;
@@ -1306,7 +1309,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr( arg );
if( unicodeToChar != nullptr )
{
- unicodeToChar->PostTraverseCXXStaticCastExpr( arg );
+ if( !unicodeToChar->PostTraverseCXXStaticCastExpr( arg, ret ))
+ saveUnicodeToChar = nullptr;
}
unicodeToChar = saveUnicodeToChar;
return ret;
@@ -1322,7 +1326,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseFriendDecl( arg );
if( unrefFun != nullptr )
{
- unrefFun->PostTraverseFriendDecl( arg );
+ if( !unrefFun->PostTraverseFriendDecl( arg, ret ))
+ saveUnrefFun = nullptr;
}
unrefFun = saveUnrefFun;
return ret;
@@ -1338,7 +1343,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseFunctionDecl( arg );
if( passParamsByRef != nullptr )
{
- passParamsByRef->PostTraverseFunctionDecl( arg );
+ if( !passParamsByRef->PostTraverseFunctionDecl( arg, ret ))
+ savePassParamsByRef = nullptr;
}
passParamsByRef = savePassParamsByRef;
return ret;
@@ -1378,7 +1384,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseLinkageSpecDecl( arg );
if( literalToBoolConversion != nullptr )
{
- literalToBoolConversion->PostTraverseLinkageSpecDecl( arg );
+ if( !literalToBoolConversion->PostTraverseLinkageSpecDecl( arg, ret ))
+ saveLiteralToBoolConversion = nullptr;
}
literalToBoolConversion = saveLiteralToBoolConversion;
return ret;
@@ -1406,7 +1413,8 @@ public:
bool ret = RecursiveASTVisitor::TraverseSwitchStmt( arg );
if( indentation != nullptr )
{
- indentation->PostTraverseSwitchStmt( arg );
+ if( !indentation->PostTraverseSwitchStmt( arg, ret ))
+ saveIndentation = nullptr;
}
indentation = saveIndentation;
return ret;
diff --git a/compilerplugins/clang/unicodetochar.cxx b/compilerplugins/clang/unicodetochar.cxx
index 17f4795495ad..3599d3081a9f 100644
--- a/compilerplugins/clang/unicodetochar.cxx
+++ b/compilerplugins/clang/unicodetochar.cxx
@@ -30,13 +30,14 @@ public:
subExprs_.push(expr->getSubExpr());
return true;
}
- void PostTraverseCStyleCastExpr(CStyleCastExpr *) {
+ bool PostTraverseCStyleCastExpr(CStyleCastExpr *, bool ) {
subExprs_.pop();
+ return true;
}
bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
PreTraverseCStyleCastExpr(expr);
bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
- PostTraverseCStyleCastExpr(expr);
+ PostTraverseCStyleCastExpr(expr, ret);
return ret;
}
@@ -44,13 +45,14 @@ public:
subExprs_.push(expr->getSubExpr());
return true;
}
- void PostTraverseCXXStaticCastExpr(CXXStaticCastExpr *) {
+ bool PostTraverseCXXStaticCastExpr(CXXStaticCastExpr *, bool) {
subExprs_.pop();
+ return true;
}
bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
PreTraverseCXXStaticCastExpr(expr);
bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
- PostTraverseCXXStaticCastExpr(expr);
+ PostTraverseCXXStaticCastExpr(expr, ret);
return ret;
}
@@ -58,13 +60,14 @@ public:
subExprs_.push(expr->getSubExpr());
return true;
}
- void PostTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr *) {
+ bool PostTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr *, bool) {
subExprs_.pop();
+ return true;
}
bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
PreTraverseCXXFunctionalCastExpr(expr);
bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
- PostTraverseCXXFunctionalCastExpr(expr);
+ PostTraverseCXXFunctionalCastExpr(expr, ret);
return ret;
}
diff --git a/compilerplugins/clang/unreffun.cxx b/compilerplugins/clang/unreffun.cxx
index ab0e01b70ecb..353eee5f0b31 100644
--- a/compilerplugins/clang/unreffun.cxx
+++ b/compilerplugins/clang/unreffun.cxx
@@ -57,13 +57,14 @@ public:
friendFunction.push( dyn_cast_or_null<FunctionDecl>(decl->getFriendDecl()));
return true;
}
- void PostTraverseFriendDecl(FriendDecl *) {
+ bool PostTraverseFriendDecl(FriendDecl *, bool ) {
friendFunction.pop();
+ return true;
}
bool TraverseFriendDecl(FriendDecl * decl) {
PreTraverseFriendDecl(decl);
auto const ret = RecursiveASTVisitor::TraverseFriendDecl(decl);
- PostTraverseFriendDecl(decl);
+ PostTraverseFriendDecl(decl, ret);
return ret;
}