blob: 1fcb964c6efeb5ad80e2639d31b1e8ff69db98a4 [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"
Douglas Gregorfc8ea232010-01-26 17:06:03 +000019#include "llvm/ADT/StringRef.h"
Ted Kremenekab188932010-01-05 19:32:54 +000020#include "llvm/System/Path.h"
Douglas Gregor4db64a42010-01-23 00:14:00 +000021#include <vector>
Ted Kremenekab188932010-01-05 19:32:54 +000022
Ted Kremenekee4db4f2010-02-17 00:41:08 +000023namespace clang {
24namespace cxstring {
25 CXString createCXString(const char *String, bool DupString = false);
26 CXString createCXString(llvm::StringRef String, bool DupString = true);
27}
28}
29
Douglas Gregora030b7c2010-01-22 20:35:53 +000030class CIndexer {
Ted Kremenekab188932010-01-05 19:32:54 +000031 bool OnlyLocalDecls;
Douglas Gregor0a812cf2010-02-18 23:07:20 +000032 bool DisplayDiagnostics;
33
Douglas Gregord1e6fdb2010-10-11 23:17:59 +000034 llvm::sys::Path ResourcesPath;
Argyrios Kyrtzidis389db162010-11-03 22:45:23 +000035 std::string WorkingDir;
36
Ted Kremenekab188932010-01-05 19:32:54 +000037public:
Douglas Gregorb10daed2010-10-11 16:52:23 +000038 CIndexer() : OnlyLocalDecls(false), DisplayDiagnostics(false) { }
Ted Kremenekab188932010-01-05 19:32:54 +000039
Ted Kremenekab188932010-01-05 19:32:54 +000040 /// \brief Whether we only want to see "local" declarations (that did not
41 /// come from a previous precompiled header). If false, we want to see all
42 /// declarations.
43 bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
44 void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
45
Douglas Gregor0a812cf2010-02-18 23:07:20 +000046 bool getDisplayDiagnostics() const { return DisplayDiagnostics; }
47 void setDisplayDiagnostics(bool Display = true) {
48 DisplayDiagnostics = Display;
49 }
50
Ted Kremenekab188932010-01-05 19:32:54 +000051 /// \brief Get the path of the clang resource files.
52 std::string getClangResourcesPath();
Argyrios Kyrtzidis389db162010-11-03 22:45:23 +000053
54 const std::string &getWorkingDirectory() const { return WorkingDir; }
55 void setWorkingDirectory(const std::string &Dir) { WorkingDir = Dir; }
Ted Kremenekab188932010-01-05 19:32:54 +000056};
57
Douglas Gregor4db64a42010-01-23 00:14:00 +000058namespace clang {
59 /**
60 * \brief Given a set of "unsaved" files, create temporary files and
61 * construct the clang -cc1 argument list needed to perform the remapping.
62 *
63 * \returns true if an error occurred.
64 */
65 bool RemapFiles(unsigned num_unsaved_files,
66 struct CXUnsavedFile *unsaved_files,
67 std::vector<std::string> &RemapArgs,
68 std::vector<llvm::sys::Path> &TemporaryFiles);
69}
70
Ted Kremenekab188932010-01-05 19:32:54 +000071#endif