2016-02-13 07:10:59 +08:00
|
|
|
//===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H
|
|
|
|
#define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H
|
|
|
|
|
2018-07-09 16:44:05 +08:00
|
|
|
#include "clang/Basic/IdentifierTable.h"
|
2016-02-13 07:10:59 +08:00
|
|
|
#include "clang/Basic/LLVM.h"
|
|
|
|
#include "clang/Index/IndexSymbol.h"
|
|
|
|
#include "clang/Index/IndexingAction.h"
|
2018-07-09 16:44:05 +08:00
|
|
|
#include "clang/Lex/MacroInfo.h"
|
2016-02-13 07:10:59 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
class ASTContext;
|
|
|
|
class Decl;
|
|
|
|
class DeclGroupRef;
|
|
|
|
class ImportDecl;
|
|
|
|
class TagDecl;
|
|
|
|
class TypeSourceInfo;
|
|
|
|
class NamedDecl;
|
|
|
|
class ObjCMethodDecl;
|
|
|
|
class DeclContext;
|
|
|
|
class NestedNameSpecifierLoc;
|
|
|
|
class Stmt;
|
|
|
|
class Expr;
|
|
|
|
class TypeLoc;
|
|
|
|
class SourceLocation;
|
|
|
|
|
|
|
|
namespace index {
|
|
|
|
class IndexDataConsumer;
|
|
|
|
|
|
|
|
class IndexingContext {
|
|
|
|
IndexingOptions IndexOpts;
|
|
|
|
IndexDataConsumer &DataConsumer;
|
|
|
|
ASTContext *Ctx = nullptr;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer)
|
|
|
|
: IndexOpts(IndexOpts), DataConsumer(DataConsumer) {}
|
|
|
|
|
|
|
|
const IndexingOptions &getIndexOpts() const { return IndexOpts; }
|
|
|
|
IndexDataConsumer &getDataConsumer() { return DataConsumer; }
|
|
|
|
|
|
|
|
void setASTContext(ASTContext &ctx) { Ctx = &ctx; }
|
|
|
|
|
2017-04-21 13:42:46 +08:00
|
|
|
bool shouldIndex(const Decl *D);
|
|
|
|
|
2017-04-24 22:04:58 +08:00
|
|
|
const LangOptions &getLangOpts() const;
|
|
|
|
|
2016-02-13 07:10:59 +08:00
|
|
|
bool shouldSuppressRefs() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool shouldIndexFunctionLocalSymbols() const;
|
|
|
|
|
2018-07-10 05:49:06 +08:00
|
|
|
bool shouldIndexImplicitInstantiation() const;
|
2016-02-13 07:10:59 +08:00
|
|
|
|
|
|
|
static bool isTemplateImplicitInstantiation(const Decl *D);
|
|
|
|
|
|
|
|
bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
|
2016-02-13 13:17:15 +08:00
|
|
|
ArrayRef<SymbolRelation> Relations = None);
|
2016-02-13 07:10:59 +08:00
|
|
|
|
|
|
|
bool handleDecl(const Decl *D, SourceLocation Loc,
|
|
|
|
SymbolRoleSet Roles = SymbolRoleSet(),
|
2016-02-13 13:17:15 +08:00
|
|
|
ArrayRef<SymbolRelation> Relations = None,
|
2016-02-13 07:10:59 +08:00
|
|
|
const DeclContext *DC = nullptr);
|
|
|
|
|
|
|
|
bool handleReference(const NamedDecl *D, SourceLocation Loc,
|
|
|
|
const NamedDecl *Parent,
|
|
|
|
const DeclContext *DC,
|
2017-03-18 07:41:59 +08:00
|
|
|
SymbolRoleSet Roles = SymbolRoleSet(),
|
2016-02-13 13:17:15 +08:00
|
|
|
ArrayRef<SymbolRelation> Relations = None,
|
2016-02-13 07:10:59 +08:00
|
|
|
const Expr *RefE = nullptr,
|
|
|
|
const Decl *RefD = nullptr);
|
|
|
|
|
2018-07-09 16:44:05 +08:00
|
|
|
void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc,
|
|
|
|
const MacroInfo &MI);
|
|
|
|
|
|
|
|
void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc,
|
|
|
|
const MacroInfo &MI);
|
|
|
|
|
|
|
|
void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc,
|
|
|
|
const MacroInfo &MD);
|
|
|
|
|
2016-02-13 07:10:59 +08:00
|
|
|
bool importedModule(const ImportDecl *ImportD);
|
|
|
|
|
|
|
|
bool indexDecl(const Decl *D);
|
|
|
|
|
2017-04-20 18:43:22 +08:00
|
|
|
void indexTagDecl(const TagDecl *D,
|
|
|
|
ArrayRef<SymbolRelation> Relations = None);
|
2016-02-13 07:10:59 +08:00
|
|
|
|
|
|
|
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
|
|
|
|
const DeclContext *DC = nullptr,
|
2017-01-12 05:01:07 +08:00
|
|
|
bool isBase = false,
|
|
|
|
bool isIBType = false);
|
2016-02-13 07:10:59 +08:00
|
|
|
|
|
|
|
void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
|
|
|
|
const DeclContext *DC = nullptr,
|
2017-01-12 05:01:07 +08:00
|
|
|
bool isBase = false,
|
|
|
|
bool isIBType = false);
|
2016-02-13 07:10:59 +08:00
|
|
|
|
|
|
|
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
|
|
|
|
const NamedDecl *Parent,
|
|
|
|
const DeclContext *DC = nullptr);
|
|
|
|
|
|
|
|
bool indexDeclContext(const DeclContext *DC);
|
|
|
|
|
|
|
|
void indexBody(const Stmt *S, const NamedDecl *Parent,
|
|
|
|
const DeclContext *DC = nullptr);
|
|
|
|
|
|
|
|
bool indexTopLevelDecl(const Decl *D);
|
|
|
|
bool indexDeclGroupRef(DeclGroupRef DG);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool shouldIgnoreIfImplicit(const Decl *D);
|
|
|
|
|
|
|
|
bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
|
|
|
|
bool IsRef, const Decl *Parent,
|
|
|
|
SymbolRoleSet Roles,
|
|
|
|
ArrayRef<SymbolRelation> Relations,
|
|
|
|
const Expr *RefE,
|
|
|
|
const Decl *RefD,
|
|
|
|
const DeclContext *ContainerDC);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace index
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|