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" |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 19 | #include "clang/Frontend/CompilerInstance.h" |
| 20 | #include "clang/Frontend/ASTUnit.h" |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/StringRef.h" |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 22 | #include "llvm/System/Path.h" |
Douglas Gregor | 4db64a4 | 2010-01-23 00:14:00 +0000 | [diff] [blame] | 23 | #include <vector> |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 24 | |
| 25 | using namespace clang; |
| 26 | |
Ted Kremenek | ee4db4f | 2010-02-17 00:41:08 +0000 | [diff] [blame^] | 27 | namespace clang { |
| 28 | namespace cxstring { |
| 29 | CXString createCXString(const char *String, bool DupString = false); |
| 30 | CXString createCXString(llvm::StringRef String, bool DupString = true); |
| 31 | } |
| 32 | } |
| 33 | |
Douglas Gregor | a030b7c | 2010-01-22 20:35:53 +0000 | [diff] [blame] | 34 | class CIndexer { |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 35 | bool UseExternalASTGeneration; |
| 36 | bool OnlyLocalDecls; |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 37 | |
| 38 | llvm::sys::Path ClangPath; |
| 39 | |
| 40 | public: |
Douglas Gregor | 936ea3b | 2010-01-28 00:56:43 +0000 | [diff] [blame] | 41 | CIndexer() : UseExternalASTGeneration(false), OnlyLocalDecls(false) { } |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 43 | /// \brief Whether we only want to see "local" declarations (that did not |
| 44 | /// come from a previous precompiled header). If false, we want to see all |
| 45 | /// declarations. |
| 46 | bool getOnlyLocalDecls() const { return OnlyLocalDecls; } |
| 47 | void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; } |
| 48 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 49 | bool getUseExternalASTGeneration() const { return UseExternalASTGeneration; } |
| 50 | void setUseExternalASTGeneration(bool Value) { |
| 51 | UseExternalASTGeneration = Value; |
| 52 | } |
| 53 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 54 | /// \brief Get the path of the clang binary. |
| 55 | const llvm::sys::Path& getClangPath(); |
| 56 | |
| 57 | /// \brief Get the path of the clang resource files. |
| 58 | std::string getClangResourcesPath(); |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
Douglas Gregor | 4db64a4 | 2010-01-23 00:14:00 +0000 | [diff] [blame] | 61 | namespace clang { |
| 62 | /** |
| 63 | * \brief Given a set of "unsaved" files, create temporary files and |
| 64 | * construct the clang -cc1 argument list needed to perform the remapping. |
| 65 | * |
| 66 | * \returns true if an error occurred. |
| 67 | */ |
| 68 | bool RemapFiles(unsigned num_unsaved_files, |
| 69 | struct CXUnsavedFile *unsaved_files, |
| 70 | std::vector<std::string> &RemapArgs, |
| 71 | std::vector<llvm::sys::Path> &TemporaryFiles); |
| 72 | } |
| 73 | |
Ted Kremenek | ab18893 | 2010-01-05 19:32:54 +0000 | [diff] [blame] | 74 | #endif |