CIndexer.h revision d1e6fdb4c5325c61fedfa62751f70ee373880a52
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"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/System/Path.h"
21#include <vector>
22
23namespace clang {
24namespace cxstring {
25  CXString createCXString(const char *String, bool DupString = false);
26  CXString createCXString(llvm::StringRef String, bool DupString = true);
27}
28}
29
30class CIndexer {
31  bool OnlyLocalDecls;
32  bool DisplayDiagnostics;
33
34  llvm::sys::Path ResourcesPath;
35
36public:
37 CIndexer() : OnlyLocalDecls(false), DisplayDiagnostics(false) { }
38
39  /// \brief Whether we only want to see "local" declarations (that did not
40  /// come from a previous precompiled header). If false, we want to see all
41  /// declarations.
42  bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
43  void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
44
45  bool getDisplayDiagnostics() const { return DisplayDiagnostics; }
46  void setDisplayDiagnostics(bool Display = true) {
47    DisplayDiagnostics = Display;
48  }
49
50  /// \brief Get the path of the clang resource files.
51  std::string getClangResourcesPath();
52};
53
54namespace clang {
55  /**
56   * \brief Given a set of "unsaved" files, create temporary files and
57   * construct the clang -cc1 argument list needed to perform the remapping.
58   *
59   * \returns true if an error occurred.
60   */
61  bool RemapFiles(unsigned num_unsaved_files,
62                  struct CXUnsavedFile *unsaved_files,
63                  std::vector<std::string> &RemapArgs,
64                  std::vector<llvm::sys::Path> &TemporaryFiles);
65}
66
67#endif
68