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

Always use public for hlsl.

Xiang Li 8 жил өмнө
parent
commit
bdcaa4caa0

+ 6 - 2
tools/clang/lib/AST/DeclPrinter.cpp

@@ -330,7 +330,9 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
       continue;
     }
 
-    if (isa<AccessSpecDecl>(*D)) {
+    if (isa<AccessSpecDecl>(*D)
+        && !Policy.LangOpts.HLSL // HLSL Change - no access specifier for hlsl.
+        ) {
       Indentation -= Policy.Indentation;
       this->Indent();
       Print(D->getAccess());
@@ -893,7 +895,9 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
           Out << "virtual ";
 
         AccessSpecifier AS = Base->getAccessSpecifierAsWritten();
-        if (AS != AS_none) {
+        if (AS != AS_none
+            && !Policy.LangOpts.HLSL // HLSL Change - no access specifier for hlsl.
+            ) {
           Print(AS);
           Out << " ";
         }

+ 1 - 1
tools/clang/lib/Parse/ParseDeclCXX.cpp

@@ -1892,6 +1892,7 @@ BaseResult Parser::ParseBaseSpecifier(Decl *ClassDecl) {
   if (Access != AS_none) Diag(Tok, diag::err_hlsl_unsupported_construct) << "base type access specifier"; // HLSL Change
   if (Access != AS_none)
     ConsumeToken();
+  if (getLangOpts().HLSL) Access = AS_public; // HLSL Change - always use public for hlsl.
 
   CheckMisplacedCXX11Attribute(Attributes, StartLoc);
 
@@ -1924,7 +1925,6 @@ BaseResult Parser::ParseBaseSpecifier(Decl *ClassDecl) {
   SourceLocation EllipsisLoc;
   TryConsumeToken(tok::ellipsis, EllipsisLoc);
   if (getLangOpts().HLSL && EllipsisLoc != SourceLocation()) Diag(Tok, diag::err_hlsl_unsupported_construct) << "base type ellipsis"; // HLSL Change
-
   // Find the complete source range for the base-specifier.
   SourceRange Range(StartLoc, EndLocation);
 

+ 22 - 0
tools/clang/test/CodeGenHLSL/parent_method.hlsl

@@ -0,0 +1,22 @@
+// RUN: %dxc -E main -T ps_6_0 %s  | FileCheck %s
+
+// CHECK: main
+
+class A {
+  float m_a;
+  void bar() { m_a = 1.2; }
+};
+class B : A {
+  int m_b;
+  void foo() {
+    m_a = 1.3;
+    m_b = 3;
+  }
+};
+
+float main() : SV_Target {
+  B b;
+  b.bar();
+  b.foo();
+  return b.m_a;
+}

+ 5 - 0
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -813,6 +813,7 @@ public:
   //TEST_METHOD(CodeGenMore_Operators_Mod)
   //TEST_METHOD(CodeGenObject_Operators_Mod)
   TEST_METHOD(CodeGenPackreg_Mod)
+  TEST_METHOD(CodeGenParentMethod)
   TEST_METHOD(CodeGenParameter_Types)
   TEST_METHOD(CodeGenScalar_Assignments_Mod)
   TEST_METHOD(CodeGenScalar_Operators_Assign_Mod)
@@ -4420,6 +4421,10 @@ TEST_F(CompilerTest, CodeGenPackreg_Mod) {
   CodeGenTest(L"..\\CodeGenHLSL\\packreg_Mod.hlsl");
 }
 
+TEST_F(CompilerTest, CodeGenParentMethod) {
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\parent_method.hlsl");
+}
+
 TEST_F(CompilerTest, CodeGenParameter_Types) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\parameter_types.hlsl");
 }