Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove assert.h include from DxilPipelineStateValidation.h #6921

Conversation

lizhengxing
Copy link
Collaborator

@lizhengxing lizhengxing commented Sep 19, 2024

DxilPipelineStateValidation.h is included from multiple environments. Don't include assert.h in it, otherwise it might overwrite the custom assert in the code that includes DxilPipelineStateValidation.h.

Fixes #6922

@lizhengxing lizhengxing requested a review from a team as a code owner September 19, 2024 00:08
Copy link
Contributor

github-actions bot commented Sep 19, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff e1bb926f63ba44119577c845e9d7a1a10c0f50e9 18751fd560d98f5f87f45520bc97efd1c438eac4 -- include/dxc/DxilContainer/DxilPipelineStateValidation.h lib/DxilContainer/DxilPipelineStateValidation.cpp lib/DxilContainer/DxilRDATBuilder.cpp lib/DxilValidation/DxilContainerValidation.cpp lib/HLSL/DxcOptimizer.cpp tools/clang/tools/dxa/dxa.cpp tools/clang/unittests/HLSL/OptimizerTest.cpp
View the diff from clang-format here.
diff --git a/lib/DxilContainer/DxilPipelineStateValidation.cpp b/lib/DxilContainer/DxilPipelineStateValidation.cpp
index 143e40bb..1c56ec39 100644
--- a/lib/DxilContainer/DxilPipelineStateValidation.cpp
+++ b/lib/DxilContainer/DxilPipelineStateValidation.cpp
@@ -9,7 +9,7 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <assert.h>  // Needed for DxilPipelineStateValidation.h
+#include <assert.h> // Needed for DxilPipelineStateValidation.h
 
 #include "dxc/DxilContainer/DxilPipelineStateValidation.h"
 #include "dxc/DXIL/DxilModule.h"
diff --git a/lib/DxilContainer/DxilRDATBuilder.cpp b/lib/DxilContainer/DxilRDATBuilder.cpp
index dda0b0ef..c2e95fb2 100644
--- a/lib/DxilContainer/DxilRDATBuilder.cpp
+++ b/lib/DxilContainer/DxilRDATBuilder.cpp
@@ -1,4 +1,4 @@
-#include <assert.h>  // Needed for DxilPipelineStateValidation.h
+#include <assert.h> // Needed for DxilPipelineStateValidation.h
 
 #include "dxc/DxilContainer/DxilRDATBuilder.h"
 #include "dxc/DxilContainer/DxilPipelineStateValidation.h"
diff --git a/lib/DxilValidation/DxilContainerValidation.cpp b/lib/DxilValidation/DxilContainerValidation.cpp
index 5b8422d0..086d77a5 100644
--- a/lib/DxilValidation/DxilContainerValidation.cpp
+++ b/lib/DxilValidation/DxilContainerValidation.cpp
@@ -31,8 +31,8 @@
 
 #include "DxilValidationUtils.h"
 
+#include <assert.h> // Needed for DxilPipelineStateValidation.h
 #include <memory>
-#include <assert.h>  // Needed for DxilPipelineStateValidation.h
 
 using std::unique_ptr;
 using std::unordered_set;
diff --git a/lib/HLSL/DxcOptimizer.cpp b/lib/HLSL/DxcOptimizer.cpp
index 98fb702c..785e1435 100644
--- a/lib/HLSL/DxcOptimizer.cpp
+++ b/lib/HLSL/DxcOptimizer.cpp
@@ -42,9 +42,9 @@
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 
 #include <algorithm>
-#include <list> // should change this for string_table
+#include <assert.h> // Needed for DxilPipelineStateValidation.h
+#include <list>     // should change this for string_table
 #include <vector>
-#include <assert.h>  // Needed for DxilPipelineStateValidation.h
 
 #include "llvm/PassPrinters/PassPrinters.h"
 
diff --git a/tools/clang/unittests/HLSL/OptimizerTest.cpp b/tools/clang/unittests/HLSL/OptimizerTest.cpp
index dd7c94eb..bd224493 100644
--- a/tools/clang/unittests/HLSL/OptimizerTest.cpp
+++ b/tools/clang/unittests/HLSL/OptimizerTest.cpp
@@ -14,13 +14,13 @@
 #endif
 
 #include <algorithm>
+#include <assert.h> // Needed for DxilPipelineStateValidation.h
 #include <cassert>
 #include <map>
 #include <memory>
 #include <sstream>
 #include <string>
 #include <vector>
-#include <assert.h> // Needed for DxilPipelineStateValidation.h
 
 // For DxilRuntimeReflection.h:
 #include "dxc/Support/WinIncludes.h"
  • Check this box to apply formatting changes to this branch.

Copy link
Member

@damyanp damyanp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that we have to do this, but I believe that this is the pragmatic change to make at this point.

Can you file an issue please to cover cleaning this up properly?

DxilPipelineStateValidation.h is included from multiple environments. Don't include assert.h in it, otherwise it might overwrite the custom assert in the code that includes DxilPipelineStateValidation.h.

This fixes #6922
@lizhengxing lizhengxing force-pushed the user/zhengxing/dont-include-assert-h-in-DxilPipelineStateValidation-h branch from db8cbd8 to 18751fd Compare September 19, 2024 01:55
@lizhengxing
Copy link
Collaborator Author

It's unfortunate that we have to do this, but I believe that this is the pragmatic change to make at this point.

Can you file an issue please to cover cleaning this up properly?

@damyanp Sure, I've filed an issue here #6922

Copy link
Member

@damyanp damyanp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you investigate whether we could do something like:

#ifndef assert
#include <assert.h>
#endif

So that we can remove all the modifications to the other files, but still have this header worked when used in the other environments please?

@lizhengxing
Copy link
Collaborator Author

Close this PR since we will use this fix #6925 .

@lizhengxing lizhengxing deleted the user/zhengxing/dont-include-assert-h-in-DxilPipelineStateValidation-h branch September 19, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Include <assert.h> in DxilPipelineStateValidation.h caused build failures
4 participants