summaryrefslogtreecommitdiffstats
path: root/clang/include/clang/AST/MangleNumberingContext.h
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-09-10 20:14:30 +0000
committerReid Kleckner <reid@kleckner.net>2013-09-10 20:14:30 +0000
commitd8110b6558ad111a1c1c1542c12122900791311e (patch)
treef33978db28811dcedd14fcba833b925738598b84 /clang/include/clang/AST/MangleNumberingContext.h
parent1cee407a9b5cec3251157378e9d44dacae51b68d (diff)
downloadbcm5719-llvm-d8110b6558ad111a1c1c1542c12122900791311e.tar.gz
bcm5719-llvm-d8110b6558ad111a1c1c1542c12122900791311e.zip
[ms-cxxabi] Implement guard variables for static initialization
Static locals requiring initialization are not thread safe on Windows. Unfortunately, it's possible to create static locals that are actually externally visible with inline functions and templates. As a result, we have to implement an initialization guard scheme that is compatible with TUs built by MSVC, which makes thread safety prohibitively difficult. MSVC's scheme is that every function that requires a guard gets an i32 bitfield. Each static local is assigned a bit that indicates if it has been initialized, up to 32 bits, at which point a new bitfield is created. MSVC rejects inline functions with more than 32 static locals, and the externally visible mangling (?_B) only allows for one guard variable per function. On Eli's recommendation, I used MangleNumberingContext to track which bit each static corresponds to. Implements PR16888. Reviewers: rjmccall, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1416 llvm-svn: 190427
Diffstat (limited to 'clang/include/clang/AST/MangleNumberingContext.h')
-rw-r--r--clang/include/clang/AST/MangleNumberingContext.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/include/clang/AST/MangleNumberingContext.h b/clang/include/clang/AST/MangleNumberingContext.h
index 4f81e0c5548..5a227f201fb 100644
--- a/clang/include/clang/AST/MangleNumberingContext.h
+++ b/clang/include/clang/AST/MangleNumberingContext.h
@@ -33,10 +33,11 @@ class VarDecl;
class MangleNumberingContext
: public RefCountedBase<MangleNumberingContext> {
llvm::DenseMap<const Type *, unsigned> ManglingNumbers;
- llvm::DenseMap<IdentifierInfo*, unsigned> VarManglingNumbers;
llvm::DenseMap<IdentifierInfo*, unsigned> TagManglingNumbers;
public:
+ virtual ~MangleNumberingContext() {}
+
/// \brief Retrieve the mangling number of a new lambda expression with the
/// given call operator within this context.
unsigned getManglingNumber(const CXXMethodDecl *CallOperator);
@@ -47,7 +48,7 @@ public:
/// \brief Retrieve the mangling number of a static local variable within
/// this context.
- unsigned getManglingNumber(const VarDecl *VD);
+ virtual unsigned getManglingNumber(const VarDecl *VD) = 0;
/// \brief Retrieve the mangling number of a static local variable within
/// this context.
OpenPOWER on IntegriCloud