And an FoldingSetImpl::NodeID::AddInteger overload for int64_t, to avoid
[oota-llvm.git] / tools / llvmc / Configuration.cpp
index 2abf651d70210dfaa3c415b96e9973dc909912b0..aafca792b19cd4507443438c624795ac1318650c 100644 (file)
@@ -10,7 +10,7 @@
 // This file implements the parsing of configuration files for the LLVM Compiler
 // Driver (llvmc).
 //
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
 
 #include "Configuration.h"
 #include "ConfigLexer.h"
@@ -116,6 +116,8 @@ namespace {
       result.clear();
       while (next_is_real()) {
         switch (token ) {
+       case LLVMGCCDIR_SUBST:
+       case LLVMGCCARCH_SUBST:
           case STRING :
           case OPTION :
             result += ConfigLexerState.StringVal;
@@ -167,9 +169,11 @@ namespace {
     bool parseSubstitution(CompilerDriver::StringVector& optList) {
       switch (token) {
         case ARGS_SUBST:        optList.push_back("%args%"); break;
+        case BINDIR_SUBST:      optList.push_back("%bindir%"); break;
         case DEFS_SUBST:        optList.push_back("%defs%"); break;
         case IN_SUBST:          optList.push_back("%in%"); break;
         case INCLS_SUBST:       optList.push_back("%incls%"); break;
+        case LIBDIR_SUBST:      optList.push_back("%libdir%"); break;
         case LIBS_SUBST:        optList.push_back("%libs%"); break;
         case OPT_SUBST:         optList.push_back("%opt%"); break;
         case OUT_SUBST:         optList.push_back("%out%"); break;
@@ -258,6 +262,11 @@ namespace {
       str.clear();
       do {
         switch (token) {
+       case BINDIR_SUBST:
+       case LLVMGCC_SUBST:
+       case LLVMGXX_SUBST:
+       case LLVMCC1_SUBST:
+       case LLVMCC1PLUS_SUBST:
           case OPTION:
           case STRING:
           case ARGS_SUBST:
@@ -282,8 +291,8 @@ namespace {
           case ASSEMBLY:
             str += "assembly";
             break;
-          case BYTECODE:
-            str += "bytecode";
+          case BITCODE:
+            str += "bitcode";
             break;
           case TRUETOK:
             str += "true";
@@ -316,7 +325,7 @@ namespace {
         {
           std::string progname;
           if (parseProgramName(progname))
-            action.program.setFile(progname);
+            action.program.set(progname);
           else
             error("Expecting a program name");
 
@@ -331,8 +340,8 @@ namespace {
               case ASSEMBLY:
                 anOption += "assembly";
                 break;
-              case BYTECODE:
-                anOption += "bytecode";
+              case BITCODE:
+                anOption += "bitcode";
                 break;
               case TRUETOK:
                 anOption += "true";
@@ -383,7 +392,7 @@ namespace {
           next();
         if (token == ASSEMBLY) {
           return true;
-        } else if (token == BYTECODE) {
+        } else if (token == BITCODE) {
           return false;
         } else {
           error("Expecting output type value");
@@ -545,30 +554,30 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
     // Try the environment variable
     const char* conf = getenv("LLVM_CONFIG_DIR");
     if (conf) {
-      confFile.setDirectory(conf);
-      confFile.appendFile(ftype);
-      if (!confFile.readable())
+      confFile.set(conf);
+      confFile.appendComponent(ftype);
+      if (!confFile.canRead())
         throw std::string("Configuration file for '") + ftype +
                           "' is not available.";
     } else {
       // Try the user's home directory
       confFile = sys::Path::GetUserHomeDirectory();
       if (!confFile.isEmpty()) {
-        confFile.appendDirectory(".llvm");
-        confFile.appendDirectory("etc");
-        confFile.appendFile(ftype);
-        if (!confFile.readable())
+        confFile.appendComponent(".llvm");
+        confFile.appendComponent("etc");
+        confFile.appendComponent(ftype);
+        if (!confFile.canRead())
           confFile.clear();
       }
-      if (!confFile.isEmpty()) {
+      if (confFile.isEmpty()) {
         // Okay, try the LLVM installation directory
         confFile = sys::Path::GetLLVMConfigDir();
-        confFile.appendFile(ftype);
-        if (!confFile.readable()) {
+        confFile.appendComponent(ftype);
+        if (!confFile.canRead()) {
           // Okay, try the "standard" place
           confFile = sys::Path::GetLLVMDefaultConfigDir();
-          confFile.appendFile(ftype);
-          if (!confFile.readable()) {
+          confFile.appendComponent(ftype);
+          if (!confFile.canRead()) {
             throw std::string("Configuration file for '") + ftype +
                               "' is not available.";
           }
@@ -577,8 +586,8 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
     }
   } else {
     confFile = configDir;
-    confFile.appendFile(ftype);
-    if (!confFile.readable())
+    confFile.appendComponent(ftype);
+    if (!confFile.canRead())
       throw std::string("Configuration file for '") + ftype +
                         "' is not available.";
   }