1*e5dd7070Spatrick //===--- SemaConsumer.h - Abstract interface for AST semantics --*- C++ -*-===// 2*e5dd7070Spatrick // 3*e5dd7070Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e5dd7070Spatrick // See https://llvm.org/LICENSE.txt for license information. 5*e5dd7070Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e5dd7070Spatrick // 7*e5dd7070Spatrick //===----------------------------------------------------------------------===// 8*e5dd7070Spatrick // 9*e5dd7070Spatrick // This file defines the SemaConsumer class, a subclass of 10*e5dd7070Spatrick // ASTConsumer that is used by AST clients that also require 11*e5dd7070Spatrick // additional semantic analysis. 12*e5dd7070Spatrick // 13*e5dd7070Spatrick //===----------------------------------------------------------------------===// 14*e5dd7070Spatrick #ifndef LLVM_CLANG_SEMA_SEMACONSUMER_H 15*e5dd7070Spatrick #define LLVM_CLANG_SEMA_SEMACONSUMER_H 16*e5dd7070Spatrick 17*e5dd7070Spatrick #include "clang/AST/ASTConsumer.h" 18*e5dd7070Spatrick 19*e5dd7070Spatrick namespace clang { 20*e5dd7070Spatrick class Sema; 21*e5dd7070Spatrick 22*e5dd7070Spatrick /// An abstract interface that should be implemented by 23*e5dd7070Spatrick /// clients that read ASTs and then require further semantic 24*e5dd7070Spatrick /// analysis of the entities in those ASTs. 25*e5dd7070Spatrick class SemaConsumer : public ASTConsumer { 26*e5dd7070Spatrick virtual void anchor(); 27*e5dd7070Spatrick public: SemaConsumer()28*e5dd7070Spatrick SemaConsumer() { 29*e5dd7070Spatrick ASTConsumer::SemaConsumer = true; 30*e5dd7070Spatrick } 31*e5dd7070Spatrick 32*e5dd7070Spatrick /// Initialize the semantic consumer with the Sema instance 33*e5dd7070Spatrick /// being used to perform semantic analysis on the abstract syntax 34*e5dd7070Spatrick /// tree. InitializeSema(Sema & S)35*e5dd7070Spatrick virtual void InitializeSema(Sema &S) {} 36*e5dd7070Spatrick 37*e5dd7070Spatrick /// Inform the semantic consumer that Sema is no longer available. ForgetSema()38*e5dd7070Spatrick virtual void ForgetSema() {} 39*e5dd7070Spatrick 40*e5dd7070Spatrick // isa/cast/dyn_cast support classof(const ASTConsumer * Consumer)41*e5dd7070Spatrick static bool classof(const ASTConsumer *Consumer) { 42*e5dd7070Spatrick return Consumer->SemaConsumer; 43*e5dd7070Spatrick } 44*e5dd7070Spatrick }; 45*e5dd7070Spatrick } 46*e5dd7070Spatrick 47*e5dd7070Spatrick #endif 48