summaryrefslogtreecommitdiffstats
path: root/tools/libclang/CXLoadedDiagnostic.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-11-11 15:19:48 +0000
committerTed Kremenek <kremenek@apple.com>2011-11-11 15:19:48 +0000
commite97ac9e684aecb5fc3fb9f86da09b8bb9dc31ff4 (patch)
tree1c17e197e47ab2480ef866efc7d351a8bb38f4fd /tools/libclang/CXLoadedDiagnostic.cpp
parent8f6457e75d0e0ed2198352a66567c51445d53951 (diff)
Tweak CXLoadedDiagnosticSetImpl::makeString() to include an extra null character, and change the creation of the FixIT's string to again just rely on this string (instead of duplicating it when calling createCXString).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CXLoadedDiagnostic.cpp')
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index 607f3bb362..510f617c58 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -55,8 +55,11 @@ public:
llvm::StringRef CXLoadedDiagnosticSetImpl::makeString(const char *blob,
unsigned bloblen) {
- char *mem = Alloc.Allocate<char>(bloblen);
+ char *mem = Alloc.Allocate<char>(bloblen + 1);
memcpy(mem, blob, bloblen);
+ // Add a null terminator for those clients accessing the buffer
+ // like a c-string.
+ mem[bloblen] = '\0';
return llvm::StringRef(mem, bloblen);
}
@@ -100,7 +103,7 @@ CXSourceLocation CXLoadedDiagnostic::getLocation() const {
}
CXString CXLoadedDiagnostic::getSpelling() const {
- return cxstring::createCXString(Spelling, false);
+ return cxstring::createCXString(Spelling, false);
}
CXString CXLoadedDiagnostic::getDiagnosticOption(CXString *Disable) const {
@@ -242,7 +245,7 @@ public:
if (errorString)
*errorString = createCXString("");
}
-
+
CXDiagnosticSet load(const char *file);
};
}
@@ -626,8 +629,8 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
llvm::StringRef RetStr;
if (readString(TopDiags, RetStr, "FIXIT", Record, BlobStart, BlobLen))
return Failure;
- D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr)));
- continue;
+ D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr, false)));
+ continue;
}
case serialized_diags::RECORD_DIAG: {