summaryrefslogtreecommitdiff
path: root/utils/TableGen/LLVMCConfigurationEmitter.cpp
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-05-30 06:13:29 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-05-30 06:13:29 +0000
commit2242456da535c83f7ecc7e3c92224b2e79835e2f (patch)
treee162d0a60ae29273105c8566b56d233bdf8171f0 /utils/TableGen/LLVMCConfigurationEmitter.cpp
parent5c7578de087fb984473277316edd19908d0e8190 (diff)
downloadllvm-2242456da535c83f7ecc7e3c92224b2e79835e2f.tar.gz
llvm-2242456da535c83f7ecc7e3c92224b2e79835e2f.tar.bz2
llvm-2242456da535c83f7ecc7e3c92224b2e79835e2f.tar.xz
Make it possible to use hooks like this: '$CALL(MyHook)/path/to/file'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51734 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/LLVMCConfigurationEmitter.cpp')
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp53
1 files changed, 36 insertions, 17 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 2dfd17e7b4..93fe90b1ee 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -862,19 +862,36 @@ void EmitOptionPropertyHandlingCode (const ToolOptionDescription& D,
/// SubstituteSpecialCommands - Perform string substitution for $CALL
/// and $ENV. Helper function used by EmitCmdLineVecFill().
std::string SubstituteSpecialCommands(const std::string& cmd) {
- if (cmd.find("$CALL(") == 0) {
- if (cmd.size() == 6)
- throw std::string("$CALL invocation: empty argument list!");
- return std::string("hooks::") + (cmd.c_str() + 6) + "()";
- }
- else if (cmd.find("$ENV(") == 0) {
- if (cmd.size() == 5)
- throw std::string("$ENV invocation: empty argument list!");
- return std::string("std::getenv(\"") + (cmd.c_str() + 5) + "\")";
- }
- else {
- throw "Unknown special command: " + cmd;
- }
+ size_t cparen = cmd.find(")");
+ std::string ret;
+
+ if (cmd.find("$CALL(") == 0) {
+ if (cmd.size() == 6)
+ throw std::string("$CALL invocation: empty argument list!");
+
+ ret += "hooks::";
+ ret += std::string(cmd.begin() + 6, cmd.begin() + cparen);
+ ret += "()";
+ }
+ else if (cmd.find("$ENV(") == 0) {
+ if (cmd.size() == 5)
+ throw std::string("$ENV invocation: empty argument list!");
+
+ ret += "std::getenv(\"";
+ ret += std::string(cmd.begin() + 5, cmd.begin() + cparen);
+ ret += "\")";
+ }
+ else {
+ throw "Unknown special command: " + cmd;
+ }
+
+ if (cmd.begin() + cparen + 1 != cmd.end()) {
+ ret += " + std::string(\"";
+ ret += (cmd.c_str() + cparen + 1);
+ ret += "\")";
+ }
+
+ return ret;
}
/// EmitCmdLineVecFill - Emit code that fills in the command line
@@ -883,7 +900,7 @@ void EmitCmdLineVecFill(const Init* CmdLine, const std::string& ToolName,
bool Version, const char* IndentLevel,
std::ostream& O) {
StrVector StrVec;
- SplitString(InitPtrToString(CmdLine), StrVec, ") ");
+ SplitString(InitPtrToString(CmdLine), StrVec);
if (StrVec.empty())
throw "Tool " + ToolName + " has empty command line!";
@@ -906,7 +923,8 @@ void EmitCmdLineVecFill(const Init* CmdLine, const std::string& ToolName,
O << "vec.push_back(outFile.toString());\n";
}
else {
- O << "vec.push_back(" << SubstituteSpecialCommands(cmd) << ");\n";
+ O << "vec.push_back(" << SubstituteSpecialCommands(cmd);
+ O << ");\n";
}
}
else {
@@ -1322,14 +1340,15 @@ void EmitPopulateCompilationGraph (Record* CompilationGraph,
/// function used by FillInHookNames().
void ExtractHookNames(const Init* CmdLine, StrVector& HookNames) {
StrVector cmds;
- llvm::SplitString(InitPtrToString(CmdLine), cmds, ") ");
+ llvm::SplitString(InitPtrToString(CmdLine), cmds);
for (StrVector::const_iterator B = cmds.begin(), E = cmds.end();
B != E; ++B) {
const std::string& cmd = *B;
if (cmd.find("$CALL(") == 0) {
if (cmd.size() == 6)
throw std::string("$CALL invocation: empty argument list!");
- HookNames.push_back(std::string(cmd.c_str() + 6));
+ HookNames.push_back(std::string(cmd.begin() + 6,
+ cmd.begin() + cmd.find(")")));
}
}
}