review: address LLVM/objcopy guideline comments

This commit is contained in:
Finn Plummer 2025-08-12 16:42:04 +00:00
parent 7ca8df7351
commit 56cbd57532
5 changed files with 20 additions and 17 deletions

View File

@ -7,11 +7,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjCopy/DXContainer/DXContainerObjcopy.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/DXContainer/DXContainerConfig.h"
#include "DXContainerReader.h"
#include "DXContainerWriter.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/DXContainer/DXContainerConfig.h"
namespace llvm {
namespace objcopy {

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#define LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#ifndef LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
#define LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
@ -44,4 +44,4 @@ struct Object {
} // end namespace objcopy
} // end namespace llvm
#endif // LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#endif // LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H

View File

@ -21,14 +21,13 @@ Expected<std::unique_ptr<Object>> DXContainerReader::create() const {
DataRefImpl PartDRI = Part.getRawDataRefImpl();
Expected<StringRef> Name = DXContainerObj.getSectionName(PartDRI);
if (auto E = Name.takeError())
return createStringError(inconvertibleErrorCode(), "Missing Part Name");
return E;
assert(Name->size() == 4 &&
"Valid DXIL Part name consists of 4 characters");
Expected<ArrayRef<uint8_t>> Data =
DXContainerObj.getSectionContents(PartDRI);
if (auto E = Data.takeError())
return createStringError(inconvertibleErrorCode(),
"Missing Part Contents");
return E;
Obj->Parts.push_back({*Name, *Data});
}
return std::move(Obj);

View File

@ -1,17 +1,19 @@
## Tests that the copied DXContainer is identical to the original
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy %t %t.out
# RUN: cmp %t %t.out
# The following DXContainer to copied was generated with:
## The DXContainer described below was generated with:
# `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
# `obj2yaml temp.dxo`
## `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
## `obj2yaml temp.dxo`
# ``` test.hlsl
# [RootSignature("")]
# [numthreads(1,1,1)]
# void main() {}
# ```
## ``` test.hlsl
## [RootSignature("")]
## [numthreads(1,1,1)]
## void main() {}
## ```
--- !dxcontainer
Header:

View File

@ -1,3 +1,6 @@
## Tests that the copied DXContainer is identical to the original, ensuring all
## the different headers are correctly handled
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy %t %t.out
# RUN: cmp %t %t.out