Remove AutoloadingTransform and use the TransactionCommitted callback
This commit is contained in:
parent
2949be0831
commit
4b86baea4b
@ -14,6 +14,7 @@
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/AST/AST.h"
|
||||
#include "clang/AST/RecursiveASTVisitor.h"
|
||||
#include "clang/AST/DeclVisitor.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
|
||||
@ -46,6 +47,31 @@ namespace cling {
|
||||
report(t->getLocation(),t->getNameAsString(),t->getAttr<AnnotateAttr>()->getAnnotation());
|
||||
return false;
|
||||
}
|
||||
class DeclFixer : public DeclVisitor<DeclFixer> {
|
||||
public:
|
||||
void VisitDecl(Decl* D) {
|
||||
if (DeclContext* DC = dyn_cast<DeclContext>(D))
|
||||
for (auto Child : DC->decls())
|
||||
Visit(Child);
|
||||
}
|
||||
|
||||
void VisitEnumDecl(EnumDecl* ED) {
|
||||
if (ED->isFixed()) {
|
||||
StringRef str = ED->getAttr<AnnotateAttr>()->getAnnotation();
|
||||
char ch = str.back();
|
||||
str.drop_back(2);
|
||||
ED->getAttr<AnnotateAttr>()->setAnnotation(ED->getASTContext(), str);
|
||||
struct EnumDeclDerived: public EnumDecl {
|
||||
static void setFixed(EnumDecl* ED, bool value = true) {
|
||||
((EnumDeclDerived*)ED)->IsFixed = value;
|
||||
}
|
||||
};
|
||||
|
||||
if (ch != '1')
|
||||
EnumDeclDerived::setFixed(ED, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class DefaultArgVisitor: public RecursiveASTVisitor<DefaultArgVisitor> {
|
||||
private:
|
||||
@ -245,6 +271,22 @@ namespace cling {
|
||||
if (DCI.m_DGR.isNull())
|
||||
continue;
|
||||
|
||||
if (const NamedDecl* ND = dyn_cast<NamedDecl>(*T.decls_begin()->m_DGR.begin()))
|
||||
if (ND->getIdentifier()
|
||||
&& ND->getName().equals("__Cling_Autoloading_Map")) {
|
||||
|
||||
DeclFixer visitor;
|
||||
for (Transaction::const_iterator I = T.decls_begin(),
|
||||
E = T.decls_end(); I != E; ++I) {
|
||||
Transaction::DelayCallInfo DCI = *I;
|
||||
for (DeclGroupRef::iterator J = DCI.m_DGR.begin(),
|
||||
JE = DCI.m_DGR.end(); J != JE; ++J) {
|
||||
visitor.Visit(*J);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (DeclGroupRef::iterator J = DCI.m_DGR.begin(),
|
||||
JE = DCI.m_DGR.end(); J != JE; ++J) {
|
||||
defaultArgsStateCollector.TrackDefaultArgStateOf(*J, m_Map, PP);
|
||||
|
@ -1,73 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// CLING - the C++ LLVM-based InterpreterG :)
|
||||
// author: Manasij Mukherjee <manasij7479@gmail.com>
|
||||
// author: Vassil Vassilev <vvasilev@cern.ch>
|
||||
//
|
||||
// This file is dual-licensed: you can choose to license it under the University
|
||||
// of Illinois Open Source License or the GNU Lesser General Public License. See
|
||||
// LICENSE.TXT for details.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "AutoloadingTransform.h"
|
||||
#include "cling/Interpreter/Transaction.h"
|
||||
|
||||
#include "clang/AST/DeclVisitor.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
|
||||
using namespace clang;
|
||||
|
||||
namespace cling {
|
||||
|
||||
class DeclFixer : public DeclVisitor<DeclFixer> {
|
||||
public:
|
||||
void VisitDecl(Decl* D) {
|
||||
if (DeclContext* DC = dyn_cast<DeclContext>(D))
|
||||
for (auto Child : DC->decls())
|
||||
Visit(Child);
|
||||
}
|
||||
|
||||
void VisitEnumDecl(EnumDecl* ED) {
|
||||
if (ED->isFixed()) {
|
||||
StringRef str = ED->getAttr<AnnotateAttr>()->getAnnotation();
|
||||
char ch = str.back();
|
||||
str.drop_back(2);
|
||||
ED->getAttr<AnnotateAttr>()->setAnnotation(ED->getASTContext(), str);
|
||||
struct EnumDeclDerived: public EnumDecl {
|
||||
static void setFixed(EnumDecl* ED, bool value = true) {
|
||||
((EnumDeclDerived*)ED)->IsFixed = value;
|
||||
}
|
||||
};
|
||||
|
||||
if (ch != '1')
|
||||
EnumDeclDerived::setFixed(ED, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AutoloadingTransform::Transform() {
|
||||
const Transaction* T = getTransaction();
|
||||
if (T->decls_begin() == T->decls_end())
|
||||
return;
|
||||
DeclGroupRef DGR = T->decls_begin()->m_DGR;
|
||||
if (DGR.isNull())
|
||||
return;
|
||||
|
||||
if (const NamedDecl* ND = dyn_cast<NamedDecl>(*DGR.begin()))
|
||||
if (ND->getIdentifier()
|
||||
&& ND->getName().equals("__Cling_Autoloading_Map")) {
|
||||
|
||||
DeclFixer visitor;
|
||||
for (Transaction::const_iterator I = T->decls_begin(),
|
||||
E = T->decls_end(); I != E; ++I) {
|
||||
Transaction::DelayCallInfo DCI = *I;
|
||||
for (DeclGroupRef::iterator J = DCI.m_DGR.begin(),
|
||||
JE = DCI.m_DGR.end(); J != JE; ++J) {
|
||||
visitor.Visit(*J);
|
||||
//FIXME: Enable when safe !
|
||||
// if ( (*J)->hasAttr<AnnotateAttr>() /*FIXME: && CorrectCallbackLoaded() how ? */ )
|
||||
// clang::Decl::castToDeclContext(*J)->setHasExternalLexicalStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end namespace cling
|
@ -18,7 +18,6 @@ set( LLVM_LINK_COMPONENTS
|
||||
|
||||
add_cling_library(clingInterpreter
|
||||
AutoSynthesizer.cpp
|
||||
AutoloadingTransform.cpp
|
||||
AutoloadCallback.cpp
|
||||
BackendPass.cpp
|
||||
CheckEmptyTransactionTransformer.cpp
|
||||
|
@ -1,4 +1,13 @@
|
||||
//TODO: Adapted from DeclPrinter, may need to be rewritten
|
||||
//--------------------------------------------------------------------*- C++ -*-
|
||||
// CLING - the C++ LLVM-based InterpreterG :)
|
||||
// author: Manasij Mukherjee <manasij7479@gmail.com>
|
||||
// author: Vassil Vassilev <vvasilev@cern.ch>
|
||||
//
|
||||
// This file is dual-licensed: you can choose to license it under the University
|
||||
// of Illinois Open Source License or the GNU Lesser General Public License. See
|
||||
// LICENSE.TXT for details.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef CLING_AUTOLOADING_VISITOR_H
|
||||
#define CLING_AUTOLOADING_VISITOR_H
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "IncrementalParser.h"
|
||||
|
||||
#include "AutoSynthesizer.h"
|
||||
#include "AutoloadingTransform.h"
|
||||
#include "BackendPass.h"
|
||||
#include "CheckEmptyTransactionTransformer.h"
|
||||
#include "DeclCollector.h"
|
||||
@ -78,7 +77,6 @@ namespace cling {
|
||||
Sema* TheSema = &CI->getSema();
|
||||
// Register the AST Transformers
|
||||
m_ASTTransformers.push_back(new AutoSynthesizer(TheSema));
|
||||
m_ASTTransformers.push_back(new AutoloadingTransform(TheSema));
|
||||
m_ASTTransformers.push_back(new EvaluateTSynthesizer(TheSema));
|
||||
m_ASTTransformers.push_back(new ValuePrinterSynthesizer(TheSema, 0));
|
||||
m_ASTTransformers.push_back(new DeclExtractor(TheSema));
|
||||
|
Loading…
Reference in New Issue
Block a user