[cfe-commits] r85307 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp

Douglas Gregor dgregor at apple.com
Tue Oct 27 14:11:48 PDT 2009


Author: dgregor
Date: Tue Oct 27 16:11:48 2009
New Revision: 85307

URL: http://llvm.org/viewvc/llvm-project?rev=85307&view=rev
Log:
Introduce FunctionDecl::isInlined() to tell whether a function should
be inlined.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=85307&r1=85306&r2=85307&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 27 16:11:48 2009
@@ -1051,6 +1051,11 @@
   /// Set whether the "inline" keyword was specified for this function.
   void setInlineSpecified(bool I) { IsInline = I; }
 
+  /// \brief Determine whether this function should be inlined, because it is
+  /// either marked "inline" or is a member function of a C++ class that
+  /// was defined in the class body.
+  bool isInlined() const;
+                       
   bool isInlineDefinitionExternallyVisible() const;
                        
   /// isOverloadedOperator - Whether this function declaration

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=85307&r1=85306&r2=85307&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 27 16:11:48 2009
@@ -642,6 +642,10 @@
   return NumRequiredArgs;
 }
 
+bool FunctionDecl::isInlined() const {
+  return isInlineSpecified() || (isa<CXXMethodDecl>(this) && !isOutOfLine());
+}
+
 /// \brief For an inline function definition in C, determine whether the 
 /// definition will be externally visible.
 ///
@@ -661,7 +665,7 @@
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
   assert(isThisDeclarationADefinition() && "Must have the function definition");
-  assert(isInlineSpecified() && "Function must be inline");
+  assert(isInlined() && "Function must be inline");
   
   if (!getASTContext().getLangOptions().C99 || hasAttr<GNUInlineAttr>()) {
     // GNU inline semantics. Based on a number of examples, we came up with the
@@ -786,8 +790,7 @@
   if (!Pattern || !PatternDecl)
     return true;
 
-  return PatternDecl->isInlineSpecified() || 
-    (isa<CXXMethodDecl>(PatternDecl) && !PatternDecl->isOutOfLine());
+  return PatternDecl->isInlined();
 }                      
    
 FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=85307&r1=85306&r2=85307&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Oct 27 16:11:48 2009
@@ -262,7 +262,7 @@
 
   if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
     // C++ member functions defined inside the class are always inline.
-    if (MD->isInlineSpecified() || !MD->isOutOfLine())
+    if (MD->isInlined())
       return CodeGenModule::GVA_CXXInline;
 
     return External;
@@ -272,7 +272,7 @@
   if (FD->getStorageClass() == FunctionDecl::Static)
     return CodeGenModule::GVA_Internal;
 
-  if (!FD->isInlineSpecified())
+  if (!FD->isInlined())
     return External;
 
   if (!Features.CPlusPlus || FD->hasAttr<GNUInlineAttr>()) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=85307&r1=85306&r2=85307&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Oct 27 16:11:48 2009
@@ -1127,7 +1127,7 @@
   //   to which they refer.
   if (Function->getTemplateSpecializationKind()
         == TSK_ExplicitInstantiationDeclaration &&
-      PatternDecl->isOutOfLine() && !PatternDecl->isInlineSpecified())
+      !PatternDecl->isInlined())
     return;
 
   InstantiatingTemplate Inst(*this, PointOfInstantiation, Function);





More information about the cfe-commits mailing list