All source files in PDBs interpreted as UTF8 (#4111)

This commit is contained in:
Adam Yang 2021-12-02 12:43:48 -08:00 коммит произвёл GitHub
Родитель 684ab384eb
Коммит 2f5dec316b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 20 добавлений и 15 удалений

Просмотреть файл

@ -374,7 +374,7 @@ struct DxilSourceInfo_SourceContentsEntry {
uint32_t AlignedSizeInBytes; // Size of the entry including this header and padding. Aligned to 4-byte boundary.
uint32_t Flags; // Reserved, must be set to 0.
uint32_t ContentSizeInBytes; // Size of the data following this header, *including* the null terminator
// Followed by NameSizeInBytes bytes of the UTF-8-encoded content (including null terminator).
// Followed by ContentSizeInBytes bytes of the UTF-8-encoded content (including null terminator).
// Followed by [0-3] zero bytes to align to a 4-byte boundary.
};

Просмотреть файл

@ -242,7 +242,7 @@ private:
struct Source_File {
std::wstring Name;
CComPtr<IDxcBlob> Content;
CComPtr<IDxcBlobEncoding> Content;
};
CComPtr<IDxcBlob> m_InputBlob;
@ -365,11 +365,11 @@ private:
Source_File file;
file.Name = ToWstring(md_name->getString());
// File content
IFR(hlsl::DxcCreateBlobOnHeapCopy(
md_content->getString().data(),
md_content->getString().size(),
&file.Content));
IFR(hlsl::DxcCreateBlob(
md_content->getString().data(), md_content->getString().size(),
/*bPinned*/false, /*bCopy*/true,
/*encodingKnown*/true, CP_UTF8,
m_pMalloc, &file.Content));
m_SourceFiles.push_back(std::move(file));
}
@ -499,10 +499,11 @@ private:
Source_File source;
source.Name = ToWstring(source_data.Name);
IFR(hlsl::DxcCreateBlobOnHeapCopy(
source_data.Content.data(),
source_data.Content.size(),
&source.Content));
IFR(hlsl::DxcCreateBlob(
source_data.Content.data(), source_data.Content.size(),
/*bPinned*/false, /*bCopy*/true,
/*encodingKnown*/true, CP_UTF8,
m_pMalloc, &source.Content));
// First file is the main file
if (i == 0) {

Просмотреть файл

@ -333,7 +333,7 @@ void SourceInfoWriter::Write(llvm::StringRef targetProfile, llvm::StringRef entr
const size_t entryOffset = m_Buffer.size();
// Write the header
hlsl::DxilSourceInfo_SourceNamesEntry entryHeader = {};
hlsl::DxilSourceInfo_SourceNamesEntry entryHeader ={};
entryHeader.NameSizeInBytes = file.Name.size()+1;
entryHeader.ContentSizeInBytes = file.Content.size()+1;
entryHeader.AlignedSizeInBytes = PadToFourBytes(sizeof(entryHeader) + file.Name.size() + 1);

Просмотреть файл

@ -1138,12 +1138,16 @@ static void VerifyPdbUtil(dxc::DxcDllSupport &dllSupport,
CComPtr<IDxcBlobEncoding> pFileContent;
VERIFY_SUCCEEDED(pPdbUtils->GetSourceName(i, &pFileName));
VERIFY_SUCCEEDED(pPdbUtils->GetSource(i, &pFileContent));
CComPtr<IDxcBlobUtf8> pFileContentUtf8;
VERIFY_SUCCEEDED(pFileContent.QueryInterface(&pFileContentUtf8));
llvm::StringRef FileContentRef(pFileContentUtf8->GetStringPointer(), pFileContentUtf8->GetStringLength());
if (0 == wcscmp(pFileName, pMainFileName)) {
VERIFY_IS_TRUE(pFileContent->GetBufferSize() == MainSource.size());
VERIFY_IS_TRUE(0 == std::memcmp(pFileContent->GetBufferPointer(), MainSource.data(), MainSource.size()));
VERIFY_ARE_EQUAL(FileContentRef, MainSource);
}
else {
VERIFY_IS_TRUE(0 == std::memcmp(pFileContent->GetBufferPointer(), IncludedFile.data(), IncludedFile.size()));
VERIFY_ARE_EQUAL(FileContentRef, IncludedFile);
}
}
}