[PATCH] D41189: [Frontend] Treat function with skipped body as definition
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 10:32:26 PST 2017
ilya-biryukov created this revision.
ilya-biryukov added reviewers: bkramer, sepavloff.
This fixes an invalid warning about missing definition of a function when
parsing with SkipFunctionBodies=true
Repository:
rC Clang
https://reviews.llvm.org/D41189
Files:
include/clang/AST/Decl.h
test/Index/skipped_function_bodies.cpp
tools/libclang/CIndex.cpp
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -830,7 +830,6 @@
// FIXME: Attributes?
}
-
if (ND->doesThisDeclarationHaveABody() && !ND->isLateTemplateParsed()) {
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(ND)) {
// Find the initializers that were written in the source.
Index: test/Index/skipped_function_bodies.cpp
===================================================================
--- /dev/null
+++ 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
Index: include/clang/AST/Decl.h
===================================================================
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1967,8 +1967,8 @@
/// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41189.126786.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171213/08d7979b/attachment.bin>
More information about the cfe-commits
mailing list