summaryrefslogtreecommitdiffstats
path: root/examples/PrintFunctionNames
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
committerdim <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
commit36c49e3f258dced101949edabd72e9bc3f1dedc4 (patch)
tree0bbe07708f7571f8b5291f6d7b96c102b7c99dee /examples/PrintFunctionNames
parentfc84956ac8b7cd244ef30e7a4d4d38a58dec5904 (diff)
downloadFreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.zip
FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.tar.gz
Vendor import of clang r114020 (from the release_28 branch):
http://llvm.org/svn/llvm-project/cfe/branches/release_28@114020 Approved by: rpaulo (mentor)
Diffstat (limited to 'examples/PrintFunctionNames')
-rw-r--r--examples/PrintFunctionNames/Makefile11
-rw-r--r--examples/PrintFunctionNames/PrintFunctionNames.cpp22
-rw-r--r--examples/PrintFunctionNames/PrintFunctionNames.exports1
3 files changed, 26 insertions, 8 deletions
diff --git a/examples/PrintFunctionNames/Makefile b/examples/PrintFunctionNames/Makefile
index 0ff5189..125ac48 100644
--- a/examples/PrintFunctionNames/Makefile
+++ b/examples/PrintFunctionNames/Makefile
@@ -10,10 +10,15 @@
CLANG_LEVEL := ../..
LIBRARYNAME = PrintFunctionNames
+# If we don't need RTTI or EH, there's no reason to export anything
+# from the plugin.
+ifneq ($(REQUIRES_RTTI), 1)
+ifneq ($(REQUIRES_EH), 1)
+EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/PrintFunctionNames.exports
+endif
+endif
+
LINK_LIBS_IN_SHARED = 1
SHARED_LIBRARY = 1
-USEDLIBS = clangIndex.a clangFrontend.a clangDriver.a clangSema.a \
- clangAnalysis.a clangAST.a clangParse.a clangLex.a clangBasic.a
-
include $(CLANG_LEVEL)/Makefile
diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp
index 397cf84..cc138f5 100644
--- a/examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -15,6 +15,7 @@
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/AST.h"
+#include "clang/Frontend/CompilerInstance.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
@@ -29,7 +30,7 @@ public:
llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
}
}
-};
+};
class PrintFunctionNamesAction : public PluginASTAction {
protected:
@@ -37,15 +38,26 @@ protected:
return new PrintFunctionsConsumer();
}
- bool ParseArgs(const std::vector<std::string>& args) {
- for (unsigned i=0; i<args.size(); ++i)
+ bool ParseArgs(const CompilerInstance &CI,
+ const std::vector<std::string>& args) {
+ for (unsigned i = 0, e = args.size(); i != e; ++i) {
llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+ // Example error handling.
+ if (args[i] == "-an-error") {
+ Diagnostic &D = CI.getDiagnostics();
+ unsigned DiagID = D.getCustomDiagID(
+ Diagnostic::Error, "invalid argument '" + args[i] + "'");
+ D.Report(DiagID);
+ return false;
+ }
+ }
if (args.size() && args[0] == "help")
PrintHelp(llvm::errs());
return true;
}
- void PrintHelp(llvm::raw_ostream& ros) {
+ void PrintHelp(llvm::raw_ostream& ros) {
ros << "Help for PrintFunctionNames plugin goes here\n";
}
@@ -53,5 +65,5 @@ protected:
}
-FrontendPluginRegistry::Add<PrintFunctionNamesAction>
+static FrontendPluginRegistry::Add<PrintFunctionNamesAction>
X("print-fns", "print function names");
diff --git a/examples/PrintFunctionNames/PrintFunctionNames.exports b/examples/PrintFunctionNames/PrintFunctionNames.exports
new file mode 100644
index 0000000..0ff590d
--- /dev/null
+++ b/examples/PrintFunctionNames/PrintFunctionNames.exports
@@ -0,0 +1 @@
+_ZN4llvm8Registry*
OpenPOWER on IntegriCloud