r320696 - [Frontend] Treat function with skipped body as definition

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 05:00:33 PST 2017


Author: ibiryukov
Date: Thu Dec 14 05:00:33 2017
New Revision: 320696

URL: http://llvm.org/viewvc/llvm-project?rev=320696&view=rev
Log:
[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

Added:
    cfe/trunk/test/Index/skipped_function_bodies.cpp
Modified:
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=320696&r1=320695&r2=320696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Dec 14 05:00:33 2017
@@ -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

Added: cfe/trunk/test/Index/skipped_function_bodies.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/skipped_function_bodies.cpp?rev=320696&view=auto
==============================================================================
--- cfe/trunk/test/Index/skipped_function_bodies.cpp (added)
+++ cfe/trunk/test/Index/skipped_function_bodies.cpp Thu Dec 14 05:00:33 2017
@@ -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




More information about the cfe-commits mailing list