From e26aea5b290165f3bccffab662a706d4a56f7540 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 6 Aug 2015 18:46:36 +0000 Subject: [PATCH] [Frontend] Fix crash when serializing diagnostics with really long text. rdar://21896690 llvm-svn: 244245 --- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp | 2 +- .../Misc/serialized-diags-really-long-text.cpp | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 clang/test/Misc/serialized-diags-really-long-text.cpp diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index d31b12e..f63f9ef 100644 --- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -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)); diff --git a/clang/test/Misc/serialized-diags-really-long-text.cpp b/clang/test/Misc/serialized-diags-really-long-text.cpp new file mode 100644 index 0000000..2cdd509 --- /dev/null +++ b/clang/test/Misc/serialized-diags-really-long-text.cpp @@ -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 +struct MyTS { + typedef MyTS type; + static type callme() { + return type::callme(); + } +}; + +template +struct MyTS<0, T...> {}; + +void foo() { + // CHECK: [[@LINE+1]]:20: note: in instantiation of member function + int e = MyTS<2>::callme(); +} -- 2.7.4