clang  12.0.0git
LangOptions.cpp
Go to the documentation of this file.
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 
14 
15 using namespace clang;
16 
18 #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 }
22 
24 #define LANGOPT(Name, Bits, Default, Description)
25 #define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = Default;
26 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
27  Name = static_cast<unsigned>(Default);
28 #include "clang/Basic/LangOptions.def"
29 
30  // These options do not affect AST generation.
34 
35  CurrentModule.clear();
36  IsHeaderFile = false;
37 }
38 
39 bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
40  for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
41  if (FuncName.equals(NoBuiltinFuncs[i]))
42  return true;
43  return false;
44 }
45 
46 VersionTuple LangOptions::getOpenCLVersionTuple() const {
47  const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
48  return VersionTuple(Ver / 100, (Ver % 100) / 10);
49 }
50 
52  FPOptions result(LO);
53  return result;
54 }
55 
56 LLVM_DUMP_METHOD void FPOptions::dump() {
57 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
58  llvm::errs() << "\n " #NAME " " << get##NAME();
59 #include "clang/Basic/FPOptions.def"
60  llvm::errs() << "\n";
61 }
62 
63 LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
64 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
65  if (has##NAME##Override()) \
66  llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
67 #include "clang/Basic/FPOptions.def"
68  llvm::errs() << "\n";
69 }
bool isNoBuiltinFunc(StringRef Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
Definition: LangOptions.cpp:39
LLVM_DUMP_METHOD void dump()
Definition: LangOptions.cpp:63
LLVM_DUMP_METHOD void dump()
Definition: LangOptions.cpp:56
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions,...
Definition: LangOptions.h:258
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
Definition: LangOptions.cpp:23
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:54
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
Definition: LangOptions.cpp:46
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Definition: LangOptions.h:291
Defines the clang::LangOptions interface.
Dataflow Directional Tag Classes.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
Definition: LangOptions.h:315
std::vector< std::string > XRayNeverInstrumentFiles
Paths to the XRay "never instrument" files specifying which objects (files, functions,...
Definition: LangOptions.h:264
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
Definition: LangOptions.h:303
std::vector< std::string > SanitizerBlacklistFiles
Paths to blacklist files specifying which objects (files, functions, variables) should not be instrum...
Definition: LangOptions.h:252
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
Definition: LangOptions.cpp:51