summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CXLoadedDiagnostic.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-10-10 22:20:26 +0000
committerJustin Bogner <mail@justinbogner.com>2014-10-10 22:20:26 +0000
commita8dd73229ebde88a130ad7b5fd668bf3593a8c58 (patch)
tree49fa06189c227edea926a0533988a2ce4a55da43 /clang/tools/libclang/CXLoadedDiagnostic.cpp
parent61cc9083d030f6b419aeb4579592b72134f39246 (diff)
downloadbcm5719-llvm-a8dd73229ebde88a130ad7b5fd668bf3593a8c58.tar.gz
bcm5719-llvm-a8dd73229ebde88a130ad7b5fd668bf3593a8c58.zip
Correctly handle reading locations from serialized diagnostics
When reading a serialized diagnostic location with no file ID, we were failing to increment the cursor past the rest of the location. This would lead to the flags and category always appearing blank in such diagnostics. This changes the function to unconditionally increment the cursor and updates the test to check for the correct output instead of testing that we were doing this wrong. I've also updated the error check to check for the correct number of fields. llvm-svn: 219538
Diffstat (limited to 'clang/tools/libclang/CXLoadedDiagnostic.cpp')
-rw-r--r--clang/tools/libclang/CXLoadedDiagnostic.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/tools/libclang/CXLoadedDiagnostic.cpp b/clang/tools/libclang/CXLoadedDiagnostic.cpp
index df8f41440ee..0e0075fc387 100644
--- a/clang/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/clang/tools/libclang/CXLoadedDiagnostic.cpp
@@ -485,12 +485,14 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
LoadResult DiagLoader::readLocation(CXLoadedDiagnosticSetImpl &TopDiags,
RecordData &Record, unsigned &offset,
CXLoadedDiagnostic::Location &Loc) {
- if (Record.size() < offset + 3) {
+ if (Record.size() < offset + 4) {
reportInvalidFile("Corrupted source location");
return Failure;
}
+ auto Fields = makeArrayRef(Record).slice(offset);
+ offset += 4;
- unsigned fileID = Record[offset++];
+ unsigned fileID = Fields[0];
if (fileID == 0) {
// Sentinel value.
Loc.file = nullptr;
@@ -506,9 +508,9 @@ LoadResult DiagLoader::readLocation(CXLoadedDiagnosticSetImpl &TopDiags,
return Failure;
}
Loc.file = const_cast<FileEntry *>(FE);
- Loc.line = Record[offset++];
- Loc.column = Record[offset++];
- Loc.offset = Record[offset++];
+ Loc.line = Fields[1];
+ Loc.column = Fields[2];
+ Loc.offset = Fields[3];
return Success;
}
OpenPOWER on IntegriCloud