2010-11-05 15:19:31 +08:00
|
|
|
//===- CIndexer.h - Clang-C Source Indexing Library -------------*- C++ -*-===//
|
2010-01-06 03:32:54 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines CIndexer, a subclass of Indexer that provides extra
|
|
|
|
// functionality needed by the CIndex library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_CINDEXER_H
|
|
|
|
#define LLVM_CLANG_CINDEXER_H
|
|
|
|
|
|
|
|
#include "clang-c/Index.h"
|
2010-01-27 01:06:03 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2010-11-30 02:12:39 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2010-01-23 08:14:00 +08:00
|
|
|
#include <vector>
|
2010-01-06 03:32:54 +08:00
|
|
|
|
2010-11-05 15:19:31 +08:00
|
|
|
namespace llvm {
|
|
|
|
class CrashRecoveryContext;
|
|
|
|
}
|
|
|
|
|
2012-03-28 10:18:02 +08:00
|
|
|
namespace clang {
|
|
|
|
|
2010-01-23 04:35:53 +08:00
|
|
|
class CIndexer {
|
2010-01-06 03:32:54 +08:00
|
|
|
bool OnlyLocalDecls;
|
2010-02-19 07:07:20 +08:00
|
|
|
bool DisplayDiagnostics;
|
2012-03-28 10:18:05 +08:00
|
|
|
unsigned Options; // CXGlobalOptFlags.
|
2010-02-19 07:07:20 +08:00
|
|
|
|
2010-10-12 07:17:59 +08:00
|
|
|
llvm::sys::Path ResourcesPath;
|
2010-11-04 06:45:23 +08:00
|
|
|
std::string WorkingDir;
|
|
|
|
|
2010-01-06 03:32:54 +08:00
|
|
|
public:
|
2012-03-28 10:18:05 +08:00
|
|
|
CIndexer() : OnlyLocalDecls(false), DisplayDiagnostics(false),
|
|
|
|
Options(CXGlobalOpt_None) { }
|
2010-01-06 03:32:54 +08:00
|
|
|
|
|
|
|
/// \brief Whether we only want to see "local" declarations (that did not
|
|
|
|
/// come from a previous precompiled header). If false, we want to see all
|
|
|
|
/// declarations.
|
|
|
|
bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
|
|
|
|
void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
|
|
|
|
|
2010-02-19 07:07:20 +08:00
|
|
|
bool getDisplayDiagnostics() const { return DisplayDiagnostics; }
|
|
|
|
void setDisplayDiagnostics(bool Display = true) {
|
|
|
|
DisplayDiagnostics = Display;
|
|
|
|
}
|
|
|
|
|
2012-03-28 10:18:05 +08:00
|
|
|
unsigned getCXGlobalOptFlags() const { return Options; }
|
|
|
|
void setCXGlobalOptFlags(unsigned options) { Options = options; }
|
|
|
|
|
|
|
|
bool isOptEnabled(CXGlobalOptFlags opt) const {
|
|
|
|
return Options & ~unsigned(opt);
|
|
|
|
}
|
|
|
|
|
2010-01-06 03:32:54 +08:00
|
|
|
/// \brief Get the path of the clang resource files.
|
|
|
|
std::string getClangResourcesPath();
|
2010-11-04 06:45:23 +08:00
|
|
|
|
|
|
|
const std::string &getWorkingDirectory() const { return WorkingDir; }
|
|
|
|
void setWorkingDirectory(const std::string &Dir) { WorkingDir = Dir; }
|
2010-01-06 03:32:54 +08:00
|
|
|
};
|
|
|
|
|
2010-01-23 08:14:00 +08:00
|
|
|
/**
|
|
|
|
* \brief Given a set of "unsaved" files, create temporary files and
|
|
|
|
* construct the clang -cc1 argument list needed to perform the remapping.
|
|
|
|
*
|
|
|
|
* \returns true if an error occurred.
|
|
|
|
*/
|
|
|
|
bool RemapFiles(unsigned num_unsaved_files,
|
|
|
|
struct CXUnsavedFile *unsaved_files,
|
|
|
|
std::vector<std::string> &RemapArgs,
|
|
|
|
std::vector<llvm::sys::Path> &TemporaryFiles);
|
2010-11-05 15:19:31 +08:00
|
|
|
|
|
|
|
/// \brief Return the current size to request for "safety".
|
|
|
|
unsigned GetSafetyThreadStackSize();
|
|
|
|
|
|
|
|
/// \brief Set the current size to request for "safety" (or 0, if safety
|
|
|
|
/// threads should not be used).
|
|
|
|
void SetSafetyThreadStackSize(unsigned Value);
|
|
|
|
|
|
|
|
/// \brief Execution the given code "safely", using crash recovery or safety
|
|
|
|
/// threads when possible.
|
|
|
|
///
|
|
|
|
/// \return False if a crash was detected.
|
|
|
|
bool RunSafely(llvm::CrashRecoveryContext &CRC,
|
2010-11-15 01:47:35 +08:00
|
|
|
void (*Fn)(void*), void *UserData, unsigned Size = 0);
|
2011-05-06 04:27:22 +08:00
|
|
|
|
2012-03-28 10:18:05 +08:00
|
|
|
/// \brief Set the thread priority to background.
|
|
|
|
/// FIXME: Move to llvm/Support.
|
|
|
|
void setBackGroundPriority();
|
|
|
|
|
2011-05-06 04:27:22 +08:00
|
|
|
/// \brief Print libclang's resource usage to standard error.
|
|
|
|
void PrintLibclangResourceUsage(CXTranslationUnit TU);
|
2010-01-23 08:14:00 +08:00
|
|
|
}
|
|
|
|
|
2010-01-06 03:32:54 +08:00
|
|
|
#endif
|