Skip to content

Commit a9ee179

Browse files
authored
Remove helper function and use target agnostic needConversion function (#146680)
This patch adds back the needed AutoConvert.h header and removes the unneeded include guard of MVS to prevent this header from being removed in the future
1 parent fc00256 commit a9ee179

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

clang/lib/Basic/SourceManager.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "llvm/ADT/StringRef.h"
2525
#include "llvm/ADT/StringSwitch.h"
2626
#include "llvm/Support/Allocator.h"
27+
#include "llvm/Support/AutoConvert.h"
2728
#include "llvm/Support/Capacity.h"
2829
#include "llvm/Support/Compiler.h"
2930
#include "llvm/Support/Endian.h"
@@ -586,17 +587,6 @@ SourceManager::getOrCreateFileID(FileEntryRef SourceFile,
586587
FileCharacter);
587588
}
588589

589-
/// Helper function to determine if an input file requires conversion
590-
bool needConversion(StringRef Filename) {
591-
#ifdef __MVS__
592-
llvm::ErrorOr<bool> NeedConversion =
593-
llvm::needzOSConversion(Filename.str().c_str());
594-
return NeedConversion && *NeedConversion;
595-
#else
596-
return false;
597-
#endif
598-
}
599-
600590
/// createFileID - Create a new FileID for the specified ContentCache and
601591
/// include position. This works regardless of whether the ContentCache
602592
/// corresponds to a file or some other input source.
@@ -616,8 +606,9 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, StringRef Filename,
616606
return FileID::get(LoadedID);
617607
}
618608
unsigned FileSize = File.getSize();
619-
bool NeedConversion = needConversion(Filename);
620-
if (NeedConversion) {
609+
llvm::ErrorOr<bool> NeedConversion =
610+
llvm::needConversion(Filename.str().c_str());
611+
if (NeedConversion && *NeedConversion) {
621612
// Buffer size may increase due to potential z/OS EBCDIC to UTF-8
622613
// conversion.
623614
if (std::optional<llvm::MemoryBufferRef> Buffer =

0 commit comments

Comments
 (0)