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: 23 ByteCodeGenError(SourceRange Range) : Range(Range) {} 24 ByteCodeGenError(const Stmt *S) : ByteCodeGenError(S->getSourceRange()) {} 25 ByteCodeGenError(const Decl *D) : ByteCodeGenError(D->getSourceRange()) {} 26 27 void log(raw_ostream &OS) const override { OS << "unimplemented feature"; } 28 29 const SourceRange &getRange() const { return Range; } 30 31 static char ID; 32 33 private: 34 // Range of the item where the error occurred. 35 SourceRange Range; 36 37 // Users are not expected to use error_code. 38 std::error_code convertToErrorCode() const override { 39 return llvm::inconvertibleErrorCode(); 40 } 41 }; 42 43 } // namespace interp 44 } // namespace clang 45 46 #endif 47