summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-08 22:37:58 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-08 22:37:58 +0000
commit5f7ece0bffcf43103950b08dc7e3939b2c56cff6 (patch)
tree059041ffc4503f5b83790e81034f7acdf68c5883 /clang/lib/Rewrite
parent5d1647daf98bdbdb77b7184154104053df1ffbc1 (diff)
downloadbcm5719-llvm-5f7ece0bffcf43103950b08dc7e3939b2c56cff6.tar.gz
bcm5719-llvm-5f7ece0bffcf43103950b08dc7e3939b2c56cff6.zip
Don't expand tabs in EscapeText, but rather expand them when writing out
the HTML file. This should reduce the amount of memory pressure on the rewriter for files that have a lot of tabs. llvm-svn: 49406
Diffstat (limited to 'clang/lib/Rewrite')
-rw-r--r--clang/lib/Rewrite/HTMLRewrite.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp
index 8bc44e3a819..3e0d71a5b6d 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -20,7 +20,8 @@
using namespace clang;
-void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) {
+void html::EscapeText(Rewriter& R, unsigned FileID,
+ bool EscapeSpaces, bool ReplaceTabs) {
const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
const char* C = Buf->getBufferStart();
@@ -41,6 +42,9 @@ void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) {
break;
case '\t': {
+ if (!ReplaceTabs)
+ break;
+
SourceLocation Loc = SourceLocation::getFileLoc(FileID, FilePos);
if (EscapeSpaces)
@@ -72,7 +76,8 @@ void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) {
}
}
-std::string html::EscapeText(const std::string& s, bool EscapeSpaces) {
+std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
+ bool ReplaceTabs) {
unsigned len = s.size();
std::ostringstream os;
@@ -90,7 +95,13 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces) {
else os << ' ';
break;
- case '\t': for (unsigned i = 0; i < 4; ++i) os << "&nbsp;"; break;
+ case '\t':
+ if (ReplaceTabs)
+ for (unsigned i = 0; i < 4; ++i) os << "&nbsp;";
+ else os << c;
+
+ break;
+
case '<': os << "&lt;"; break;
case '>': os << "&gt;"; break;
case '&': os << "&amp;"; break;
OpenPOWER on IntegriCloud