Coverage Report

Created: 2022-01-25 06:29

/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
8.32M
LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
20
1.97G
#define LANGOPT(Name, Bits, Default, Description) Name = 
Default16.6M
;
21
224M
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
22
8.32M
#include "clang/Basic/LangOptions.def"
23
8.32M
}
24
25
1.78k
void LangOptions::resetNonModularOptions() {
26
1.78k
#define LANGOPT(Name, Bits, Default, Description)
27
99.9k
#define BENIGN_LANGOPT(Name, Bits, Default, Description) Name = 
Default2.75k
;
28
1.78k
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
29
7.14k
  Name = static_cast<unsigned>(Default);
30
1.78k
#include "clang/Basic/LangOptions.def"
31
32
  // These options do not affect AST generation.
33
1.78k
  NoSanitizeFiles.clear();
34
1.78k
  XRayAlwaysInstrumentFiles.clear();
35
1.78k
  XRayNeverInstrumentFiles.clear();
36
37
1.78k
  CurrentModule.clear();
38
1.78k
  IsHeaderFile = false;
39
1.78k
}
40
41
222M
bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
42
222M
  for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; 
++i192k
)
43
192k
    if (FuncName.equals(NoBuiltinFuncs[i]))
44
103
      return true;
45
222M
  return false;
46
222M
}
47
48
154
VersionTuple LangOptions::getOpenCLVersionTuple() const {
49
154
  const int Ver = OpenCLCPlusPlus ? 
OpenCLCPlusPlusVersion42
:
OpenCLVersion112
;
50
154
  if (OpenCLCPlusPlus && 
Ver != 10042
)
51
34
    return VersionTuple(Ver / 100);
52
120
  return VersionTuple(Ver / 100, (Ver % 100) / 10);
53
154
}
54
55
363M
unsigned LangOptions::getOpenCLCompatibleVersion() const {
56
363M
  if (!OpenCLCPlusPlus)
57
363M
    return OpenCLVersion;
58
601k
  if (OpenCLCPlusPlusVersion == 100)
59
355k
    return 200;
60
246k
  if (OpenCLCPlusPlusVersion == 202100)
61
246k
    return 300;
62
18.4E
  llvm_unreachable("Unknown OpenCL version");
63
18.4E
}
64
65
503
void LangOptions::remapPathPrefix(SmallString<256> &Path) const {
66
503
  for (const auto &Entry : MacroPrefixMap)
67
41
    if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
68
13
      break;
69
503
}
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
726k
FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
82
726k
  FPOptions result(LO);
83
726k
  return result;
84
726k
}
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
}