]> granicus.if.org Git - clang/commitdiff
Correctly handle reading locations from serialized diagnostics
authorJustin Bogner <mail@justinbogner.com>
Fri, 10 Oct 2014 22:20:26 +0000 (22:20 +0000)
committerJustin Bogner <mail@justinbogner.com>
Fri, 10 Oct 2014 22:20:26 +0000 (22:20 +0000)
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

test/Misc/serialized-diags.m
tools/libclang/CXLoadedDiagnostic.cpp

index aac791e9e2872aa3fbdb6889910d2a6ee354bc8a..71c983b883853c8d95eae57bf5c4cc9aa80efc84 100644 (file)
@@ -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
index df8f41440ee0addeaf76c8b291e22df238bd9fbd..0e0075fc387ef8c779d6cf1d750c9580b95ac00a 100644 (file)
@@ -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;
 }