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