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 {
|
2012-04-11 10:11:16 +08:00
|
|
|
class ASTUnit;
|
2013-01-08 03:16:25 +08:00
|
|
|
class MacroInfo;
|
|
|
|
class MacroDefinition;
|
|
|
|
class SourceLocation;
|
|
|
|
class Token;
|
|
|
|
class IdentifierInfo;
|
2012-03-28 10:18:02 +08:00
|
|
|
|
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
|
|
|
|
2013-06-13 21:56:37 +08:00
|
|
|
std::string ResourcesPath;
|
2010-11-04 06:45:23 +08:00
|
|
|
|
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 {
|
2012-03-29 04:42:59 +08:00
|
|
|
return Options & opt;
|
2012-03-28 10:18:05 +08:00
|
|
|
}
|
|
|
|
|
2010-01-06 03:32:54 +08:00
|
|
|
/// \brief Get the path of the clang resource files.
|
2013-06-13 21:56:37 +08:00
|
|
|
const std::string &getClangResourcesPath();
|
2010-01-06 03:32:54 +08:00
|
|
|
};
|
|
|
|
|
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.
|
2012-03-28 10:49:54 +08:00
|
|
|
void setThreadBackgroundPriority();
|
2012-03-28 10:18:05 +08:00
|
|
|
|
2011-05-06 04:27:22 +08:00
|
|
|
/// \brief Print libclang's resource usage to standard error.
|
|
|
|
void PrintLibclangResourceUsage(CXTranslationUnit TU);
|
2012-04-11 10:11:16 +08:00
|
|
|
|
|
|
|
namespace cxindex {
|
|
|
|
void printDiagsToStderr(ASTUnit *Unit);
|
2013-01-08 03:16:25 +08:00
|
|
|
|
|
|
|
/// \brief If \c MacroDefLoc points at a macro definition with \c II as
|
|
|
|
/// its name, this retrieves its MacroInfo.
|
|
|
|
MacroInfo *getMacroInfo(const IdentifierInfo &II,
|
|
|
|
SourceLocation MacroDefLoc,
|
|
|
|
CXTranslationUnit TU);
|
|
|
|
|
|
|
|
/// \brief Retrieves the corresponding MacroInfo of a MacroDefinition.
|
2013-01-12 05:01:49 +08:00
|
|
|
const MacroInfo *getMacroInfo(const MacroDefinition *MacroDef,
|
|
|
|
CXTranslationUnit TU);
|
2013-01-08 03:16:25 +08:00
|
|
|
|
|
|
|
/// \brief If \c Loc resides inside the definition of \c MI and it points at
|
|
|
|
/// an identifier that has ever been a macro name, this returns the latest
|
|
|
|
/// MacroDefinition for that name, otherwise it returns NULL.
|
|
|
|
MacroDefinition *checkForMacroInMacroDefinition(const MacroInfo *MI,
|
|
|
|
SourceLocation Loc,
|
|
|
|
CXTranslationUnit TU);
|
|
|
|
|
|
|
|
/// \brief If \c Tok resides inside the definition of \c MI and it points at
|
|
|
|
/// an identifier that has ever been a macro name, this returns the latest
|
|
|
|
/// MacroDefinition for that name, otherwise it returns NULL.
|
|
|
|
MacroDefinition *checkForMacroInMacroDefinition(const MacroInfo *MI,
|
|
|
|
const Token &Tok,
|
|
|
|
CXTranslationUnit TU);
|
2012-04-11 10:11:16 +08:00
|
|
|
}
|
2010-01-23 08:14:00 +08:00
|
|
|
}
|
|
|
|
|
2010-01-06 03:32:54 +08:00
|
|
|
#endif
|