SeanP added inline comments.
================
Comment at: clang/tools/driver/driver.cpp:251
+ std::string &OptFile) {
+ T OptVal = ::getenv(EnvOptSet);
+ if (OptVal) {
----------------
This change is not POSIX compliant. If T is char *, the next call to getenv()
on line 253 invalidates the value saved into OptVal. getenv() is allowed to
use the same buffer for the return value. That means the value OptVal is
pointing at will be overwritten by the next call.
When T is bool you need the `!!` operators to get the char * converted to bool
correctly.
I suggest leaving this function as it was and calling getenv() directly for the
scenario involving CC_PRINT_HEADERS_FORMAT. Make sure you save the getenv()
results into std::string so the value isn't overridden.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137996/new/
https://reviews.llvm.org/D137996
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits