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