summaryrefslogtreecommitdiffstats
path: root/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
commit62136e45499812f005a012443ad0bed920a91628 (patch)
tree96b86c6dbacee3733bef2f5295ef9380c99aedcb /tools/libclang/CXLoadedDiagnostic.cpp
parent356de0fe6a992d808626ada693d3b89bf7b02f1a (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CXLoadedDiagnostic.cpp')
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index df8f41440e..0e0075fc38 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/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;
}