blob: 516b1ff1b7e217ea169aec42f4fcce4175e0182c [file] [log] [blame]
Eugene Zelenko25cae5a22018-02-16 23:40:07 +00001//===- LangOptions.cpp - C Language Family Language Options ---------------===//
Douglas Gregor79a91412011-09-13 17:21:33 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Douglas Gregor79a91412011-09-13 17:21:33 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the LangOptions class.
10//
11//===----------------------------------------------------------------------===//
Eugene Zelenko25cae5a22018-02-16 23:40:07 +000012
Douglas Gregor79a91412011-09-13 17:21:33 +000013#include "clang/Basic/LangOptions.h"
14
15using namespace clang;
16
Eugene Zelenko25cae5a22018-02-16 23:40:07 +000017LangOptions::LangOptions() {
Douglas Gregor79a91412011-09-13 17:21:33 +000018#define LANGOPT(Name, Bits, Default, Description) Name = Default;
19#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
20#include "clang/Basic/LangOptions.def"
21}
Douglas Gregorf1312a82011-09-13 20:44:41 +000022
23void LangOptions::resetNonModularOptions() {
24#define LANGOPT(Name, Bits, Default, Description)
25#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
Douglas Gregor8455e762011-09-15 14:56:27 +000026#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
27 Name = Default;
28#include "clang/Basic/LangOptions.def"
Will Dietzf54319c2013-01-18 11:30:38 +000029
Vedant Kumar85a83c22017-06-01 20:01:01 +000030 // These options do not affect AST generation.
Alexey Samsonova511cdd2015-02-04 17:40:08 +000031 SanitizerBlacklistFiles.clear();
Dean Michael Berris835832d2017-03-30 00:29:36 +000032 XRayAlwaysInstrumentFiles.clear();
33 XRayNeverInstrumentFiles.clear();
Will Dietzf54319c2013-01-18 11:30:38 +000034
Douglas Gregor7d106e42011-11-15 19:35:01 +000035 CurrentModule.clear();
Erik Verbruggene0bde752016-10-27 14:17:10 +000036 IsHeaderFile = false;
Douglas Gregorf1312a82011-09-13 20:44:41 +000037}
38
Mehdi Aminice2da5e2016-10-10 16:34:07 +000039bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
Chad Rosier7dbc9cf2016-01-06 14:35:46 +000040 for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
41 if (FuncName.equals(NoBuiltinFuncs[i]))
42 return true;
43 return false;
44}
Sven van Haastregt35b61392018-05-08 13:47:43 +000045
46VersionTuple LangOptions::getOpenCLVersionTuple() const {
47 const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
48 return VersionTuple(Ver / 100, (Ver % 100) / 10);
49}