Skip to content

Commit b796d5c

Browse files
ferdymercurymcbarton
authored andcommitted
Simplify getenv call using cstdlib
1 parent 0b1271a commit b796d5c

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

lib/CppInterOp/Compatibility.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@
2020
#define fileno _fileno
2121
#endif
2222

23-
static inline char* GetEnv(const char* Var_Name) {
24-
#ifdef _MSC_VER
25-
char* Env = nullptr;
26-
size_t sz = 0;
27-
getenv_s(&sz, Env, sz, Var_Name);
28-
return Env;
29-
#else
30-
return getenv(Var_Name);
31-
#endif
32-
}
33-
3423
#if CLANG_VERSION_MAJOR < 19
3524
#define Template_Deduction_Result Sema::TemplateDeductionResult
3625
#define Template_Deduction_Result_Success \

lib/CppInterOp/DynamicLibraryManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//------------------------------------------------------------------------------
99

1010
#include "DynamicLibraryManager.h"
11-
#include "Compatibility.h"
1211
#include "Paths.h"
1312

1413
#include "llvm/ADT/StringSet.h"
@@ -23,6 +22,7 @@
2322
#include "llvm/Support/Endian.h"
2423
#endif
2524

25+
#include <cstdlib>
2626
#include <fstream>
2727
#include <sys/stat.h>
2828
#include <system_error>
@@ -53,7 +53,7 @@ DynamicLibraryManager::DynamicLibraryManager() {
5353
// Behaviour is to not add paths that don't exist...In an interpreted env
5454
// does this make sense? Path could pop into existence at any time.
5555
for (const char* Var : kSysLibraryEnv) {
56-
if (const char* Env = GetEnv(Var)) {
56+
if (const char* Env = std::getenv(Var)) {
5757
SmallVector<StringRef, 10> CurPaths;
5858
SplitPaths(Env, CurPaths, utils::kPruneNonExistent,
5959
Cpp::utils::platform::kEnvDelim);

lib/CppInterOp/Paths.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//------------------------------------------------------------------------------
99

1010
#include "Paths.h"
11-
#include "Compatibility.h"
1211

1312
#include "clang/Basic/FileManager.h"
1413
#include "clang/Lex/HeaderSearchOptions.h"

0 commit comments

Comments
 (0)