New log file name format, and skip function templates with default function arguments

This commit is contained in:
manasij7479 2014-08-11 02:58:42 +05:30 committed by sftnight
parent a53c908fba
commit 3c260f9e4a
9 changed files with 63 additions and 36 deletions

View File

@ -627,7 +627,7 @@ namespace cling {
void GenerateAutoloadingMap(llvm::StringRef inFile, llvm::StringRef outFile,
bool enableMacros = false);
bool enableMacros = false, bool enableLogs = true);
friend class runtime::internal::LifetimeHandler;
// FIXME: workaround until JIT supports exceptions

View File

@ -927,6 +927,15 @@ namespace cling {
return D->getNameAsString().find("operator") == 0;
}
bool ForwardDeclPrinter::hasDefaultArgument(FunctionDecl *D) {
auto N = D->getNumParams();
for (uint i=0; i < N; ++i) {
if (D->getParamDecl(i)->hasDefaultArg())
return true;
}
return false;
}
bool ForwardDeclPrinter::shouldSkip(FunctionDecl *D) {
bool param = false;
//will be true if any of the params turn out to have incompatible types
@ -1154,8 +1163,17 @@ namespace cling {
return false;
}
bool ForwardDeclPrinter::shouldSkip(FunctionTemplateDecl* D){
return ContainsIncompatibleName(D->getTemplateParameters())
|| shouldSkip(D->getAsFunction());
bool inctype = ContainsIncompatibleName(D->getTemplateParameters());
bool func = shouldSkip(D->getTemplatedDecl());
bool hasdef = hasDefaultArgument(D->getTemplatedDecl());
if (inctype || func || hasdef ) {
if (D->getDeclName().isIdentifier()){
m_IncompatibleNames.insert(D->getName());
if (hasdef) Log() << D->getName() << " Function Template : Has default argument\n";
}
return true;
}
return false;
}
bool ForwardDeclPrinter::shouldSkip(UsingDecl *D) {
@ -1172,6 +1190,6 @@ namespace cling {
}
void ForwardDeclPrinter::printStats() {
llvm::outs() << m_SkipCounter << " decls skipped out of " << m_TotalDecls << "\n";
Log() << m_SkipCounter << " decls skipped out of " << m_TotalDecls << "\n";
}
}//end namespace cling

View File

@ -139,6 +139,7 @@ namespace cling {
bool isIncompatibleType(clang::QualType q, bool includeNNS = true);
bool isOperator(clang::FunctionDecl* D);
bool hasDefaultArgument(clang::FunctionDecl* D);
template<typename DeclT>
bool shouldSkip(DeclT* D){return false;}
@ -156,6 +157,7 @@ namespace cling {
bool shouldSkip(clang::FunctionTemplateDecl* D);
bool shouldSkip(clang::TypeAliasTemplateDecl* D);
bool ContainsIncompatibleName(clang::TemplateParameterList* Params);
void skipCurrentDecl(bool skip = true);

View File

@ -1204,7 +1204,8 @@ namespace cling {
void Interpreter::GenerateAutoloadingMap(llvm::StringRef inFile,
llvm::StringRef outFile,
bool enableMacros) {
bool enableMacros,
bool enableLogs) {
const char *const dummy="cling";
// Create an interpreter without any runtime, producing the fwd decls.
@ -1236,13 +1237,17 @@ namespace cling {
std::string err;
llvm::raw_fd_ostream out(outFile.data(), err,
llvm::sys::fs::OpenFlags::F_None);
llvm::raw_fd_ostream log("skiplog", err,
llvm::sys::fs::OpenFlags::F_None);
ForwardDeclPrinter visitor(out, log, fwdGen.getSema().getSourceManager(), *T);
visitor.printStats();
if (enableLogs){
llvm::raw_fd_ostream log(llvm::Twine(outFile).concat(llvm::Twine(".skipped")).str().c_str(),
err, llvm::sys::fs::OpenFlags::F_None);
log << "Generated for :" << inFile << "\n";
ForwardDeclPrinter visitor(out, log, fwdGen.getSema().getSourceManager(), *T);
visitor.printStats();
}
else {
llvm::raw_null_ostream sink;
ForwardDeclPrinter visitor(out, sink, fwdGen.getSema().getSourceManager(), *T);
}
// Avoid assertion in the ~IncrementalParser.
T->setState(Transaction::kCommitted);
// unload(1);

View File

@ -11,14 +11,11 @@
//XFAIL: *
//All the currently failing stuff
#include "cling/Interpreter/Interpreter.h"
// #include "cling/Interpreter/AutoloadCallback.h"
gCling->GenerateAutoloadingMap("Fail.h","test.h");
gCling->process("const char * const argV = \"cling\";");
gCling->process("cling::Interpreter *DefaultInterp;");
gCling->process("DefaultInterp = new cling::Interpreter(1, &argV);");
gCling->process("DefaultInterp->process(\"#include \\\"test.h\\\"\");");
.T Fail.h fwd_fail.h
#include "fwd_fail.h"
#include "Fail.h"
#include "FakeFwd.h" //Because we skip function templates having default function arguments
#include "FunctionTemplate.h"
//expected-no-diagnostics
.q

View File

@ -6,6 +6,7 @@ namespace test { //implicit instantiation
struct conditional<false, T, F> { typedef F type; };
template <typename _Tp> using example = typename conditional<true,int,float>::type;
}//end namespace test
namespace test { //nested name specifier
@ -16,7 +17,7 @@ namespace test { //nested name specifier
HasSubType::SubType FunctionUsingSubtype(HasSubType::SubType s){return s;}
extern HasSubType::SubType variable;//locale::id id
}//end namespace test
}//end namespace test // This problem is bypassed by skipping types containing "::"
namespace test { //restrict keyword: try include/mmprivate.h and strlcpy.h when fixed
typedef long ssize_t;
@ -24,15 +25,16 @@ namespace test { //restrict keyword: try include/mmprivate.h and strlcpy.h when
//Has signature of readlink from unistd.h
extern ssize_t FunctionUsingRestrictPtr (const char *__restrict __path,
char *__restrict __buf, size_t __len);
}//end namespace test
}//end namespace test // This is bypassed by forcibly removing restrict from types
namespace test { //default template arg
template <typename T,int MAX=100> class Stack {
};
Stack<int> FunctionReturningStack(){return Stack<int>();}
}//end namespace test
// namespace test { //default template arg
// template <typename T,int MAX=100> class Stack {
// };
// Stack<int> FunctionReturningStack(){return Stack<int>();}
// }//end namespace test // Fixed with callback, strip old default args before including new file
// namespace test {
// //#include<tuple> //'tie' function
// //commented out to skip huge output
// } //Fixed bug in VisitFunctionDecl
namespace test {
//#include<tuple> //'tie' function
//commented out to skip huge output
}

View File

@ -0,0 +1,3 @@
namespace test {
template <typename T> void foo(int x=0);
}

View File

@ -28,14 +28,11 @@ filesToIgnore += "__wmmintrin_pclmul.h;rtmintrin.h;fma4intrin.h;avx2intrin.h;";
// Wrong setups, i.e not self-contained header files:
filesToIgnore += "dlg_colors.h;dialog.h;plugin-api.h;regexp.h;etip.h;dlg_keys.h;";
filesToIgnore += "cursesw.h;cursesm.h;cursesf.h;cursslk.h;cursesapp.h;term_entry.h;";
filesToIgnore += "cursesp.h;ft2build.h;";
filesToIgnore += "cursesp.h;ft2build.h;shared_mutex;ciso646;cxxabi.h;future";
// AUX:
filesToIgnore += "Makefile;CMakeLists.txt;";
// Temporary
filesToIgnore += "map;";
.rawInput 1
bool has_suffix(const std::string &str, const std::string &suffix) {
return str.size() >= suffix.size() &&

View File

@ -0,0 +1,3 @@
namespace test {
template <typename T> void foo(int x=0){}
}