diff options
author | John Brawn <john.brawn@arm.com> | 2016-06-15 14:14:51 +0000 |
---|---|---|
committer | John Brawn <john.brawn@arm.com> | 2016-06-15 14:14:51 +0000 |
commit | 6be9afbe2802b2acc8403ce4c75a10f7fbeabd88 (patch) | |
tree | 51201380a27e68fb9fe7976181a1925c097c1651 /include/clang/AST/DeclBase.h | |
parent | 6411069e7ccde19b551d39f6f233c6551dc0f1f8 (diff) |
Don't use static variables in LambdaCapture
When static variables are used in inline functions in header files anything that
uses that function ends up with a reference to the variable. Because
RecursiveASTVisitor uses the inline functions in LambdaCapture that use static
variables any AST plugin that uses RecursiveASTVisitor, such as the
PrintFunctionNames example, ends up with a reference to these variables. This is
bad on Windows when building with MSVC with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON
as variables used across a DLL boundary need to be explicitly dllimported in
the DLL using them.
This patch avoids that by adjusting LambdaCapture to be similar to before
r263921, with a capture of either 'this' or a VLA represented by a null Decl
pointer in DeclAndBits with an extra flag added to the bits to distinguish
between the two. This requires the use of an extra bit, and while Decl does
happen to be sufficiently aligned to allow this it's done in a way that means
PointerIntPair doesn't realise it and gives an assertion failure. Therefore I
also adjust Decl slightly to use LLVM_ALIGNAS to allow this.
Differential Revision: http://reviews.llvm.org/D20732
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/DeclBase.h')
-rw-r--r-- | include/clang/AST/DeclBase.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 26cbd3802f..ec8bb3aaa3 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -73,13 +73,10 @@ namespace clang { /// /// Note: There are objects tacked on before the *beginning* of Decl /// (and its subclasses) in its Decl::operator new(). Proper alignment -/// of all subclasses (not requiring more than DeclObjAlignment) is +/// of all subclasses (not requiring more than the alignment of Decl) is /// asserted in DeclBase.cpp. -class Decl { +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) Decl { public: - /// \brief Alignment guaranteed when allocating Decl and any subtypes. - enum { DeclObjAlignment = llvm::AlignOf<uint64_t>::Alignment }; - /// \brief Lists the kind of concrete classes of Decl. enum Kind { #define DECL(DERIVED, BASE) DERIVED, |