diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 03:23:45 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-02 03:23:45 +0000 |
commit | 7b55668db7618334cc40011d3c1e128524d89462 (patch) | |
tree | 96291a6941a167a8e7a1ed721a88ab164a8eefa8 /include/clang | |
parent | daab7b1016f0a82fefa4f7be6e63c57c06b19ffc (diff) |
Add ASTUnit::LoadFromCommandLine, which creates an ASTUnit out of a list of
(clang/driver) command line arguments (including the source file).
- The arguments are expected to include the source file.
- The idea is that even though this is a somewhat odd API, its the form which
many tools can most easily use (for example, by interposing with the compiler).
Also, switch index-test's -ast-from-source to use this entry point, and provide
a -arg command line argument which can be used to test that the command line
arguments are handled correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/DiagnosticFrontendKinds.td | 8 | ||||
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 24 |
2 files changed, 30 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index cbc287c58c..9dbd9cfa21 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -15,8 +15,8 @@ def err_fe_error_reading_stdin : Error<"error reading stdin">; def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal; def err_fe_invalid_ast_file : Error<"invalid AST file: '%0'">, DefaultFatal; def err_fe_invalid_ast_action : Error<"invalid action for AST input">, DefaultFatal; -def err_fe_invalid_code_complete_file - : Error<"cannot locate code-completion file %0">, DefaultFatal; +def err_fe_invalid_code_complete_file : Error< + "cannot locate code-completion file %0">, DefaultFatal; def err_fe_stdout_binary : Error<"unable to change standard output to binary">, DefaultFatal; def err_fe_dependency_file_requires_MT : Error< @@ -29,6 +29,10 @@ def err_fe_unable_to_find_fixit_file : Error< "FIX-IT could not find file '%0'">; def err_fe_invalid_plugin_name : Error< "unable to find plugin '%0'">; +def err_fe_expected_compiler_job : Error< + "unable to handle compilation, expected exactly one compiler job in '%0'">; +def err_fe_expected_clang_command : Error< + "expected a clang compiler command">; def err_verify_bogus_characters : Error< "bogus characters before '{{' in expected string">; diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 04dc5ed8cc..c55638a237 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -122,6 +122,30 @@ public: bool OnlyLocalDecls = false, bool UseBumpAllocator = false); + /// LoadFromCommandLine - Create an ASTUnit from a vector of command line + /// arguments, which must specify exactly one source file. + /// + /// \param ArgBegin - The beginning of the argument vector. + /// + /// \param ArgEnd - The end of the argument vector. + /// + /// \param Diags - The diagnostics engine to use for reporting errors. + /// + /// \param Argv0 - The program path (from argv[0]), for finding the builtin + /// compiler path. + /// + /// \param MainAddr - The address of main (or some other function in the main + /// executable), for finding the builtin compiler path. + // + // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we + // shouldn't need to specify them at construction time. + static ASTUnit *LoadFromCommandLine(const char **ArgBegin, + const char **ArgEnd, + Diagnostic &Diags, + const char *Arg0, + void *MainAddr, + bool OnlyLocalDecls = false, + bool UseBumpAllocator = false); }; } // namespace clang |