r244245 - [Frontend] Fix crash when serializing diagnostics with really long text.

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 6 11:46:36 PDT 2015


Author: akirtzidis
Date: Thu Aug  6 13:46:36 2015
New Revision: 244245

URL: http://llvm.org/viewvc/llvm-project?rev=244245&view=rev
Log:
[Frontend] Fix crash when serializing diagnostics with really long text.

rdar://21896690

Added:
    cfe/trunk/test/Misc/serialized-diags-really-long-text.cpp
Modified:
    cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=244245&r1=244244&r2=244245&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Thu Aug  6 13:46:36 2015
@@ -478,7 +478,7 @@ void SDiagsWriter::EmitBlockInfoBlock()
   AddSourceLocationAbbrev(Abbrev);
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Category.  
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Mapped Diag ID.
-  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Text size.
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Text size.
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Diagnostc text.
   Abbrevs.set(RECORD_DIAG, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG, Abbrev));
   

Added: cfe/trunk/test/Misc/serialized-diags-really-long-text.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags-really-long-text.cpp?rev=244245&view=auto
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags-really-long-text.cpp (added)
+++ cfe/trunk/test/Misc/serialized-diags-really-long-text.cpp Thu Aug  6 13:46:36 2015
@@ -0,0 +1,30 @@
+// Make sure that diagnostics serialization does not crash with a really long diagnostic text.
+
+// RUN: not %clang_cc1 -std=c++11 %s -serialize-diagnostic-file %t.dia
+// RUN: c-index-test -read-diagnostics %t.dia 2>&1 | FileCheck %s
+
+typedef class AReallyLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName {} alias;
+
+template <int N, typename ...T>
+struct MyTS {
+  typedef MyTS<N-1, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias,
+    alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, alias, T...> type;
+  static type callme() {
+    return type::callme();
+  }
+};
+
+template <typename ...T>
+struct MyTS<0, T...> {};
+
+void foo() {
+  // CHECK: [[@LINE+1]]:20: note: in instantiation of member function
+  int e = MyTS<2>::callme();
+}




More information about the cfe-commits mailing list