[cfe-commits] r47512 - in /cfe/trunk/AST: StmtPrinter.cpp StmtSerialization.cpp
Ted Kremenek
kremenek at apple.com
Fri Feb 22 16:52:04 PST 2008
Author: kremenek
Date: Fri Feb 22 18:52:04 2008
New Revision: 47512
URL: http://llvm.org/viewvc/llvm-project?rev=47512&view=rev
Log:
Patch from Argiris Kirtzidis:
The patch fixes some debug assertions that the msvcrt throws:
1)
- if (isprint(value) && value < 256) {
+ if (value < 256 && isprint(value)) {
isprint() does an assertion check of its own for value < 256; check value before calling it to prevent it.
2)
- Stmt->Names.push_back(std::string(&data[0], data.size()));
+ if (data.size() == 0)
+ Stmt->Names.push_back(std::string());
+ else
+ Stmt->Names.push_back(std::string(&data[0], data.size()));
If data.size() == 0 then data[0] throws "out of range" assertion.
Modified:
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/AST/StmtSerialization.cpp
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=47512&r1=47511&r2=47512&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Fri Feb 22 18:52:04 2008
@@ -536,7 +536,7 @@
OS << "'\\v'";
break;
default:
- if (isprint(value) && value < 256) {
+ if (value < 256 && isprint(value)) {
OS << "'" << (char)value << "'";
} else if (value < 256) {
OS << "'\\x" << std::hex << value << std::dec << "'";
Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=47512&r1=47511&r2=47512&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Fri Feb 22 18:52:04 2008
@@ -270,7 +270,10 @@
std::vector<char> data;
D.ReadCStr(data, false);
- Stmt->Names.push_back(std::string(&data[0], data.size()));
+ if (data.size() == 0)
+ Stmt->Names.push_back(std::string());
+ else
+ Stmt->Names.push_back(std::string(&data[0], data.size()));
}
Stmt->Constraints.reserve(size);
More information about the cfe-commits
mailing list