tools/clang/lib/Sema/SemaHLSL.cpp
/// <summary>Processes an attribute for a statement.</summary>
/// <param name="S">Sema with context.</param>
/// <param name="St">Statement annotated.</param>
/// <param name="A">Single parsed attribute to process.</param>
/// <param name="Range">Range of all attribute lists (useful for FixIts to suggest inclusions).</param>
/// <param name="Handled">After execution, whether this was recognized and handled.</param>
/// <returns>An attribute instance if processed, nullptr if not recognized or an error was found.</returns>
Processes an attribute for a statement.
Sema with context.
Statement annotated.
Single parsed attribute to process.
Range of all attribute lists (useful for FixIts to suggest inclusions).
After execution, whether this was recognized and handled.
An attribute instance if processed, nullptr if not recognized or an error was found.
Processes an attribute for a statement . Sema with context . Statement annotated . Single parsed attribute to process . Range of all attribute lists ( useful for FixIts to suggest inclusions ) . After execution whether this was recognized and handled . An attribute instance if processed nullptr if not recognized or an error was found .
Attr *hlsl::ProcessStmtAttributeForHLSL(Sema &S, Stmt *St, const AttributeList &A, SourceRange Range, bool& Handled)
{
  Attr * result = nullptr;
  Handled = true;
  switch (A.getKind())
  {
  case AttributeList::AT_HLSLUnroll:
    ValidateAttributeOnLoop(S, St, A);
    result = HandleUnrollAttribute(S, A);
    break;
  case AttributeList::AT_HLSLAllowUAVCondition:
    ValidateAttributeOnLoop(S, St, A);
    result = ::new (S.Context) HLSLAllowUAVConditionAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLLoop:
    ValidateAttributeOnLoop(S, St, A);
    result = ::new (S.Context) HLSLLoopAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLFastOpt:
    ValidateAttributeOnLoop(S, St, A);
    result = ::new (S.Context) HLSLFastOptAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLBranch:
    ValidateAttributeOnSwitchOrIf(S, St, A);
    result = ::new (S.Context) HLSLBranchAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLFlatten:
    ValidateAttributeOnSwitchOrIf(S, St, A);
    result = ::new (S.Context) HLSLFlattenAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLForceCase:
    ValidateAttributeOnSwitch(S, St, A);
    result = ::new (S.Context) HLSLForceCaseAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  case AttributeList::AT_HLSLCall:
    ValidateAttributeOnSwitch(S, St, A);
    result = ::new (S.Context) HLSLCallAttr(
      A.getRange(), S.Context, A.getAttributeSpellingListIndex());
    break;
  default:
    Handled = false;
    break;
  }
  return result;
}
Attr * hlsl :: ProcessStmtAttributeForHLSL ( Sema & S , Stmt * St , const AttributeList & A , SourceRange Range , bool & Handled ) { Attr * result = nullptr ; Handled = true ; switch ( A . getKind ( ) ) { case AttributeList :: AT_HLSLUnroll : ValidateAttributeOnLoop ( S , St , A ) ; result = HandleUnrollAttribute ( S , A ) ; break ; case AttributeList :: AT_HLSLAllowUAVCondition : ValidateAttributeOnLoop ( S , St , A ) ; result = :: new ( S . Context ) HLSLAllowUAVConditionAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLLoop : ValidateAttributeOnLoop ( S , St , A ) ; result = :: new ( S . Context ) HLSLLoopAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLFastOpt : ValidateAttributeOnLoop ( S , St , A ) ; result = :: new ( S . Context ) HLSLFastOptAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLBranch : ValidateAttributeOnSwitchOrIf ( S , St , A ) ; result = :: new ( S . Context ) HLSLBranchAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLFlatten : ValidateAttributeOnSwitchOrIf ( S , St , A ) ; result = :: new ( S . Context ) HLSLFlattenAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLForceCase : ValidateAttributeOnSwitch ( S , St , A ) ; result = :: new ( S . Context ) HLSLForceCaseAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; case AttributeList :: AT_HLSLCall : ValidateAttributeOnSwitch ( S , St , A ) ; result = :: new ( S . Context ) HLSLCallAttr ( A . getRange ( ) , S . Context , A . getAttributeSpellingListIndex ( ) ) ; break ; default : Handled = false ; break ; } return result ; }
<summary>Processes an attribute for a statement.</summary>
<param name="S">Sema with context.</param>
<param name="St">Statement annotated.</param>
<param name="A">Single parsed attribute to process.</param>
<param name="Range">Range of all attribute lists (useful for FixIts to suggest inclusions).</param>
<param name="Handled">After execution, whether this was recognized and handled.</param>
<returns>An attribute instance if processed, nullptr if not recognized or an error was found.</returns>
<summary > Processes an attribute for a statement . < / summary > <param name = " S " > Sema with context . < / param > <param name = " St " > Statement annotated . < / param > <param name = " A " > Single parsed attribute to process . < / param > <param name = " Range " > Range of all attribute lists ( useful for FixIts to suggest inclusions ) . < / param > <param name = " Handled " > After execution whether this was recognized and handled . < / param > <returns > An attribute instance if processed nullptr if not recognized or an error was found . < / returns >
// | Construct        | Allowed Attributes                         | // +------------------+--------------------------------------------+ // | for, while, do   | loop, fastopt, unroll, allow_uav_condition | // | if               | branch, flatten                            | // | switch           | branch, flatten, forcecase, call           |