2016-02-13 07:10:59 +08:00
|
|
|
//===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-02-13 07:10:59 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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
|
|
|
|
2019-02-11 21:02:21 +08:00
|
|
|
bool shouldIndexParametersInDeclarations() const;
|
|
|
|
|
2019-02-21 17:52:33 +08:00
|
|
|
bool shouldIndexTemplateParameters() 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);
|
|
|
|
|
[index] Improve macro indexing support
The major change here is to index macro occurrences in more places than
before, specifically
* In non-expansion references such as `#if`, `#ifdef`, etc.
* When the macro is a reference to a builtin macro such as __LINE__.
* When using the preprocessor state instead of callbacks, we now include
all definition locations and undefinitions instead of just the latest
one (which may also have had the wrong location previously).
* When indexing an existing module file (.pcm), we now include module
macros, and we no longer report unrelated preprocessor macros during
indexing the module, which could have caused duplication.
Additionally, we now correctly obey the system symbol filter for macros,
so by default in system headers only definition/undefinition occurrences
are reported, but it can be configured to report references as well if
desired.
Extends FileIndexRecord to support occurrences of macros. Since the
design of this type is to keep a single list of entities organized by
source location, we incorporate macros into the existing DeclOccurrence
struct.
Differential Revision: https://reviews.llvm.org/D99758
2021-03-24 06:22:58 +08:00
|
|
|
bool shouldIndexMacroOccurrence(bool IsRef, SourceLocation Loc);
|
|
|
|
|
2016-02-13 07:10:59 +08:00
|
|
|
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
|