[PATCH] D20732: Don't use static variables in LambdaCapture

John Brawn via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 08:13:56 PDT 2016


john.brawn created this revision.
john.brawn added reviewers: faisalv, rsmith, jyknight.
john.brawn added a subscriber: cfe-commits.
john.brawn set the repository for this revision to rL LLVM.

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.

Repository:
  rL LLVM

http://reviews.llvm.org/D20732

Files:
  include/clang/AST/DeclBase.h
  include/clang/AST/LambdaCapture.h
  lib/AST/DeclBase.cpp
  lib/AST/ExprCXX.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20732.58787.patch
Type: text/x-patch
Size: 7234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160527/14499dd1/attachment-0001.bin>


More information about the cfe-commits mailing list