| 1 | //===--- CodeGenOptions.cpp -----------------------------------------------===// |
| 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 | #include "clang/Basic/CodeGenOptions.h" |
| 10 | |
| 11 | namespace clang { |
| 12 | |
| 13 | CodeGenOptions::CodeGenOptions() { |
| 14 | #define CODEGENOPT(Name, Bits, Default) Name = Default; |
| 15 | #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); |
| 16 | #include "clang/Basic/CodeGenOptions.def" |
| 17 | |
| 18 | RelocationModel = llvm::Reloc::PIC_; |
| 19 | } |
| 20 | |
| 21 | void CodeGenOptions::resetNonModularOptions(StringRef ModuleFormat) { |
| 22 | // First reset all CodeGen options only. The Debug options are handled later. |
| 23 | #define DEBUGOPT(Name, Bits, Default) |
| 24 | #define VALUE_DEBUGOPT(Name, Bits, Default) |
| 25 | #define ENUM_DEBUGOPT(Name, Type, Bits, Default) |
| 26 | #define CODEGENOPT(Name, Bits, Default) Name = Default; |
| 27 | #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); |
| 28 | // Do not reset AST affecting code generation options. |
| 29 | #define AFFECTING_VALUE_CODEGENOPT(Name, Bits, Default) |
| 30 | #include "clang/Basic/CodeGenOptions.def" |
| 31 | |
| 32 | // Next reset all debug options that can always be reset, because they never |
| 33 | // affect the PCM. |
| 34 | #define DEBUGOPT(Name, Bits, Default) |
| 35 | #define VALUE_DEBUGOPT(Name, Bits, Default) |
| 36 | #define ENUM_DEBUGOPT(Name, Type, Bits, Default) |
| 37 | #define BENIGN_DEBUGOPT(Name, Bits, Default) Name = Default; |
| 38 | #define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) Name = Default; |
| 39 | #define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default); |
| 40 | #include "clang/Basic/DebugOptions.def" |
| 41 | |
| 42 | // Conditionally reset debug options that only matter when the debug info is |
| 43 | // emitted into the PCM (-gmodules). |
| 44 | if (ModuleFormat == "raw" && !DebugTypeExtRefs) { |
| 45 | #define DEBUGOPT(Name, Bits, Default) Name = Default; |
| 46 | #define VALUE_DEBUGOPT(Name, Bits, Default) Name = Default; |
| 47 | #define ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default); |
| 48 | #define BENIGN_DEBUGOPT(Name, Bits, Default) |
| 49 | #define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) |
| 50 | #define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) |
| 51 | #include "clang/Basic/DebugOptions.def" |
| 52 | } |
| 53 | |
| 54 | RelocationModel = llvm::Reloc::PIC_; |
| 55 | } |
| 56 | |
| 57 | } // end namespace clang |
| 58 | |