summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/libclang/CXLoadedDiagnostic.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/clang/tools/libclang/CXLoadedDiagnostic.cpp b/clang/tools/libclang/CXLoadedDiagnostic.cpp
index 510f617c589..61b9e33c2da 100644
--- a/clang/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud