diff options
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/localconsts.h | 38 | ||||
-rw-r--r-- | src/nodes/node.h | 37 | ||||
-rw-r--r-- | src/parsers/generic.cpp | 33 | ||||
-rw-r--r-- | src/parsers/generic.h | 32 | ||||
-rw-r--r-- | src/plugin.cpp | 15 | ||||
-rw-r--r-- | src/plugin.h | 27 |
7 files changed, 181 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 96deabd..7dd9c74 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,14 @@ AUTOMAKE_OPTIONS = subdir-objects -SRC = plugin.cpp +SRC = nodes/node.h \ + parsers/generic.cpp \ + parsers/generic.h \ + plugin.cpp CXX := g++ SHARED_CXXFLAGS = -pipe -ffast-math -Wall -Wextra \ +-std=gnu++1y -Wc++14-compat \ +-Wno-literal-suffix \ -I$(shell $(CC) -print-file-name=plugin)/include SHARED_LDFLAGS = -avoid-version -lgcc_s diff --git a/src/localconsts.h b/src/localconsts.h new file mode 100644 index 0000000..e9708a3 --- /dev/null +++ b/src/localconsts.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#define A_DELETE(func) func = delete +#define A_DELETE_COPY(name) name(const name &) = delete; \ + name &operator=(const name&) = delete; + +#define A_UNUSED __attribute__ ((unused)) +#define A_WARN_UNUSED __attribute__ ((warn_unused_result)) +#define DEPRECATED __attribute__ ((deprecated)) +#define restrict __restrict__ + +#define notfinal + +#define FOR_EACH(type, iter, array) for (type iter = array.begin(), \ + iter##_end = array.end(); iter != iter##_end; ++ iter) + +#define FOR_EACHR(type, iter, array) for (type iter = array.rbegin(), \ + iter##_end = array.rend(); iter != iter##_end; ++ iter) + +#define FOR_EACHP(type, iter, array) for (type iter = array->begin(), \ + iter##_end = array->end(); iter != iter##_end; ++ iter) diff --git a/src/nodes/node.h b/src/nodes/node.h new file mode 100644 index 0000000..c1e327d --- /dev/null +++ b/src/nodes/node.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef NODES_NODE_H +#define NODES_NODE_H + +#include <string> + +struct Node +{ + Node() : + parent(nullptr) + { + } + + Node *parent; + std::string file; + int line; +}; + +#endif // NODES_NODE_H diff --git a/src/parsers/generic.cpp b/src/parsers/generic.cpp new file mode 100644 index 0000000..d5016eb --- /dev/null +++ b/src/parsers/generic.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "parsers/generic.h" + +#include "localconsts.h" + +extern int plugin_is_GPL_compatible; + +namespace Generic +{ + +void parseNodes(tree node) +{ +} + +} diff --git a/src/parsers/generic.h b/src/parsers/generic.h new file mode 100644 index 0000000..f40fdae --- /dev/null +++ b/src/parsers/generic.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef PARSERS_GENERIC_H +#define PARSERS_GENERIC_H + +#include "plugin.h" + +#include <string> + +namespace Generic +{ + void parseNodes(tree node); +} + +#endif // PARSERS_GENERIC_H diff --git a/src/plugin.cpp b/src/plugin.cpp index 837aa7b..597a1fc 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -17,21 +17,22 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gcc-plugin.h" -#include "print-tree.h" -#include "tree.h" +#include "plugin.h" + +#include "parsers/generic.h" + +#include "localconsts.h" int plugin_is_GPL_compatible = 1; static void pre_generic(void *gcc_data, - void *user_data) + void *user_data A_UNUSED) { - tree node = (tree)gcc_data; - printf("pre_generic\n"); + Generic::parseNodes((tree)gcc_data); } int plugin_init (struct plugin_name_args *plugin_info, - struct plugin_gcc_version *version) + struct plugin_gcc_version *version A_UNUSED) { register_callback(plugin_info->base_name, PLUGIN_PRE_GENERICIZE, diff --git a/src/plugin.h b/src/plugin.h new file mode 100644 index 0000000..369cb6c --- /dev/null +++ b/src/plugin.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2015 Andrei Karas + * + * This file is part of AstDumper. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef PLUGIN_H +#define PLUGIN_H + +#include "gcc-plugin.h" +#include "print-tree.h" +#include "tree.h" + +#endif // PLUGIN_H |