diff options
| author | Alp Toker <alp@nuanti.com> | 2014-01-26 05:08:07 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2014-01-26 05:08:07 +0000 |
| commit | 4af8fa9ae42eea771f56f45658d3c182d2c5f4f6 (patch) | |
| tree | 0dd68e11e55b16a0035ff1838a0c773f24de4299 | |
| parent | 42aa21222d37406e22d48587ca4dc65ce9948b71 (diff) | |
| download | bcm5719-llvm-4af8fa9ae42eea771f56f45658d3c182d2c5f4f6.tar.gz bcm5719-llvm-4af8fa9ae42eea771f56f45658d3c182d2c5f4f6.zip | |
Remove buggy example code from the documentation
Instead point readers to the latest, correct example code in SVN until we find
a way to automatically include example sources into the documentation (or until
someone steps up to maintain these actively).
This ensures that the examples are up-to-date, buildable, and most of all that
readers don't pick up incorrect usage.
llvm-svn: 200125
| -rw-r--r-- | clang/docs/ClangPlugins.rst | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/clang/docs/ClangPlugins.rst b/clang/docs/ClangPlugins.rst index 7c5c65ccf1d..9a5bc142130 100644 --- a/clang/docs/ClangPlugins.rst +++ b/clang/docs/ClangPlugins.rst @@ -47,70 +47,10 @@ Putting it all together ======================= Let's look at an example plugin that prints top-level function names. This -example is also checked into the clang repository; please also take a look at -the latest `checked in version of PrintFunctionNames.cpp +example is checked into the clang repository; please take a look at +the `latest version of PrintFunctionNames.cpp <http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp?view=markup>`_. -.. code-block:: c++ - - #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; - - namespace { - - class PrintFunctionsConsumer : public ASTConsumer { - public: - virtual bool HandleTopLevelDecl(DeclGroupRef DG) { - for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) { - const Decl *D = *i; - if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) - llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n"; - } - - return true; - } - }; - - class PrintFunctionNamesAction : public PluginASTAction { - protected: - ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) { - return new PrintFunctionsConsumer(); - } - - 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") { - DiagnosticsEngine &D = CI.getDiagnostics(); - unsigned DiagID = D.getCustomDiagID( - DiagnosticsEngine::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) { - ros << "Help for PrintFunctionNames plugin goes here\n"; - } - - }; - - } - - static FrontendPluginRegistry::Add<PrintFunctionNamesAction> - X("print-fns", "print function names"); - Running the plugin ================== |

