[llvm] r273005 - [MCContext] Don't use getenv inside class constructor

Igor Laevsky via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 08:19:41 PDT 2016


Author: igor.laevsky
Date: Fri Jun 17 10:19:41 2016
New Revision: 273005

URL: http://llvm.org/viewvc/llvm-project?rev=273005&view=rev
Log:
[MCContext] Don't use getenv inside class constructor

Differential Revision: http://reviews.llvm.org/D21471


Modified:
    llvm/trunk/lib/MC/MCContext.cpp

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=273005&r1=273004&r2=273005&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Fri Jun 17 10:19:41 2016
@@ -25,6 +25,7 @@
 #include "llvm/MC/MCSymbolELF.h"
 #include "llvm/MC/MCSymbolMachO.h"
 #include "llvm/Support/COFF.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -33,6 +34,13 @@
 
 using namespace llvm;
 
+static cl::opt<char*>
+AsSecureLogFileName("as-secure-log-file-name",
+        cl::desc("As secure log file name (initialized from "
+                 "AS_SECURE_LOG_FILE env variable)"),
+        cl::init(getenv("AS_SECURE_LOG_FILE")), cl::Hidden);
+
+
 MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri,
                      const MCObjectFileInfo *mofi, const SourceMgr *mgr,
                      bool DoAutoReset)
@@ -42,7 +50,7 @@ MCContext::MCContext(const MCAsmInfo *ma
       GenDwarfForAssembly(false), GenDwarfFileNumber(0), DwarfVersion(4),
       AllowTemporaryLabels(true), DwarfCompileUnitID(0),
       AutoReset(DoAutoReset), HadError(false) {
-  SecureLogFile = getenv("AS_SECURE_LOG_FILE");
+  SecureLogFile = AsSecureLogFileName;
   SecureLog = nullptr;
   SecureLogUsed = false;
 




More information about the llvm-commits mailing list