From 03e5ef7668826446908eb84b12825a287c90ace4 Mon Sep 17 00:00:00 2001 From: manasij7479 Date: Tue, 22 Jul 2014 22:00:30 +0530 Subject: [PATCH] Prevent printing non-fixed enums Remove skipping of system headers Also, do not print default template arguments if they do not have a name. --- include/cling/Interpreter/Interpreter.h | 5 ++-- lib/Interpreter/AutoloadCallback.cpp | 1 + lib/Interpreter/ForwardDeclPrinter.cpp | 6 ++-- lib/Interpreter/Interpreter.cpp | 37 ++----------------------- test/Autoloading/EnumTest.C | 21 -------------- 5 files changed, 10 insertions(+), 60 deletions(-) delete mode 100644 test/Autoloading/EnumTest.C diff --git a/include/cling/Interpreter/Interpreter.h b/include/cling/Interpreter/Interpreter.h index ce24e33e..4311061c 100644 --- a/include/cling/Interpreter/Interpreter.h +++ b/include/cling/Interpreter/Interpreter.h @@ -615,9 +615,8 @@ namespace cling { void AddAtExitFunc(void (*Func) (void*), void* Arg); - void GenerateAutoloadingMap(llvm::StringRef inFile,llvm::StringRef outFile, - bool enableMacros = false, - bool skipSystem = true); + void GenerateAutoloadingMap(llvm::StringRef inFile, llvm::StringRef outFile, + bool enableMacros = false); void SetAutoloadCallback(); // FIXME: workaround for double deletion problem diff --git a/lib/Interpreter/AutoloadCallback.cpp b/lib/Interpreter/AutoloadCallback.cpp index 14fa75a4..ffe2fc45 100644 --- a/lib/Interpreter/AutoloadCallback.cpp +++ b/lib/Interpreter/AutoloadCallback.cpp @@ -99,6 +99,7 @@ namespace cling { AutoloadCallback::AutoloadCallback(Interpreter* interp) : InterpreterCallbacks(interp,true,false,true), m_Interpreter(interp){ + } AutoloadCallback::~AutoloadCallback() { } diff --git a/lib/Interpreter/ForwardDeclPrinter.cpp b/lib/Interpreter/ForwardDeclPrinter.cpp index 822b2254..c73836f1 100644 --- a/lib/Interpreter/ForwardDeclPrinter.cpp +++ b/lib/Interpreter/ForwardDeclPrinter.cpp @@ -205,7 +205,7 @@ namespace cling { } void ForwardDeclPrinter::VisitEnumDecl(EnumDecl *D) { - if (D->getName().size() == 0) { + if (D->getName().size() == 0 || !D->isFixed()) { m_SkipFlag = true; return; } @@ -571,6 +571,7 @@ namespace cling { //So, we ignore restrict here T.removeLocalRestrict(); T.print(Out, Policy, D->getName()); +// llvm::outs()<getName()<<"\n"; T.addRestrict(); Expr *Init = D->getInit(); @@ -743,6 +744,7 @@ namespace cling { if (const TemplateTypeParmDecl *TTP = dyn_cast(Param)) { + if (TTP->wasDeclaredWithTypename()) Out << "typename "; else @@ -756,7 +758,7 @@ namespace cling { if (Args) { Out << " = "; Args->get(i).print(Policy, Out); - } else if (TTP->hasDefaultArgument()) { + } else if (TTP->hasDefaultArgument() && TTP->getName().size() != 0) { Out << " = "; Out << TTP->getDefaultArgument().getAsString(Policy); }; diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index dec55c90..f4e81692 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -1192,23 +1192,7 @@ namespace cling { void Interpreter::GenerateAutoloadingMap(llvm::StringRef inFile, llvm::StringRef outFile, - bool enableMacros, - bool skipSystem) { - - llvm::SmallVector withSys; - GetIncludePaths(withSys,true,false); - - llvm::SmallVector withoutSys; - GetIncludePaths(withoutSys,false,false); - - std::sort(withSys.begin(),withSys.end()); - std::sort(withoutSys.begin(),withoutSys.end()); - - std::vector incpaths(withSys.size()); - if(skipSystem) - std::set_difference(withSys.begin(),withSys.end(), - withoutSys.begin(),withoutSys.end(), - incpaths.begin()); + bool enableMacros) { CompilationOptions CO; CO.DeclarationExtraction = 0; @@ -1256,23 +1240,6 @@ namespace cling { for(auto dit = dci.m_DGR.begin(); dit != dci.m_DGR.end(); ++dit) { clang::Decl* decl = *dit; - if(skipSystem) { - bool skip = false; - auto filename = getSema().getSourceManager().getFilename - (decl->getSourceRange().getBegin()); - auto path = llvm::sys::path::parent_path(filename); - for (auto p : incpaths) { - if (llvm::sys::fs::equivalent(p,path) - || llvm::sys::fs::equivalent - (p,llvm::sys::path::parent_path(path))) { - skip = true; - break; - } - } - if (skip) - continue; - } - visitor.Visit(decl); visitor.printSemiColon(); } @@ -1283,7 +1250,9 @@ namespace cling { out << "#undef " << m << "\n"; } } + T->setState(Transaction::kCommitted); + unload(1); return; } void Interpreter::SetAutoloadCallback() { diff --git a/test/Autoloading/EnumTest.C b/test/Autoloading/EnumTest.C deleted file mode 100644 index 50fe4398..00000000 --- a/test/Autoloading/EnumTest.C +++ /dev/null @@ -1,21 +0,0 @@ -//------------------------------------------------------------------------------ -// CLING - the C++ LLVM-based InterpreterG :) -// -// 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. -//------------------------------------------------------------------------------ - -// RUN: cat %s | %cling -I %S -Xclang -verify -// Test EnumTest -//XFAIL: * - -#include "cling/Interpreter/Interpreter.h" -gCling->GenerateAutoloadingMap("Enum.h","test.h"); -.undo 1 -#include "test.h" -#include "Enum.h" - -//expected-no-diagnostics - -.q \ No newline at end of file