diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-05-26 08:07:49 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-05-26 08:07:49 +0000 |
commit | 33684f9e64828ee5408ab72ba54beb3b7b2ec754 (patch) | |
tree | 0dafb1f0500f1dfe05c4af8bddfb2d1c814c56ae /llvm/lib/TableGen/TableGenBackend.cpp | |
parent | cb7648be17bfeed88e2e54fa8f84d7dc17fdb985 (diff) | |
download | bcm5719-llvm-33684f9e64828ee5408ab72ba54beb3b7b2ec754.tar.gz bcm5719-llvm-33684f9e64828ee5408ab72ba54beb3b7b2ec754.zip |
[TableGen] Rewrite an assert to not do a bunch unsigned math and then try to ensure the result is a positive number.
I think the fact that it was explicitly excluding 0 kept this from being a tautology. The exclusion of 0 for the old math was also a bug that's easily hit if the description gets split into multiple lines.
llvm-svn: 238186
Diffstat (limited to 'llvm/lib/TableGen/TableGenBackend.cpp')
-rw-r--r-- | llvm/lib/TableGen/TableGenBackend.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/TableGen/TableGenBackend.cpp b/llvm/lib/TableGen/TableGenBackend.cpp index 9763f85c793..43f8cb089ec 100644 --- a/llvm/lib/TableGen/TableGenBackend.cpp +++ b/llvm/lib/TableGen/TableGenBackend.cpp @@ -22,11 +22,11 @@ const size_t MAX_LINE_LEN = 80U; static void printLine(raw_ostream &OS, const Twine &Prefix, char Fill, StringRef Suffix) { size_t Pos = (size_t)OS.tell(); - assert((MAX_LINE_LEN - Prefix.str().size() - Suffix.size() > 0) && + assert((Prefix.str().size() + Suffix.size() <= MAX_LINE_LEN) && "header line exceeds max limit"); OS << Prefix; - const size_t e = MAX_LINE_LEN - Suffix.size(); - for (size_t i = (size_t)OS.tell() - Pos; i < e; ++i) + for (size_t i = (size_t)OS.tell() - Pos, e = MAX_LINE_LEN - Suffix.size(); + i < e; ++i) OS << Fill; OS << Suffix << '\n'; } |