summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-08 17:45:16 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-08 17:45:16 +0300
commit0ad1e8efbd7e4b467d93568136e7beafe1e23fb5 (patch)
treea148bb981a616eff70aeec5c162f3368f798a797
parent2abca5bd038805c23d8a84b73cbe1b9410442841 (diff)
downloadparanucker-0ad1e8efbd7e4b467d93568136e7beafe1e23fb5.tar.gz
paranucker-0ad1e8efbd7e4b467d93568136e7beafe1e23fb5.tar.bz2
paranucker-0ad1e8efbd7e4b467d93568136e7beafe1e23fb5.tar.xz
paranucker-0ad1e8efbd7e4b467d93568136e7beafe1e23fb5.zip
Add plugin parameters *-specialdump=filename for dump only this file AST tree.
-rw-r--r--src/command.h3
-rw-r--r--src/parsers/decl/function_decl.cpp17
-rw-r--r--src/plugin.cpp5
3 files changed, 25 insertions, 0 deletions
diff --git a/src/command.h b/src/command.h
index 7fb7386..1ba0e2b 100644
--- a/src/command.h
+++ b/src/command.h
@@ -23,6 +23,8 @@
#define checkCommand(val) ((command & Command::val) == Command::val)
#define disableCommand(val) command = static_cast<Command>(static_cast<int>( \
command | Command::val) ^ static_cast<int>(Command::val))
+#define enableCommand(val) command = static_cast<Command>(static_cast<int>( \
+ command | Command::val))
enum Command : int
{
@@ -38,5 +40,6 @@ enum Command : int
};
extern Command command;
+extern std::string dumpFile;
#endif // COMMAND_H
diff --git a/src/parsers/decl/function_decl.cpp b/src/parsers/decl/function_decl.cpp
index f8a5579..3bd774d 100644
--- a/src/parsers/decl/function_decl.cpp
+++ b/src/parsers/decl/function_decl.cpp
@@ -19,6 +19,8 @@
#include "includes/parserincludes.h"
+#include "command.h"
+
parserDefine(FunctionDecl);
#include "parsers/base/decl.h"
@@ -35,6 +37,15 @@ void parseFunctionDeclNode(FunctionDeclNode *node)
fillLocation(node);
fillDeclLabel(node);
+ bool spoofCommand(false);
+ Command oldCommand = command;
+ if (!node->parent && !dumpFile.empty() && node->file == dumpFile)
+ {
+ spoofCommand = true;
+ enableCommand(Dump);
+ Log::log("start dump\n");
+ }
+
Log::dump(node);
fillDeclAutoGenerated(node);
@@ -79,6 +90,12 @@ void parseFunctionDeclNode(FunctionDeclNode *node)
node,
DECL_FUNCTION_SPECIFIC_OPTIMIZATION(node->gccNode),
"optiomisations");
+
+ if (spoofCommand)
+ {
+ command = oldCommand;
+ Log::log("end dump\n");
+ }
}
}
diff --git a/src/plugin.cpp b/src/plugin.cpp
index a4f7b66..27b6d18 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -39,6 +39,7 @@ struct Node;
Command command = Command::DetectNullPointers;
std::map<tree, Node*> foundNodesMap;
std::map<Node*, Node*> updateNodesMap;
+std::string dumpFile;
// copy/paste from plugin.h look like again guard header issue.
extern void register_attribute (const struct attribute_spec *attr);
@@ -139,6 +140,10 @@ int plugin_init (struct plugin_name_args *plugin_info,
return 0;
}
}
+ if (!strcmp (argv[f].key, "specialdump"))
+ {
+ dumpFile = argv[f].value;
+ }
}
register_callback(plugin_info->base_name,