[cfe-commits] Use GCC_INSTALL_PREFIX to initialize SysRoot

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sun Mar 11 06:44:40 PDT 2012

> The code in the Driver happens before Compilation is created.
> I took care of this duplication of code by initializing a field in Compilation
> with the value that we computed in the Driver::SysRoot field.

That should work.

+    TranslatedArgs(_TranslatedArgs), Redirects(0), SysRoot(D.SysRoot)

Is this value of SysRoot ever used? It should not, right? It is
probably better to initialize SysRoot with an invalid value instead of

  if (SysRoot != "") {
+    llvm::SmallString<128> Prefix(SysRoot);
+    if (Prefix.back() == '/') {
+      llvm::sys::path::remove_filename(Prefix); // remove the /
+      SysRoot = Prefix.str();
+    }
+  }

This points a StringRef to a value that is destroyed at the closing brace.


More information about the cfe-commits mailing list