"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "projects/CodeThorn/src/thorn2.C" between
rose-0.11.53.0.tar.gz and rose-0.11.54.0.tar.gz

About: ROSE is a compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C, C++, UPC, Fortran, OpenMP, Java, Python and PHP applications.

thorn2.C  (rose-0.11.53.0):thorn2.C  (rose-0.11.54.0)
skipping to change at line 165 skipping to change at line 165
<< (++uid); << (++uid);
return buf.str(); return buf.str();
} }
std::string encodedKey(ClassKeyType key, ClassNameFn* fn, const char* prefix, si ze_t maxlen) std::string encodedKey(ClassKeyType key, ClassNameFn* fn, const char* prefix, si ze_t maxlen)
{ {
return encodedName((*fn)(key), prefix, maxlen); return encodedName((*fn)(key), prefix, maxlen);
} }
std::string encodedVar(VariableId key, VarNameFn* fn, const char* prefix, size_t maxlen) std::string encodedVar(VariableKeyType key, VarNameFn* fn, const char* prefix, s ize_t maxlen)
{ {
return encodedName((*fn)(key), prefix, maxlen); return encodedName((*fn)(key), prefix, maxlen);
} }
/// ///
template <class GeneratorFunction> template <class GeneratorFunction>
struct NameGenerator; struct NameGenerator;
/// For classes the memoization is applied to class key type /// For classes the memoization is applied to class key type
/// \details /// \details
skipping to change at line 208 skipping to change at line 208
/// For variables the memoization is applied to class key type /// For variables the memoization is applied to class key type
/// \details /// \details
/// different classes get different names /// different classes get different names
template <> template <>
struct NameGenerator<VarNameFn> struct NameGenerator<VarNameFn>
{ {
NameGenerator(VarNameFn gen, const char* nameprefix, size_t numCharsOfOrigin alName) NameGenerator(VarNameFn gen, const char* nameprefix, size_t numCharsOfOrigin alName)
: memo(&encodedVar), nameGen(gen), prefix(nameprefix), maxlen(numCharsOfOrig inalName) : memo(&encodedVar), nameGen(gen), prefix(nameprefix), maxlen(numCharsOfOrig inalName)
{} {}
std::string operator()(VariableId key) std::string operator()(VariableKeyType key)
{ {
return memo(key, &nameGen, prefix, maxlen); return memo(key, &nameGen, prefix, maxlen);
} }
private: private:
using EncoderFn = decltype(&encodedVar); using EncoderFn = decltype(&encodedVar);
Memoizer<EncoderFn> memo; Memoizer<EncoderFn> memo;
VarNameFn nameGen; VarNameFn nameGen;
const char* const prefix; const char* const prefix;
skipping to change at line 232 skipping to change at line 232
/// For functions the memoization is applied to the actual function name /// For functions the memoization is applied to the actual function name
/// \details /// \details
/// to preserve overload and override relationships /// to preserve overload and override relationships
template <> template <>
struct NameGenerator<FuncNameFn> struct NameGenerator<FuncNameFn>
{ {
NameGenerator(FuncNameFn gen, const char* nameprefix, size_t numCharsOfOrigi nalName) NameGenerator(FuncNameFn gen, const char* nameprefix, size_t numCharsOfOrigi nalName)
: memo(&encodedName), nameGen(gen), prefix(nameprefix), maxlen(numCharsOfOri ginalName) : memo(&encodedName), nameGen(gen), prefix(nameprefix), maxlen(numCharsOfOri ginalName)
{} {}
std::string operator()(FunctionId id) std::string operator()(FunctionKeyType id)
{ {
return memo(nameGen(id), prefix, maxlen); return memo(nameGen(id), prefix, maxlen);
} }
private: private:
using EncoderFn = decltype(&encodedName); using EncoderFn = decltype(&encodedName);
Memoizer<EncoderFn> memo; Memoizer<EncoderFn> memo;
FuncNameFn nameGen; FuncNameFn nameGen;
const char* const prefix; const char* const prefix;
skipping to change at line 310 skipping to change at line 310
ROSE_ASSERT(success); ROSE_ASSERT(success);
} }
); );
return res; return res;
} }
struct Parameters struct Parameters
{ {
std::string dotfile_output = opt_none; std::string dotfile_output = opt_none;
std::string txtfile_layout = opt_none; std::string txtfile_layout = opt_none;
std::string dotfile_layout = opt_none; std::string dotfile_layout = opt_none;
std::string txtfile_vfun = opt_none; std::string txtfile_vfun = opt_none;
int numCharsOfOriginalName = -1; std::string txtfile_vbaseclass = opt_none;
bool withOverridden = false; int numCharsOfOriginalName = -1;
bool withOverridden = false;
static const std::string dot_output; static const std::string dot_output;
static const std::string txt_layout; static const std::string txt_layout;
static const std::string dot_layout; static const std::string dot_layout;
static const std::string txt_vfun; static const std::string txt_vfun;
static const std::string txt_vbaseclass;
static const std::string name_encoding; static const std::string name_encoding;
static const std::string vfun_overridden; static const std::string vfun_overridden;
static const std::string opt_none; static const std::string opt_none;
}; };
const std::string Parameters::dot_output("dot"); const std::string Parameters::dot_output("dot");
const std::string Parameters::txt_layout("layout_txt"); const std::string Parameters::txt_layout("layout_txt");
const std::string Parameters::dot_layout("layout_dot"); const std::string Parameters::dot_layout("layout_dot");
const std::string Parameters::txt_vfun("virtual_functions"); const std::string Parameters::txt_vfun("virtual_functions");
const std::string Parameters::txt_vbaseclass("virtual_bases_txt");
const std::string Parameters::name_encoding("original_name"); const std::string Parameters::name_encoding("original_name");
const std::string Parameters::vfun_overridden("with_overriden"); const std::string Parameters::vfun_overridden("with_overriden");
const std::string Parameters::opt_none(""); const std::string Parameters::opt_none("");
} // anonymous namespace } // anonymous namespace
struct Acuity struct Acuity
{ {
/// sets the Acuity settings using the command line arguments /// sets the Acuity settings using the command line arguments
/// \returns a list of unparsed arguments /// \returns a list of unparsed arguments
skipping to change at line 371 skipping to change at line 374
.doc("filename for printing object layout tables as dot graph")); .doc("filename for printing object layout tables as dot graph"));
acuity.insert(scl::Switch(Parameters::txt_layout) acuity.insert(scl::Switch(Parameters::txt_layout)
.argument("filename", scl::anyParser(params.txtfile_layout)) .argument("filename", scl::anyParser(params.txtfile_layout))
.doc("filename for printing object layout tables")); .doc("filename for printing object layout tables"));
acuity.insert(scl::Switch(Parameters::txt_vfun) acuity.insert(scl::Switch(Parameters::txt_vfun)
.argument("filename", scl::anyParser(params.txtfile_vfun)) .argument("filename", scl::anyParser(params.txtfile_vfun))
.doc("filename for printing virtual function information")); .doc("filename for printing virtual function information"));
acuity.insert(scl::Switch(Parameters::txt_vbaseclass)
.argument("filename", scl::anyParser(params.txtfile_vbaseclass))
.doc("filename for printing virtual class construction order"));
acuity.insert(scl::Switch(Parameters::name_encoding) acuity.insert(scl::Switch(Parameters::name_encoding)
//~ .intrinsicValue(true, params.nameEncoding) //~ .intrinsicValue(true, params.nameEncoding)
.argument("int", scl::anyParser(params.numCharsOfOriginalName)) .argument("int", scl::anyParser(params.numCharsOfOriginalName))
.doc("length of original name to be used in output\n(default: use or iginal name entirely).")); .doc("length of original name to be used in output\n(default: use or iginal name entirely)."));
acuity.insert(scl::Switch(Parameters::vfun_overridden, 'o') acuity.insert(scl::Switch(Parameters::vfun_overridden, 'o')
.intrinsicValue(true, params.withOverridden) .intrinsicValue(true, params.withOverridden)
.doc("lists all overriding functions in derived classes.")); .doc("lists all overriding functions in derived classes."));
scl::ParserResult cmdline = p.with(acuity).parse(args).apply(); scl::ParserResult cmdline = p.with(acuity).parse(args).apply();
skipping to change at line 410 skipping to change at line 417
void void
writeVFunInfoIfRequested( const ct::RoseCompatibilityBridge& compatLayer, writeVFunInfoIfRequested( const ct::RoseCompatibilityBridge& compatLayer,
const Parameters& params, const Parameters& params,
ct::ClassNameFn& classNameFn, ct::ClassNameFn& classNameFn,
ct::FuncNameFn& funcNameFn, ct::FuncNameFn& funcNameFn,
ct::ClassFilterFn include, ct::ClassFilterFn include,
const ct::AnalysesTuple& analyses const ct::AnalysesTuple& analyses
); );
void process(SgProject& project, ct::VariableIdMapping& vmap, const ct::Func void
tionIdMapping& fmap) writeVBaseInfoIfRequested( const ct::RoseCompatibilityBridge& compatLayer,
{ const Parameters& params,
using CompatibilityBridge = ct::RoseCompatibilityBridge; ct::ClassNameFn& classNameFn,
ct::ClassFilterFn include,
const ct::AnalysesTuple& analyses
);
logInfo() << "Thorn 2 (aka Acuity): " void process(SgProject& project, ct::VariableIdMapping&, const ct::FunctionI
dMapping& fmap)
{
logInfo() << "Thorn 2: "
<< params.dotfile_output << params.dotfile_output
<< " - " << params.txtfile_layout << " - " << params.txtfile_layout
<< std::endl; << std::endl;
logInfo() << "getting all classes.. " << std::endl; logInfo() << "getting all classes.. " << std::endl;
CompatibilityBridge compatLayer{vmap, fmap}; ct::RoseCompatibilityBridge compatLayer;
ct::AnalysesTuple analyses = ct::analyzeClassesAndCasts(compatLayer, &pr oject); ct::AnalysesTuple analyses = ct::analyzeClassesAndCasts(compatLayer, &pr oject);
logInfo() << "getting all classes done. " << std::endl; logInfo() << "getting all classes done. " << std::endl;
IncludeInOutputSet outset = buildOutputSet(std::get<0>(analyses)); IncludeInOutputSet outset = buildOutputSet(std::get<0>(analyses));
const int maxlen = params.numCharsOfOriginalName; const int maxlen = params.numCharsOfOriginalName;
ct::ClassNameFn clsNameGen = createNameGenerator(compatLayer.classNome nclator(), "Cl", maxlen); ct::ClassNameFn clsNameGen = createNameGenerator(compatLayer.classNome nclator(), "Cl", maxlen);
ct::FuncNameFn funNameGen = createNameGenerator(compatLayer.functionN omenclator(), "fn", maxlen); ct::FuncNameFn funNameGen = createNameGenerator(compatLayer.functionN omenclator(), "fn", maxlen);
ct::VarNameFn varNameGen = createNameGenerator(compatLayer.variableN omenclator(), "var", maxlen); ct::VarNameFn varNameGen = createNameGenerator(compatLayer.variableN omenclator(), "var", maxlen);
writeDotFileIfRequested (params, clsNameGen, outset, analyses); writeDotFileIfRequested (params, clsNameGen, outset, analyses);
writeLayoutIfRequested(compatLayer, params, clsNameGen, varNameGen, outset , analyses); writeLayoutIfRequested(compatLayer, params, clsNameGen, varNameGen, outset , analyses);
writeVFunInfoIfRequested (compatLayer, params, clsNameGen, funNameGen, out set, analyses); writeVFunInfoIfRequested (compatLayer, params, clsNameGen, funNameGen, out set, analyses);
writeVBaseInfoIfRequested(compatLayer, params, clsNameGen, outset, analyse s);
} }
private: private:
Parameters params; Parameters params;
}; };
void void
Acuity::writeLayoutIfRequested( const ct::RoseCompatibilityBridge& compatLayer, Acuity::writeLayoutIfRequested( const ct::RoseCompatibilityBridge& compatLayer,
const Parameters& params, const Parameters& params,
ct::ClassNameFn& classNameFn, ct::ClassNameFn& classNameFn,
skipping to change at line 496 skipping to change at line 510
ct::ClassFilterFn include, ct::ClassFilterFn include,
const ct::AnalysesTuple& analyses const ct::AnalysesTuple& analyses
) )
{ {
if (params.txtfile_vfun == Parameters::opt_none) if (params.txtfile_vfun == Parameters::opt_none)
return; return;
logInfo() << "computing virtual function information" logInfo() << "computing virtual function information"
<< std::endl; << std::endl;
ct::VirtualFunctionAnalysis vfa = virtualFunctionAnalysis(compatLayer, analyse s.classAnalysis()); ct::VirtualFunctionAnalysis vfa = analyzeVirtualFunctions(compatLayer, analyse s.classAnalysis());
logInfo() << "writing virtual function information file " << params.txtfile_vf un << ".." logInfo() << "writing virtual function information file " << params.txtfile_vf un << ".."
<< std::endl; << std::endl;
std::ofstream outfile{params.txtfile_vfun}; std::ofstream outfile{params.txtfile_vfun};
virtualFunctionsTxt( outfile, virtualFunctionsTxt( outfile,
classNameFn, classNameFn,
funcNameFn, funcNameFn,
include, include,
analyses.classAnalysis(), analyses.classAnalysis(),
vfa, vfa,
params.withOverridden params.withOverridden
); );
logInfo() << "writing virtual function information done" << std::endl; logInfo() << "writing virtual function information done" << std::endl;
} }
void void
Acuity::writeVBaseInfoIfRequested( const ct::RoseCompatibilityBridge& compatLaye
r,
const Parameters& params,
ct::ClassNameFn& classNameFn,
ct::ClassFilterFn include,
const ct::AnalysesTuple& analyses
)
{
if (params.txtfile_vbaseclass == Parameters::opt_none)
return;
logInfo() << "writing virtual base class initialization order file " << params
.txtfile_vbaseclass << ".."
<< std::endl;
std::ofstream outfile{params.txtfile_vbaseclass};
virtualBaseClassInitOrderTxt( outfile,
classNameFn,
include,
analyses.classAnalysis()
);
logInfo() << "writing virtual base class initialization order file done" << st
d::endl;
}
void
Acuity::writeDotFileIfRequested( const Parameters& params, Acuity::writeDotFileIfRequested( const Parameters& params,
ct::ClassNameFn& classNameFn, ct::ClassNameFn& classNameFn,
ct::ClassFilterFn include, ct::ClassFilterFn include,
const ct::AnalysesTuple& analyses const ct::AnalysesTuple& analyses
) )
{ {
if (params.dotfile_output == Parameters::opt_none) if (params.dotfile_output == Parameters::opt_none)
return; return;
logInfo() << "writing dot file " << params.dotfile_output << ".." logInfo() << "writing dot file " << params.dotfile_output << ".."
 End of changes. 13 change blocks. 
16 lines changed or deleted 58 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)