- FileInputProvider fip( std::string("/etc/llvm/") + ftype );
- if (!fip.okay()) {
- fip.error("Configuration for '" + ftype + "' is not available.");
- fip.checkErrors();
- }
- else {
- result = new CompilerDriver::ConfigData();
- ParseConfigData(fip,*result);
+ // Try the environment variable
+ const char* conf = getenv("LLVM_CONFIG_DIR");
+ if (conf) {
+ dir_name = conf;
+ dir_name += "/";
+ if (!::sys::FileReadable(dir_name + ftype))
+ throw "Configuration file for '" + ftype + "' is not available.";
+ } else {
+ // Try the user's home directory
+ const char* home = getenv("HOME");
+ if (home) {
+ dir_name = home;
+ dir_name += "/.llvm/etc/";
+ if (!::sys::FileReadable(dir_name + ftype)) {
+ // Okay, try the LLVM installation directory
+ dir_name = LLVM_ETCDIR;
+ dir_name += "/";
+ if (!::sys::FileReadable(dir_name + ftype)) {
+ // Okay, try the "standard" place
+ dir_name = "/etc/llvm/";
+ if (!::sys::FileReadable(dir_name + ftype)) {
+ throw "Configuration file for '" + ftype + "' is not available.";
+ }
+ }
+ }
+ }