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 27 using CompletionFunction = std::function<void(CXXRecordDecl *)>; 28 llvm::DenseMap<CXXRecordDecl *, CompletionFunction> Completions; 29 30 void defineHLSLVectorAlias(); 31 void defineTrivialHLSLTypes(); 32 void defineHLSLTypesWithForwardDeclarations(); 33 34 void onCompletion(CXXRecordDecl *Record, CompletionFunction Fn); 35 36 public: 37 ~HLSLExternalSemaSource() override; 38 39 /// Initialize the semantic source with the Sema instance 40 /// being used to perform semantic analysis on the abstract syntax 41 /// tree. 42 void InitializeSema(Sema &S) override; 43 44 /// Inform the semantic consumer that Sema is no longer available. ForgetSema()45 void ForgetSema() override { SemaPtr = nullptr; } 46 47 using ExternalASTSource::CompleteType; 48 /// Complete an incomplete HLSL builtin type 49 void CompleteType(TagDecl *Tag) override; 50 }; 51 52 } // namespace clang 53 54 #endif // CLANG_SEMA_HLSLEXTERNALSEMASOURCE_H 55