From 3af0dd33a234a1a18fb251f0f39dbee39d37eb51 Mon Sep 17 00:00:00 2001 From: tmayer-pippinware Date: Sun, 16 Nov 2025 09:56:01 -0800 Subject: [PATCH 1/2] DXC: fix ObjC rewrite for HLSL function types + enable modern CMake policies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added clang/Basic/Specifiers.h and passed the required ArrayRef to ASTContext::getFunctionType. This fixes the Clang ObjC rewrite helper when HLSL’s function-signature extensions are enabled, so upstream LLVM/DXC users would hit the same issue. - Added enforcement for CMP0051/CMP0056/CMP0063/CMP0077 to NEW. That removes deprecated policy warnings for anyone building DXC with modern CMake, so it’s a generic build-system cleanup upstream will likely appreciate. --- CMakeLists.txt | 13 +++++++++++++ tools/clang/CMakeLists.txt | 13 +++++++++++++ tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5210718005..925f6c7903 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,19 @@ if(POLICY CMP0022) cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required endif() +set(_DXC_ENFORCED_POLICIES + CMP0051 # Include_DIRECTORIES target scope + CMP0056 # Honor per-config link flags + CMP0063 # Visibility presets for targets + CMP0077 # option() honors normal variables + ) +foreach(_policy IN LISTS _DXC_ENFORCED_POLICIES) + if(POLICY ${_policy}) + cmake_policy(SET ${_policy} NEW) + endif() +endforeach() +unset(_DXC_ENFORCED_POLICIES) + if(CMAKE_VERSION VERSION_LESS 3.1.20141117) set(cmake_3_2_USES_TERMINAL) else() diff --git a/tools/clang/CMakeLists.txt b/tools/clang/CMakeLists.txt index 449e6c28b4..a250c36e44 100644 --- a/tools/clang/CMakeLists.txt +++ b/tools/clang/CMakeLists.txt @@ -14,6 +14,19 @@ else() endif() endif() +set(_CLANG_ENFORCED_POLICIES + CMP0051 + CMP0056 + CMP0063 + CMP0077 + ) +foreach(_policy IN LISTS _CLANG_ENFORCED_POLICIES) + if(POLICY ${_policy}) + cmake_policy(SET ${_policy} NEW) + endif() +endforeach() +unset(_CLANG_ENFORCED_POLICIES) + # If we are not building as a part of LLVM, build Clang as an # standalone project, using LLVM as an external library: if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) diff --git a/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 204820b304..486cf458ea 100644 --- a/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -19,6 +19,7 @@ #include "clang/Basic/CharInfo.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/Specifiers.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" #include "clang/Rewrite/Core/Rewriter.h" @@ -483,7 +484,8 @@ namespace { result = Context->getObjCIdType(); FunctionProtoType::ExtProtoInfo fpi; fpi.Variadic = variadic; - return Context->getFunctionType(result, args, fpi); + return Context->getFunctionType(result, args, fpi, + llvm::ArrayRef()); } // Helper function: create a CStyleCastExpr with trivial type source info. From 6e1f918ea430e3a68d325dd9f97f92a7d85f2be7 Mon Sep 17 00:00:00 2001 From: tmayer-pippinware Date: Sun, 16 Nov 2025 10:03:45 -0800 Subject: [PATCH 2/2] Fix clang formatting issues --- tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 486cf458ea..43f7d8ec05 100644 --- a/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "clang/Rewrite/Frontend/ASTConsumers.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/Attr.h" @@ -19,10 +18,11 @@ #include "clang/Basic/CharInfo.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/IdentifierTable.h" -#include "clang/Basic/Specifiers.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/Specifiers.h" #include "clang/Lex/Lexer.h" #include "clang/Rewrite/Core/Rewriter.h" +#include "clang/Rewrite/Frontend/ASTConsumers.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringExtras.h" @@ -484,8 +484,8 @@ namespace { result = Context->getObjCIdType(); FunctionProtoType::ExtProtoInfo fpi; fpi.Variadic = variadic; - return Context->getFunctionType(result, args, fpi, - llvm::ArrayRef()); + return Context->getFunctionType( + result, args, fpi, llvm::ArrayRef()); } // Helper function: create a CStyleCastExpr with trivial type source info.