2
0
Эх сурвалжийг харах

Use llvm::make_unique instead of std::make_unique (#201)

std::make_unique is a C++14 feature.
Lei Zhang 8 жил өмнө
parent
commit
8afb120125

+ 16 - 16
lib/HLSL/HLModule.cpp

@@ -16,6 +16,7 @@
 #include "dxc/HLSL/DxilTypeSystem.h"
 #include "dxc/HLSL/DxilRootSignature.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
@@ -32,7 +33,6 @@ using std::string;
 using std::vector;
 using std::unique_ptr;
 
-
 namespace hlsl {
 
 static void
@@ -42,10 +42,10 @@ CreateSignatures(const ShaderModel *pSM,
                  std::unique_ptr<DxilSignature> &PatchConstantSignature,
                  std::unique_ptr<RootSignatureHandle> &RootSignature) {
   DXIL::ShaderKind shaderKind = pSM->GetKind();
-  InputSignature = std::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::Input);
-  OutputSignature = std::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::Output);
-  PatchConstantSignature = std::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::PatchConstant);
-  RootSignature = std::make_unique<RootSignatureHandle>();
+  InputSignature = llvm::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::Input);
+  OutputSignature = llvm::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::Output);
+  PatchConstantSignature = llvm::make_unique<DxilSignature>(shaderKind, DxilSignature::Kind::PatchConstant);
+  RootSignature = llvm::make_unique<RootSignatureHandle>();
 }
 
 //------------------------------------------------------------------------------
@@ -58,10 +58,10 @@ HLModule::HLModule(Module *pModule)
     , m_pEntryFunc(nullptr)
     , m_EntryName("")
     , m_pSM(nullptr)
