From: Eli Friedman Date: Tue, 10 Sep 2013 22:57:15 +0000 (+0000) Subject: Add unused markings to suppress warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bafe46fe35ff58cc10487ba8bdcbcccd6d3319e7;p=clang Add unused markings to suppress warnings. trunk clang is a bit more aggressive about emitting unused-declaration warnings, so adjust some AST code to match. Specifically, use LLVM_ATTRIBUTE_UNUSED for declarations which are never supposed to be referenced, and turn references to declarations which are supposed to be referenced into odr-uses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190443 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp index 79cabdb776..f24a23d34c 100644 --- a/lib/AST/Comment.cpp +++ b/lib/AST/Comment.cpp @@ -42,14 +42,16 @@ good implements_child_begin_end(Comment::child_iterator (T::*)() const) { return good(); } +LLVM_ATTRIBUTE_UNUSED static inline bad implements_child_begin_end( Comment::child_iterator (Comment::*)() const) { return bad(); } #define ASSERT_IMPLEMENTS_child_begin(function) \ - (void) sizeof(good(implements_child_begin_end(function))) + (void) good(implements_child_begin_end(function)) +LLVM_ATTRIBUTE_UNUSED static inline void CheckCommentASTNodes() { #define ABSTRACT_COMMENT(COMMENT) #define COMMENT(CLASS, PARENT) \ diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index b83bd7f5d6..0321592744 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -135,6 +135,7 @@ namespace { template good implements_children(children_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_children(children_t Stmt::*) { return bad(); } @@ -143,6 +144,7 @@ namespace { template good implements_getLocStart(getLocStart_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_getLocStart(getLocStart_t Stmt::*) { return bad(); } @@ -151,20 +153,22 @@ namespace { template good implements_getLocEnd(getLocEnd_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) { return bad(); } #define ASSERT_IMPLEMENTS_children(type) \ - (void) sizeof(is_good(implements_children(&type::children))) + (void) is_good(implements_children(&type::children)) #define ASSERT_IMPLEMENTS_getLocStart(type) \ - (void) sizeof(is_good(implements_getLocStart(&type::getLocStart))) + (void) is_good(implements_getLocStart(&type::getLocStart)) #define ASSERT_IMPLEMENTS_getLocEnd(type) \ - (void) sizeof(is_good(implements_getLocEnd(&type::getLocEnd))) + (void) is_good(implements_getLocEnd(&type::getLocEnd)) } /// Check whether the various Stmt classes implement their member /// functions. +LLVM_ATTRIBUTE_UNUSED static inline void check_implementations() { #define ABSTRACT_STMT(type) #define STMT(type, base) \