New tests for the 'case' expression: not_empty, in_language.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51744 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 68548d6..0b6e8d7 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -667,6 +667,16 @@
} else if (TestName == "input_languages_contain") {
O << "InLangs.count(\"" << OptName << "\") != 0";
return true;
+ } else if (TestName == "in_language") {
+ // Works only for cmd_line!
+ O << "GetLanguage(inFile) == \"" << OptName << '\"';
+ return true;
+ } else if (TestName == "not_empty") {
+ const GlobalOptionDescription& OptDesc = OptDescs.FindOption(OptName);
+ if (OptDesc.Type == OptionType::Switch)
+ throw OptName + ": incorrect option type!";
+ O << '!' << OptDesc.GenVariableName() << ".empty()";
+ return true;
}
return false;
@@ -1026,7 +1036,7 @@
else
EmitCaseConstructHandler(&InitPtrToDag(P.CmdLine), Indent2,
EmitCmdLineVecFillCallback(Version, P.Name),
- true, OptDescs, O);
+ false, OptDescs, O);
// For every understood option, emit handling code.
for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(),
@@ -1222,7 +1232,7 @@
throw std::string("Error in the language map definition!");
// Generate code
- O << "void llvmc::PopulateLanguageMap(LanguageMap& language_map) {\n";
+ O << "void llvmc::PopulateLanguageMap() {\n";
for (unsigned i = 0; i < LangsToSuffixesList->size(); ++i) {
Record* LangToSuffixes = LangsToSuffixesList->getElementAsRecord(i);
@@ -1231,7 +1241,7 @@
const ListInit* Suffixes = LangToSuffixes->getValueAsListInit("suffixes");
for (unsigned i = 0; i < Suffixes->size(); ++i)
- O << Indent1 << "language_map[\""
+ O << Indent1 << "GlobalLanguageMap[\""
<< InitPtrToString(Suffixes->getElement(i))
<< "\"] = \"" << Lang << "\";\n";
}
@@ -1360,7 +1370,7 @@
// Generate code
O << "void llvmc::PopulateCompilationGraph(CompilationGraph& G) {\n"
- << Indent1 << "PopulateLanguageMap(G.ExtsToLangs);\n\n";
+ << Indent1 << "PopulateLanguageMap();\n\n";
// Insert vertices