aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-11-29 00:30:52 +0000
committerTed Kremenek <kremenek@apple.com>2011-11-29 00:30:52 +0000
commit952538d48d75b2c01d98002a46691638f9f9a4ac (patch)
tree96b98da96b7b9e8785d0133154c98c935525ca7e /tools/libclang
parentee77d3d70973dcfdb7e571f1139801f6dbc144a3 (diff)
Fix serialized diagnostics to handle FixIts that only remove text. Fixes <rdar://problem/10473903>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang')
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index 510f617c58..61b9e33c2d 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -220,14 +220,16 @@ class DiagLoader {
Strings &strings, llvm::StringRef errorContext,
RecordData &Record,
const char *BlobStart,
- unsigned BlobLen);
+ unsigned BlobLen,
+ bool allowEmptyString = false);
LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
llvm::StringRef &RetStr,
llvm::StringRef errorContext,
RecordData &Record,
const char *BlobStart,
- unsigned BlobLen);
+ unsigned BlobLen,
+ bool allowEmptyString = false);
LoadResult readRange(CXLoadedDiagnosticSetImpl &TopDiags,
RecordData &Record, unsigned RecStartIdx,
@@ -445,7 +447,8 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
llvm::StringRef errorContext,
RecordData &Record,
const char *BlobStart,
- unsigned BlobLen) {
+ unsigned BlobLen,
+ bool allowEmptyString) {
// Basic buffer overflow check.
if (BlobLen > 65536) {
@@ -453,6 +456,11 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
std::string(errorContext));
return Failure;
}
+
+ if (allowEmptyString && Record.size() >= 1 && BlobLen == 0) {
+ RetStr = "";
+ return Success;
+ }
if (Record.size() < 1 || BlobLen == 0) {
reportInvalidFile(std::string("Corrupted ") + std::string(errorContext)
@@ -469,9 +477,11 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
llvm::StringRef errorContext,
RecordData &Record,
const char *BlobStart,
- unsigned BlobLen) {
+ unsigned BlobLen,
+ bool allowEmptyString) {
llvm::StringRef RetStr;
- if (readString(TopDiags, RetStr, errorContext, Record, BlobStart, BlobLen))
+ if (readString(TopDiags, RetStr, errorContext, Record, BlobStart, BlobLen,
+ allowEmptyString))
return Failure;
strings[Record[0]] = RetStr;
return Success;
@@ -627,7 +637,8 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
if (readRange(TopDiags, Record, 0, SR))
return Failure;
llvm::StringRef RetStr;
- if (readString(TopDiags, RetStr, "FIXIT", Record, BlobStart, BlobLen))
+ if (readString(TopDiags, RetStr, "FIXIT", Record, BlobStart, BlobLen,
+ /* allowEmptyString */ true))
return Failure;
D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr, false)));
continue;