aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/Indexing.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-18 00:26:51 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-18 00:26:51 +0000
commitb395c63b473bf1b3783bff371a993332e8c4c5e3 (patch)
treef4f47baaeab8513c8b478c3461f2c4d45aa11d12 /tools/libclang/Indexing.cpp
parent144b6c0c50b5523609cbac523f168b9e3cb01175 (diff)
[libclang] Indexing API:
-For indexDeclaration, also pass the declaration attributes as an array of cursors. -Rename CXIndexOpt_OneRefPerFile -> CXIndexOpt_SuppressRedundantRefs, and only pass a reference if a declaration/definition does not exist in the file. -Other fixes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r--tools/libclang/Indexing.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 4540f9731d..5858faad2e 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -117,6 +117,10 @@ public:
virtual void HandleTopLevelDecl(DeclGroupRef DG) {
IndexCtx.indexDeclGroupRef(DG);
+ // FIXME: Indicate to parser to abort.
+// if (IndexCtx.shouldAbort()) {
+//
+// }
}
/// \brief Handle the specified top-level declaration that occurred inside
@@ -133,29 +137,9 @@ public:
};
//===----------------------------------------------------------------------===//
-// IndexingDiagnosticConsumer
+// CaptureDiagnosticConsumer
//===----------------------------------------------------------------------===//
-class IndexingDiagnosticConsumer : public DiagnosticConsumer {
- IndexingContext &IndexCtx;
-
-public:
- explicit IndexingDiagnosticConsumer(IndexingContext &indexCtx)
- : IndexCtx(indexCtx) {}
-
- virtual void HandleDiagnostic(DiagnosticsEngine::Level Level,
- const Diagnostic &Info) {
- // Default implementation (Warnings/errors count).
- DiagnosticConsumer::HandleDiagnostic(Level, Info);
-
- IndexCtx.handleDiagnostic(StoredDiagnostic(Level, Info));
- }
-
- DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const {
- return new IgnoringDiagConsumer();
- }
-};
-
class CaptureDiagnosticConsumer : public DiagnosticConsumer {
SmallVector<StoredDiagnostic, 4> Errors;
public:
@@ -187,8 +171,6 @@ public:
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
- CI.getDiagnostics().setClient(new IndexingDiagnosticConsumer(IndexCtx),
- /*own=*/true);
IndexCtx.setASTContext(CI.getASTContext());
Preprocessor &PP = CI.getPreprocessor();
PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx));
@@ -426,6 +408,8 @@ static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {
TLEnd = Unit.top_level_end();
TL != TLEnd; ++TL) {
IdxCtx.indexTopLevelDecl(*TL);
+ if (IdxCtx.shouldAbort())
+ return;
}
} else {
@@ -433,17 +417,15 @@ static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {
for (TranslationUnitDecl::decl_iterator
I = TUDecl->decls_begin(), E = TUDecl->decls_end(); I != E; ++I) {
IdxCtx.indexTopLevelDecl(*I);
+ if (IdxCtx.shouldAbort())
+ return;
}
}
}
static void indexDiagnostics(CXTranslationUnit TU, IndexingContext &IdxCtx) {
- unsigned Num = clang_getNumDiagnostics(TU);
- for (unsigned i = 0; i != Num; ++i) {
- CXDiagnostic Diag = clang_getDiagnostic(TU, i);
- IdxCtx.handleDiagnostic(Diag);
- clang_disposeDiagnostic(Diag);
- }
+ // FIXME: Create a CXDiagnosticSet from TU;
+ // IdxCtx.handleDiagnosticSet(Set);
}
static void clang_indexTranslationUnit_Impl(void *UserData) {
@@ -568,6 +550,19 @@ clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *DInfo) {
return 0;
}
+const CXIdxIBOutletCollectionAttrInfo *
+clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *AInfo) {
+ if (!AInfo)
+ return 0;
+
+ const AttrInfo *DI = static_cast<const AttrInfo *>(AInfo);
+ if (const IBOutletCollectionInfo *
+ IBInfo = dyn_cast<IBOutletCollectionInfo>(DI))
+ return &IBInfo->IBCollInfo;
+
+ return 0;
+}
+
int clang_indexSourceFile(CXIndex CIdx,
CXClientData client_data,
IndexerCallbacks *index_callbacks,