diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-28 06:37:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-28 06:37:30 +0000 |
commit | 9f9bf258f8ebae30bfb70feb9d797d6eb67b0460 (patch) | |
tree | a7b60bcf16c7d500d0c628be8008637d87c1d490 /lib/AST/Decl.cpp | |
parent | a902d5599961dbeb91631ec912fae6a10f6c2839 (diff) |
Improve compatibility with GCC regarding inline semantics in GNU89
mode and in the presence of __gnu_inline__ attributes. This should fix
both PR3989 and PR4069.
As part of this, we now keep track of all of the attributes attached
to each declaration even after we've performed declaration
merging. This fixes PR3264.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70292 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index aa0fc702a4..9aba33c943 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -468,6 +468,30 @@ unsigned FunctionDecl::getMinRequiredArguments() const { return NumRequiredArgs; } +bool FunctionDecl::hasActiveGNUInlineAttribute() const { + if (!isInline() || !hasAttr<GNUInlineAttr>()) + return false; + + for (const FunctionDecl *FD = getPreviousDeclaration(); FD; + FD = FD->getPreviousDeclaration()) { + if (FD->isInline() && !FD->hasAttr<GNUInlineAttr>()) + return false; + } + + return true; +} + +bool FunctionDecl::isExternGNUInline() const { + if (!hasActiveGNUInlineAttribute()) + return false; + + for (const FunctionDecl *FD = this; FD; FD = FD->getPreviousDeclaration()) + if (FD->getStorageClass() == Extern && FD->hasAttr<GNUInlineAttr>()) + return true; + + return false; +} + /// getOverloadedOperator - Which C++ overloaded operator this /// function represents, if any. OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const { |