Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 1 | //===- CIndexer.h - Clang-C Source Indexing Library -----------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines CIndexer, a subclass of Indexer that provides extra |
| 11 | // functionality needed by the CIndex library. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_CINDEXER_H |
| 16 | #define LLVM_CLANG_CINDEXER_H |
| 17 | |
| 18 | #include "clang-c/Index.h" |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringRef.h" |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 20 | #include "llvm/System/Path.h" |
Douglas Gregor | 4db64a4 | 2010-01-23 00:14:00 +0000 | [diff] [blame] | 21 | #include <vector> |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 22 | |
Ted Kremenek | ee4db4f | 2010-02-17 00:41:08 +0000 | [diff] [blame] | 23 | namespace clang { |
| 24 | namespace cxstring { |
| 25 | CXString createCXString(const char *String, bool DupString = false); |
| 26 | CXString createCXString(llvm::StringRef String, bool DupString = true); |
| 27 | } |
| 28 | } |
| 29 | |
Douglas Gregor | a030b7c | 2010-01-22 20:35:53 +0000 | [diff] [blame] | 30 | class CIndexer { |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 31 | bool UseExternalASTGeneration; |
| 32 | bool OnlyLocalDecls; |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 33 | bool DisplayDiagnostics; |
| 34 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 35 | llvm::sys::Path ClangPath; |
| 36 | |
| 37 | public: |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 38 | CIndexer() |
| 39 | : UseExternalASTGeneration(false), OnlyLocalDecls(false), |
| 40 | DisplayDiagnostics(false) { } |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 41 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 42 | /// \brief Whether we only want to see "local" declarations (that did not |
| 43 | /// come from a previous precompiled header). If false, we want to see all |
| 44 | /// declarations. |
| 45 | bool getOnlyLocalDecls() const { return OnlyLocalDecls; } |
| 46 | void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; } |
| 47 | |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 48 | bool getDisplayDiagnostics() const { return DisplayDiagnostics; } |
| 49 | void setDisplayDiagnostics(bool Display = true) { |
| 50 | DisplayDiagnostics = Display; |
| 51 | } |
| 52 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 53 | bool getUseExternalASTGeneration() const { return UseExternalASTGeneration; } |
| 54 | void setUseExternalASTGeneration(bool Value) { |
| 55 | UseExternalASTGeneration = Value; |
| 56 | } |
| 57 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 58 | /// \brief Get the path of the clang binary. |
| 59 | const llvm::sys::Path& getClangPath(); |
| 60 | |
| 61 | /// \brief Get the path of the clang resource files. |
| 62 | std::string getClangResourcesPath(); |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Douglas Gregor | 4db64a4 | 2010-01-23 00:14:00 +0000 | [diff] [blame] | 65 | namespace clang { |
| 66 | /** |
| 67 | * \brief Given a set of "unsaved" files, create temporary files and |
| 68 | * construct the clang -cc1 argument list needed to perform the remapping. |
| 69 | * |
| 70 | * \returns true if an error occurred. |
| 71 | */ |
| 72 | bool RemapFiles(unsigned num_unsaved_files, |
| 73 | struct CXUnsavedFile *unsaved_files, |
| 74 | std::vector<std::string> &RemapArgs, |
| 75 | std::vector<llvm::sys::Path> &TemporaryFiles); |
| 76 | } |
| 77 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 78 | #endif |