Skip to content

Commit

Permalink
Handle case where SALT_FORTRAN_CONFIG_FILE is set, but empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaimov committed Dec 13, 2024
1 parent ab3ca29 commit cfbc553
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/salt_instrument_flang_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,12 @@ class SaltInstrumentAction final : public PluginParseTreeAction {
}

[[nodiscard]] static std::string getConfigPath() {
// If config path env var is set and non-empty, use that;
// otherwise use default.
if (const char *val = getenv(SALT_FORTRAN_CONFIG_FILE_VAR)) {
return std::string{val};
if (const std::string configPath{val}; !configPath.empty()) {
return configPath;
}
}
return SALT_FORTRAN_CONFIG_DEFAULT_PATH;
}
Expand All @@ -602,7 +606,7 @@ class SaltInstrumentAction final : public PluginParseTreeAction {
std::ifstream inputStream{configPath};
if (!inputStream) {
llvm::errs() << "ERROR: Could not open configuration file " << configPath << "\n"
<< "Set " SALT_FORTRAN_CONFIG_FILE_VAR " to path to desired configuration file.\n";
<< "Set $" SALT_FORTRAN_CONFIG_FILE_VAR " to path to desired configuration file.\n";
std::exit(-3);
}
std::stringstream configStream;
Expand Down

0 comments on commit cfbc553

Please sign in to comment.