[clang] [llvm] Alisonz/tmp1 (PR #205163)
Alison Zhang via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 22 13:49:38 PDT 2026
================
@@ -913,20 +912,28 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary,
// Initialization Utilities
bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input){
- // Retrieve the converter to the internal charset if it exists.
- llvm::TextEncodingConverter *Converter =
- hasPreprocessor() ? getPreprocessor().getTextEncoding().getConverter(
- CA_FromInputEncoding)
- : nullptr;
-
- return InitializeSourceManager(Input, Converter, getDiagnostics(),
- getFileManager(), getSourceManager());
+ // Get the input encoding and add converter to cache if specified
+ std::string InputEncoding;
+ if (hasPreprocessor()) {
+ InputEncoding = getLangOpts().InputEncoding;
+ if (!InputEncoding.empty()) {
+ // Add the converter to SourceManager's cache
+ auto ConverterOrErr = getSourceManager().getOrCreateConverter(InputEncoding, "UTF-8");
+ // If converter creation fails, the error will be reported when createFileID tries to use it
+ (void)ConverterOrErr;
+ }
+ }
+
+ return InitializeSourceManager(Input, getDiagnostics(),
+ getFileManager(), getSourceManager(),
+ InputEncoding);
----------------
azhan92 wrote:
Change InputEncoding to
```
hasPreprocessor() ? llvm::StringRef(getLangOpts().InputEncoding) : llvm::StringRef()
```
https://github.com/llvm/llvm-project/pull/205163
More information about the cfe-commits
mailing list