ByteCodeGenError.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H
  9. #define LLVM_CLANG_AST_INTERP_BYTECODEGENERROR_H
  10. #include "clang/AST/Decl.h"
  11. #include "clang/AST/Stmt.h"
  12. #include "clang/Basic/SourceLocation.h"
  13. #include "llvm/Support/Error.h"
  14. namespace clang {
  15. namespace interp {
  16. /// Error thrown by the compiler.
  17. struct ByteCodeGenError : public llvm::ErrorInfo<ByteCodeGenError> {
  18. public:
  19. ByteCodeGenError(SourceLocation Loc) : Loc(Loc) {}
  20. ByteCodeGenError(const Stmt *S) : ByteCodeGenError(S->getBeginLoc()) {}
  21. ByteCodeGenError(const Decl *D) : ByteCodeGenError(D->getBeginLoc()) {}
  22. void log(raw_ostream &OS) const override { OS << "unimplemented feature"; }
  23. const SourceLocation &getLoc() const { return Loc; }
  24. static char ID;
  25. private:
  26. // Start of the item where the error occurred.
  27. SourceLocation Loc;
  28. // Users are not expected to use error_code.
  29. std::error_code convertToErrorCode() const override {
  30. return llvm::inconvertibleErrorCode();
  31. }
  32. };
  33. } // namespace interp
  34. } // namespace clang
  35. #endif