[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: [PATCH] Fix crash in comments::Sema::checkDeprecatedCommand
From: Olivier Goffart <ogoffart () kde ! org>
Date: 2014-01-26 18:18:27
Message-ID: 1641863.3YTRKMr479 () finn
[Download RAW message or body]
["0001-CommentParser-Fix-crash-in-parsing-deprecated-comman.patch" (0001-CommentParser-Fix-crash-in-parsing-deprecated-comman.patch)]
From 44f9deeecbcdef32096f0ac692be80ab9dd17fae Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@woboq.com>
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
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic