xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Basic/LangOptions.cpp (revision e038c9c4676b0f19b1b7dd08a940c6ed64a6d5ae)
17330f729Sjoerg //===- LangOptions.cpp - C Language Family Language Options ---------------===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg //
97330f729Sjoerg //  This file defines the LangOptions class.
107330f729Sjoerg //
117330f729Sjoerg //===----------------------------------------------------------------------===//
127330f729Sjoerg 
137330f729Sjoerg #include "clang/Basic/LangOptions.h"
147330f729Sjoerg 
157330f729Sjoerg using namespace clang;
167330f729Sjoerg 
LangOptions()17*e038c9c4Sjoerg LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
187330f729Sjoerg #define LANGOPT(Name, Bits, Default, Description) Name = Default;
197330f729Sjoerg #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
207330f729Sjoerg #include "clang/Basic/LangOptions.def"
217330f729Sjoerg }
227330f729Sjoerg 
resetNonModularOptions()237330f729Sjoerg void LangOptions::resetNonModularOptions() {
247330f729Sjoerg #define LANGOPT(Name, Bits, Default, Description)
257330f729Sjoerg #define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
267330f729Sjoerg #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
27*e038c9c4Sjoerg   Name = static_cast<unsigned>(Default);
287330f729Sjoerg #include "clang/Basic/LangOptions.def"
297330f729Sjoerg 
307330f729Sjoerg   // These options do not affect AST generation.
31*e038c9c4Sjoerg   NoSanitizeFiles.clear();
327330f729Sjoerg   XRayAlwaysInstrumentFiles.clear();
337330f729Sjoerg   XRayNeverInstrumentFiles.clear();
347330f729Sjoerg 
357330f729Sjoerg   CurrentModule.clear();
367330f729Sjoerg   IsHeaderFile = false;
377330f729Sjoerg }
387330f729Sjoerg 
isNoBuiltinFunc(StringRef FuncName) const397330f729Sjoerg bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
407330f729Sjoerg   for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
417330f729Sjoerg     if (FuncName.equals(NoBuiltinFuncs[i]))
427330f729Sjoerg       return true;
437330f729Sjoerg   return false;
447330f729Sjoerg }
457330f729Sjoerg 
getOpenCLVersionTuple() const467330f729Sjoerg VersionTuple LangOptions::getOpenCLVersionTuple() const {
477330f729Sjoerg   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
487330f729Sjoerg   return VersionTuple(Ver / 100, (Ver % 100) / 10);
497330f729Sjoerg }
50*e038c9c4Sjoerg 
defaultWithoutTrailingStorage(const LangOptions & LO)51*e038c9c4Sjoerg FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
52*e038c9c4Sjoerg   FPOptions result(LO);
53*e038c9c4Sjoerg   return result;
54*e038c9c4Sjoerg }
55*e038c9c4Sjoerg 
dump()56*e038c9c4Sjoerg LLVM_DUMP_METHOD void FPOptions::dump() {
57*e038c9c4Sjoerg #define OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                    \
58*e038c9c4Sjoerg   llvm::errs() << "\n " #NAME " " << get##NAME();
59*e038c9c4Sjoerg #include "clang/Basic/FPOptions.def"
60*e038c9c4Sjoerg   llvm::errs() << "\n";
61*e038c9c4Sjoerg }
62*e038c9c4Sjoerg 
dump()63*e038c9c4Sjoerg LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
64*e038c9c4Sjoerg #define OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                    \
65*e038c9c4Sjoerg   if (has##NAME##Override())                                                   \
66*e038c9c4Sjoerg     llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
67*e038c9c4Sjoerg #include "clang/Basic/FPOptions.def"
68*e038c9c4Sjoerg   llvm::errs() << "\n";
69*e038c9c4Sjoerg }
70