From f38a7e77a530c9c439c9b49f033deabf00a569bd Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 14 Dec 2017 13:00:33 +0000 Subject: [PATCH] [Frontend] Treat function with skipped body as definition Summary: This fixes an invalid warning about missing definition of a function when parsing with SkipFunctionBodies=true Reviewers: bkramer, sepavloff Reviewed By: sepavloff Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41189 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320696 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Decl.h | 4 ++-- test/Index/skipped_function_bodies.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/Index/skipped_function_bodies.cpp diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 3bf79bba8f..2f9d4dfde1 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1967,8 +1967,8 @@ public: /// This does not determine whether the function has been defined (e.g., in a /// previous definition); for that information, use isDefined. bool isThisDeclarationADefinition() const { - return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed || - WillHaveBody || hasDefiningAttr(); + return IsDeleted || IsDefaulted || Body || HasSkippedBody || + IsLateTemplateParsed || WillHaveBody || hasDefiningAttr(); } /// doesThisDeclarationHaveABody - Returns whether this specific diff --git a/test/Index/skipped_function_bodies.cpp b/test/Index/skipped_function_bodies.cpp new file mode 100644 index 0000000000..4258f71f42 --- /dev/null +++ b/test/Index/skipped_function_bodies.cpp @@ -0,0 +1,9 @@ +// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s 2>&1 \ +// RUN: | FileCheck %s + +inline int with_body() { return 10; } +inline int without_body(); + +int x = with_body() + without_body(); +// CHECK: warning: inline function 'without_body' is not defined +// CHECK-NOT: warning: inline function 'with_body' is not defined -- 2.50.1