Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/LangOptions.cpp
Line
Count
Source (jump to first uncovered line)
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 "llvm/ADT/SmallString.h"
15
#include "llvm/Support/Path.h"
16
17
using namespace clang;
18
19
7.96M
LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
20
1.85G
#define LANGOPT(Name, Bits, Default, Description) Name = 
Default15.9M
;
21
214M
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
22
7.96M
#include "clang/Basic/LangOptions.def"
23
7.96M
}
24
25
1.73k
void LangOptions::resetNonModularOptions() {
26
1.73k
#define LANGOPT(Name, Bits, Default, Description)
27
97.3k
#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = 
Default2.69k
;
28
1.73k
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
29
6.95k
  Name = static_cast<unsigned>(Default);
30
1.73k
#include "clang/Basic/LangOptions.def"
31
32
  // These options do not affect AST generation.
33
1.73k
  NoSanitizeFiles.clear();
34
1.73k
  XRayAlwaysInstrumentFiles.clear();
35
1.73k
  XRayNeverInstrumentFiles.clear();
36
37
1.73k
  CurrentModule.clear();
38
1.73k
  IsHeaderFile = false;
39
1.73k
}
40
41
233M
bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
42
233M
  for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; 
++i194k
)
43
194k
    if (FuncName.equals(NoBuiltinFuncs[i]))
44
103
      return true;
45
233M
  return false;
46
233M
}
47
48
224
VersionTuple LangOptions::getOpenCLVersionTuple() const {
49
224
  const int Ver = OpenCLCPlusPlus ? 
OpenCLCPlusPlusVersion42
:
OpenCLVersion182
;
50
224
  if (OpenCLCPlusPlus && 
Ver != 10042
)
51
34
    return VersionTuple(Ver / 100);
52
190
  return VersionTuple(Ver / 100, (Ver % 100) / 10);
53
224
}
54
55
428M
unsigned LangOptions::getOpenCLCompatibleVersion() const {
56
428M
  if (!OpenCLCPlusPlus)
57
428M
    return OpenCLVersion;
58
591k
  if (OpenCLCPlusPlusVersion == 100)
59
355k
    return 200;
60
235k
  if (OpenCLCPlusPlusVersion == 202100)
61
237k
    return 300;
62
18.4E
  llvm_unreachable("Unknown OpenCL version");
63
18.4E
}
64
65
497
void LangOptions::remapPathPrefix(SmallString<256> &Path) const {
66
497
  for (const auto &Entry : MacroPrefixMap)
67
41
    if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
68
13
      break;
69
497
}
70
71
60
std::string LangOptions::getOpenCLVersionString() const {
72
60
  std::string Result;
73
60
  {
74
60
    llvm::raw_string_ostream Out(Result);
75
60
    Out << (OpenCLCPlusPlus ? 
"C++ for OpenCL"21
:
"OpenCL C"39
) << " version "
76
60
        << getOpenCLVersionTuple().getAsString();
77
60
  }
78
60
  return Result;
79
60
}
80
81
739k
FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
82
739k
  FPOptions result(LO);
83
739k
  return result;
84
739k
}
85
86
0
LLVM_DUMP_METHOD void FPOptions::dump() {
87
0
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                    \
88
0
  llvm::errs() << "\n " #NAME " " << get##NAME();
89
0
#include "clang/Basic/FPOptions.def"
90
0
  llvm::errs() << "\n";
91
0
}
92
93
0
LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
94
0
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                    \
95
0
  if (has##NAME##Override())                                                   \
96
0
    llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
97
0
#include "clang/Basic/FPOptions.def"
98
0
  llvm::errs() << "\n";
99
0
}