1 //===--- HLSLExternalSemaSource.h - HLSL Sema Source ------------*- C++ -*-===// 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 defines the HLSLExternalSemaSource interface. 10 // 11 //===----------------------------------------------------------------------===// 12 #ifndef CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H 13 #define CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H 14 15 #include "llvm/ADT/DenseMap.h" 16 17 #include "clang/Sema/ExternalSemaSource.h" 18 19 namespace clang { 20 class NamespaceDecl; 21 class Sema; 22 23 class HLSLExternalSemaSource : public ExternalSemaSource { 24 Sema *SemaPtr = nullptr; 25 NamespaceDecl *HLSLNamespace = nullptr; 26 CXXRecordDecl *ResourceDecl = nullptr; 27 28 using CompletionFunction = std::function<void(CXXRecordDecl *)>; 29 llvm::DenseMap<CXXRecordDecl *, CompletionFunction> Completions; 30 31 void defineHLSLVectorAlias(); 32 void defineTrivialHLSLTypes(); 33 void defineHLSLTypesWithForwardDeclarations(); 34 35 void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn); 36 37 public: 38 ~HLSLExternalSemaSource() override; 39 40 /// Initialize the semantic source with the Sema instance 41 /// being used to perform semantic analysis on the abstract syntax 42 /// tree. 43 void InitializeSema(Sema &S) override; 44 45 /// Inform the semantic consumer that Sema is no longer available. 46 void ForgetSema() override { SemaPtr = nullptr; } 47 48 using ExternalASTSource::CompleteType; 49 /// Complete an incomplete HLSL builtin type 50 void CompleteType(TagDecl *Tag) override; 51 }; 52 53 } // namespace clang 54 55 #endif // CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H 56