本文整理汇总了C++中ASTUnit::isMainFileAST方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTUnit::isMainFileAST方法的具体用法?C++ ASTUnit::isMainFileAST怎么用?C++ ASTUnit::isMainFileAST使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTUnit
的用法示例。
在下文中一共展示了ASTUnit::isMainFileAST方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: indexTranslationUnit
static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {
// FIXME: Only deserialize stuff from the last chained PCH, not the PCH/Module
// that it depends on.
bool OnlyLocal = !Unit.isMainFileAST() && Unit.getOnlyLocalDecls();
if (OnlyLocal) {
for (ASTUnit::top_level_iterator TL = Unit.top_level_begin(),
TLEnd = Unit.top_level_end();
TL != TLEnd; ++TL) {
IdxCtx.indexTopLevelDecl(*TL);
if (IdxCtx.shouldAbort())
return;
}
} else {
TranslationUnitDecl *TUDecl = Unit.getASTContext().getTranslationUnitDecl();
for (TranslationUnitDecl::decl_iterator
I = TUDecl->decls_begin(), E = TUDecl->decls_end(); I != E; ++I) {
IdxCtx.indexTopLevelDecl(*I);
if (IdxCtx.shouldAbort())
return;
}
}
}
示例2: indexPreprocessingRecord
static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) {
Preprocessor &PP = Unit.getPreprocessor();
if (!PP.getPreprocessingRecord())
return;
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
// FIXME: Only deserialize inclusion directives.
// FIXME: Only deserialize stuff from the last chained PCH, not the PCH/Module
// that it depends on.
bool OnlyLocal = !Unit.isMainFileAST() && Unit.getOnlyLocalDecls();
PreprocessingRecord::iterator I, E;
if (OnlyLocal) {
I = PPRec.local_begin();
E = PPRec.local_end();
} else {
I = PPRec.begin();
E = PPRec.end();
}
for (; I != E; ++I) {
PreprocessedEntity *PPE = *I;
if (InclusionDirective *ID = dyn_cast<InclusionDirective>(PPE)) {
IdxCtx.ppIncludedFile(ID->getSourceRange().getBegin(), ID->getFileName(),
ID->getFile(), ID->getKind() == InclusionDirective::Import,
!ID->wasInQuotes());
}
}
}