FLANG
Todo.h
1//===-- Optimizer/Builder/Todo.h --------------------------------*- 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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_LOWER_TODO_H
14#define FORTRAN_LOWER_TODO_H
15
16#include "flang/Optimizer/Support/FatalError.h"
17#include "llvm/Support/ErrorHandling.h"
18#include "llvm/Support/raw_ostream.h"
19#include <cstdlib>
20
21// This is throw-away code used to mark areas of the code that have not yet been
22// developed.
23
24#undef TODO
25// Use TODO_NOLOC if no mlir location is available to indicate the line in
26// Fortran source file that requires an unimplemented feature.
27#undef TODO_NOLOC
28
29#undef TODOQUOTE
30#define TODOQUOTE(X) #X
31
32// Give backtrace only in debug builds.
33#undef GEN_TRACE
34#ifdef NDEBUG
35#define GEN_TRACE false
36#else
37#define GEN_TRACE true
38#endif
39
40#undef TODO_NOLOCDEFN
41#define TODO_NOLOCDEFN(ToDoMsg, ToDoFile, ToDoLine, GenTrace) \
42 do { \
43 llvm::report_fatal_error(llvm::Twine(ToDoFile ":" TODOQUOTE( \
44 ToDoLine) ": not yet implemented: ") + \
45 llvm::Twine(ToDoMsg), \
46 GenTrace); \
47 } while (false)
48
49#define TODO_NOLOC(ToDoMsg) TODO_NOLOCDEFN(ToDoMsg, __FILE__, __LINE__, false)
50#define TODO_NOLOC_TRACE(ToDoMsg) \
51 TODO_NOLOCDEFN(ToDoMsg, __FILE__, __LINE__, GENTRACE)
52
53#undef TODO_DEFN
54#define TODO_DEFN(MlirLoc, ToDoMsg, ToDoFile, ToDoLine, GenTrace) \
55 do { \
56 fir::emitFatalError(MlirLoc, \
57 llvm::Twine(ToDoFile ":" TODOQUOTE( \
58 ToDoLine) ": not yet implemented: ") + \
59 llvm::Twine(ToDoMsg), \
60 GenTrace); \
61 } while (false)
62
63#define TODO(MlirLoc, ToDoMsg) \
64 TODO_DEFN(MlirLoc, ToDoMsg, __FILE__, __LINE__, false)
65#define TODO_TRACE(MlirLoc, ToDoMsg) \
66 TODO_DEFN(MlirLoc, ToDoMsg, __FILE__, __LINE__, GEN_TRACE)
67
68#endif // FORTRAN_LOWER_TODO_H