r219538 - Correctly handle reading locations from serialized diagnostics
Justin Bogner
mail at justinbogner.com
Fri Oct 10 15:20:26 PDT 2014
Author: bogner
Date: Fri Oct 10 17:20:26 2014
New Revision: 219538
URL: http://llvm.org/viewvc/llvm-project?rev=219538&view=rev
Log:
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.
Modified:
cfe/trunk/test/Misc/serialized-diags.m
cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
Modified: cfe/trunk/test/Misc/serialized-diags.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags.m?rev=219538&r1=219537&r2=219538&view=diff
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags.m (original)
+++ cfe/trunk/test/Misc/serialized-diags.m Fri Oct 10 17:20:26 2014
@@ -21,7 +21,7 @@
// CHECK: Range: {{.*[/\\]}}serialized-diags.m:8:4 {{.*[/\\]}}serialized-diags.m:8:9
// CHECK: Number FIXITs = 1
// CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.m:8:4 - {{.*[/\\]}}serialized-diags.m:8:9): "self"
-// CHECK: +-(null):0:0: note: 'self' is an implicit parameter [] []
+// CHECK: +-(null):0:0: note: 'self' is an implicit parameter [] [Semantic Issue]
// CHECK: Number FIXITs = 0
// CHECK: {{.*[/\\]}}serialized-diags.m:1:12: warning: class 'Foo' defined without specifying a base class [-Wobjc-root-class] [Semantic Issue]
// CHECK: Number FIXITs = 0
Modified: cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp?rev=219538&r1=219537&r2=219538&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp Fri Oct 10 17:20:26 2014
@@ -485,12 +485,14 @@ LoadResult DiagLoader::readString(CXLoad
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(CXLo
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;
}
More information about the cfe-commits
mailing list