Coverage Report

Created: 2020-10-24 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Driver/ToolChains/VEToolchain.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- VE.cpp - VE ToolChain Implementations ------------------*- C++ -*-===//
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
#include "VEToolchain.h"
10
#include "CommonArgs.h"
11
#include "clang/Driver/Compilation.h"
12
#include "clang/Driver/Driver.h"
13
#include "clang/Driver/Options.h"
14
#include "llvm/Option/ArgList.h"
15
#include "llvm/Support/FileSystem.h"
16
#include "llvm/Support/Path.h"
17
#include <cstdlib> // ::getenv
18
19
using namespace clang::driver;
20
using namespace clang::driver::toolchains;
21
using namespace clang;
22
using namespace llvm::opt;
23
24
/// VE tool chain
25
VEToolChain::VEToolChain(const Driver &D, const llvm::Triple &Triple,
26
                         const ArgList &Args)
27
0
    : Linux(D, Triple, Args) {
28
0
  getProgramPaths().push_back("/opt/nec/ve/bin");
29
  // ProgramPaths are found via 'PATH' environment variable.
30
31
  // default file paths are:
32
  //   ${RESOURCEDIR}/lib/linux/ve (== getArchSpecificLibPath)
33
  //   /lib/../lib64
34
  //   /usr/lib/../lib64
35
  //   ${BINPATH}/../lib
36
  //   /lib
37
  //   /usr/lib
38
  //
39
  // These are OK for host, but no go for VE.  So, defines them all
40
  // from scratch here.
41
0
  getFilePaths().clear();
42
0
  getFilePaths().push_back(getArchSpecificLibPath());
43
0
  getFilePaths().push_back(computeSysRoot() + "/opt/nec/ve/lib");
44
0
}
45
46
0
Tool *VEToolChain::buildAssembler() const {
47
0
  return new tools::gnutools::Assembler(*this);
48
0
}
49
50
0
Tool *VEToolChain::buildLinker() const {
51
0
  return new tools::gnutools::Linker(*this);
52
0
}
53
54
0
bool VEToolChain::isPICDefault() const { return false; }
55
56
0
bool VEToolChain::isPIEDefault() const { return false; }
57
58
0
bool VEToolChain::isPICDefaultForced() const { return false; }
59
60
0
bool VEToolChain::SupportsProfiling() const { return false; }
61
62
0
bool VEToolChain::hasBlocksRuntime() const { return false; }
63
64
void VEToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
65
0
                                            ArgStringList &CC1Args) const {
66
0
  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
67
0
    return;
68
69
0
  if (DriverArgs.hasArg(options::OPT_nobuiltininc) &&
70
0
      DriverArgs.hasArg(options::OPT_nostdlibinc))
71
0
    return;
72
73
0
  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
74
0
    SmallString<128> P(getDriver().ResourceDir);
75
0
    llvm::sys::path::append(P, "include");
76
0
    addSystemInclude(DriverArgs, CC1Args, P);
77
0
  }
78
79
0
  if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
80
0
    if (const char *cl_include_dir = getenv("NCC_C_INCLUDE_PATH")) {
81
0
      SmallVector<StringRef, 4> Dirs;
82
0
      const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
83
0
      StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
84
0
      ArrayRef<StringRef> DirVec(Dirs);
85
0
      addSystemIncludes(DriverArgs, CC1Args, DirVec);
86
0
    } else {
87
0
      addSystemInclude(DriverArgs, CC1Args,
88
0
                       getDriver().SysRoot + "/opt/nec/ve/include");
89
0
    }
90
0
  }
91
0
}
92
93
void VEToolChain::addClangTargetOptions(const ArgList &DriverArgs,
94
                                        ArgStringList &CC1Args,
95
0
                                        Action::OffloadKind) const {
96
0
  CC1Args.push_back("-nostdsysteminc");
97
0
  bool UseInitArrayDefault = true;
98
0
  if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
99
0
                          options::OPT_fno_use_init_array, UseInitArrayDefault))
100
0
    CC1Args.push_back("-fno-use-init-array");
101
0
}
102
103
void VEToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
104
0
                                               ArgStringList &CC1Args) const {
105
  // TODO upstream VE libc++ patches
106
0
  llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
107
0
}
108
109
void VEToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
110
0
                                      ArgStringList &CmdArgs) const {
111
  // TODO upstream VE libc++ patches
112
0
  llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
113
0
}
114
115
llvm::ExceptionHandling
116
0
VEToolChain::GetExceptionModel(const ArgList &Args) const {
117
  // VE uses SjLj exceptions.
118
0
  return llvm::ExceptionHandling::SjLj;
119
0
}