Do not blindly skip existing attributes, also fixes macro typedef redefinition issue

This commit is contained in:
manasij7479 2014-08-11 23:51:02 +05:30 committed by sftnight
parent a415711407
commit b556856580
2 changed files with 22 additions and 11 deletions

View File

@ -175,10 +175,10 @@ namespace cling {
AutoloadCallback::AutoloadCallback(Interpreter* interp) :
InterpreterCallbacks(interp,true,false,true), m_Interpreter(interp){
#ifdef _POSIX_C_SOURCE
//Workaround for differnt expansion of macros to typedefs
m_Interpreter->parse("#include <sys/types.h>");
#endif
//#ifdef _POSIX_C_SOURCE
// //Workaround for differnt expansion of macros to typedefs
// m_Interpreter->parse("#include <sys/types.h>");
//#endif
}
AutoloadCallback::~AutoloadCallback() {

View File

@ -71,13 +71,13 @@ namespace cling {
}
if (dci.m_Call == Transaction::kCCIHandleTopLevelDecl) {
for (auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) {
llvm::StringRef filename = m_SMgr.getFilename
((*dit)->getSourceRange().getBegin());
#ifdef _POSIX_C_SOURCE
//Workaround for differnt expansion of macros to typedefs
if (filename.endswith("sys/types.h"))
continue;
#endif
// llvm::StringRef filename = m_SMgr.getFilename
// ((*dit)->getSourceRange().getBegin());
//#ifdef _POSIX_C_SOURCE
// //Workaround for differnt expansion of macros to typedefs
// if (filename.endswith("sys/types.h"))
// continue;
//#endif
//This may indicate a bug in cling.
//This condition should ideally never be triggered
//But is needed in case of generating fwd decls for
@ -139,6 +139,17 @@ namespace cling {
void ForwardDeclPrinter::prettyPrintAttributes(Decl *D, std::string extra) {
if (D->getSourceRange().isInvalid())
return;
if (D->hasAttrs() && ! isa<FunctionDecl>(D)) {
AttrVec &Attrs = D->getAttrs();
for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i != e; ++i) {
Attr *A = *i;
if (!A->isImplicit() && !A->isInherited() && A->getKind() != attr::Kind::Final){
A->printPretty(Out(), m_Policy);
}
}
}
std::string file = m_SMgr.getFilename(m_SMgr.getSpellingLoc(D->getLocStart()));
// assert ( file.length() != 0 && "Filename Should not be blank");
Out() << " __attribute__((annotate(\""