From c55c6fc6e38c31fafa767b71ad496539c700c075 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Wed, 19 Dec 2012 17:34:55 +0000 Subject: [PATCH] Fix PR14591: Windows newlines in doxygen comments cause failed assertion in TextDiagnostic Patch by Janusz Chorko. llvm-svn: 170566 --- clang/lib/AST/CommentParser.cpp | 3 +-- clang/test/Sema/warn-documentation-crlf.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/warn-documentation-crlf.c diff --git a/clang/lib/AST/CommentParser.cpp b/clang/lib/AST/CommentParser.cpp index 7113f14..a7ba013 100644 --- a/clang/lib/AST/CommentParser.cpp +++ b/clang/lib/AST/CommentParser.cpp @@ -175,8 +175,7 @@ public: memcpy(TextPtr, WordText.c_str(), Length + 1); StringRef Text = StringRef(TextPtr, Length); - formTokenWithChars(Tok, Loc, WordBegin, - Pos.BufferPtr - WordBegin, Text); + formTokenWithChars(Tok, Loc, WordBegin, Length, Text); return true; } diff --git a/clang/test/Sema/warn-documentation-crlf.c b/clang/test/Sema/warn-documentation-crlf.c new file mode 100644 index 0000000..99c0714 --- /dev/null +++ b/clang/test/Sema/warn-documentation-crlf.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation %s +// The run line does not have '-verify' because we were crashing while printing +// the diagnostic. + +// This file has DOS-style line endings (CR LF). Please don't change it to +// Unix-style LF! + +// PR14591. Check that we don't crash on this. +/** + * @param abc + */ +void nocrash1(int qwerty); + -- 2.7.4