r257411 - Add an Action* member to InputInfo.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 11 15:15:21 PST 2016
Author: jlebar
Date: Mon Jan 11 17:15:21 2016
New Revision: 257411
URL: http://llvm.org/viewvc/llvm-project?rev=257411&view=rev
Log:
Add an Action* member to InputInfo.
Summary:
The CUDA toolchain needs to know which Actions created which InputInfos,
because it needs to attach GPU archs to the various InputInfos.
Reviewers: echristo
Subscribers: jfb, dschuff, jhen, tra, cfe-commits
Differential Revision: http://reviews.llvm.org/D16078
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/InputInfo.h
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257411&r1=257410&r2=257411&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jan 11 17:15:21 2016
@@ -1801,9 +1801,9 @@ InputInfo Driver::BuildJobsForAction(Com
Input.claim();
if (Input.getOption().matches(options::OPT_INPUT)) {
const char *Name = Input.getValue();
- return InputInfo(Name, A->getType(), Name);
+ return InputInfo(A, Name, /* BaseInput = */ Name);
}
- return InputInfo(&Input, A->getType(), "");
+ return InputInfo(A, &Input, /* BaseInput = */ "");
}
if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
@@ -1877,11 +1877,11 @@ InputInfo Driver::BuildJobsForAction(Com
// Determine the place to write output to, if any.
InputInfo Result;
if (JA->getType() == types::TY_Nothing)
- Result = InputInfo(A->getType(), BaseInput);
+ Result = InputInfo(A, BaseInput);
else
- Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
- AtTopLevel, MultipleArchs),
- A->getType(), BaseInput);
+ Result = InputInfo(A, GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
+ AtTopLevel, MultipleArchs),
+ BaseInput);
if (CCCPrintBindings && !CCGenDiagnostics) {
llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'
Modified: cfe/trunk/lib/Driver/InputInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/InputInfo.h?rev=257411&r1=257410&r2=257411&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/InputInfo.h (original)
+++ cfe/trunk/lib/Driver/InputInfo.h Mon Jan 11 17:15:21 2016
@@ -10,6 +10,7 @@
#ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
#define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
+#include "clang/Driver/Action.h"
#include "clang/Driver/Types.h"
#include "llvm/Option/Arg.h"
#include <cassert>
@@ -38,21 +39,36 @@ class InputInfo {
const llvm::opt::Arg *InputArg;
} Data;
Class Kind;
+ const Action* Act;
types::ID Type;
const char *BaseInput;
+ static types::ID GetActionType(const Action *A) {
+ return A != nullptr ? A->getType() : types::TY_Nothing;
+ }
+
public:
- InputInfo() {}
- InputInfo(types::ID _Type, const char *_BaseInput)
- : Kind(Nothing), Type(_Type), BaseInput(_BaseInput) {
+ InputInfo() : InputInfo(nullptr, nullptr) {}
+ InputInfo(const Action *A, const char *_BaseInput)
+ : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {}
+
+ InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput)
+ : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+ Data.Filename = _Filename;
}
- InputInfo(const char *_Filename, types::ID _Type, const char *_BaseInput)
- : Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
+ InputInfo(const Action *A, const char *_Filename, const char *_BaseInput)
+ : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
Data.Filename = _Filename;
}
- InputInfo(const llvm::opt::Arg *_InputArg, types::ID _Type,
+
+ InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg,
+ const char *_BaseInput)
+ : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+ Data.InputArg = _InputArg;
+ }
+ InputInfo(const Action *A, const llvm::opt::Arg *_InputArg,
const char *_BaseInput)
- : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
+ : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
Data.InputArg = _InputArg;
}
@@ -61,6 +77,9 @@ public:
bool isInputArg() const { return Kind == InputArg; }
types::ID getType() const { return Type; }
const char *getBaseInput() const { return BaseInput; }
+ /// The action for which this InputInfo was created. May be null.
+ const Action *getAction() const { return Act; }
+ void setAction(const Action *A) { Act = A; }
const char *getFilename() const {
assert(isFilename() && "Invalid accessor.");
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257411&r1=257410&r2=257411&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jan 11 17:15:21 2016
@@ -2980,7 +2980,7 @@ static void SplitDebugInfo(const ToolCha
ExtractArgs.push_back(OutFile);
const char *Exec = Args.MakeArgString(TC.GetProgramPath("objcopy"));
- InputInfo II(Output.getFilename(), types::TY_Object, Output.getFilename());
+ InputInfo II(types::TY_Object, Output.getFilename(), Output.getFilename());
// First extract the dwo sections.
C.addCommand(llvm::make_unique<Command>(JA, T, Exec, ExtractArgs, II));
@@ -8987,7 +8987,7 @@ void nacltools::AssemblerARM::ConstructJ
const char *LinkingOutput) const {
const toolchains::NaClToolChain &ToolChain =
static_cast<const toolchains::NaClToolChain &>(getToolChain());
- InputInfo NaClMacros(ToolChain.GetNaClArmMacrosPath(), types::TY_PP_Asm,
+ InputInfo NaClMacros(types::TY_PP_Asm, ToolChain.GetNaClArmMacrosPath(),
"nacl-arm-macros.s");
InputInfoList NewInputs;
NewInputs.push_back(NaClMacros);
More information about the cfe-commits
mailing list