From 0a33e615f31ca2882893cf16f619e21632fbad66 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 1 Apr 2015 16:23:44 +0000 Subject: Mark instantiated function decls as inline specified if any pattern is A function template pattern can be declared without the 'inline' specifier and defined later with the 'inline' specifier. However, during instantiation, we were only looking at the canonical decl to see if we should mark the instantiated decl as inline specified. Since the instantiated decl actually represents many pattern declarations, put the inline specifier on the instantiation decl if any of the pattern decls have it. llvm-svn: 233817 --- clang/test/CodeGenCXX/inlinehint.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 clang/test/CodeGenCXX/inlinehint.cpp (limited to 'clang/test/CodeGenCXX/inlinehint.cpp') diff --git a/clang/test/CodeGenCXX/inlinehint.cpp b/clang/test/CodeGenCXX/inlinehint.cpp new file mode 100644 index 00000000000..57873b173da --- /dev/null +++ b/clang/test/CodeGenCXX/inlinehint.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s + +inline void InlineFunc() {} +// CHECK: define linkonce_odr void @_Z10InlineFuncv() #[[INLINEHINTATTR:[0-9]+]] comdat { + +struct MyClass { + static void InlineStaticMethod(); + void InlineInstanceMethod(); +}; +inline void MyClass::InlineStaticMethod() {} +// CHECK: define linkonce_odr void @_ZN7MyClass18InlineStaticMethodEv() #[[INLINEHINTATTR]] comdat +inline void MyClass::InlineInstanceMethod() {} +// CHECK: define linkonce_odr void @_ZN7MyClass20InlineInstanceMethodEv(%struct.MyClass* %this) #[[INLINEHINTATTR]] comdat + +template +struct MyTemplate { + static void InlineStaticMethod(); + void InlineInstanceMethod(); +}; +template inline void MyTemplate::InlineStaticMethod() {} +// CHECK: define linkonce_odr void @_ZN10MyTemplateIiE18InlineStaticMethodEv() #[[INLINEHINTATTR]] comdat +template inline void MyTemplate::InlineInstanceMethod() {} +// CHECK: define linkonce_odr void @_ZN10MyTemplateIiE20InlineInstanceMethodEv(%struct.MyTemplate* %this) #[[INLINEHINTATTR]] comdat + +void UseThem() { + InlineFunc(); + MyClass::InlineStaticMethod(); + MyClass().InlineInstanceMethod(); + MyTemplate::InlineStaticMethod(); + MyTemplate().InlineInstanceMethod(); +} + +// CHECK: attributes #[[INLINEHINTATTR]] = { {{.*}}inlinehint{{.*}} } -- cgit v1.2.3