github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp --
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Frontend/CompilerInstance.h clang/lib/Basic/FileManager.cpp
clang/lib/Basic/SourceManager.cpp clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/Preprocessor.cpp
clang/lib/Serialization/ASTReader.cpp llvm/include/llvm/Support/AutoConvert.h
llvm/include/llvm/Support/TextEncoding.h
llvm/include/llvm/Support/VirtualFileSystem.h llvm/lib/Support/TextEncoding.cpp
llvm/lib/Support/VirtualFileSystem.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Basic/LangOptions.h
b/clang/include/clang/Basic/LangOptions.h
index bfa9cdca3..3200d73f0 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -622,8 +622,8 @@ public:
std::optional<llvm::AllocTokenMode> AllocTokenMode;
/// Name of the input encoding to convert to the internal encoding.
- std::string InputEncoding;
-
+ std::string InputEncoding;
+
LangOptions();
/// Set language defaults for the given input language and
diff --git a/clang/include/clang/Basic/SourceManager.h
b/clang/include/clang/Basic/SourceManager.h
index c44271c43..6590738f8 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -851,7 +851,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// This includes both the input charset converter and file tag converters.
/// Maps from "source_encoding:target_encoding" to the converter.
llvm::StringMap<std::unique_ptr<llvm::TextEncodingConverter>> ConverterCache;
-
+
/// Read-write mutex to protect ConverterCache for thread-safe access.
/// Allows multiple concurrent readers while ensuring exclusive write access.
mutable llvm::sys::RWMutex ConverterCacheMutex;
@@ -947,8 +947,7 @@ public:
/// the cache using this encoding name.
FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos,
SrcMgr::CharacteristicKind FileCharacter,
- int LoadedID = 0,
- llvm::StringRef InputEncodingName = "",
+ int LoadedID = 0, llvm::StringRef InputEncodingName = "",
SourceLocation::UIntTy LoadedOffset = 0);
/// Create a new FileID that represents the specified memory buffer.
@@ -973,7 +972,7 @@ public:
/// new FileID for the \p SourceFile.
FileID getOrCreateFileID(FileEntryRef SourceFile,
SrcMgr::CharacteristicKind FileCharacter,
- llvm::StringRef InputEncodingName = "");
+ llvm::StringRef InputEncodingName = "");
/// Creates an expansion SLocEntry for the substitution of an argument into a
/// function-like macro's body. Returns the start of the expansion.
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 7cd293923..f250c1979 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -555,8 +555,11 @@ FileManager::getBufferForFile(FileEntryRef FE, bool
isVolatile,
}
// Open the file with the requested mode.
- llvm::errs() << "DEBUG: Opening file " << Filename << " with IsText=" <<
IsText
- << (IsText ? " (autoconversion enabled)" : " (autoconversion
DISABLED)") << "\n";
+ llvm::errs() << "DEBUG: Opening file " << Filename
+ << " with IsText=" << IsText
+ << (IsText ? " (autoconversion enabled)"
+ : " (autoconversion DISABLED)")
+ << "\n";
return getBufferForFileImpl(Filename, FileSize, isVolatile,
RequiresNullTerminator, IsText);
}
diff --git a/clang/lib/Basic/SourceManager.cpp
b/clang/lib/Basic/SourceManager.cpp
index 475e542f6..6d30bbf03 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -30,8 +30,8 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SmallVectorMemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
@@ -120,17 +120,17 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag,
FileManager &FM,
// Start with the assumption that the buffer is invalid to simplify early
// return paths.
IsBufferInvalid = true;
-
+
// If a converter is set, open the file in binary mode to get raw bytes
// and avoid platform-specific auto-conversion (e.g., EBCDIC->ASCII on z/OS,
- // CRLF->LF on Windows). The explicit converter will handle all
transformations.
+ // CRLF->LF on Windows). The explicit converter will handle all
+ // transformations.
bool NeedsExplicitConversion = FileIDConverterInfo.getPointer() != nullptr;
bool IsText = !NeedsExplicitConversion;
auto BufferOrError = FM.getBufferForFile(*ContentsEntry, IsFileVolatile,
/*RequiresNullTerminator=*/true,
- /*MaybeLimit=*/std::nullopt,
- IsText);
+ /*MaybeLimit=*/std::nullopt,
IsText);
// If we were unable to open the file, then we are in an inconsistent
// situation where the content cache referenced a file which no longer
@@ -160,7 +160,8 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag,
FileManager &FM,
// Convert source from the input charset to UTF-8 if necessary.
llvm::TextEncodingConverter *Converter = FileIDConverterInfo.getPointer();
if (Converter) {
- llvm::errs() << "DEBUG: Converting file " << ContentsEntry->getName() << "
using converter\n";
+ llvm::errs() << "DEBUG: Converting file " << ContentsEntry->getName()
+ << " using converter\n";
StringRef OriginalBuf = Buffer->getBuffer();
llvm::SmallString<0> UTF8Buf;
UTF8Buf.reserve(OriginalBuf.size() + 1);
@@ -181,13 +182,15 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag,
FileManager &FM,
// TODO: Consider adjusting the message to omit the "interpreting as
// UTF-8" recovery description if the warning has been upgraded to an
// error.
- llvm::errs() << "DEBUG: Conversion failed for " <<
ContentsEntry->getName()
- << ": " << EC.message() << " - falling back to UTF-8\n";
+ llvm::errs() << "DEBUG: Conversion failed for "
+ << ContentsEntry->getName() << ": " << EC.message()
+ << " - falling back to UTF-8\n";
Diag.Report(Loc, diag::warn_charset_conversion_failed)
<< ContentsEntry->getName() << EC.message();
} else {
- llvm::errs() << "DEBUG: Successfully converted " <<
ContentsEntry->getName()
- << " from " << OriginalBuf.size() << " to " <<
UTF8Buf.size() << " bytes\n";
+ llvm::errs() << "DEBUG: Successfully converted "
+ << ContentsEntry->getName() << " from " <<
OriginalBuf.size()
+ << " to " << UTF8Buf.size() << " bytes\n";
// TODO: Reclaim memory if the buffer size exceeds the content.
auto NewBuf = std::make_unique<llvm::SmallVectorMemoryBuffer>(
std::move(UTF8Buf), Buffer->getBufferIdentifier());
@@ -489,11 +492,12 @@ SourceManager::getOrCreateConverter(llvm::StringRef
SourceEncoding,
llvm::TextEncodingConverter::getKnownEncoding(SourceEncoding);
std::optional<llvm::TextEncoding> TargetKnown =
llvm::TextEncodingConverter::getKnownEncoding(TargetEncoding);
-
+
if (SourceKnown == TargetKnown)
return nullptr;
- // Create a cache key - use enum values for known encodings, raw names
otherwise
+ // Create a cache key - use enum values for known encodings, raw names
+ // otherwise
llvm::SmallString<64> CacheKey;
if (SourceKnown) {
CacheKey += llvm::Twine(static_cast<int>(*SourceKnown)).str();
@@ -517,7 +521,7 @@ SourceManager::getOrCreateConverter(llvm::StringRef
SourceEncoding,
// Converter not found, acquire write lock to create it
llvm::sys::ScopedWriter WriteLock(ConverterCacheMutex);
-
+
// Double-check that another thread didn't create it while we were waiting
auto It = ConverterCache.find(CacheKey);
if (It != ConverterCache.end())
@@ -526,15 +530,15 @@ SourceManager::getOrCreateConverter(llvm::StringRef
SourceEncoding,
// Create a new converter
llvm::ErrorOr<llvm::TextEncodingConverter> NewConverter =
llvm::TextEncodingConverter::create(SourceEncoding, TargetEncoding);
-
+
if (!NewConverter)
return NewConverter.getError();
// Store the converter in the cache
- auto Inserted = ConverterCache.insert(
- std::make_pair(CacheKey, std::make_unique<llvm::TextEncodingConverter>(
- std::move(*NewConverter))));
-
+ auto Inserted = ConverterCache.insert(std::make_pair(
+ CacheKey,
+
std::make_unique<llvm::TextEncodingConverter>(std::move(*NewConverter))));
+
return Inserted.first->second.get();
}
@@ -663,32 +667,41 @@ FileID SourceManager::createFileID(FileEntryRef
SourceFile,
}
if (!Ccsid->empty()) {
// File has a tag, use the converter from SourceManager's cache
- llvm::errs() << "DEBUG: File " << SourceFile.getName() << " has tag
encoding: " << *Ccsid << "\n";
+ llvm::errs() << "DEBUG: File " << SourceFile.getName()
+ << " has tag encoding: " << *Ccsid << "\n";
Converter = getOrCreateConverter(*Ccsid, "UTF-8");
if (!Converter) {
- llvm::errs() << "DEBUG: Failed to get converter for file tag: " <<
Converter.getError().message() << "\n";
+ llvm::errs() << "DEBUG: Failed to get converter for file tag: "
+ << Converter.getError().message() << "\n";
Diag.Report(SourceLocation(), diag::err_cannot_open_file)
<< SourceFile.getName() << Converter.getError().message();
return FileID();
}
- llvm::errs() << "DEBUG: Using file tag converter for " <<
SourceFile.getName() << "\n";
+ llvm::errs() << "DEBUG: Using file tag converter for "
+ << SourceFile.getName() << "\n";
} else if (!InputEncodingName.empty()) {
// No file tag but -finput-charset conversion is desired.
// Get the converter from the cache using the input encoding name.
- llvm::errs() << "DEBUG: File " << SourceFile.getName() << " has no tag,
using input charset: " << InputEncodingName << "\n";
+ llvm::errs() << "DEBUG: File " << SourceFile.getName()
+ << " has no tag, using input charset: " << InputEncodingName
+ << "\n";
Converter = getOrCreateConverter(InputEncodingName, "UTF-8");
if (!Converter) {
- llvm::errs() << "DEBUG: Failed to get input charset converter: " <<
Converter.getError().message() << "\n";
+ llvm::errs() << "DEBUG: Failed to get input charset converter: "
+ << Converter.getError().message() << "\n";
Diag.Report(SourceLocation(), diag::err_cannot_open_file)
<< SourceFile.getName() << Converter.getError().message();
return FileID();
}
- llvm::errs() << "DEBUG: Using input charset converter for " <<
SourceFile.getName() << "\n";
+ llvm::errs() << "DEBUG: Using input charset converter for "
+ << SourceFile.getName() << "\n";
} else {
- llvm::errs() << "DEBUG: File " << SourceFile.getName() << " has no tag and
no input charset specified - no conversion\n";
+ llvm::errs()
+ << "DEBUG: File " << SourceFile.getName()
+ << " has no tag and no input charset specified - no conversion\n";
}
- #ifndef NDEBUG
+#ifndef NDEBUG
// Either the content cache has never been used for a FileID (and, if we are
// being asked to use a converter, there should be no valid buffer set up for
// it) or the conversion (or lack thereof) should be the same as that used
@@ -700,7 +713,8 @@ FileID SourceManager::createFileID(FileEntryRef SourceFile,
else
assert(!ConverterPtr || IR.IsBufferInvalid || !IR.getBufferIfLoaded());
#endif
- IR.FileIDConverterInfo.setPointerAndInt(Converter ? *Converter : nullptr,
true);
+ IR.FileIDConverterInfo.setPointerAndInt(Converter ? *Converter : nullptr,
+ true);
// If this is a named pipe, immediately load the buffer to ensure subsequent
// calls to ContentCache::getSize() are accurate.
@@ -744,12 +758,12 @@ FileID SourceManager::createFileID(const
llvm::MemoryBufferRef &Buffer,
FileID
SourceManager::getOrCreateFileID(FileEntryRef SourceFile,
SrcMgr::CharacteristicKind FileCharacter,
- llvm::StringRef InputEncodingName) {
+ llvm::StringRef InputEncodingName) {
FileID ID = translateFile(SourceFile);
return ID.isValid()
- ? ID
- : createFileID(SourceFile, SourceLocation(),
- FileCharacter, /*LoadedID=*/0,
InputEncodingName);
+ ? ID
+ : createFileID(SourceFile, SourceLocation(), FileCharacter,
+ /*LoadedID=*/0, InputEncodingName);
}
/// createFileID - Create a new FileID for the specified ContentCache and
/// include position. This works regardless of whether the ContentCache
diff --git a/clang/lib/Frontend/CompilerInstance.cpp
b/clang/lib/Frontend/CompilerInstance.cpp
index e4902797d..44c8fba0a 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -917,30 +917,33 @@ bool CompilerInstance::InitializeSourceManager(const
FrontendInputFile &Input){
if (hasPreprocessor()) {
InputEncoding = getLangOpts().InputEncoding;
if (!InputEncoding.empty()) {
- llvm::errs() << "DEBUG: Setting input charset converter: " <<
InputEncoding << " -> UTF-8\n";
+ llvm::errs() << "DEBUG: Setting input charset converter: "
+ << InputEncoding << " -> UTF-8\n";
// Add the converter to SourceManager's cache
- auto ConverterOrErr =
getSourceManager().getOrCreateConverter(InputEncoding, "UTF-8");
+ auto ConverterOrErr =
+ getSourceManager().getOrCreateConverter(InputEncoding, "UTF-8");
if (ConverterOrErr) {
- llvm::errs() << "DEBUG: Input charset converter successfully added to
cache\n";
+ llvm::errs()
+ << "DEBUG: Input charset converter successfully added to cache\n";
} else {
llvm::errs() << "DEBUG: Failed to create input charset converter: "
<< ConverterOrErr.getError().message() << "\n";
}
- // If converter creation fails, the error will be reported when
createFileID tries to use it
+ // If converter creation fails, the error will be reported when
+ // createFileID tries to use it
} else {
llvm::errs() << "DEBUG: No input charset converter specified\n";
}
}
-
- return InitializeSourceManager(Input, getDiagnostics(),
- getFileManager(), getSourceManager(),
- InputEncoding);
+
+ return InitializeSourceManager(Input, getDiagnostics(), getFileManager(),
+ getSourceManager(), InputEncoding);
}
// static
bool CompilerInstance::InitializeSourceManager(
- const FrontendInputFile &Input,
- DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr,
+ const FrontendInputFile &Input, DiagnosticsEngine &Diags,
+ FileManager &FileMgr, SourceManager &SourceMgr,
llvm::StringRef InputEncodingName) {
SrcMgr::CharacteristicKind Kind =
Input.getKind().getFormat() == InputKind::ModuleMap
@@ -973,8 +976,7 @@ bool CompilerInstance::InitializeSourceManager(
// Pass the input encoding name for charset conversion if specified
SourceMgr.setMainFileID(
SourceMgr.createFileID(*FileOrErr, SourceLocation(), Kind,
- /*LoadedID=*/0,
- InputEncodingName));
+ /*LoadedID=*/0, InputEncodingName));
assert(SourceMgr.getMainFileID().isValid() &&
"Couldn't establish MainFileID!");
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 4343c6e29..e1a6ae1df 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -616,8 +616,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED,
SourceManager &SM,
// Get input encoding from LangOptions for charset conversion
llvm::StringRef InputEncoding = PP->getLangOpts().InputEncoding;
FID = SM.createFileID(*File, Pos, SrcMgr::C_User,
- /*LoadedID=*/0,
- InputEncoding);
+ /*LoadedID=*/0, InputEncoding);
}
if (PH.Next(Line) && Line > 0)
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index a8a7a0e45..ba6100d85 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1473,13 +1473,13 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File,
bool IsSystem,
if (LocalFID.isInvalid()) {
auto FileCharacter =
IsSystem ? SrcMgr::C_System_ModuleMap : SrcMgr::C_User_ModuleMap;
- // Module map files are textual "source files". Use input charset
converter
- // if available, and file tag converters are handled by SourceManager's
cache.
- // Get input encoding from LangOptions for charset conversion
+ // Module map files are textual "source files". Use input charset
+ // converter if available, and file tag converters are handled by
+ // SourceManager's cache. Get input encoding from LangOptions for charset
+ // conversion
llvm::StringRef InputEncoding = LangOpts.InputEncoding;
LocalFID = SourceMgr.createFileID(File, ExternModuleLoc, FileCharacter,
- /*LoadedID=*/0,
- InputEncoding);
+ /*LoadedID=*/0, InputEncoding);
}
ID = LocalFID;
}
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 07a5c0456..390455b92 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2796,13 +2796,12 @@ Preprocessor::ImportAction
Preprocessor::HandleHeaderIncludeOrImport(
// position on the file where it will be included and after the expansions.
if (IncludePos.isMacroID())
IncludePos = SourceMgr.getExpansionRange(IncludePos).getEnd();
-
+
// Use the SourceManager's input charset converter for non-tagged files
// by passing the input encoding name
llvm::StringRef InputEncoding = getLangOpts().InputEncoding;
FileID FID = SourceMgr.createFileID(*File, IncludePos, FileCharacter,
- /*LoadedID=*/0,
- InputEncoding);
+ /*LoadedID=*/0, InputEncoding);
if (!FID.isValid()) {
TheModuleLoader.HadFatalFailure = true;
return ImportAction::Failure;
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 374fd460f..f2f7544cc 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -653,10 +653,9 @@ void Preprocessor::EnterMainSourceFile() {
// are handled by SourceManager's cache.
// Get input encoding from LangOptions for charset conversion
llvm::StringRef InputEncoding = LangOpts.InputEncoding;
- setPCHThroughHeaderFileID(SourceMgr.createFileID(
- *File, SourceLocation(), SrcMgr::C_User,
- /*LoadedID=*/0,
- InputEncoding));
+ setPCHThroughHeaderFileID(
+ SourceMgr.createFileID(*File, SourceLocation(), SrcMgr::C_User,
+ /*LoadedID=*/0, InputEncoding));
}
// Skip tokens from the Predefines and if needed the main file.
diff --git a/clang/lib/Serialization/ASTReader.cpp
b/clang/lib/Serialization/ASTReader.cpp
index e5bed260d..f84cdfba7 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2004,8 +2004,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
// Note: If conversion was originally necessary, OverriddenBuffer should be
// true and the associated handling will trigger.
- FileID FID = SourceMgr.createFileID(*File, IncludeLoc, FileCharacter,
- ID, /*InputEncodingName=*/"",
+ FileID FID = SourceMgr.createFileID(*File, IncludeLoc, FileCharacter, ID,
+ /*InputEncodingName=*/"",
BaseOffset + Record[0]);
SrcMgr::FileInfo &FileInfo = SourceMgr.getSLocEntry(FID).getFile();
FileInfo.NumCreatedFIDs = Record[5];
diff --git a/llvm/include/llvm/Support/AutoConvert.h
b/llvm/include/llvm/Support/AutoConvert.h
index 337befec1..bdaae2439 100644
--- a/llvm/include/llvm/Support/AutoConvert.h
+++ b/llvm/include/llvm/Support/AutoConvert.h
@@ -105,8 +105,8 @@ inline ErrorOr<bool> needConversion(const Twine &FileName,
const int FD = -1) {
return false;
}
-inline ErrorOr<std::string>
-getEncodingNameFromFileTag(const Twine &FileName, const int FD = -1) {
+inline ErrorOr<std::string> getEncodingNameFromFileTag(const Twine &FileName,
+ const int FD = -1) {
#ifdef __MVS__
ErrorOr<__ccsid_t> TagOrErr = getzOSFileTag(FileName, FD);
if (!TagOrErr)
diff --git a/llvm/include/llvm/Support/TextEncoding.h
b/llvm/include/llvm/Support/TextEncoding.h
index b9c851b8c..597406886 100644
--- a/llvm/include/llvm/Support/TextEncoding.h
+++ b/llvm/include/llvm/Support/TextEncoding.h
@@ -147,7 +147,7 @@ public:
/// Cache for TextEncodingConverter instances.
class TextEncodingConverterCache {
- public:
+public:
/// Get or create a cached TextEncodingConverter.
/// If the converter exists in the cache, returns it. Otherwise, creates a
new
/// converter, caches it, and returns it.
diff --git a/llvm/lib/Support/TextEncoding.cpp
b/llvm/lib/Support/TextEncoding.cpp
index 448ecb84c..4e9533080 100644
--- a/llvm/lib/Support/TextEncoding.cpp
+++ b/llvm/lib/Support/TextEncoding.cpp
@@ -52,7 +52,8 @@ static void normalizeCharSetName(StringRef CSName,
}
// Maps the encoding name to enum constant if possible.
-std::optional<TextEncoding> TextEncodingConverter::getKnownEncoding(StringRef
Name) {
+std::optional<TextEncoding>
+TextEncodingConverter::getKnownEncoding(StringRef Name) {
SmallString<16> Normalized;
normalizeCharSetName(Name, Normalized);
if (Normalized.equals("utf8") || Normalized.equals("1208"))
@@ -387,7 +388,8 @@ TextEncodingConverterCache::getOrCreateConverter(StringRef
SourceEncoding,
Key += " -> ";
Key += TargetEncoding;
- // First, try to find existing converter with shared lock (allows concurrent
reads)
+ // First, try to find existing converter with shared lock (allows concurrent
+ // reads)
{
llvm::sys::ScopedReader ReadLock(GlobalConverterCache->Mutex);
auto Iter = GlobalConverterCache->Cache.find(Key);
@@ -397,7 +399,7 @@ TextEncodingConverterCache::getOrCreateConverter(StringRef
SourceEncoding,
// Not found, need to create - acquire unique lock for writing
llvm::sys::ScopedWriter WriteLock(GlobalConverterCache->Mutex);
-
+
// Double-check: another thread might have created it while we were waiting
auto Iter = GlobalConverterCache->Cache.find(Key);
if (Iter != GlobalConverterCache->Cache.end())
``````````
</details>
https://github.com/llvm/llvm-project/pull/205163
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits