[LLVMdev] More questions on CompilerDriver.
Sylvere Teissier
st at invia.fr
Tue Dec 8 04:56:09 PST 2009
Mikhail Glushenkov a écrit :
> Hi Sanjiv,
>
> On Tue, Dec 8, 2009 at 4:41 AM, Sanjiv Gupta <sanjiv.gupta at microchip.com> wrote:
>> Mikhail Glushenkov wrote:
>>>> 2. Is there anyway to call a C++ hook from inside actions?
>>>> for example
>>>> (actions (case
>>>> (not_empty "Wl,"), (append_cmd "$CALL(Myhook)" )))
>>> Not yet, this is something I'm working on right now.
Sorry, I didn't see this thread but I have a patch for that.
It's more a hack than really a new feature but that works well...
Index: LLVMCConfigurationEmitter.cpp
===================================================================
--- LLVMCConfigurationEmitter.cpp (révision 90849)
+++ LLVMCConfigurationEmitter.cpp (copie de travail)
@@ -1794,9 +1814,24 @@
StrVector Out;
llvm::SplitString(Cmd, Out);
- for (StrVector::const_iterator B = Out.begin(), E = Out.end();
- B != E; ++B)
- O.indent(IndentLevel) << "vec.push_back(\"" << *B << "\");\n";
+ StrVector StrVec;
+ TokenizeCmdline(Cmd, StrVec);
+ StrVector::const_iterator I = StrVec.begin(), E = StrVec.end();
+ for (; I != E; ++I) {
+ const std::string& cmd = *I;
+ if (cmd.at(0) == '$') {
+ O << "vec.push_back(";
+ I=SubstituteSpecialCommands(I,E,O);
+ O << ");\n";
+ }
+ else{
+ O.indent(IndentLevel) << "vec.push_back(\"" << *I << "\");\n";
+ }
+ }
+
+ //for (StrVector::const_iterator B = Out.begin(), E = Out.end();
+ // B != E; ++B)
+ // O.indent(IndentLevel) << "vec.push_back(\"" << *B << "\");\n";
}
void onForward (const DagInit& Dag,
More information about the llvm-dev
mailing list