diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/TableGen | |
parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) |
Notes
Diffstat (limited to 'lib/TableGen')
-rw-r--r-- | lib/TableGen/Error.cpp | 4 | ||||
-rw-r--r-- | lib/TableGen/Main.cpp | 4 | ||||
-rw-r--r-- | lib/TableGen/Record.cpp | 2 | ||||
-rw-r--r-- | lib/TableGen/StringMatcher.cpp | 25 |
4 files changed, 21 insertions, 14 deletions
diff --git a/lib/TableGen/Error.cpp b/lib/TableGen/Error.cpp index fd0893566254..b4830178a269 100644 --- a/lib/TableGen/Error.cpp +++ b/lib/TableGen/Error.cpp @@ -39,6 +39,10 @@ static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind, "instantiated from multiclass"); } +void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg) { + PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); +} + void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg) { PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); } diff --git a/lib/TableGen/Main.cpp b/lib/TableGen/Main.cpp index 278b567fb220..fc9d0cc08885 100644 --- a/lib/TableGen/Main.cpp +++ b/lib/TableGen/Main.cpp @@ -61,7 +61,7 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) { return reportError(argv0, "the option -d must be used together with -o\n"); std::error_code EC; - tool_output_file DepOut(DependFilename, EC, sys::fs::F_Text); + ToolOutputFile DepOut(DependFilename, EC, sys::fs::F_Text); if (EC) return reportError(argv0, "error opening " + DependFilename + ":" + EC.message() + "\n"); @@ -97,7 +97,7 @@ int llvm::TableGenMain(char *argv0, TableGenMainFn *MainFn) { return 1; std::error_code EC; - tool_output_file Out(OutputFilename, EC, sys::fs::F_Text); + ToolOutputFile Out(OutputFilename, EC, sys::fs::F_Text); if (EC) return reportError(argv0, "error opening " + OutputFilename + ":" + EC.message() + "\n"); diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index b2636e1e6cb4..2c5b745433b8 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -496,7 +496,7 @@ Init *ListInit::convertInitializerTo(RecTy *Ty) const { Elements.push_back(CI); if (CI != I) Changed = true; - } else + } else return nullptr; if (!Changed) diff --git a/lib/TableGen/StringMatcher.cpp b/lib/TableGen/StringMatcher.cpp index 7e510f0c2fdc..32599104f6a2 100644 --- a/lib/TableGen/StringMatcher.cpp +++ b/lib/TableGen/StringMatcher.cpp @@ -46,17 +46,18 @@ FindFirstNonCommonLetter(const std::vector<const /// code to verify that CharNo and later are the same. /// /// \return - True if control can leave the emitted code fragment. -bool StringMatcher:: -EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches, - unsigned CharNo, unsigned IndentCount) const { +bool StringMatcher::EmitStringMatcherForChar( + const std::vector<const StringPair *> &Matches, unsigned CharNo, + unsigned IndentCount, bool IgnoreDuplicates) const { assert(!Matches.empty() && "Must have at least one string to match!"); - std::string Indent(IndentCount*2+4, ' '); + std::string Indent(IndentCount * 2 + 4, ' '); // If we have verified that the entire string matches, we're done: output the // matching code. if (CharNo == Matches[0]->first.size()) { - assert(Matches.size() == 1 && "Had duplicate keys to match on"); - + if (Matches.size() > 1 && !IgnoreDuplicates) + report_fatal_error("Had duplicate keys to match on"); + // If the to-execute code has \n's in it, indent each subsequent line. StringRef Code = Matches[0]->second; @@ -100,8 +101,9 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches, << NumChars << ") != 0)\n"; OS << Indent << " break;\n"; } - - return EmitStringMatcherForChar(Matches, FirstNonCommonLetter, IndentCount); + + return EmitStringMatcherForChar(Matches, FirstNonCommonLetter, IndentCount, + IgnoreDuplicates); } // Otherwise, we have multiple possible things, emit a switch on the @@ -116,7 +118,8 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches, << LI->second.size() << " string"; if (LI->second.size() != 1) OS << 's'; OS << " to match.\n"; - if (EmitStringMatcherForChar(LI->second, CharNo+1, IndentCount+1)) + if (EmitStringMatcherForChar(LI->second, CharNo + 1, IndentCount + 1, + IgnoreDuplicates)) OS << Indent << " break;\n"; } @@ -126,7 +129,7 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches, /// Emit - Top level entry point. /// -void StringMatcher::Emit(unsigned Indent) const { +void StringMatcher::Emit(unsigned Indent, bool IgnoreDuplicates) const { // If nothing to match, just fall through. if (Matches.empty()) return; @@ -146,7 +149,7 @@ void StringMatcher::Emit(unsigned Indent) const { OS.indent(Indent*2+2) << "case " << LI->first << ":\t // " << LI->second.size() << " string" << (LI->second.size() == 1 ? "" : "s") << " to match.\n"; - if (EmitStringMatcherForChar(LI->second, 0, Indent)) + if (EmitStringMatcherForChar(LI->second, 0, Indent, IgnoreDuplicates)) OS.indent(Indent*2+4) << "break;\n"; } |