Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/web/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2476,16 +2476,13 @@ @article{onimus_polycrystalline_2009
file = {ScienceDirect Snapshot:/home/th202608/.zotero/zotero/vzpzva46.default/zotero/storage/S2AIW7IH/S0022311508006910.html:text/html}
}



@online{cea_edf_madnex_library_2020,
title = {The `MADNEX` library},
url = {https://thelfer.github.io/madnex/web/index.html},
author = {CEA, EDF},
date = {2020}
}


@article{garcia_effect_2020,
title = {The effect of oxygen partial pressure on dislocation creep in polycrystalline uranium dioxide},
issn = {0955-2219},
Expand Down
4 changes: 4 additions & 0 deletions docs/web/release-notes-5.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ The page describes the new functionalities of Version 5.1.1 of the

# Issues fixed

## Issue 947: [mfront] Warnings in Windows

For more details, see <https://github.com/thelfer/tfel/issues/947>

## Issue 913: `env.sh.in` shall not define the `PYTHONPATH`

For more details, see <https://github.com/thelfer/tfel/issues/913>
Expand Down
18 changes: 18 additions & 0 deletions mfront/include/MFront/CodeGeneratorUtilities.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,24 @@ namespace mfront {
const std::string_view,
const bool,
const bool);
/*!
* \brief print a `#line` pragma indicating a line number and a file name
*
* \param[os] os: output stream
* \param[in] ln: line number
* \param[in] f: file name
*/
MFRONT_VISIBILITY_EXPORT
void printLinePragma(std::ostream&, const std::size_t, std::string_view);

/*!
* \brief print a `#line` pragma indicating a line number and a file name
*
* \param[in] ln: line number
* \param[in] f: file name
*/
MFRONT_VISIBILITY_EXPORT [[nodiscard]] std::string printLinePragma(
const std::size_t, std::string_view);

} // end of namespace mfront

Expand Down
14 changes: 4 additions & 10 deletions mfront/src/BehaviourCodeGeneratorBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,8 @@ namespace mfront {
const auto t = (!useTimeDerivative)
? v.type
: SupportedTypes::getTimeDerivativeType(v.type);
if ((!getDebugMode()) && (v.lineNumber != 0u)) {
f << "#line " << v.lineNumber << " \"" << fileName << "\"\n";
if (!getDebugMode()) {
printLinePragma(f, v.lineNumber, this->fd.fileName);
}
if (v.arraySize == 1u) {
f << t << " " << n << ";\n";
Expand Down Expand Up @@ -3635,10 +3635,7 @@ namespace mfront {
continue;
}
if (!getDebugMode()) {
if (p.lineNumber != 0u) {
os << "#line " << p.lineNumber << " \"" << this->fd.fileName
<< "\"\n";
}
printLinePragma(os, p.lineNumber, this->fd.fileName);
}
if (use_static_variables) {
os << "static constexpr ";
Expand Down Expand Up @@ -3708,10 +3705,7 @@ namespace mfront {
this->checkBehaviourFile(os);
for (const auto& v : md.getStaticVariables()) {
if (!getDebugMode()) {
if (v.lineNumber != 0u) {
os << "#line " << v.lineNumber << " \"" << this->fd.fileName
<< "\"\n";
}
printLinePragma(os, v.lineNumber, this->fd.fileName);
}
os << "static constexpr auto " << v.name << " = " //
<< v.type << "{" << v.value << "};\n";
Expand Down
10 changes: 9 additions & 1 deletion mfront/src/CastemMaterialPropertyInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,18 @@ namespace mfront {
writeMaterialKnowledgeTypeSymbol(out, name,
MaterialKnowledgeType::MATERIALPROPERTY);
writeParametersSymbols(out, name, mpd);
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
exportStringSymbol(
out, name + "_src",
tfel::utilities::replace_all(
tfel::utilities::tokenize(file, tfel::system::dirSeparator())
.back()),
"\\", "\\\\");
#else
exportStringSymbol(
out, name + "_src",
tfel::utilities::tokenize(file, tfel::system::dirSeparator()).back());

#endif
if ((!areParametersTreatedAsStaticVariables(mpd)) && (!params.empty())) {
const auto hn = getMaterialPropertyParametersHandlerClassName(name);
out << "MFRONT_SHAREDOBJ int\n"
Expand Down
6 changes: 3 additions & 3 deletions mfront/src/CastemModelInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,14 @@ namespace mfront {
// material properties
for (const auto& mp : md.constantMaterialProperties) {
if (!getDebugMode()) {
os << "#line " << mp.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, mp.lineNumber, fd.fileName);
}
os << "const " << mp.type << " " << mp.name << ";\n";
}
// parameters
for (const auto& p : md.parameters) {
if (!getDebugMode()) {
os << "#line " << p.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, p.lineNumber, fd.fileName);
}
if ((isRealParameter(p)) &&
(!areParametersTreatedAsStaticVariables(md))) {
Expand All @@ -589,7 +589,7 @@ namespace mfront {
// static variables
for (const auto& v : md.staticVars) {
if (!getDebugMode()) {
os << "#line " << v.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, v.lineNumber, fd.fileName);
}
os << "static constexpr " << v.type << " " << v.name << " = " //
<< v.value << ";\n";
Expand Down
28 changes: 27 additions & 1 deletion mfront/src/CodeGeneratorUtilities.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ namespace mfront {
}
for (const auto& v : vc) {
if (getDebugMode()) {
os << "#line " << v.lineNumber << " \"" << f << "\"\n";
printLinePragma(os, v.lineNumber, f);
}
if (v.type == "short") {
os << "static " << constexpr_c << " short " << v.name << " = "
Expand Down Expand Up @@ -681,4 +681,30 @@ namespace mfront {
checkEndOfTimeStepValue, true);
} // end of writePhysicalBoundsChecks

std::string printLinePragma(const std::size_t ln, std::string_view f) {
if (ln == 0) {
return {};
}
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
return "#line " + std::to_string(ln) + " \"" +
tfel::utilities::replace_all(f, "\\", "\\\\") + "\"\n";
#else
return "#line " + std::to_string(ln) + " \"" + std::string{f} + "\"\n";
#endif
}

void printLinePragma(std::ostream& os,
const std::size_t ln,
std::string_view f) {
if (ln == 0) {
return;
}
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
os << "#line " << ln << " \""
<< tfel::utilities::replace_all(f, "\\", "\\\\") << "\"\n";
#else
os << "#line " << ln << " \"" << f << "\"\n";
#endif
}

} // end of namespace mfront
17 changes: 4 additions & 13 deletions mfront/src/DSLBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "MFront/MFrontUtilities.hxx"
#include "MFront/MFrontDebugMode.hxx"
#include "MFront/MFrontLogStream.hxx"
#include "MFront/CodeGeneratorUtilities.hxx"
#include "MFront/MFrontMaterialPropertyInterface.hxx"
#include "MFront/StaticVariableDescription.hxx"
#include "MFront/GlobalDomainSpecificLanguageOptionsManager.hxx"
Expand Down Expand Up @@ -393,11 +394,7 @@ namespace mfront {
}
auto currentLine = this->current->line;
if ((registerLine) && (!getDebugMode())) {
res = "#line ";
res += std::to_string(currentLine);
res += " \"";
res += this->fd.fileName;
res += "\"\n";
res = printLinePragma(currentLine, this->fd.fileName);
}
if (!this->current->comment.empty()) {
if (!b.description.empty()) {
Expand Down Expand Up @@ -454,15 +451,9 @@ namespace mfront {
currentValue = demangle(*(this->current));
if (currentLine != this->current->line) {
currentLine = this->current->line;
res += "\n";
if ((registerLine) && (!getDebugMode())) {
res += "\n";
res += "#line ";
res += std::to_string(currentLine);
res += " \"";
res += this->fd.fileName;
res += "\"\n";
} else {
res += "\n";
res += printLinePragma(currentLine, this->fd.fileName);
}
}
if ((currentValue == ";") && (!allowSemiColon)) {
Expand Down
6 changes: 3 additions & 3 deletions mfront/src/GenericModelInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ namespace mfront {
// material properties
for (const auto& mp : md.constantMaterialProperties) {
if (!getDebugMode()) {
os << "#line " << mp.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, mp.lineNumber, fd.fileName);
}
os << "const " << mp.type << " " << mp.name << ";\n";
}
// parameters
for (const auto& p : md.parameters) {
if (!getDebugMode()) {
os << "#line " << p.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, p.lineNumber, fd.fileName);
}
if ((isRealParameter(p)) &&
(!areParametersTreatedAsStaticVariables(md))) {
Expand All @@ -472,7 +472,7 @@ namespace mfront {
// static variables
for (const auto& v : md.staticVars) {
if (!getDebugMode()) {
os << "#line " << v.lineNumber << " \"" << fd.fileName << "\"\n";
printLinePragma(os, v.lineNumber, fd.fileName);
}
os << "static constexpr " << v.type << " " << v.name << " = " //
<< v.value << ";\n";
Expand Down
4 changes: 2 additions & 2 deletions mfront/src/ImplicitCodeGeneratorBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,8 @@ namespace mfront {
const auto& d = this->bd.getBehaviourData(h);
this->checkBehaviourFile(os);
for (const auto& v : d.getIntegrationVariables()) {
if ((!getDebugMode()) && (v.lineNumber != 0u)) {
os << "#line " << v.lineNumber << " \"" << this->fd.fileName << "\"\n";
if (!getDebugMode()) {
printLinePragma(os, v.lineNumber, this->fd.fileName);
}
if (v.arraySize == 1u) {
if (SupportedTypes::getTypeFlag(v.type) == SupportedTypes::SCALAR) {
Expand Down
6 changes: 2 additions & 4 deletions mfront/src/MaterialPropertyDSL.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,15 @@ namespace mfront {
currentLine = this->current->line;
newLine = true;
if (!getDebugMode()) {
this->md.f.body += "#line " + std::to_string(currentLine) + " \"" +
this->fd.fileName + "\"\n";
this->md.f.body += printLinePragma(currentLine, this->fd.fileName);
}
for (; (this->current != this->tokens.end()) && (openedBrackets != 0);
++(this->current)) {
if (this->current->line != currentLine) {
currentLine = this->current->line;
this->md.f.body += "\n";
if (!getDebugMode()) {
this->md.f.body += "#line " + std::to_string(currentLine) + " \"" +
this->fd.fileName + "\"\n";
this->md.f.body += printLinePragma(currentLine, this->fd.fileName);
}
newLine = true;
}
Expand Down
7 changes: 3 additions & 4 deletions mfront/src/ModelDSLCommon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "MFront/ModelDSLCommon.hxx"
#include "MFront/TargetsDescription.hxx"
#include "MFront/ModelInterfaceFactory.hxx"
#include "MFront/CodeGeneratorUtilities.hxx"

// fixing a bug on current glibc++ cygwin versions (19/08/2015)
#if defined __CYGWIN__ && (!defined _GLIBCXX_USE_C99)
Expand Down Expand Up @@ -482,17 +483,15 @@ namespace mfront {
auto newInstruction = true;
auto newLine = true;
if (!getDebugMode()) {
f.body += "#line " + std::to_string(currentLine) + " \"" +
this->fd.fileName + "\"\n";
f.body += printLinePragma(currentLine, this->fd.fileName);
}
for (; (this->current != this->tokens.end()) && (openedBrackets != 0);
++(this->current)) {
if (this->current->line != currentLine) {
currentLine = this->current->line;
f.body += "\n";
if (!getDebugMode()) {
f.body += "#line " + std::to_string(currentLine) + " \"" +
this->fd.fileName + "\"\n";
f.body += printLinePragma(currentLine, this->fd.fileName);
}
newLine = true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/System/System.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ namespace tfel::system {
}
#endif /* (defined _WIN32) || (defined _WIN64) */

char dirSeparator() { return '/'; } // end of dirSeparator
char dirSeparator() {
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
return '\\';
#else
return '/';
#endif
} // end of dirSeparator

const std::string& dirStringSeparator() {
static std::string s(1u, dirSeparator());
Expand Down
Loading