blob: 1fa3ca93876e30aafc59cb67361959069163063b [file] [log] [blame]
Ted Kremenekab188932010-01-05 19:32:54 +00001//===- 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 Kremenekab188932010-01-05 19:32:54 +000019#include "clang/Frontend/CompilerInstance.h"
20#include "clang/Frontend/ASTUnit.h"
Douglas Gregorfc8ea232010-01-26 17:06:03 +000021#include "llvm/ADT/StringRef.h"
Ted Kremenekab188932010-01-05 19:32:54 +000022#include "llvm/System/Path.h"
Douglas Gregor4db64a42010-01-23 00:14:00 +000023#include <vector>
Ted Kremenekab188932010-01-05 19:32:54 +000024
25using namespace clang;
26
Ted Kremenekee4db4f2010-02-17 00:41:08 +000027namespace clang {
28namespace cxstring {
29 CXString createCXString(const char *String, bool DupString = false);
30 CXString createCXString(llvm::StringRef String, bool DupString = true);
31}
32}
33
Douglas Gregora030b7c2010-01-22 20:35:53 +000034class CIndexer {
Ted Kremenekab188932010-01-05 19:32:54 +000035 bool UseExternalASTGeneration;
36 bool OnlyLocalDecls;
Douglas Gregor0a812cf2010-02-18 23:07:20 +000037 bool DisplayDiagnostics;
38
Ted Kremenekab188932010-01-05 19:32:54 +000039 llvm::sys::Path ClangPath;
40
41public:
Douglas Gregor0a812cf2010-02-18 23:07:20 +000042 CIndexer()
43 : UseExternalASTGeneration(false), OnlyLocalDecls(false),
44 DisplayDiagnostics(false) { }
Ted Kremenekab188932010-01-05 19:32:54 +000045
Ted Kremenekab188932010-01-05 19:32:54 +000046 /// \brief Whether we only want to see "local" declarations (that did not
47 /// come from a previous precompiled header). If false, we want to see all
48 /// declarations.
49 bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
50 void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
51
Douglas Gregor0a812cf2010-02-18 23:07:20 +000052 bool getDisplayDiagnostics() const { return DisplayDiagnostics; }
53 void setDisplayDiagnostics(bool Display = true) {
54 DisplayDiagnostics = Display;
55 }
56
Ted Kremenekab188932010-01-05 19:32:54 +000057 bool getUseExternalASTGeneration() const { return UseExternalASTGeneration; }
58 void setUseExternalASTGeneration(bool Value) {
59 UseExternalASTGeneration = Value;
60 }
61
Ted Kremenekab188932010-01-05 19:32:54 +000062 /// \brief Get the path of the clang binary.
63 const llvm::sys::Path& getClangPath();
64
65 /// \brief Get the path of the clang resource files.
66 std::string getClangResourcesPath();
Ted Kremenekab188932010-01-05 19:32:54 +000067};
68
Douglas Gregor4db64a42010-01-23 00:14:00 +000069namespace clang {
70 /**
71 * \brief Given a set of "unsaved" files, create temporary files and
72 * construct the clang -cc1 argument list needed to perform the remapping.
73 *
74 * \returns true if an error occurred.
75 */
76 bool RemapFiles(unsigned num_unsaved_files,
77 struct CXUnsavedFile *unsaved_files,
78 std::vector<std::string> &RemapArgs,
79 std::vector<llvm::sys::Path> &TemporaryFiles);
80}
81
Ted Kremenekab188932010-01-05 19:32:54 +000082#endif