1*950b70dcSNandor Licker //===--- ByteCodeGenError.h - Byte code generation error ----------*- C -*-===//
2*950b70dcSNandor Licker //
3*950b70dcSNandor Licker // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*950b70dcSNandor Licker // See https://llvm.org/LICENSE.txt for license information.
5*950b70dcSNandor Licker // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*950b70dcSNandor Licker //
7*950b70dcSNandor Licker //===----------------------------------------------------------------------===//
8*950b70dcSNandor Licker 
9*950b70dcSNandor Licker #ifndef LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H
10*950b70dcSNandor Licker #define LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H
11*950b70dcSNandor Licker 
12*950b70dcSNandor Licker #include "clang/AST/Decl.h"
13*950b70dcSNandor Licker #include "clang/AST/Stmt.h"
14*950b70dcSNandor Licker #include "clang/Basic/SourceLocation.h"
15*950b70dcSNandor Licker #include "llvm/Support/Error.h"
16*950b70dcSNandor Licker 
17*950b70dcSNandor Licker namespace clang {
18*950b70dcSNandor Licker namespace interp {
19*950b70dcSNandor Licker 
20*950b70dcSNandor Licker /// Error thrown by the compiler.
21*950b70dcSNandor Licker struct ByteCodeGenError : public llvm::ErrorInfo<ByteCodeGenError> {
22*950b70dcSNandor Licker public:
ByteCodeGenErrorByteCodeGenError23*950b70dcSNandor Licker   ByteCodeGenError(SourceLocation Loc) : Loc(Loc) {}
ByteCodeGenErrorByteCodeGenError24*950b70dcSNandor Licker   ByteCodeGenError(const Stmt *S) : ByteCodeGenError(S->getBeginLoc()) {}
ByteCodeGenErrorByteCodeGenError25*950b70dcSNandor Licker   ByteCodeGenError(const Decl *D) : ByteCodeGenError(D->getBeginLoc()) {}
26*950b70dcSNandor Licker 
logByteCodeGenError27*950b70dcSNandor Licker   void log(raw_ostream &OS) const override { OS << "unimplemented feature"; }
28*950b70dcSNandor Licker 
getLocByteCodeGenError29*950b70dcSNandor Licker   const SourceLocation &getLoc() const { return Loc; }
30*950b70dcSNandor Licker 
31*950b70dcSNandor Licker   static char ID;
32*950b70dcSNandor Licker 
33*950b70dcSNandor Licker private:
34*950b70dcSNandor Licker   // Start of the item where the error occurred.
35*950b70dcSNandor Licker   SourceLocation Loc;
36*950b70dcSNandor Licker 
37*950b70dcSNandor Licker   // Users are not expected to use error_code.
convertToErrorCodeByteCodeGenError38*950b70dcSNandor Licker   std::error_code convertToErrorCode() const override {
39*950b70dcSNandor Licker     return llvm::inconvertibleErrorCode();
40*950b70dcSNandor Licker   }
41*950b70dcSNandor Licker };
42*950b70dcSNandor Licker 
43*950b70dcSNandor Licker } // namespace interp
44*950b70dcSNandor Licker } // namespace clang
45*950b70dcSNandor Licker 
46*950b70dcSNandor Licker #endif
47