Skip to content

Commit 5cd5ef8

Browse files
committed
[ser] Add 'namespace dx' unconditionally
1 parent 46a768b commit 5cd5ef8

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,15 +4061,13 @@ class HLSLExternalSource : public ExternalSemaSource {
40614061
// Namespace ::dx only introduced with SM6.9
40624062
const auto *SM =
40634063
hlsl::ShaderModel::GetByName(m_sema->getLangOpts().HLSLProfile.c_str());
4064-
if (SM->IsSM69Plus()) {
4065-
m_dxNSDecl =
4066-
NamespaceDecl::Create(context, context.getTranslationUnitDecl(),
4067-
/*Inline*/ false, SourceLocation(),
4068-
SourceLocation(), &context.Idents.get("dx"),
4069-
/*PrevDecl*/ nullptr);
4070-
m_dxNSDecl->setImplicit();
4071-
context.getTranslationUnitDecl()->addDecl(m_dxNSDecl);
4072-
}
4064+
m_dxNSDecl =
4065+
NamespaceDecl::Create(context, context.getTranslationUnitDecl(),
4066+
/*Inline*/ false, SourceLocation(),
4067+
SourceLocation(), &context.Idents.get("dx"),
4068+
/*PrevDecl*/ nullptr);
4069+
m_dxNSDecl->setImplicit();
4070+
context.getTranslationUnitDecl()->addDecl(m_dxNSDecl);
40734071

40744072
#ifdef ENABLE_SPIRV_CODEGEN
40754073
if (m_sema->getLangOpts().SPIRV) {
@@ -5133,8 +5131,6 @@ class HLSLExternalSource : public ExternalSemaSource {
51335131
auto tableCount = _countof(g_Intrinsics);
51345132
if (isDxNamespace) {
51355133
// Namespace ::dx disabled pre SM 6.9
5136-
if (!m_dxNSDecl)
5137-
return false;
51385134
table = g_DxIntrinsics;
51395135
tableCount = _countof(g_DxIntrinsics);
51405136
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %dxc -T lib_6_8 %s -verify
22

3+
// expected-no-diagnostics
4+
using namespace dx;
5+
36
[shader("raygeneration")]
47
void main() {
5-
// expected-error@+1{{use of undeclared identifier 'dx'}}
6-
dx::HitObject hit;
78
}

0 commit comments

Comments
 (0)