forked from apple/swift-clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
- Loading branch information
Showing
86 changed files
with
9,123 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//===- DirectoryWatcher.h - Listens for directory file changes --*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
/// \brief Utility class for listening for file system changes in a directory. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H | ||
#define LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H | ||
|
||
#include "clang/Basic/LLVM.h" | ||
#include "clang/Index/IndexDataStore.h" | ||
#include <functional> | ||
#include <memory> | ||
#include <string> | ||
|
||
namespace clang { | ||
|
||
/// Provides notifications for file system changes in a directory. | ||
/// | ||
/// Guarantees that the first time the directory is processed, the receiver will | ||
/// be invoked even if the directory is empty. | ||
class DirectoryWatcher : public index::AbstractDirectoryWatcher { | ||
struct Implementation; | ||
Implementation &Impl; | ||
|
||
DirectoryWatcher(); | ||
|
||
DirectoryWatcher(const DirectoryWatcher&) = delete; | ||
DirectoryWatcher &operator =(const DirectoryWatcher&) = delete; | ||
|
||
public: | ||
~DirectoryWatcher(); | ||
|
||
static std::unique_ptr<DirectoryWatcher> | ||
create(StringRef Path, EventReceiver Receiver, bool waitInitialSync, | ||
std::string &Error); | ||
}; | ||
|
||
} // namespace clang | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
//===--- IndexDataStore.h - Index data store info -------------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_INDEX_INDEXDATASTORE_H | ||
#define LLVM_CLANG_INDEX_INDEXDATASTORE_H | ||
|
||
#include "clang/Basic/LLVM.h" | ||
#include "llvm/ADT/ArrayRef.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/ADT/STLExtras.h" | ||
#include <functional> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace clang { | ||
namespace index { | ||
|
||
class AbstractDirectoryWatcher { | ||
public: | ||
enum class EventKind { | ||
/// A file was added. | ||
Added, | ||
/// A file was removed. | ||
Removed, | ||
/// A file was modified. | ||
Modified, | ||
/// The watched directory got deleted. No more events will follow. | ||
DirectoryDeleted, | ||
}; | ||
|
||
struct Event { | ||
EventKind Kind; | ||
std::string Filename; | ||
timespec ModTime; | ||
}; | ||
|
||
typedef std::function<void(ArrayRef<Event> Events, bool isInitial)> EventReceiver; | ||
typedef std::unique_ptr<AbstractDirectoryWatcher>(CreateFnTy) | ||
(StringRef Path, EventReceiver Receiver, bool waitInitialSync, std::string &Error); | ||
|
||
virtual ~AbstractDirectoryWatcher() {} | ||
}; | ||
|
||
class IndexDataStore { | ||
public: | ||
~IndexDataStore(); | ||
|
||
static std::unique_ptr<IndexDataStore> | ||
create(StringRef IndexStorePath, std::string &Error); | ||
|
||
StringRef getFilePath() const; | ||
bool foreachUnitName(bool sorted, | ||
llvm::function_ref<bool(StringRef unitName)> receiver); | ||
|
||
static unsigned getFormatVersion(); | ||
|
||
enum class UnitEventKind { | ||
Added, | ||
Removed, | ||
Modified, | ||
/// The directory got deleted. No more events will follow. | ||
DirectoryDeleted, | ||
}; | ||
struct UnitEvent { | ||
UnitEventKind Kind; | ||
StringRef UnitName; | ||
timespec ModTime; | ||
}; | ||
struct UnitEventNotification { | ||
bool IsInitial; | ||
ArrayRef<UnitEvent> Events; | ||
}; | ||
typedef std::function<void(UnitEventNotification)> UnitEventHandler; | ||
|
||
void setUnitEventHandler(UnitEventHandler Handler); | ||
/// \returns true if an error occurred. | ||
bool startEventListening(llvm::function_ref<AbstractDirectoryWatcher::CreateFnTy> createFn, | ||
bool waitInitialSync, std::string &Error); | ||
void stopEventListening(); | ||
|
||
void discardUnit(StringRef UnitName); | ||
void discardRecord(StringRef RecordName); | ||
|
||
void purgeStaleData(); | ||
|
||
private: | ||
IndexDataStore(void *Impl) : Impl(Impl) {} | ||
|
||
void *Impl; // An IndexDataStoreImpl. | ||
}; | ||
|
||
} // namespace index | ||
} // namespace clang | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//===--- IndexDataStoreSymbolUtils.h - Utilities for indexstore symbols ---===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_INDEX_INDEXDATASTORESYMBOLUTILS_H | ||
#define LLVM_CLANG_INDEX_INDEXDATASTORESYMBOLUTILS_H | ||
|
||
#include "indexstore/indexstore.h" | ||
#include "clang/Index/IndexSymbol.h" | ||
|
||
namespace clang { | ||
namespace index { | ||
|
||
/// Map an indexstore_symbol_kind_t to a SymbolKind, handling unknown values. | ||
SymbolKind getSymbolKind(indexstore_symbol_kind_t K); | ||
|
||
SymbolSubKind getSymbolSubKind(indexstore_symbol_subkind_t K); | ||
|
||
/// Map an indexstore_symbol_language_t to a SymbolLanguage, handling unknown | ||
/// values. | ||
SymbolLanguage getSymbolLanguage(indexstore_symbol_language_t L); | ||
|
||
/// Map an indexstore representation to a SymbolPropertySet, handling | ||
/// unknown values. | ||
SymbolPropertySet getSymbolProperties(uint64_t Props); | ||
|
||
/// Map an indexstore representation to a SymbolRoleSet, handling unknown | ||
/// values. | ||
SymbolRoleSet getSymbolRoles(uint64_t Roles); | ||
|
||
/// Map a SymbolLanguage to a indexstore_symbol_language_t. | ||
indexstore_symbol_kind_t getIndexStoreKind(SymbolKind K); | ||
|
||
indexstore_symbol_subkind_t getIndexStoreSubKind(SymbolSubKind K); | ||
|
||
/// Map a SymbolLanguage to a indexstore_symbol_language_t. | ||
indexstore_symbol_language_t getIndexStoreLang(SymbolLanguage L); | ||
|
||
/// Map a SymbolPropertySet to its indexstore representation. | ||
uint64_t getIndexStoreProperties(SymbolPropertySet Props); | ||
|
||
/// Map a SymbolRoleSet to its indexstore representation. | ||
uint64_t getIndexStoreRoles(SymbolRoleSet Roles); | ||
|
||
} // end namespace index | ||
} // end namespace clang | ||
|
||
#endif // LLVM_CLANG_INDEX_INDEXDATASTORESYMBOLUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//===--- IndexRecordReader.h - Index record deserialization ---------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_INDEX_INDEXRECORDREADER_H | ||
#define LLVM_CLANG_INDEX_INDEXRECORDREADER_H | ||
|
||
#include "clang/Index/IndexSymbol.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/ADT/StringRef.h" | ||
#include <memory> | ||
|
||
namespace llvm { | ||
class MemoryBuffer; | ||
} | ||
|
||
namespace clang { | ||
namespace index { | ||
|
||
struct IndexRecordDecl { | ||
unsigned DeclID; | ||
SymbolInfo SymInfo; | ||
SymbolRoleSet Roles; | ||
SymbolRoleSet RelatedRoles; | ||
StringRef Name; | ||
StringRef USR; | ||
StringRef CodeGenName; | ||
}; | ||
|
||
struct IndexRecordRelation { | ||
SymbolRoleSet Roles; | ||
const IndexRecordDecl *Dcl = nullptr; | ||
|
||
IndexRecordRelation() = default; | ||
IndexRecordRelation(SymbolRoleSet Roles, const IndexRecordDecl *Dcl) | ||
: Roles(Roles), Dcl(Dcl) {} | ||
}; | ||
|
||
struct IndexRecordOccurrence { | ||
const IndexRecordDecl *Dcl; | ||
SmallVector<IndexRecordRelation, 4> Relations; | ||
SymbolRoleSet Roles; | ||
unsigned Line; | ||
unsigned Column; | ||
}; | ||
|
||
class IndexRecordReader { | ||
IndexRecordReader(); | ||
|
||
public: | ||
static std::unique_ptr<IndexRecordReader> | ||
createWithRecordFilename(StringRef RecordFilename, StringRef StorePath, | ||
std::string &Error); | ||
static std::unique_ptr<IndexRecordReader> | ||
createWithFilePath(StringRef FilePath, std::string &Error); | ||
static std::unique_ptr<IndexRecordReader> | ||
createWithBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer, | ||
std::string &Error); | ||
|
||
~IndexRecordReader(); | ||
|
||
struct DeclSearchReturn { | ||
bool AcceptDecl; | ||
bool ContinueSearch; | ||
}; | ||
typedef DeclSearchReturn(DeclSearchCheck)(const IndexRecordDecl &); | ||
|
||
/// Goes through and passes record decls, after filtering using a \c Checker | ||
/// function. | ||
/// | ||
/// Resulting decls can be used as filter for \c foreachOccurrence. This | ||
/// allows allocating memory only for the record decls that the caller is | ||
/// interested in. | ||
bool searchDecls(llvm::function_ref<DeclSearchCheck> Checker, | ||
llvm::function_ref<void(const IndexRecordDecl *)> Receiver); | ||
|
||
/// \param NoCache if true, avoids allocating memory for the decls. | ||
/// Useful when the caller does not intend to keep \c IndexRecordReader | ||
/// for more queries. | ||
bool foreachDecl(bool NoCache, | ||
llvm::function_ref<bool(const IndexRecordDecl *)> Receiver); | ||
|
||
/// \param DeclsFilter if non-empty indicates the list of decls that we want | ||
/// to get occurrences for. An empty array indicates that we want occurrences | ||
/// for all decls. | ||
/// \param RelatedDeclsFilter Same as \c DeclsFilter but for related decls. | ||
bool foreachOccurrence(ArrayRef<const IndexRecordDecl *> DeclsFilter, | ||
ArrayRef<const IndexRecordDecl *> RelatedDeclsFilter, | ||
llvm::function_ref<bool(const IndexRecordOccurrence &)> Receiver); | ||
bool foreachOccurrence( | ||
llvm::function_ref<bool(const IndexRecordOccurrence &)> Receiver); | ||
|
||
bool foreachOccurrenceInLineRange(unsigned lineStart, unsigned lineCount, | ||
llvm::function_ref<bool(const IndexRecordOccurrence &)> Receiver); | ||
|
||
struct Implementation; | ||
private: | ||
Implementation &Impl; | ||
}; | ||
|
||
} // namespace index | ||
} // namespace clang | ||
|
||
#endif |
Oops, something went wrong.