-    , m_pOP(std::make_unique<OP>(pModule->getContext(), pModule))
-    , m_pTypeSystem(std::make_unique<DxilTypeSystem>(pModule))
-    , m_pMDHelper(std::make_unique<DxilMDHelper>(
-          pModule, std::make_unique<HLExtraPropertyHelper>(pModule)))
+    , m_pOP(llvm::make_unique<OP>(pModule->getContext(), pModule))
+    , m_pTypeSystem(llvm::make_unique<DxilTypeSystem>(pModule))
+    , m_pMDHelper(llvm::make_unique<DxilMDHelper>(
+          pModule, llvm::make_unique<HLExtraPropertyHelper>(pModule)))
     , m_pDebugInfoFinder(nullptr)
     , m_DxilMajor(1)
     , m_DxilMinor(0) {
@@ -507,7 +507,7 @@ void HLModule::LoadHLMetadata() {
     while (propIdx < fnProps->getNumOperands()) {
       MDTuple *pProps = dyn_cast<MDTuple>(fnProps->getOperand(propIdx++));
 
-      std::unique_ptr<hlsl::HLFunctionProps> props = std::make_unique<hlsl::HLFunctionProps>();
+      std::unique_ptr<hlsl::HLFunctionProps> props = llvm::make_unique<hlsl::HLFunctionProps>();
       unsigned idx = 0;
       Function *F = dyn_cast<Function>(dyn_cast<ValueAsMetadata>(pProps->getOperand(idx++))->getValue());
       switch (m_pSM->GetKind()) {
@@ -653,7 +653,7 @@ void HLModule::LoadHLResources(const llvm::MDOperand &MDO) {
   // Load CBuffer records.
   if (pCBuffers != nullptr) {
     for (unsigned i = 0; i < pCBuffers->getNumOperands(); i++) {
-      unique_ptr<DxilCBuffer> pCB = std::make_unique<DxilCBuffer>();
+      unique_ptr<DxilCBuffer> pCB = llvm::make_unique<DxilCBuffer>();
       m_pMDHelper->LoadDxilCBuffer(pCBuffers->getOperand(i), *pCB);
       AddCBuffer(std::move(pCB));
     }
@@ -795,7 +795,7 @@ void HLModule::AddResourceWithGlobalVariableAndMDNode(llvm::Constant *GV,
 
   switch (RC) {
   case DxilResource::Class::Sampler: {
-    std::unique_ptr<DxilSampler> S = std::make_unique<DxilSampler>();
+    std::unique_ptr<DxilSampler> S = llvm::make_unique<DxilSampler>();
     m_pMDHelper->LoadDxilSampler(Meta, *S);
     S->SetGlobalSymbol(GV);
     S->SetGlobalName(GV->getName());
@@ -803,7 +803,7 @@ void HLModule::AddResourceWithGlobalVariableAndMDNode(llvm::Constant *GV,
     AddSampler(std::move(S));
   } break;
   case DxilResource::Class::SRV: {
-    std::unique_ptr<HLResource> Res = std::make_unique<HLResource>();
+    std::unique_ptr<HLResource> Res = llvm::make_unique<HLResource>();
     m_pMDHelper->LoadDxilSRV(Meta, *Res);
     Res->SetGlobalSymbol(GV);
     Res->SetGlobalName(GV->getName());
@@ -811,7 +811,7 @@ void HLModule::AddResourceWithGlobalVariableAndMDNode(llvm::Constant *GV,
     AddSRV(std::move(Res));
   } break;
   case DxilResource::Class::UAV: {
-    std::unique_ptr<HLResource> Res = std::make_unique<HLResource>();
+    std::unique_ptr<HLResource> Res = llvm::make_unique<HLResource>();
     m_pMDHelper->LoadDxilUAV(Meta, *Res);
     Res->SetGlobalSymbol(GV);
     Res->SetGlobalName(GV->getName());
@@ -1367,7 +1367,7 @@ void HLModule::UpdateGlobalVariableDebugInfo(
 
 DebugInfoFinder &HLModule::GetOrCreateDebugInfoFinder() {
   if (m_pDebugInfoFinder == nullptr) {
-    m_pDebugInfoFinder = std::make_unique<llvm::DebugInfoFinder>();
+    m_pDebugInfoFinder = llvm::make_unique<llvm::DebugInfoFinder>();
     m_pDebugInfoFinder->processModule(*m_pModule);
   }
   return *m_pDebugInfoFinder;
@@ -1397,7 +1397,7 @@ namespace llvm {
 hlsl::HLModule &Module::GetOrCreateHLModule(bool skipInit) {
   std::unique_ptr<hlsl::HLModule> M;
   if (!HasHLModule()) {
-    M = std::make_unique<hlsl::HLModule>(this);
+    M = llvm::make_unique<hlsl::HLModule>(this);
     if (!skipInit) {
       M->LoadHLMetadata();
     }

+ 6 - 6
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -24,6 +24,7 @@
 #include "clang/AST/HlslTypes.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Lex/HLSLMacroExpander.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
@@ -352,7 +353,7 @@ CGMSHLSLRuntime::CGMSHLSLRuntime(CodeGenModule &CGM)
            "else CGMSHLSLRuntime Constructor needs to be updated");
 
   // add globalCB
-  unique_ptr<HLCBuffer> CB = std::make_unique<HLCBuffer>();
+  unique_ptr<HLCBuffer> CB = llvm::make_unique<HLCBuffer>();
   std::string globalCBName = "$Globals";
   CB->SetGlobalSymbol(nullptr);
   CB->SetGlobalName(globalCBName);
@@ -954,7 +955,6 @@ static DxilResource::Kind KeywordToKind(StringRef keyword) {
   return DxilResource::Kind::Invalid;
 }
 
-
 static DxilSampler::SamplerKind KeywordToSamplerKind(const std::string &keyword) {
   // TODO: refactor for faster search (switch by 1/2/3 first letters, then
   // compare)
@@ -1041,7 +1041,7 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
   if (isEntry)
     EntryFunc = F;
 
-  std::unique_ptr<HLFunctionProps> funcProps = std::make_unique<HLFunctionProps>();
+  std::unique_ptr<HLFunctionProps> funcProps = llvm::make_unique<HLFunctionProps>();
 
   // Save patch constant function to patchConstantFunctionMap.
   bool isPatchConstantFunction = false;
@@ -2310,7 +2310,7 @@ void CGMSHLSLRuntime::AddConstant(VarDecl *constDecl, HLCBuffer &CB) {
     }
   }
 
-  std::unique_ptr<DxilResourceBase> pHlslConst = std::make_unique<DxilResourceBase>(DXIL::ResourceClass::Invalid);
+  std::unique_ptr<DxilResourceBase> pHlslConst = llvm::make_unique<DxilResourceBase>(DXIL::ResourceClass::Invalid);
   pHlslConst->SetLowerBound(UINT_MAX);
   pHlslConst->SetGlobalSymbol(cast<llvm::GlobalVariable>(constVal));
   pHlslConst->SetGlobalName(constDecl->getName());
@@ -2352,7 +2352,7 @@ void CGMSHLSLRuntime::AddConstant(VarDecl *constDecl, HLCBuffer &CB) {
 }
 
 uint32_t CGMSHLSLRuntime::AddCBuffer(HLSLBufferDecl *D) {
-  unique_ptr<HLCBuffer> CB = std::make_unique<HLCBuffer>();
+  unique_ptr<HLCBuffer> CB = llvm::make_unique<HLCBuffer>();
 
   // setup the CB
   CB->SetGlobalSymbol(nullptr);
@@ -2734,7 +2734,7 @@ static bool CreateCBufferVariable(HLCBuffer &CB,
           IRBuilder<> *instBuilder = &Builder;
           unique_ptr<IRBuilder<>> B;
           if (I) {
-            B = make_unique<IRBuilder<>>(I);
+            B = llvm::make_unique<IRBuilder<>>(I);
             instBuilder = B.get();
           }