⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245662 in webkit


Ignore:
Timestamp:
May 22, 2019, 5:33:45 PM (7 years ago)
Author:
sbarati@apple.com
Message:

WHLSL: fix enum parsing
https://bugs.webkit.org/show_bug.cgi?id=198087

Reviewed by Myles Maxfield.

Source/WebCore:

This fixes two bugs:

  1. We were using a String by reference after moving the underlying owner of

the string. This would lead to the String becoming the empty value, and
crashing when used as a key in a hash map.

  1. We were incorrectly producing a syntax error for enum declarations by

saying it's invalid if an enum value was added to a hash map for the first
time. This logic should be negated. We need to error when it's added for
the second time and onwards.

Test: webgpu/whlsl-dont-crash-parsing-enum.html

  • Modules/webgpu/WHLSL/AST/WHLSLAST.h: Replaced.
  • Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h:

(WebCore::WHLSL::AST::EnumerationDefinition::add):

  • Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h:

(WebCore::WHLSL::AST::EnumerationMember::name):

  • Modules/webgpu/WHLSL/WHLSLASTDumper.cpp: Replaced.

(WebCore::WHLSL::ASTDumper::visit):

  • Modules/webgpu/WHLSL/WHLSLASTDumper.h: Replaced.

LayoutTests:

  • webgpu/whlsl-dont-crash-parsing-enum-expected.html: Added.
  • webgpu/whlsl-dont-crash-parsing-enum.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245661 r245662  
     12019-05-22  Saam barati  <sbarati@apple.com>
     2
     3        WHLSL: fix enum parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=198087
     5
     6        Reviewed by Myles Maxfield.
     7
     8        * webgpu/whlsl-dont-crash-parsing-enum-expected.html: Added.
     9        * webgpu/whlsl-dont-crash-parsing-enum.html: Added.
     10
    1112019-05-22  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r245656 r245662  
     12019-05-22  Saam barati  <sbarati@apple.com>
     2
     3        WHLSL: fix enum parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=198087
     5
     6        Reviewed by Myles Maxfield.
     7
     8        This fixes two bugs:
     9       
     10        1. We were using a String by reference after moving the underlying owner of
     11        the string. This would lead to the String becoming the empty value, and
     12        crashing when used as a key in a hash map.
     13        2. We were incorrectly producing a syntax error for enum declarations by
     14        saying it's invalid if an enum value was added to a hash map for the first
     15        time. This logic should be negated. We need to error when it's added for
     16        the second time and onwards.
     17
     18        Test: webgpu/whlsl-dont-crash-parsing-enum.html
     19
     20        * Modules/webgpu/WHLSL/AST/WHLSLAST.h: Replaced.
     21        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h:
     22        (WebCore::WHLSL::AST::EnumerationDefinition::add):
     23        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h:
     24        (WebCore::WHLSL::AST::EnumerationMember::name):
     25        * Modules/webgpu/WHLSL/WHLSLASTDumper.cpp: Replaced.
     26        (WebCore::WHLSL::ASTDumper::visit):
     27        * Modules/webgpu/WHLSL/WHLSLASTDumper.h: Replaced.
     28
    1292019-05-22  Simon Fraser  <simon.fraser@apple.com>
    230
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h

    r239930 r245662  
    6565    {
    6666        auto result = m_members.add(member.name(), std::make_unique<EnumerationMember>(WTFMove(member)));
    67         return !result.isNewEntry;
     67        return result.isNewEntry;
    6868    }
    6969
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h

    r239844 r245662  
    5656
    5757    const Lexer::Token& origin() const { return m_origin; }
    58     String& name() { return m_name; }
     58    String name() { return m_name; }
    5959    Optional<ConstantExpression>& value() { return m_value; }
    6060
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDumper.cpp

    r245613 r245662  
    112112void ASTDumper::visit(AST::EnumerationDefinition& enumerationDefinition)
    113113{
    114     // FIXME: Test this once we parse enums:
    115     // https://bugs.webkit.org/show_bug.cgi?id=198087
    116 
    117     m_out.println(m_indent, "enum ");
     114    m_out.print(m_indent, "enum ");
    118115    visit(enumerationDefinition.type());
    119116    m_out.print(" {");
     
    340337}
    341338
    342 void ASTDumper::visit(AST::EnumerationMemberLiteral&)
    343 {
    344     // FIXME: Handle this when we can parse enums:
    345     // https://bugs.webkit.org/show_bug.cgi?id=198087
     339void ASTDumper::visit(AST::EnumerationMemberLiteral& enumerationMemberLiteral)
     340{
     341    m_out.print(enumerationMemberLiteral.left(), ".", enumerationMemberLiteral.right());
    346342}
    347343
Note: See TracChangeset for help on using the changeset viewer.