summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-08-01 10:50:43 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-08-01 12:39:47 +0000
commitc6105e0ad35094d0f0cb36e45398864dfbd47074 (patch)
tree042f451acc8bd733d8c5f52c3f9df942750b8bde /include
parent61f9ff7bb83fe0e09b576b30c85ce88ca83e7b77 (diff)
Index while build. Non-Apple platforms
https://reviews.llvm.org/D49009 adapted for 6.0 Change-Id: If42f023af1e032b49c40b6d94e2c9ad8b91a8461 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'include')
-rw-r--r--include/clang/Driver/Options.td6
-rw-r--r--include/clang/Index/IndexDataStore.h2
-rw-r--r--include/indexstore/IndexStoreCXX.h98
-rw-r--r--include/indexstore/indexstore.h53
4 files changed, 110 insertions, 49 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 504bb0ddf7..5481563474 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -324,11 +324,11 @@ def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flag
def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>,
Alias<objcmt_whitelist_dir_path>;
-def index_store_path : Separate<["-"], "index-store-path">, Flags<[CC1Option]>,
+def index_store_path : Separate<["-"], "index-store-path">, Flags<[CoreOption,CC1Option]>,
HelpText<"Enable indexing with the specified data store path">;
-def index_ignore_system_symbols : Flag<["-"], "index-ignore-system-symbols">, Flags<[CC1Option]>,
+def index_ignore_system_symbols : Flag<["-"], "index-ignore-system-symbols">, Flags<[CoreOption,CC1Option]>,
HelpText<"Ignore symbols from system headers">;
-def index_record_codegen_name : Flag<["-"], "index-record-codegen-name">, Flags<[CC1Option]>,
+def index_record_codegen_name : Flag<["-"], "index-record-codegen-name">, Flags<[CoreOption,CC1Option]>,
HelpText<"Record the codegen name for symbols">;
// Make sure all other -ccc- options are rejected.
diff --git a/include/clang/Index/IndexDataStore.h b/include/clang/Index/IndexDataStore.h
index b95bf4e0b0..eb49c2d95a 100644
--- a/include/clang/Index/IndexDataStore.h
+++ b/include/clang/Index/IndexDataStore.h
@@ -14,6 +14,8 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+
+#include <ctime>
#include <functional>
#include <memory>
#include <string>
diff --git a/include/indexstore/IndexStoreCXX.h b/include/indexstore/IndexStoreCXX.h
index 7971d02233..96c677c9af 100644
--- a/include/indexstore/IndexStoreCXX.h
+++ b/include/indexstore/IndexStoreCXX.h
@@ -86,14 +86,15 @@ public:
uint64_t getRoles() { return indexstore_occurrence_get_roles(obj); }
bool foreachRelation(llvm::function_ref<bool(IndexSymbolRelation)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_occurrence_relations_apply(
- obj, ^bool(indexstore_symbol_relation_t sym_rel) {
- return receiver(sym_rel);
- });
+ obj,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_symbol_relation_t sym_rel) {
#else
- return false;
+ [receiver](indexstore_symbol_relation_t sym_rel) {
#endif
+ return receiver(sym_rel);
+ });
}
std::pair<unsigned, unsigned> getLineCol() {
@@ -141,14 +142,15 @@ public:
bool foreachUnit(bool sorted,
llvm::function_ref<bool(StringRef unitName)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_store_units_apply(
- obj, sorted, ^bool(indexstore_string_ref_t unit_name) {
- return receiver(stringFromIndexStoreStringRef(unit_name));
- });
+ obj, sorted,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_string_ref_t unit_name) {
#else
- return false;
+ [receiver](indexstore_string_ref_t unit_name) {
#endif
+ return receiver(stringFromIndexStoreStringRef(unit_name));
+ });
}
class UnitEvent {
@@ -215,17 +217,21 @@ public:
typedef std::function<void(UnitEventNotification)> UnitEventHandler;
void setUnitEventHandler(UnitEventHandler handler) {
-#if INDEXSTORE_HAS_BLOCKS
if (!handler) {
- indexstore_store_set_unit_event_handler(obj, nullptr);
+ indexstore_store_set_unit_event_handler(obj,
+ [](indexstore_unit_event_notification_t evt_note){});
return;
}
indexstore_store_set_unit_event_handler(
- obj, ^(indexstore_unit_event_notification_t evt_note) {
+ obj,
+#if INDEXSTORE_HAS_BLOCKS
+ ^(indexstore_unit_event_notification_t evt_note) {
+#else
+ [handler](indexstore_unit_event_notification_t evt_note) {
+#endif
handler(UnitEventNotification(evt_note));
});
-#endif
}
bool startEventListening(bool waitInitialSync, std::string &error) {
@@ -332,20 +338,26 @@ public:
receiver(symbol);
});
#else
- return false;
+ return indexstore_record_reader_search_symbols(
+ obj,
+ [filter](indexstore_symbol_t symbol, bool *stop) {
+ return filter(symbol, *stop);
+ },
+ [receiver](indexstore_symbol_t symbol) { receiver(symbol); });
#endif
}
bool foreachSymbol(bool noCache,
llvm::function_ref<bool(IndexRecordSymbol)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_record_reader_symbols_apply(
- obj, noCache, ^bool(indexstore_symbol_t sym) {
- return receiver(sym);
- });
+ obj, noCache,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_symbol_t sym) {
#else
- return false;
+ [receiver](indexstore_symbol_t sym) {
#endif
+ return receiver(sym);
+ });
}
/// \param DeclsFilter if non-empty indicates the list of decls that we want
@@ -356,7 +368,6 @@ public:
foreachOccurrence(ArrayRef<IndexRecordSymbol> symbolsFilter,
ArrayRef<IndexRecordSymbol> relatedSymbolsFilter,
llvm::function_ref<bool(IndexRecordOccurrence)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
llvm::SmallVector<indexstore_symbol_t, 16> c_symbolsFilter;
c_symbolsFilter.reserve(symbolsFilter.size());
for (IndexRecordSymbol sym : symbolsFilter) {
@@ -367,27 +378,30 @@ public:
for (IndexRecordSymbol sym : relatedSymbolsFilter) {
c_relatedSymbolsFilter.push_back(sym.obj);
}
+
return indexstore_record_reader_occurrences_of_symbols_apply(
obj, c_symbolsFilter.data(), c_symbolsFilter.size(),
c_relatedSymbolsFilter.data(), c_relatedSymbolsFilter.size(),
+#if INDEXSTORE_HAS_BLOCKS
^bool(indexstore_occurrence_t occur) {
- return receiver(occur);
- });
#else
- return false;
+ [receiver](indexstore_occurrence_t occur) {
#endif
+ return receiver(occur);
+ });
}
bool
foreachOccurrence(llvm::function_ref<bool(IndexRecordOccurrence)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_record_reader_occurrences_apply(
- obj, ^bool(indexstore_occurrence_t occur) {
- return receiver(occur);
- });
+ obj,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_occurrence_t occur) {
#else
- return false;
+ [receiver](indexstore_occurrence_t occur) {
#endif
+ return receiver(occur);
+ });
}
bool foreachOccurrenceInLineRange(
@@ -399,7 +413,9 @@ public:
return receiver(occur);
});
#else
- return false;
+ return indexstore_record_reader_occurrences_in_line_range_apply(
+ obj, lineStart, lineEnd,
+ [receiver](indexstore_occurrence_t occur) { return receiver(occur); });
#endif
}
};
@@ -541,25 +557,27 @@ public:
bool
foreachDependency(llvm::function_ref<bool(IndexUnitDependency)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_unit_reader_dependencies_apply(
- obj, ^bool(indexstore_unit_dependency_t dep) {
- return receiver(dep);
- });
+ obj,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_unit_dependency_t dep) {
#else
- return false;
+ [receiver](indexstore_unit_dependency_t dep) {
#endif
+ return receiver(dep);
+ });
}
bool foreachInclude(llvm::function_ref<bool(IndexUnitInclude)> receiver) {
-#if INDEXSTORE_HAS_BLOCKS
return indexstore_unit_reader_includes_apply(
- obj, ^bool(indexstore_unit_include_t inc) {
- return receiver(inc);
- });
+ obj,
+#if INDEXSTORE_HAS_BLOCKS
+ ^bool(indexstore_unit_include_t inc) {
#else
- return false;
+ [receiver](indexstore_unit_include_t inc) {
#endif
+ return receiver(inc);
+ });
}
};
diff --git a/include/indexstore/indexstore.h b/include/indexstore/indexstore.h
index 61e3dc3be2..8682d1b299 100644
--- a/include/indexstore/indexstore.h
+++ b/include/indexstore/indexstore.h
@@ -14,6 +14,8 @@
#ifndef LLVM_CLANG_C_INDEXSTORE_INDEXSTORE_H
#define LLVM_CLANG_C_INDEXSTORE_INDEXSTORE_H
+#include "llvm/ADT/STLExtras.h"
+
#include <ctime>
#include <stddef.h>
#include <stdint.h>
@@ -49,7 +51,11 @@
#ifndef INDEXSTORE_PUBLIC
#if defined(_MSC_VER)
-#define INDEXSTORE_PUBLIC __declspec(dllimport)
+#ifdef _INDEXSTORE_LIB_
+ #define INDEXSTORE_PUBLIC __declspec(dllexport)
+#else
+ #define INDEXSTORE_PUBLIC __declspec(dllimport)
+#endif
#else
#define INDEXSTORE_PUBLIC
#endif
@@ -88,10 +94,12 @@ indexstore_store_create(const char *store_path, indexstore_error_t *error);
INDEXSTORE_PUBLIC void indexstore_store_dispose(indexstore_t store);
-#if INDEXSTORE_HAS_BLOCKS
INDEXSTORE_PUBLIC bool indexstore_store_units_apply(
indexstore_t, unsigned sorted,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_string_ref_t unit_name));
+#else
+ llvm::function_ref<bool(indexstore_string_ref_t)> applier);
#endif
typedef void *indexstore_unit_event_notification_t;
@@ -129,6 +137,13 @@ typedef void (^indexstore_unit_event_handler_t)(
INDEXSTORE_PUBLIC void indexstore_store_set_unit_event_handler(
indexstore_t store, indexstore_unit_event_handler_t handler);
+#else
+typedef std::function<void(indexstore_unit_event_notification_t)>
+indexstore_unit_event_handler_t;
+
+INDEXSTORE_PUBLIC void indexstore_store_set_unit_event_handler(
+ indexstore_t store,
+ llvm::function_ref<void(indexstore_unit_event_notification_t)> handler);
#endif
typedef struct {
@@ -294,10 +309,12 @@ typedef void *indexstore_occurrence_t;
INDEXSTORE_PUBLIC indexstore_symbol_t
indexstore_occurrence_get_symbol(indexstore_occurrence_t occur);
-#if INDEXSTORE_HAS_BLOCKS
INDEXSTORE_PUBLIC bool indexstore_occurrence_relations_apply(
indexstore_occurrence_t occur,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_symbol_relation_t relation));
+#else
+ llvm::function_ref<bool(indexstore_symbol_relation_t)> applier);
#endif
INDEXSTORE_PUBLIC uint64_t
@@ -315,7 +332,6 @@ INDEXSTORE_PUBLIC indexstore_record_reader_t indexstore_record_reader_create(
INDEXSTORE_PUBLIC void
indexstore_record_reader_dispose(indexstore_record_reader_t reader);
-#if INDEXSTORE_HAS_BLOCKS
/// Goes through the symbol data and passes symbols to \c receiver, for the
/// symbol data that \c filter returns true on.
///
@@ -323,23 +339,40 @@ indexstore_record_reader_dispose(indexstore_record_reader_t reader);
/// interested in.
INDEXSTORE_PUBLIC bool indexstore_record_reader_search_symbols(
indexstore_record_reader_t reader,
+#if INDEXSTORE_HAS_BLOCKS
bool (^filter)(indexstore_symbol_t symbol, bool *stop),
void (^receiver)(indexstore_symbol_t symbol));
+#else
+ llvm::function_ref<bool(indexstore_symbol_t, bool *)> filter,
+ llvm::function_ref<void(indexstore_symbol_t)> receiver);
+#endif
/// \param nocache if true, avoids allocating memory for the symbols.
/// Useful when the caller does not intend to keep \c indexstore_record_reader_t
/// for more queries.
INDEXSTORE_PUBLIC bool indexstore_record_reader_symbols_apply(
indexstore_record_reader_t reader, bool nocache,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_symbol_t symbol));
+#else
+ llvm::function_ref<bool(indexstore_symbol_t)> applier);
+#endif
INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_apply(
indexstore_record_reader_t reader,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_occurrence_t occur));
+#else
+ llvm::function_ref<bool(indexstore_occurrence_t)> applier);
+#endif
INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_in_line_range_apply(
indexstore_record_reader_t reader, unsigned line_start, unsigned line_count,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_occurrence_t occur));
+#else
+ llvm::function_ref<bool(indexstore_occurrence_t)> applier);
+#endif
/// \param symbols if non-zero \c symbols_count, indicates the list of symbols
/// that we want to get occurrences for. An empty array indicates that we want
@@ -349,7 +382,10 @@ INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_of_symbols_apply(
indexstore_record_reader_t reader, indexstore_symbol_t *symbols,
size_t symbols_count, indexstore_symbol_t *related_symbols,
size_t related_symbols_count,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_occurrence_t occur));
+#else
+ llvm::function_ref<bool(indexstore_occurrence_t)> applier);
#endif
typedef void *indexstore_unit_reader_t;
@@ -438,15 +474,20 @@ indexstore_unit_include_get_target_path(indexstore_unit_include_t dep);
INDEXSTORE_PUBLIC unsigned
indexstore_unit_include_get_source_line(indexstore_unit_include_t dep);
-#if INDEXSTORE_HAS_BLOCKS
INDEXSTORE_PUBLIC bool indexstore_unit_reader_dependencies_apply(
indexstore_unit_reader_t reader,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_unit_dependency_t dep));
+#else
+ llvm::function_ref<bool(indexstore_unit_dependency_t)> applier);
+#endif
INDEXSTORE_PUBLIC bool indexstore_unit_reader_includes_apply(
indexstore_unit_reader_t reader,
+#if INDEXSTORE_HAS_BLOCKS
bool (^applier)(indexstore_unit_include_t include));
-
+#else
+ llvm::function_ref<bool(indexstore_unit_include_t)> applier);
#endif
INDEXSTORE_END_DECLS