1 //===--- ByteCodeGenError.h - Byte code generation error ----------*- 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 #ifndef LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H 10 #define LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H 11 12 #include "clang/AST/Decl.h" 13 #include "clang/AST/Stmt.h" 14 #include "clang/Basic/SourceLocation.h" 15 #include "llvm/Support/Error.h" 16 17 namespace clang { 18 namespace interp { 19 20 /// Error thrown by the compiler. 21 struct ByteCodeGenError : public llvm::ErrorInfo<ByteCodeGenError> { 22 public: ByteCodeGenErrorByteCodeGenError23 ByteCodeGenError(SourceLocation Loc) : Loc(Loc) {} ByteCodeGenErrorByteCodeGenError24 ByteCodeGenError(const Stmt *S) : ByteCodeGenError(S->getBeginLoc()) {} ByteCodeGenErrorByteCodeGenError25 ByteCodeGenError(const Decl *D) : ByteCodeGenError(D->getBeginLoc()) {} 26 logByteCodeGenError27 void log(raw_ostream &OS) const override { OS << "unimplemented feature"; } 28 getLocByteCodeGenError29 const SourceLocation &getLoc() const { return Loc; } 30 31 static char ID; 32 33 private: 34 // Start of the item where the error occurred. 35 SourceLocation Loc; 36 37 // Users are not expected to use error_code. convertToErrorCodeByteCodeGenError38 std::error_code convertToErrorCode() const override { 39 return llvm::inconvertibleErrorCode(); 40 } 41 }; 42 43 } // namespace interp 44 } // namespace clang 45 46 #endif 47