Warning: This file is not a C or C++ file. It does not have highlighting.

1//===- PreprocessorOptions.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/// \file
10/// This file contains the declaration of the PreprocessorOptions class, which
11/// is the class for all preprocessor options.
12///
13//===----------------------------------------------------------------------===//
14//
15// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef FORTRAN_FRONTEND_PREPROCESSOROPTIONS_H
20#define FORTRAN_FRONTEND_PREPROCESSOROPTIONS_H
21
22#include "llvm/ADT/StringRef.h"
23
24namespace Fortran::frontend {
25
26/// Communicates whether to include/exclude predefined and command
27/// line preprocessor macros
28enum class PPMacrosFlag : uint8_t {
29 /// Use the file extension to decide
30 Unknown,
31
32 Include,
33 Exclude
34};
35
36/// This class is used for passing the various options used
37/// in preprocessor initialization to the parser options.
38struct PreprocessorOptions {
39 PreprocessorOptions() {}
40
41 std::vector<std::pair<std::string, /*isUndef*/ bool>> macros;
42
43 // Search directories specified by the user with -I
44 // TODO: When adding support for more options related to search paths,
45 // consider collecting them in a separate aggregate. For now we keep it here
46 // as there is no point creating a class for just one field.
47 std::vector<std::string> searchDirectoriesFromDashI;
48 // Search directories specified by the user with -fintrinsic-modules-path
49 std::vector<std::string> searchDirectoriesFromIntrModPath;
50
51 PPMacrosFlag macrosFlag = PPMacrosFlag::Unknown;
52
53 // -P: Suppress #line directives in -E output
54 bool noLineDirectives{false};
55
56 // -fno-reformat: Emit cooked character stream as -E output
57 bool noReformat{false};
58
59 // -dM: Show macro definitions with -dM -E
60 bool showMacros{false};
61
62 void addMacroDef(llvm::StringRef name) {
63 macros.emplace_back(std::string(name), false);
64 }
65
66 void addMacroUndef(llvm::StringRef name) {
67 macros.emplace_back(std::string(name), true);
68 }
69};
70
71} // namespace Fortran::frontend
72
73#endif // FORTRAN_FRONTEND_PREPROCESSOROPTIONS_H
74

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of flang/include/flang/Frontend/PreprocessorOptions.h