summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/oncevar.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-21 15:01:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-22 08:46:34 +0200
commit0281b187752a6da62b801f4a4acf5cf74c2c31f2 (patch)
tree1a9dbdf2d44009aec94acc28b4b8716e4afe5093 /compilerplugins/clang/oncevar.cxx
parent827aa375ddc89cbc468267cbf94a8cea1ef4215c (diff)
make oncevar plugin ignore methods with #ifdef-ery
Change-Id: I8a9cf2c4b81b95bf654f7e90306328d72e3d3408 Reviewed-on: https://gerrit.libreoffice.org/40280 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/oncevar.cxx')
-rw-r--r--compilerplugins/clang/oncevar.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/compilerplugins/clang/oncevar.cxx b/compilerplugins/clang/oncevar.cxx
index 18105584bbb8..00ecb1b6003a 100644
--- a/compilerplugins/clang/oncevar.cxx
+++ b/compilerplugins/clang/oncevar.cxx
@@ -242,6 +242,7 @@ public:
bool VisitDeclRefExpr( const DeclRefExpr* );
bool VisitVarDecl( const VarDecl* );
+ bool TraverseFunctionDecl( FunctionDecl* functionDecl );
private:
std::unordered_set<VarDecl const *> maVarDeclSet;
@@ -287,6 +288,16 @@ private:
}
};
+bool OnceVar::TraverseFunctionDecl( FunctionDecl* functionDecl )
+{
+ // Ignore functions that contains #ifdef-ery, can be quite tricky
+ // to make useful changes when this plugin fires in such functions
+ if (containsPreprocessingConditionalInclusion(
+ functionDecl->getSourceRange()))
+ return true;
+ return RecursiveASTVisitor::TraverseFunctionDecl(functionDecl);
+}
+
bool OnceVar::VisitVarDecl( const VarDecl* varDecl )
{
if (ignoreLocation(varDecl)) {