>From 44f9deeecbcdef32096f0ac692be80ab9dd17fae Mon Sep 17 00:00:00 2001
From: Olivier Goffart <[email protected]>
Date: Sun, 26 Jan 2014 19:10:59 +0100
Subject: [PATCH] CommentParser: Fix crash in parsing @deprecated command
If there is no declaration, ThisDeclInfo is 0.
All the others function check if ThisDeclInfo is not null, so should
checkDeprecatedCommand.
---
lib/AST/CommentSema.cpp | 3 +++
unittests/AST/CommentParser.cpp | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp
index d324c5c..2400ecc 100644
--- a/lib/AST/CommentSema.cpp
+++ b/lib/AST/CommentSema.cpp
@@ -636,6 +636,9 @@ void Sema::checkDeprecatedCommand(const BlockCommandComment *Command) {
if (!Traits.getCommandInfo(Command->getCommandID())->IsDeprecatedCommand)
return;
+ if (!ThisDeclInfo)
+ return;
+
const Decl *D = ThisDeclInfo->CommentDecl;
if (!D)
return;
diff --git a/unittests/AST/CommentParser.cpp b/unittests/AST/CommentParser.cpp
index f75c636..6f2824b 100644
--- a/unittests/AST/CommentParser.cpp
+++ b/unittests/AST/CommentParser.cpp
@@ -1420,6 +1420,20 @@ TEST_F(CommentParserTest, VerbatimLine2) {
}
}
+TEST_F(CommentParserTest, Deprecated) {
+ const char *Sources[] = {
+ "/** @deprecated */",
+ "/// @deprecated \n"
+ };
+
+ for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+ FullComment *FC = parseString(Sources[i]);
+ ASSERT_TRUE(HasChildCount(FC, 2));
+
+ ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
+ }
+}
+
} // unnamed namespace
} // end namespace comments
--
1.8.5.3
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits