In the TestConfig PathToLLTestFiles, PathToTxtTestFiles and PathToJSONTestFiles are globals that depend on the global Configuration::PhasarDir. However, the initialization order of global variables is not defined, so at initialization-time of the three globals from the TestConfig, the PhasarDir might not have been initialized yet leading to undefined behavior. This might materialize in the unittests not finding the llvm test files.
The fix makes PhasarDir a static local inside Configuration::PhasarDirectory(). Here, it is guaranteed by the standard that the static local variable is initialized exactly once the first time the enclosing function is being called.
In the TestConfig
PathToLLTestFiles
,PathToTxtTestFiles
andPathToJSONTestFiles
are globals that depend on the globalConfiguration::PhasarDir
. However, the initialization order of global variables is not defined, so at initialization-time of the three globals from the TestConfig, thePhasarDir
might not have been initialized yet leading to undefined behavior. This might materialize in the unittests not finding the llvm test files.The fix makes
PhasarDir
a static local insideConfiguration::PhasarDirectory()
. Here, it is guaranteed by the standard that the static local variable is initialized exactly once the first time the enclosing function is being called.