forked from OSchip/llvm-project
[Driver] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 328044
This commit is contained in:
parent
0f110a88be
commit
5e4511cfc7
|
@ -1,4 +1,4 @@
|
|||
//===--- Action.h - Abstract compilation steps ------------------*- C++ -*-===//
|
||||
//===- Action.h - Abstract compilation steps --------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -10,20 +10,23 @@
|
|||
#ifndef LLVM_CLANG_DRIVER_ACTION_H
|
||||
#define LLVM_CLANG_DRIVER_ACTION_H
|
||||
|
||||
#include "clang/Basic/Cuda.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Driver/Types.h"
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class StringRef;
|
||||
|
||||
namespace opt {
|
||||
class Arg;
|
||||
}
|
||||
}
|
||||
|
||||
class Arg;
|
||||
|
||||
} // namespace opt
|
||||
} // namespace llvm
|
||||
|
||||
namespace clang {
|
||||
namespace driver {
|
||||
|
@ -44,11 +47,11 @@ class ToolChain;
|
|||
/// actions via MakeAction().
|
||||
class Action {
|
||||
public:
|
||||
typedef ActionList::size_type size_type;
|
||||
typedef ActionList::iterator input_iterator;
|
||||
typedef ActionList::const_iterator input_const_iterator;
|
||||
typedef llvm::iterator_range<input_iterator> input_range;
|
||||
typedef llvm::iterator_range<input_const_iterator> input_const_range;
|
||||
using size_type = ActionList::size_type;
|
||||
using input_iterator = ActionList::iterator;
|
||||
using input_const_iterator = ActionList::const_iterator;
|
||||
using input_range = llvm::iterator_range<input_iterator>;
|
||||
using input_const_range = llvm::iterator_range<input_const_iterator>;
|
||||
|
||||
enum ActionClass {
|
||||
InputClass = 0,
|
||||
|
@ -78,8 +81,10 @@ public:
|
|||
// to designate the host offloading tool chain.
|
||||
enum OffloadKind {
|
||||
OFK_None = 0x00,
|
||||
|
||||
// The host offloading tool chain.
|
||||
OFK_Host = 0x01,
|
||||
|
||||
// The device offloading tool chains - one bit for each programming model.
|
||||
OFK_Cuda = 0x02,
|
||||
OFK_OpenMP = 0x04,
|
||||
|
@ -110,8 +115,10 @@ protected:
|
|||
/// Multiple programming models may be supported simultaneously by the same
|
||||
/// host.
|
||||
unsigned ActiveOffloadKindMask = 0u;
|
||||
|
||||
/// Offloading kind of the device.
|
||||
OffloadKind OffloadingDeviceKind = OFK_None;
|
||||
|
||||
/// The Offloading architecture associated with this action.
|
||||
const char *OffloadingArch = nullptr;
|
||||
|
||||
|
@ -149,6 +156,7 @@ public:
|
|||
void setCannotBeCollapsedWithNextDependentAction() {
|
||||
CanBeCollapsedWithNextDependentAction = false;
|
||||
}
|
||||
|
||||
/// Return true if this function can be collapsed with others.
|
||||
bool isCollapsingWithNextDependentActionLegal() const {
|
||||
return CanBeCollapsedWithNextDependentAction;
|
||||
|
@ -156,22 +164,26 @@ public:
|
|||
|
||||
/// Return a string containing the offload kind of the action.
|
||||
std::string getOffloadingKindPrefix() const;
|
||||
|
||||
/// Return a string that can be used as prefix in order to generate unique
|
||||
/// files for each offloading kind. By default, no prefix is used for
|
||||
/// non-device kinds, except if \a CreatePrefixForHost is set.
|
||||
static std::string
|
||||
GetOffloadingFileNamePrefix(OffloadKind Kind,
|
||||
llvm::StringRef NormalizedTriple,
|
||||
StringRef NormalizedTriple,
|
||||
bool CreatePrefixForHost = false);
|
||||
|
||||
/// Return a string containing a offload kind name.
|
||||
static StringRef GetOffloadKindName(OffloadKind Kind);
|
||||
|
||||
/// Set the device offload info of this action and propagate it to its
|
||||
/// dependences.
|
||||
void propagateDeviceOffloadInfo(OffloadKind OKind, const char *OArch);
|
||||
|
||||
/// Append the host offload info of this action and propagate it to its
|
||||
/// dependences.
|
||||
void propagateHostOffloadInfo(unsigned OKinds, const char *OArch);
|
||||
|
||||
/// Set the offload info of this action to be the same as the provided action,
|
||||
/// and propagate it to its dependences.
|
||||
void propagateOffloadInfo(const Action *A);
|
||||
|
@ -179,6 +191,7 @@ public:
|
|||
unsigned getOffloadingHostActiveKinds() const {
|
||||
return ActiveOffloadKindMask;
|
||||
}
|
||||
|
||||
OffloadKind getOffloadingDeviceKind() const { return OffloadingDeviceKind; }
|
||||
const char *getOffloadingArch() const { return OffloadingArch; }
|
||||
|
||||
|
@ -196,9 +209,10 @@ public:
|
|||
};
|
||||
|
||||
class InputAction : public Action {
|
||||
virtual void anchor();
|
||||
const llvm::opt::Arg &Input;
|
||||
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
InputAction(const llvm::opt::Arg &Input, types::ID Type);
|
||||
|
||||
|
@ -211,6 +225,7 @@ public:
|
|||
|
||||
class BindArchAction : public Action {
|
||||
virtual void anchor();
|
||||
|
||||
/// The architecture to bind, or 0 if the default architecture
|
||||
/// should be bound.
|
||||
StringRef ArchName;
|
||||
|
@ -236,9 +251,9 @@ public:
|
|||
/// toolchain, and offload kind to each action.
|
||||
class DeviceDependences final {
|
||||
public:
|
||||
typedef SmallVector<const ToolChain *, 3> ToolChainList;
|
||||
typedef SmallVector<const char *, 3> BoundArchList;
|
||||
typedef SmallVector<OffloadKind, 3> OffloadKindList;
|
||||
using ToolChainList = SmallVector<const ToolChain *, 3>;
|
||||
using BoundArchList = SmallVector<const char *, 3>;
|
||||
using OffloadKindList = SmallVector<OffloadKind, 3>;
|
||||
|
||||
private:
|
||||
// Lists that keep the information for each dependency. All the lists are
|
||||
|
@ -248,10 +263,13 @@ public:
|
|||
|
||||
/// The dependence actions.
|
||||
ActionList DeviceActions;
|
||||
|
||||
/// The offloading toolchains that should be used with the action.
|
||||
ToolChainList DeviceToolChains;
|
||||
|
||||
/// The architectures that should be used with this action.
|
||||
BoundArchList DeviceBoundArchs;
|
||||
|
||||
/// The offload kind of each dependence.
|
||||
OffloadKindList DeviceOffloadKinds;
|
||||
|
||||
|
@ -262,12 +280,12 @@ public:
|
|||
OffloadKind OKind);
|
||||
|
||||
/// Get each of the individual arrays.
|
||||
const ActionList &getActions() const { return DeviceActions; };
|
||||
const ToolChainList &getToolChains() const { return DeviceToolChains; };
|
||||
const BoundArchList &getBoundArchs() const { return DeviceBoundArchs; };
|
||||
const ActionList &getActions() const { return DeviceActions; }
|
||||
const ToolChainList &getToolChains() const { return DeviceToolChains; }
|
||||
const BoundArchList &getBoundArchs() const { return DeviceBoundArchs; }
|
||||
const OffloadKindList &getOffloadKinds() const {
|
||||
return DeviceOffloadKinds;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// Type used to communicate host actions. It associates bound architecture,
|
||||
|
@ -275,10 +293,13 @@ public:
|
|||
class HostDependence final {
|
||||
/// The dependence action.
|
||||
Action &HostAction;
|
||||
|
||||
/// The offloading toolchain that should be used with the action.
|
||||
const ToolChain &HostToolChain;
|
||||
|
||||
/// The architectures that should be used with this action.
|
||||
const char *HostBoundArch = nullptr;
|
||||
|
||||
/// The offload kind of each dependence.
|
||||
unsigned HostOffloadKinds = 0u;
|
||||
|
||||
|
@ -286,19 +307,20 @@ public:
|
|||
HostDependence(Action &A, const ToolChain &TC, const char *BoundArch,
|
||||
const unsigned OffloadKinds)
|
||||
: HostAction(A), HostToolChain(TC), HostBoundArch(BoundArch),
|
||||
HostOffloadKinds(OffloadKinds){};
|
||||
HostOffloadKinds(OffloadKinds) {}
|
||||
|
||||
/// Constructor version that obtains the offload kinds from the device
|
||||
/// dependencies.
|
||||
HostDependence(Action &A, const ToolChain &TC, const char *BoundArch,
|
||||
const DeviceDependences &DDeps);
|
||||
Action *getAction() const { return &HostAction; };
|
||||
const ToolChain *getToolChain() const { return &HostToolChain; };
|
||||
const char *getBoundArch() const { return HostBoundArch; };
|
||||
unsigned getOffloadKinds() const { return HostOffloadKinds; };
|
||||
Action *getAction() const { return &HostAction; }
|
||||
const ToolChain *getToolChain() const { return &HostToolChain; }
|
||||
const char *getBoundArch() const { return HostBoundArch; }
|
||||
unsigned getOffloadKinds() const { return HostOffloadKinds; }
|
||||
};
|
||||
|
||||
typedef llvm::function_ref<void(Action *, const ToolChain *, const char *)>
|
||||
OffloadActionWorkTy;
|
||||
using OffloadActionWorkTy =
|
||||
llvm::function_ref<void(Action *, const ToolChain *, const char *)>;
|
||||
|
||||
private:
|
||||
/// The host offloading toolchain that should be used with the action.
|
||||
|
@ -349,6 +371,7 @@ public:
|
|||
|
||||
class JobAction : public Action {
|
||||
virtual void anchor();
|
||||
|
||||
protected:
|
||||
JobAction(ActionClass Kind, Action *Input, types::ID Type);
|
||||
JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
|
||||
|
@ -362,6 +385,7 @@ public:
|
|||
|
||||
class PreprocessJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
PreprocessJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -372,6 +396,7 @@ public:
|
|||
|
||||
class PrecompileJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
PrecompileJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -382,6 +407,7 @@ public:
|
|||
|
||||
class AnalyzeJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
AnalyzeJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -392,6 +418,7 @@ public:
|
|||
|
||||
class MigrateJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
MigrateJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -402,6 +429,7 @@ public:
|
|||
|
||||
class CompileJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
CompileJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -412,6 +440,7 @@ public:
|
|||
|
||||
class BackendJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
BackendJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -422,6 +451,7 @@ public:
|
|||
|
||||
class AssembleJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
AssembleJobAction(Action *Input, types::ID OutputType);
|
||||
|
||||
|
@ -432,6 +462,7 @@ public:
|
|||
|
||||
class LinkJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
LinkJobAction(ActionList &Inputs, types::ID Type);
|
||||
|
||||
|
@ -442,6 +473,7 @@ public:
|
|||
|
||||
class LipoJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
LipoJobAction(ActionList &Inputs, types::ID Type);
|
||||
|
||||
|
@ -452,6 +484,7 @@ public:
|
|||
|
||||
class DsymutilJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
DsymutilJobAction(ActionList &Inputs, types::ID Type);
|
||||
|
||||
|
@ -462,8 +495,10 @@ public:
|
|||
|
||||
class VerifyJobAction : public JobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
VerifyJobAction(ActionClass Kind, Action *Input, types::ID Type);
|
||||
|
||||
static bool classof(const Action *A) {
|
||||
return A->getKind() == VerifyDebugInfoJobClass ||
|
||||
A->getKind() == VerifyPCHJobClass;
|
||||
|
@ -472,8 +507,10 @@ public:
|
|||
|
||||
class VerifyDebugInfoJobAction : public VerifyJobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
VerifyDebugInfoJobAction(Action *Input, types::ID Type);
|
||||
|
||||
static bool classof(const Action *A) {
|
||||
return A->getKind() == VerifyDebugInfoJobClass;
|
||||
}
|
||||
|
@ -481,8 +518,10 @@ public:
|
|||
|
||||
class VerifyPCHJobAction : public VerifyJobAction {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
VerifyPCHJobAction(Action *Input, types::ID Type);
|
||||
|
||||
static bool classof(const Action *A) {
|
||||
return A->getKind() == VerifyPCHJobClass;
|
||||
}
|
||||
|
@ -509,16 +548,19 @@ public:
|
|||
struct DependentActionInfo final {
|
||||
/// \brief The tool chain of the dependent action.
|
||||
const ToolChain *DependentToolChain = nullptr;
|
||||
|
||||
/// \brief The bound architecture of the dependent action.
|
||||
StringRef DependentBoundArch;
|
||||
|
||||
/// \brief The offload kind of the dependent action.
|
||||
const OffloadKind DependentOffloadKind = OFK_None;
|
||||
|
||||
DependentActionInfo(const ToolChain *DependentToolChain,
|
||||
StringRef DependentBoundArch,
|
||||
const OffloadKind DependentOffloadKind)
|
||||
: DependentToolChain(DependentToolChain),
|
||||
DependentBoundArch(DependentBoundArch),
|
||||
DependentOffloadKind(DependentOffloadKind){};
|
||||
DependentOffloadKind(DependentOffloadKind) {}
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -546,7 +588,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
} // end namespace clang
|
||||
} // namespace driver
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_DRIVER_ACTION_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Compilation.h - Compilation Task Data Structure --------*- C++ -*-===//
|
||||
//===- Compilation.h - Compilation Task Data Structure ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -10,24 +10,36 @@
|
|||
#ifndef LLVM_CLANG_DRIVER_COMPILATION_H
|
||||
#define LLVM_CLANG_DRIVER_COMPILATION_H
|
||||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Driver/Action.h"
|
||||
#include "clang/Driver/Job.h"
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
namespace opt {
|
||||
class DerivedArgList;
|
||||
class InputArgList;
|
||||
}
|
||||
}
|
||||
|
||||
class DerivedArgList;
|
||||
class InputArgList;
|
||||
|
||||
} // namespace opt
|
||||
} // namespace llvm
|
||||
|
||||
namespace clang {
|
||||
namespace driver {
|
||||
class Driver;
|
||||
class JobList;
|
||||
class ToolChain;
|
||||
|
||||
class Driver;
|
||||
class ToolChain;
|
||||
|
||||
/// Compilation - A set of tasks to perform for a single driver
|
||||
/// invocation.
|
||||
|
@ -40,7 +52,7 @@ class Compilation {
|
|||
|
||||
/// A mask of all the programming models the host has to support in the
|
||||
/// current compilation.
|
||||
unsigned ActiveOffloadMask;
|
||||
unsigned ActiveOffloadMask = 0;
|
||||
|
||||
/// Array with the toolchains of offloading host and devices in the order they
|
||||
/// were requested by the user. We are preserving that order in case the code
|
||||
|
@ -73,6 +85,11 @@ class Compilation {
|
|||
const ToolChain *TC = nullptr;
|
||||
StringRef BoundArch;
|
||||
Action::OffloadKind DeviceOffloadKind = Action::OFK_None;
|
||||
|
||||
TCArgsKey(const ToolChain *TC, StringRef BoundArch,
|
||||
Action::OffloadKind DeviceOffloadKind)
|
||||
: TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
|
||||
|
||||
bool operator<(const TCArgsKey &K) const {
|
||||
if (TC < K.TC)
|
||||
return true;
|
||||
|
@ -83,9 +100,6 @@ class Compilation {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
TCArgsKey(const ToolChain *TC, StringRef BoundArch,
|
||||
Action::OffloadKind DeviceOffloadKind)
|
||||
: TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
|
||||
};
|
||||
std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;
|
||||
|
||||
|
@ -103,7 +117,7 @@ class Compilation {
|
|||
std::vector<Optional<StringRef>> Redirects;
|
||||
|
||||
/// Whether we're compiling for diagnostic purposes.
|
||||
bool ForDiagnostics;
|
||||
bool ForDiagnostics = false;
|
||||
|
||||
/// Whether an error during the parsing of the input args.
|
||||
bool ContainsError;
|
||||
|
@ -123,12 +137,12 @@ public:
|
|||
}
|
||||
|
||||
/// Iterator that visits device toolchains of a given kind.
|
||||
typedef const std::multimap<Action::OffloadKind,
|
||||
const ToolChain *>::const_iterator
|
||||
const_offload_toolchains_iterator;
|
||||
typedef std::pair<const_offload_toolchains_iterator,
|
||||
const_offload_toolchains_iterator>
|
||||
const_offload_toolchains_range;
|
||||
using const_offload_toolchains_iterator =
|
||||
const std::multimap<Action::OffloadKind,
|
||||
const ToolChain *>::const_iterator;
|
||||
using const_offload_toolchains_range =
|
||||
std::pair<const_offload_toolchains_iterator,
|
||||
const_offload_toolchains_iterator>;
|
||||
|
||||
template <Action::OffloadKind Kind>
|
||||
const_offload_toolchains_range getOffloadToolChains() const {
|
||||
|
@ -289,7 +303,7 @@ public:
|
|||
void Redirect(ArrayRef<Optional<StringRef>> Redirects);
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
} // end namespace clang
|
||||
} // namespace driver
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_DRIVER_COMPILATION_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===//
|
||||
//===- Job.h - Commands to Execute ------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -12,21 +12,22 @@
|
|||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include <memory>
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
}
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
namespace driver {
|
||||
|
||||
class Action;
|
||||
class Command;
|
||||
class Tool;
|
||||
class InputInfo;
|
||||
class Tool;
|
||||
|
||||
// Re-export this as clang::driver::ArgStringList.
|
||||
using llvm::opt::ArgStringList;
|
||||
|
@ -60,7 +61,7 @@ class Command {
|
|||
|
||||
/// Response file name, if this command is set to use one, or nullptr
|
||||
/// otherwise
|
||||
const char *ResponseFile;
|
||||
const char *ResponseFile = nullptr;
|
||||
|
||||
/// The input file list in case we need to emit a file list instead of a
|
||||
/// proper response file
|
||||
|
@ -92,7 +93,7 @@ public:
|
|||
// FIXME: This really shouldn't be copyable, but is currently copied in some
|
||||
// error handling in Driver::generateCompilationDiagnostics.
|
||||
Command(const Command &) = default;
|
||||
virtual ~Command() {}
|
||||
virtual ~Command() = default;
|
||||
|
||||
virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
|
||||
CrashReportInfo *CrashInfo = nullptr) const;
|
||||
|
@ -165,10 +166,10 @@ public:
|
|||
/// JobList - A sequence of jobs to perform.
|
||||
class JobList {
|
||||
public:
|
||||
typedef SmallVector<std::unique_ptr<Command>, 4> list_type;
|
||||
typedef list_type::size_type size_type;
|
||||
typedef llvm::pointee_iterator<list_type::iterator> iterator;
|
||||
typedef llvm::pointee_iterator<list_type::const_iterator> const_iterator;
|
||||
using list_type = SmallVector<std::unique_ptr<Command>, 4>;
|
||||
using size_type = list_type::size_type;
|
||||
using iterator = llvm::pointee_iterator<list_type::iterator>;
|
||||
using const_iterator = llvm::pointee_iterator<list_type::const_iterator>;
|
||||
|
||||
private:
|
||||
list_type Jobs;
|
||||
|
@ -193,7 +194,7 @@ public:
|
|||
const_iterator end() const { return Jobs.end(); }
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
} // end namespace clang
|
||||
} // namespace driver
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_DRIVER_JOB_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Multilib.h ---------------------------------------------*- C++ -*-===//
|
||||
//===- Multilib.h -----------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,10 +11,14 @@
|
|||
#define LLVM_CLANG_DRIVER_MULTILIB_H
|
||||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
|
@ -24,7 +28,7 @@ namespace driver {
|
|||
/// by a command line flag
|
||||
class Multilib {
|
||||
public:
|
||||
typedef std::vector<std::string> flags_list;
|
||||
using flags_list = std::vector<std::string>;
|
||||
|
||||
private:
|
||||
std::string GCCSuffix;
|
||||
|
@ -33,8 +37,8 @@ private:
|
|||
flags_list Flags;
|
||||
|
||||
public:
|
||||
Multilib(StringRef GCCSuffix = "", StringRef OSSuffix = "",
|
||||
StringRef IncludeSuffix = "");
|
||||
Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
|
||||
StringRef IncludeSuffix = {});
|
||||
|
||||
/// \brief Get the detected GCC installation path suffix for the multi-arch
|
||||
/// target variant. Always starts with a '/', unless empty
|
||||
|
@ -43,6 +47,7 @@ public:
|
|||
(StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
|
||||
return GCCSuffix;
|
||||
}
|
||||
|
||||
/// Set the GCC installation path suffix.
|
||||
Multilib &gccSuffix(StringRef S);
|
||||
|
||||
|
@ -53,6 +58,7 @@ public:
|
|||
(StringRef(OSSuffix).front() == '/' && OSSuffix.size() > 1));
|
||||
return OSSuffix;
|
||||
}
|
||||
|
||||
/// Set the os path suffix.
|
||||
Multilib &osSuffix(StringRef S);
|
||||
|
||||
|
@ -63,6 +69,7 @@ public:
|
|||
(StringRef(IncludeSuffix).front() == '/' && IncludeSuffix.size() > 1));
|
||||
return IncludeSuffix;
|
||||
}
|
||||
|
||||
/// Set the include directory suffix
|
||||
Multilib &includeSuffix(StringRef S);
|
||||
|
||||
|
@ -102,14 +109,12 @@ raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);
|
|||
|
||||
class MultilibSet {
|
||||
public:
|
||||
typedef std::vector<Multilib> multilib_list;
|
||||
typedef multilib_list::iterator iterator;
|
||||
typedef multilib_list::const_iterator const_iterator;
|
||||
|
||||
typedef std::function<std::vector<std::string>(const Multilib &M)>
|
||||
IncludeDirsFunc;
|
||||
|
||||
typedef llvm::function_ref<bool(const Multilib &)> FilterCallback;
|
||||
using multilib_list = std::vector<Multilib>;
|
||||
using iterator = multilib_list::iterator;
|
||||
using const_iterator = multilib_list::const_iterator;
|
||||
using IncludeDirsFunc =
|
||||
std::function<std::vector<std::string>(const Multilib &M)>;
|
||||
using FilterCallback = llvm::function_ref<bool(const Multilib &)>;
|
||||
|
||||
private:
|
||||
multilib_list Multilibs;
|
||||
|
@ -117,7 +122,7 @@ private:
|
|||
IncludeDirsFunc FilePathsCallback;
|
||||
|
||||
public:
|
||||
MultilibSet() {}
|
||||
MultilibSet() = default;
|
||||
|
||||
/// Add an optional Multilib segment
|
||||
MultilibSet &Maybe(const Multilib &M);
|
||||
|
@ -135,6 +140,7 @@ public:
|
|||
|
||||
/// Filter out some subset of the Multilibs using a user defined callback
|
||||
MultilibSet &FilterOut(FilterCallback F);
|
||||
|
||||
/// Filter out those Multilibs whose gccSuffix matches the given expression
|
||||
MultilibSet &FilterOut(const char *Regex);
|
||||
|
||||
|
@ -165,12 +171,14 @@ public:
|
|||
IncludeCallback = std::move(F);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const IncludeDirsFunc &includeDirsCallback() const { return IncludeCallback; }
|
||||
|
||||
MultilibSet &setFilePathsCallback(IncludeDirsFunc F) {
|
||||
FilePathsCallback = std::move(F);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const IncludeDirsFunc &filePathsCallback() const { return FilePathsCallback; }
|
||||
|
||||
private:
|
||||
|
@ -182,8 +190,8 @@ private:
|
|||
};
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, const MultilibSet &MS);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace driver
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_DRIVER_MULTILIB_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
|
||||
//===- ToolChain.h - Collections of tools for one platform ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -10,59 +10,70 @@
|
|||
#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
|
||||
#define LLVM_CLANG_DRIVER_TOOLCHAIN_H
|
||||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/Sanitizers.h"
|
||||
#include "clang/Basic/VersionTuple.h"
|
||||
#include "clang/Driver/Action.h"
|
||||
#include "clang/Driver/Multilib.h"
|
||||
#include "clang/Driver/Types.h"
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/MC/MCTargetOptions.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
namespace opt {
|
||||
class ArgList;
|
||||
class DerivedArgList;
|
||||
class InputArgList;
|
||||
}
|
||||
}
|
||||
|
||||
class Arg;
|
||||
class ArgList;
|
||||
class DerivedArgList;
|
||||
|
||||
} // namespace opt
|
||||
} // namespace llvm
|
||||
|
||||
namespace clang {
|
||||
|
||||
class ObjCRuntime;
|
||||
|
||||
namespace vfs {
|
||||
|
||||
class FileSystem;
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
|
||||
namespace driver {
|
||||
class Compilation;
|
||||
class CudaInstallationDetector;
|
||||
class Driver;
|
||||
class InputInfo;
|
||||
class JobAction;
|
||||
class RegisterEffectiveTriple;
|
||||
class SanitizerArgs;
|
||||
class Tool;
|
||||
class XRayArgs;
|
||||
|
||||
class Driver;
|
||||
class InputInfo;
|
||||
class SanitizerArgs;
|
||||
class Tool;
|
||||
class XRayArgs;
|
||||
|
||||
/// Helper structure used to pass information extracted from clang executable
|
||||
/// name such as `i686-linux-android-g++`.
|
||||
///
|
||||
struct ParsedClangName {
|
||||
/// Target part of the executable name, as `i686-linux-android`.
|
||||
std::string TargetPrefix;
|
||||
|
||||
/// Driver mode part of the executable name, as `g++`.
|
||||
std::string ModeSuffix;
|
||||
/// Corresponding driver mode argument, as '--driver-mode=g++'
|
||||
const char *DriverMode;
|
||||
/// True if TargetPrefix is recognized as a registered target name.
|
||||
bool TargetIsValid;
|
||||
|
||||
ParsedClangName() : DriverMode(nullptr), TargetIsValid(false) {}
|
||||
/// Corresponding driver mode argument, as '--driver-mode=g++'
|
||||
const char *DriverMode = nullptr;
|
||||
|
||||
/// True if TargetPrefix is recognized as a registered target name.
|
||||
bool TargetIsValid = false;
|
||||
|
||||
ParsedClangName() = default;
|
||||
ParsedClangName(std::string Suffix, const char *Mode)
|
||||
: ModeSuffix(Suffix), DriverMode(Mode), TargetIsValid(false) {}
|
||||
: ModeSuffix(Suffix), DriverMode(Mode) {}
|
||||
ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
|
||||
bool IsRegistered)
|
||||
: TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
|
||||
|
@ -72,7 +83,7 @@ struct ParsedClangName {
|
|||
/// ToolChain - Access to tools for a single platform.
|
||||
class ToolChain {
|
||||
public:
|
||||
typedef SmallVector<std::string, 16> path_list;
|
||||
using path_list = SmallVector<std::string, 16>;
|
||||
|
||||
enum CXXStdlibType {
|
||||
CST_Libcxx,
|
||||
|
@ -92,25 +103,28 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
friend class RegisterEffectiveTriple;
|
||||
|
||||
const Driver &D;
|
||||
llvm::Triple Triple;
|
||||
const llvm::opt::ArgList &Args;
|
||||
|
||||
// We need to initialize CachedRTTIArg before CachedRTTIMode
|
||||
const llvm::opt::Arg *const CachedRTTIArg;
|
||||
|
||||
const RTTIMode CachedRTTIMode;
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for
|
||||
/// files.
|
||||
/// The list of toolchain specific path prefixes to search for files.
|
||||
path_list FilePaths;
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for
|
||||
/// programs.
|
||||
/// The list of toolchain specific path prefixes to search for programs.
|
||||
path_list ProgramPaths;
|
||||
|
||||
mutable std::unique_ptr<Tool> Clang;
|
||||
mutable std::unique_ptr<Tool> Assemble;
|
||||
mutable std::unique_ptr<Tool> Link;
|
||||
mutable std::unique_ptr<Tool> OffloadBundler;
|
||||
|
||||
Tool *getClang() const;
|
||||
Tool *getAssemble() const;
|
||||
Tool *getLink() const;
|
||||
|
@ -128,8 +142,6 @@ private:
|
|||
EffectiveTriple = std::move(ET);
|
||||
}
|
||||
|
||||
friend class RegisterEffectiveTriple;
|
||||
|
||||
protected:
|
||||
MultilibSet Multilibs;
|
||||
|
||||
|
@ -231,7 +243,6 @@ public:
|
|||
/// e.g., argv[0]).
|
||||
/// \return A structure of type ParsedClangName that contains the executable
|
||||
/// name parts.
|
||||
///
|
||||
static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
|
||||
|
||||
// Tool access.
|
||||
|
@ -328,9 +339,7 @@ public:
|
|||
}
|
||||
|
||||
/// GetDefaultLinker - Get the default linker to use.
|
||||
virtual const char *getDefaultLinker() const {
|
||||
return "ld";
|
||||
}
|
||||
virtual const char *getDefaultLinker() const { return "ld"; }
|
||||
|
||||
/// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
|
||||
virtual RuntimeLibType GetDefaultRuntimeLibType() const {
|
||||
|
@ -407,9 +416,7 @@ public:
|
|||
GetExceptionModel(const llvm::opt::ArgList &Args) const;
|
||||
|
||||
/// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
|
||||
virtual bool SupportsEmbeddedBitcode() const {
|
||||
return false;
|
||||
}
|
||||
virtual bool SupportsEmbeddedBitcode() const { return false; }
|
||||
|
||||
/// getThreadModel() - Which thread model does this target use?
|
||||
virtual std::string getThreadModel() const { return "posix"; }
|
||||
|
@ -500,6 +507,7 @@ public:
|
|||
/// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
|
||||
virtual bool AddFastMathRuntimeIfAvailable(
|
||||
const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
|
||||
|
||||
/// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
|
||||
/// a suitable profile runtime library to the linker.
|
||||
virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
|
||||
|
@ -537,7 +545,8 @@ public:
|
|||
~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
} // end namespace clang
|
||||
} // namespace driver
|
||||
|
||||
#endif
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Action.cpp - Abstract compilation steps --------------------------===//
|
||||
//===- Action.cpp - Abstract compilation steps ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -8,16 +8,15 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Driver/Action.h"
|
||||
#include "clang/Driver/ToolChain.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Regex.h"
|
||||
#include <cassert>
|
||||
using namespace clang::driver;
|
||||
#include <string>
|
||||
|
||||
using namespace clang;
|
||||
using namespace driver;
|
||||
using namespace llvm::opt;
|
||||
|
||||
Action::~Action() {}
|
||||
Action::~Action() = default;
|
||||
|
||||
const char *Action::getClassName(ActionClass AC) {
|
||||
switch (AC) {
|
||||
|
@ -102,7 +101,7 @@ std::string Action::getOffloadingKindPrefix() const {
|
|||
}
|
||||
|
||||
if (!ActiveOffloadKindMask)
|
||||
return "";
|
||||
return {};
|
||||
|
||||
std::string Res("host");
|
||||
if (ActiveOffloadKindMask & OFK_Cuda)
|
||||
|
@ -119,11 +118,11 @@ std::string Action::getOffloadingKindPrefix() const {
|
|||
/// for each offloading kind.
|
||||
std::string
|
||||
Action::GetOffloadingFileNamePrefix(OffloadKind Kind,
|
||||
llvm::StringRef NormalizedTriple,
|
||||
StringRef NormalizedTriple,
|
||||
bool CreatePrefixForHost) {
|
||||
// Don't generate prefix for host actions unless required.
|
||||
if (!CreatePrefixForHost && (Kind == OFK_None || Kind == OFK_Host))
|
||||
return "";
|
||||
return {};
|
||||
|
||||
std::string Res("-");
|
||||
Res += GetOffloadKindName(Kind);
|
||||
|
@ -134,7 +133,7 @@ Action::GetOffloadingFileNamePrefix(OffloadKind Kind,
|
|||
|
||||
/// Return a string with the offload kind name. If that is not defined, we
|
||||
/// assume 'host'.
|
||||
llvm::StringRef Action::GetOffloadKindName(OffloadKind Kind) {
|
||||
StringRef Action::GetOffloadKindName(OffloadKind Kind) {
|
||||
switch (Kind) {
|
||||
case OFK_None:
|
||||
case OFK_Host:
|
||||
|
@ -153,12 +152,11 @@ llvm::StringRef Action::GetOffloadKindName(OffloadKind Kind) {
|
|||
void InputAction::anchor() {}
|
||||
|
||||
InputAction::InputAction(const Arg &_Input, types::ID _Type)
|
||||
: Action(InputClass, _Type), Input(_Input) {
|
||||
}
|
||||
: Action(InputClass, _Type), Input(_Input) {}
|
||||
|
||||
void BindArchAction::anchor() {}
|
||||
|
||||
BindArchAction::BindArchAction(Action *Input, llvm::StringRef ArchName)
|
||||
BindArchAction::BindArchAction(Action *Input, StringRef ArchName)
|
||||
: Action(BindArchClass, Input), ArchName(ArchName) {}
|
||||
|
||||
void OffloadAction::anchor() {}
|
||||
|
@ -300,8 +298,7 @@ JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
|
|||
: Action(Kind, Input, Type) {}
|
||||
|
||||
JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
|
||||
: Action(Kind, Inputs, Type) {
|
||||
}
|
||||
: Action(Kind, Inputs, Type) {}
|
||||
|
||||
void PreprocessJobAction::anchor() {}
|
||||
|
||||
|
@ -341,20 +338,17 @@ AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
|
|||
void LinkJobAction::anchor() {}
|
||||
|
||||
LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
|
||||
: JobAction(LinkJobClass, Inputs, Type) {
|
||||
}
|
||||
: JobAction(LinkJobClass, Inputs, Type) {}
|
||||
|
||||
void LipoJobAction::anchor() {}
|
||||
|
||||
LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
|
||||
: JobAction(LipoJobClass, Inputs, Type) {
|
||||
}
|
||||
: JobAction(LipoJobClass, Inputs, Type) {}
|
||||
|
||||
void DsymutilJobAction::anchor() {}
|
||||
|
||||
DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
|
||||
: JobAction(DsymutilJobClass, Inputs, Type) {
|
||||
}
|
||||
: JobAction(DsymutilJobClass, Inputs, Type) {}
|
||||
|
||||
void VerifyJobAction::anchor() {}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Compilation.cpp - Compilation Task Implementation ----------------===//
|
||||
//===- Compilation.cpp - Compilation Task Implementation ------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -8,26 +8,37 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Driver/Compilation.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Driver/Action.h"
|
||||
#include "clang/Driver/Driver.h"
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/Job.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "clang/Driver/ToolChain.h"
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/OptSpecifier.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
using namespace clang::driver;
|
||||
using namespace clang;
|
||||
using namespace driver;
|
||||
using namespace llvm::opt;
|
||||
|
||||
Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
|
||||
InputArgList *_Args, DerivedArgList *_TranslatedArgs,
|
||||
bool ContainsError)
|
||||
: TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u),
|
||||
Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false),
|
||||
ContainsError(ContainsError) {
|
||||
: TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args),
|
||||
TranslatedArgs(_TranslatedArgs), ContainsError(ContainsError) {
|
||||
// The offloading host toolchain is the default toolchain.
|
||||
OrderedOffloadingToolchains.insert(
|
||||
std::make_pair(Action::OFK_Host, &DefaultToolChain));
|
||||
|
@ -74,9 +85,8 @@ Compilation::getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
|
|||
}
|
||||
|
||||
// Add allocated arguments to the final DAL.
|
||||
for (auto ArgPtr : AllocatedArgs) {
|
||||
for (auto ArgPtr : AllocatedArgs)
|
||||
Entry->AddSynthesizedArg(ArgPtr);
|
||||
}
|
||||
}
|
||||
|
||||
return *Entry;
|
||||
|
@ -105,7 +115,7 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
|
|||
// so we don't need to check again.
|
||||
|
||||
if (IssueErrors)
|
||||
getDriver().Diag(clang::diag::err_drv_unable_to_remove_file)
|
||||
getDriver().Diag(diag::err_drv_unable_to_remove_file)
|
||||
<< EC.message();
|
||||
return false;
|
||||
}
|
||||
|
@ -115,9 +125,8 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
|
|||
bool Compilation::CleanupFileList(const ArgStringList &Files,
|
||||
bool IssueErrors) const {
|
||||
bool Success = true;
|
||||
for (ArgStringList::const_iterator
|
||||
it = Files.begin(), ie = Files.end(); it != ie; ++it)
|
||||
Success &= CleanupFile(*it, IssueErrors);
|
||||
for (const auto &File: Files)
|
||||
Success &= CleanupFile(File, IssueErrors);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
@ -125,14 +134,12 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files,
|
|||
const JobAction *JA,
|
||||
bool IssueErrors) const {
|
||||
bool Success = true;
|
||||
for (ArgStringMap::const_iterator
|
||||
it = Files.begin(), ie = Files.end(); it != ie; ++it) {
|
||||
|
||||
for (const auto &File : Files) {
|
||||
// If specified, only delete the files associated with the JobAction.
|
||||
// Otherwise, delete all files in the map.
|
||||
if (JA && it->first != JA)
|
||||
if (JA && File.first != JA)
|
||||
continue;
|
||||
Success &= CleanupFile(it->second, IssueErrors);
|
||||
Success &= CleanupFile(File.second, IssueErrors);
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
@ -151,7 +158,7 @@ int Compilation::ExecuteCommand(const Command &C,
|
|||
llvm::sys::fs::F_Append |
|
||||
llvm::sys::fs::F_Text);
|
||||
if (EC) {
|
||||
getDriver().Diag(clang::diag::err_drv_cc_print_options_failure)
|
||||
getDriver().Diag(diag::err_drv_cc_print_options_failure)
|
||||
<< EC.message();
|
||||
FailingCommand = &C;
|
||||
delete OS;
|
||||
|
@ -173,7 +180,7 @@ int Compilation::ExecuteCommand(const Command &C,
|
|||
int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
|
||||
if (!Error.empty()) {
|
||||
assert(Res && "Error string set with 0 result code!");
|
||||
getDriver().Diag(clang::diag::err_drv_command_failure) << Error;
|
||||
getDriver().Diag(diag::err_drv_command_failure) << Error;
|
||||
}
|
||||
|
||||
if (Res)
|
||||
|
@ -186,7 +193,6 @@ using FailingCommandList = SmallVectorImpl<std::pair<int, const Command *>>;
|
|||
|
||||
static bool ActionFailed(const Action *A,
|
||||
const FailingCommandList &FailingCommands) {
|
||||
|
||||
if (FailingCommands.empty())
|
||||
return false;
|
||||
|
||||
|
@ -200,7 +206,7 @@ static bool ActionFailed(const Action *A,
|
|||
if (A == &(CI.second->getSource()))
|
||||
return true;
|
||||
|
||||
for (const Action *AI : A->inputs())
|
||||
for (const auto *AI : A->inputs())
|
||||
if (ActionFailed(AI, FailingCommands))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Job.cpp - Command to Execute -------------------------------------===//
|
||||
//===- Job.cpp - Command to Execute ---------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -9,14 +9,14 @@
|
|||
|
||||
#include "clang/Driver/Job.h"
|
||||
#include "InputInfo.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Driver/Driver.h"
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/Tool.h"
|
||||
#include "clang/Driver/ToolChain.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
@ -24,17 +24,21 @@
|
|||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/Program.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
using namespace clang::driver;
|
||||
using llvm::raw_ostream;
|
||||
using llvm::StringRef;
|
||||
using llvm::ArrayRef;
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
using namespace clang;
|
||||
using namespace driver;
|
||||
|
||||
Command::Command(const Action &Source, const Tool &Creator,
|
||||
const char *Executable, const ArgStringList &Arguments,
|
||||
ArrayRef<InputInfo> Inputs)
|
||||
: Source(Source), Creator(Creator), Executable(Executable),
|
||||
Arguments(Arguments), ResponseFile(nullptr) {
|
||||
Arguments(Arguments) {
|
||||
for (const auto &II : Inputs)
|
||||
if (II.isFilename())
|
||||
InputFilenames.push_back(II.getFilename());
|
||||
|
@ -67,7 +71,7 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
|
|||
.Cases("-iframework", "-include-pch", true)
|
||||
.Default(false);
|
||||
if (IsInclude)
|
||||
return HaveCrashVFS ? false : true;
|
||||
return !HaveCrashVFS;
|
||||
|
||||
// The remaining flags are treated as a single argument.
|
||||
|
||||
|
@ -86,7 +90,7 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
|
|||
StringRef FlagRef(Flag);
|
||||
IsInclude = FlagRef.startswith("-F") || FlagRef.startswith("-I");
|
||||
if (IsInclude)
|
||||
return HaveCrashVFS ? false : true;
|
||||
return !HaveCrashVFS;
|
||||
if (FlagRef.startswith("-fmodules-cache-path="))
|
||||
return true;
|
||||
|
||||
|
@ -104,7 +108,7 @@ void Command::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
|
|||
|
||||
// Quote and escape. This isn't really complete, but good enough.
|
||||
OS << '"';
|
||||
for (const char c : Arg) {
|
||||
for (const auto c : Arg) {
|
||||
if (c == '"' || c == '\\' || c == '$')
|
||||
OS << '\\';
|
||||
OS << c;
|
||||
|
@ -115,7 +119,7 @@ void Command::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
|
|||
void Command::writeResponseFile(raw_ostream &OS) const {
|
||||
// In a file list, we only write the set of inputs to the response file
|
||||
if (Creator.getResponseFilesSupport() == Tool::RF_FileList) {
|
||||
for (const char *Arg : InputFileList) {
|
||||
for (const auto *Arg : InputFileList) {
|
||||
OS << Arg << '\n';
|
||||
}
|
||||
return;
|
||||
|
@ -124,7 +128,7 @@ void Command::writeResponseFile(raw_ostream &OS) const {
|
|||
// In regular response files, we send all arguments to the response file.
|
||||
// Wrapping all arguments in double quotes ensures that both Unix tools and
|
||||
// Windows tools understand the response file.
|
||||
for (const char *Arg : Arguments) {
|
||||
for (const auto *Arg : Arguments) {
|
||||
OS << '"';
|
||||
|
||||
for (; *Arg != '\0'; Arg++) {
|
||||
|
@ -150,13 +154,13 @@ void Command::buildArgvForResponseFile(
|
|||
}
|
||||
|
||||
llvm::StringSet<> Inputs;
|
||||
for (const char *InputName : InputFileList)
|
||||
for (const auto *InputName : InputFileList)
|
||||
Inputs.insert(InputName);
|
||||
Out.push_back(Executable);
|
||||
// In a file list, build args vector ignoring parameters that will go in the
|
||||
// response file (elements of the InputFileList vector)
|
||||
bool FirstInput = true;
|
||||
for (const char *Arg : Arguments) {
|
||||
for (const auto *Arg : Arguments) {
|
||||
if (Inputs.count(Arg) == 0) {
|
||||
Out.push_back(Arg);
|
||||
} else if (FirstInput) {
|
||||
|
@ -174,6 +178,7 @@ rewriteIncludes(const llvm::ArrayRef<const char *> &Args, size_t Idx,
|
|||
llvm::SmallVectorImpl<llvm::SmallString<128>> &IncFlags) {
|
||||
using namespace llvm;
|
||||
using namespace sys;
|
||||
|
||||
auto getAbsPath = [](StringRef InInc, SmallVectorImpl<char> &OutInc) -> bool {
|
||||
if (path::is_absolute(InInc)) // Nothing to do here...
|
||||
return false;
|
||||
|
@ -212,8 +217,8 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
|
|||
OS << ' ';
|
||||
printArg(OS, Executable, /*Quote=*/true);
|
||||
|
||||
llvm::ArrayRef<const char *> Args = Arguments;
|
||||
llvm::SmallVector<const char *, 128> ArgsRespFile;
|
||||
ArrayRef<const char *> Args = Arguments;
|
||||
SmallVector<const char *, 128> ArgsRespFile;
|
||||
if (ResponseFile != nullptr) {
|
||||
buildArgvForResponseFile(ArgsRespFile);
|
||||
Args = ArrayRef<const char *>(ArgsRespFile).slice(1); // no executable name
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Multilib.cpp - Multilib Implementation ---------------------------===//
|
||||
//===- Multilib.cpp - Multilib Implementation -----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -8,25 +8,22 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Driver/Multilib.h"
|
||||
#include "ToolChains/CommonArgs.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/Option/Arg.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/OptTable.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/Regex.h"
|
||||
#include "llvm/Support/YAMLParser.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
using namespace clang::driver;
|
||||
using namespace clang;
|
||||
using namespace llvm::opt;
|
||||
using namespace driver;
|
||||
using namespace llvm::sys;
|
||||
|
||||
/// normalize Segment to "/foo/bar" or "".
|
||||
|
@ -34,7 +31,7 @@ static void normalizePathSegment(std::string &Segment) {
|
|||
StringRef seg = Segment;
|
||||
|
||||
// Prune trailing "/" or "./"
|
||||
while (1) {
|
||||
while (true) {
|
||||
StringRef last = path::filename(seg);
|
||||
if (last != ".")
|
||||
break;
|
||||
|
@ -42,7 +39,7 @@ static void normalizePathSegment(std::string &Segment) {
|
|||
}
|
||||
|
||||
if (seg.empty() || seg == "/") {
|
||||
Segment = "";
|
||||
Segment.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -198,8 +195,8 @@ MultilibSet &MultilibSet::Either(ArrayRef<Multilib> MultilibSegments) {
|
|||
Multilibs.insert(Multilibs.end(), MultilibSegments.begin(),
|
||||
MultilibSegments.end());
|
||||
else {
|
||||
for (const Multilib &New : MultilibSegments) {
|
||||
for (const Multilib &Base : *this) {
|
||||
for (const auto &New : MultilibSegments) {
|
||||
for (const auto &Base : *this) {
|
||||
Multilib MO = compose(Base, New);
|
||||
if (MO.isValid())
|
||||
Composed.push_back(MO);
|
||||
|
@ -262,7 +259,7 @@ bool MultilibSet::select(const Multilib::flags_list &Flags, Multilib &M) const {
|
|||
return false;
|
||||
}, Multilibs);
|
||||
|
||||
if (Filtered.size() == 0)
|
||||
if (Filtered.empty())
|
||||
return false;
|
||||
if (Filtered.size() == 1) {
|
||||
M = Filtered[0];
|
||||
|
@ -279,7 +276,7 @@ LLVM_DUMP_METHOD void MultilibSet::dump() const {
|
|||
}
|
||||
|
||||
void MultilibSet::print(raw_ostream &OS) const {
|
||||
for (const Multilib &M : *this)
|
||||
for (const auto &M : *this)
|
||||
OS << M << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- ToolChain.cpp - Collections of tools for one platform ------------===//
|
||||
//===- ToolChain.cpp - Collections of tools for one platform --------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -8,33 +8,45 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Driver/ToolChain.h"
|
||||
#include "ToolChains/CommonArgs.h"
|
||||
#include "InputInfo.h"
|
||||
#include "ToolChains/Arch/ARM.h"
|
||||
#include "ToolChains/Clang.h"
|
||||
#include "clang/Basic/ObjCRuntime.h"
|
||||
#include "clang/Basic/Sanitizers.h"
|
||||
#include "clang/Basic/VersionTuple.h"
|
||||
#include "clang/Basic/VirtualFileSystem.h"
|
||||
#include "clang/Config/config.h"
|
||||
#include "clang/Driver/Action.h"
|
||||
#include "clang/Driver/Driver.h"
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/Job.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "clang/Driver/SanitizerArgs.h"
|
||||
#include "clang/Driver/XRayArgs.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
#include "llvm/Option/Arg.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/OptTable.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCTargetOptions.h"
|
||||
#include "llvm/Support/TargetParser.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
using namespace clang::driver;
|
||||
using namespace clang::driver::tools;
|
||||
using namespace clang;
|
||||
using namespace driver;
|
||||
using namespace tools;
|
||||
using namespace llvm;
|
||||
using namespace llvm::opt;
|
||||
|
||||
|
@ -74,8 +86,7 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
|
|||
ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
|
||||
const ArgList &Args)
|
||||
: D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
|
||||
CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
|
||||
EffectiveTriple() {
|
||||
CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
|
||||
std::string CandidateLibPath = getArchSpecificLibPath();
|
||||
if (getVFS().exists(CandidateLibPath))
|
||||
getFilePaths().push_back(CandidateLibPath);
|
||||
|
@ -87,8 +98,7 @@ void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) {
|
|||
EffectiveTriple.setEnvironment(Env);
|
||||
}
|
||||
|
||||
ToolChain::~ToolChain() {
|
||||
}
|
||||
ToolChain::~ToolChain() = default;
|
||||
|
||||
vfs::FileSystem &ToolChain::getVFS() const { return getDriver().getVFS(); }
|
||||
|
||||
|
@ -115,12 +125,15 @@ const XRayArgs& ToolChain::getXRayArgs() const {
|
|||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct DriverSuffix {
|
||||
const char *Suffix;
|
||||
const char *ModeFlag;
|
||||
};
|
||||
|
||||
const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
|
||||
} // namespace
|
||||
|
||||
static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
|
||||
// A list of known driver suffixes. Suffixes are compared against the
|
||||
// program name in order. If there is a match, the frontend type is updated as
|
||||
// necessary by applying the ModeFlag.
|
||||
|
@ -151,7 +164,7 @@ const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
|
|||
|
||||
/// Normalize the program name from argv[0] by stripping the file extension if
|
||||
/// present and lower-casing the string on Windows.
|
||||
std::string normalizeProgramName(llvm::StringRef Argv0) {
|
||||
static std::string normalizeProgramName(llvm::StringRef Argv0) {
|
||||
std::string ProgName = llvm::sys::path::stem(Argv0);
|
||||
#ifdef LLVM_ON_WIN32
|
||||
// Transform to lowercase for case insensitive file systems.
|
||||
|
@ -160,7 +173,7 @@ std::string normalizeProgramName(llvm::StringRef Argv0) {
|
|||
return ProgName;
|
||||
}
|
||||
|
||||
const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) {
|
||||
static const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) {
|
||||
// Try to infer frontend type and default target from the program name by
|
||||
// comparing it against DriverSuffixes in order.
|
||||
|
||||
|
@ -185,7 +198,6 @@ const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) {
|
|||
}
|
||||
return DS;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
ParsedClangName
|
||||
ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
|
||||
|
@ -193,7 +205,7 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
|
|||
size_t SuffixPos;
|
||||
const DriverSuffix *DS = parseDriverSuffix(ProgName, SuffixPos);
|
||||
if (!DS)
|
||||
return ParsedClangName();
|
||||
return {};
|
||||
size_t SuffixEnd = SuffixPos + strlen(DS->Suffix);
|
||||
|
||||
size_t LastComponent = ProgName.rfind('-', SuffixPos);
|
||||
|
@ -589,7 +601,7 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
|
|||
// CollectArgsForIntegratedAssembler but we can't change the ArchName at
|
||||
// that point. There is no assembler equivalent of -mno-thumb, -marm, or
|
||||
// -mno-arm.
|
||||
for (const Arg *A :
|
||||
for (const auto *A :
|
||||
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
|
||||
for (StringRef Value : A->getValues()) {
|
||||
if (Value == "-mthumb")
|
||||
|
@ -707,7 +719,7 @@ void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
|
|||
/*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args,
|
||||
ArrayRef<StringRef> Paths) {
|
||||
for (StringRef Path : Paths) {
|
||||
for (const auto Path : Paths) {
|
||||
CC1Args.push_back("-internal-isystem");
|
||||
CC1Args.push_back(DriverArgs.MakeArgString(Path));
|
||||
}
|
||||
|
@ -789,7 +801,9 @@ bool ToolChain::AddFastMathRuntimeIfAvailable(const ArgList &Args,
|
|||
SanitizerMask ToolChain::getSupportedSanitizers() const {
|
||||
// Return sanitizers which don't require runtime support and are not
|
||||
// platform dependent.
|
||||
|
||||
using namespace SanitizerKind;
|
||||
|
||||
SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
|
||||
CFICastStrict | UnsignedIntegerOverflow | Nullability |
|
||||
LocalBounds;
|
||||
|
@ -871,7 +885,7 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
|
|||
bool Modified = false;
|
||||
|
||||
// Handle -Xopenmp-target flags
|
||||
for (Arg *A : Args) {
|
||||
for (auto *A : Args) {
|
||||
// Exclude flags which may only apply to the host toolchain.
|
||||
// Do not exclude flags when the host triple (AuxTriple)
|
||||
// matches the current toolchain triple. If it is not present
|
||||
|
|
Loading…
Reference in New Issue