1 //===--- ParseHLSL.cpp - HLSL-specific parsing support --------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements the parsing logic for HLSL language features. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "clang/Basic/AttributeCommonInfo.h" 14 #include "clang/Parse/ParseDiagnostic.h" 15 #include "clang/Parse/Parser.h" 16 17 using namespace clang; 18 19 void Parser::ParseHLSLSemantics(ParsedAttributes &Attrs, 20 SourceLocation *EndLoc) { 21 assert(Tok.is(tok::colon) && "Not a HLSL Semantic"); 22 ConsumeToken(); 23 24 if (!Tok.is(tok::identifier)) { 25 Diag(Tok.getLocation(), diag::err_expected_semantic_identifier); 26 return; 27 } 28 29 IdentifierInfo *II = Tok.getIdentifierInfo(); 30 SourceLocation Loc = ConsumeToken(); 31 if (EndLoc) 32 *EndLoc = Tok.getLocation(); 33 ParsedAttr::Kind AttrKind = 34 ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_HLSLSemantic); 35 36 if (AttrKind == ParsedAttr::UnknownAttribute) { 37 Diag(Loc, diag::err_unknown_hlsl_semantic) << II; 38 return; 39 } 40 Attrs.addNew(II, Loc, nullptr, SourceLocation(), nullptr, 0, 41 ParsedAttr::AS_HLSLSemantic); 42 } 43