1 //===- LangOptions.cpp - C Language Family Language Options ---------------===// 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 // This file defines the LangOptions class. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "clang/Basic/LangOptions.h" 14 #include "clang/AST/ASTContext.h" 15 16 using namespace clang; 17 18 LangOptions::LangOptions() { 19 #define LANGOPT(Name, Bits, Default, Description) Name = Default; 20 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default); 21 #include "clang/Basic/LangOptions.def" 22 } 23 24 void LangOptions::resetNonModularOptions() { 25 #define LANGOPT(Name, Bits, Default, Description) 26 #define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default; 27 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 28 Name = Default; 29 #include "clang/Basic/LangOptions.def" 30 31 // These options do not affect AST generation. 32 SanitizerBlacklistFiles.clear(); 33 XRayAlwaysInstrumentFiles.clear(); 34 XRayNeverInstrumentFiles.clear(); 35 36 CurrentModule.clear(); 37 IsHeaderFile = false; 38 } 39 40 bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const { 41 for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i) 42 if (FuncName.equals(NoBuiltinFuncs[i])) 43 return true; 44 return false; 45 } 46 47 VersionTuple LangOptions::getOpenCLVersionTuple() const { 48 const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion; 49 return VersionTuple(Ver / 100, (Ver % 100) / 10); 50 } 51 52 FPOptions FPOptions::defaultWithoutTrailingStorage(const ASTContext &C) { 53 FPOptions result(C.getLangOpts()); 54 return result; 55 } 56 57 bool FPOptions::requiresTrailingStorage(const ASTContext &C) { 58 return getAsOpaqueInt() != defaultWithoutTrailingStorage(C).getAsOpaqueInt(); 59 } 60