本文整理汇总了C++中ASTContext::getTranslationUnitDecl方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext::getTranslationUnitDecl方法的具体用法?C++ ASTContext::getTranslationUnitDecl怎么用?C++ ASTContext::getTranslationUnitDecl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTContext
的用法示例。
在下文中一共展示了ASTContext::getTranslationUnitDecl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleTranslationUnit
void EmptyStructToInt::HandleTranslationUnit(ASTContext &Ctx)
{
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
doAnalysis();
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
removeRecordDecls();
RewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
// sanity check that we actually
// have done some text modifications.
// It could be false due to invalid code being transformed.
if (!Rewritten) {
TransError = TransNoTextModificationError;
return;
}
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例2: HandleTranslationUnit
void KeyPathValidationConsumer::HandleTranslationUnit(ASTContext &Context) {
cacheNSTypes();
ValueForKeyVisitor(this, Compiler).TraverseDecl(Context.getTranslationUnitDecl());
KeyPathsAffectingVisitor(this, Compiler).TraverseDecl(Context.getTranslationUnitDecl());
FBBinderVisitor(this, Compiler).TraverseDecl(Context.getTranslationUnitDecl());
}
示例3: HandleTranslationUnit
void ReduceClassTemplateParameter::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isCLangOpt() ||
TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TheClassTemplateDecl && "NULL TheClassTemplateDecl!");
TransAssert(ArgRewriteVisitor && "NULL ArgRewriteVisitor!");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
removeParameterFromDecl();
removeParameterFromMethods();
removeParameterFromPartialSpecs();
ArgRewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例4: HandleTranslationUnit
void TemplateNonTypeArgToInt::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isCLangOpt() ||
TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
ArgCollector->TraverseDecl(Ctx.getTranslationUnitDecl());
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
if (TheExpr) {
RewriteHelper->replaceExpr(TheExpr, IntString);
}
else if (TheValueDecl) {
RewriteHelper->replaceValueDecl(TheValueDecl,
"int " + TheValueDecl->getNameAsString());
}
else {
TransAssert(0 && "No valid targets!");
}
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例5: HandleTranslationUnit
void LocalToGlobal::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
FunctionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TransformationASTVisitor && "NULL TransformationASTVisitor!");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
TransAssert(TheFuncDecl && "NULL TheFuncDecl!");
TransAssert(TheVarDecl && "NULL TheVarDecl!");
TransformationASTVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例6: HandleTranslationUnit
void InstantiateTemplateParam::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isCLangOpt() ||
TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
TransAssert(TheParameter && "NULL TheParameter!");
TransAssert((TheInstantiationString != "") && "Invalid InstantiationString!");
TransAssert(ParamRewriteVisitor && "NULL ParamRewriteVisitor!");
ParamRewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
removeTemplateKeyword();
addForwardDecl();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例7: HandleTranslationUnit
void RemoveUnusedFunction::HandleTranslationUnit(ASTContext &Ctx)
{
VisitorWrapper->TraverseDecl(Ctx.getTranslationUnitDecl());
// visit using decls declared outsided function-scope
UsingDeclVisitor Visitor(NULL, this);
Visitor.TraverseDecl(Ctx.getTranslationUnitDecl());
SpecializationVisitor SpecVisitor(this);
SpecVisitor.TraverseDecl(Ctx.getTranslationUnitDecl());
AnalysisVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
if (ToCounter > ValidInstanceNum) {
TransError = TransToCounterTooBigError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
doRewriting();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例8: HandleTranslationUnit
void ReducePointerLevel::HandleTranslationUnit(ASTContext &Ctx)
{
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
doAnalysis();
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(CollectionVisitor && "NULL CollectionVisitor!");
TransAssert(RewriteVisitor && "NULL CollectionVisitor!");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
TransAssert(TheDecl && "NULL TheDecl!");
setRecordDecl();
RewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例9: HandleTranslationUnit
void RemoveBaseClass::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isCLangOpt() ||
TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TheBaseClass && "TheBaseClass is NULL!");
TransAssert(TheDerivedClass && "TheDerivedClass is NULL!");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
RewriteVisitor =
new RemoveBaseClassRewriteVisitor(&TheRewriter, RewriteHelper,
TheBaseClass->getCanonicalDecl(),
TheDerivedClass->getNameAsString());
TransAssert(RewriteVisitor && "NULL RewriteVisitor!");
RewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
doRewrite();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例10: HandleTranslationUnit
void ReplaceSimpleTypedef::HandleTranslationUnit(ASTContext &Ctx)
{
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
TransAssert(TheTypedefDecl && "NULL TheTypedefDecl!");
RewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
removeTypedefs();
if (!Rewritten) {
TransError = TransNoTextModificationError;
return;
}
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例11: HandleTranslationUnit
void TemplateArgToInt::HandleTranslationUnit(ASTContext &Ctx)
{
const LangOptions &LO = Ctx.getLangOpts();
if (LO.C99 || LO.OpenCL) {
ValidInstanceNum = 0;
}
else {
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
GlobalParamFilter->TraverseDecl(Ctx.getTranslationUnitDecl());
ArgCollector->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
rewriteTemplateArgument();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例12: HandleTranslationUnit
void ReplaceClassWithBaseTemplateSpec::HandleTranslationUnit(ASTContext &Ctx)
{
if (TransformationManager::isCLangOpt() ||
TransformationManager::isOpenCLLangOpt()) {
ValidInstanceNum = 0;
}
else {
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
}
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TheCXXRecord && "TheCXXRecord is NULL!");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
TransAssert(RewriteVisitor && "NULL RewriteVisitor!");
RewriteVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
removeBaseSpecifier();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例13: HandleTranslationUnit
void CallExprToValue::HandleTranslationUnit(ASTContext &Ctx)
{
CollectionVisitor->TraverseDecl(Ctx.getTranslationUnitDecl());
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TheCallExpr && "NULL TheCallExpr!");
TransAssert(CurrentFD && "NULL CurrentFD");
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
NameQueryWrap->TraverseDecl(Ctx.getTranslationUnitDecl());
NamePostfix = NameQueryWrap->getMaxNamePostfix() + 1;
replaceCallExpr();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
示例14: HandleTranslationUnit
virtual void HandleTranslationUnit(ASTContext& context) {
// Resolve all string class names to clang NamedDecls.
m_resolveVisitor.TraverseDecl(context.getTranslationUnitDecl());
// Visit all declarations.
m_generator.preVisit();
m_generator.TraverseDecl(context.getTranslationUnitDecl());
m_generator.emitScanMethods();
}
示例15: HandleTranslationUnit
void BlinkGCPluginConsumer::HandleTranslationUnit(ASTContext& context) {
// Don't run the plugin if the compilation unit is already invalid.
if (diagnostic_.hasErrorOccurred())
return;
ParseFunctionTemplates(context.getTranslationUnitDecl());
CollectVisitor visitor;
visitor.TraverseDecl(context.getTranslationUnitDecl());
if (options_.dump_graph) {
std::error_code err;
// TODO: Make createDefaultOutputFile or a shorter createOutputFile work.
json_ = JsonWriter::from(instance_.createOutputFile(
"", // OutputPath
err, // Errors
true, // Binary
true, // RemoveFileOnSignal
instance_.getFrontendOpts().OutputFile, // BaseInput
"graph.json", // Extension
false, // UseTemporary
false, // CreateMissingDirectories
0, // ResultPathName
0)); // TempPathName
if (!err && json_) {
json_->OpenList();
} else {
json_ = 0;
llvm::errs()
<< "[blink-gc] "
<< "Failed to create an output file for the object graph.\n";
}
}
for (CollectVisitor::RecordVector::iterator it =
visitor.record_decls().begin();
it != visitor.record_decls().end();
++it) {
CheckRecord(cache_.Lookup(*it));
}
for (CollectVisitor::MethodVector::iterator it =
visitor.trace_decls().begin();
it != visitor.trace_decls().end();
++it) {
CheckTracingMethod(*it);
}
if (json_) {
json_->CloseList();
delete json_;
json_ = 0;
}
}