Index: src/AST/Expr.cpp
===================================================================
--- src/AST/Expr.cpp	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ src/AST/Expr.cpp	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -264,4 +264,10 @@
 }
 
+ConstantExpr * ConstantExpr::from_ulonglong( const CodeLocation & loc, unsigned long long i ) {
+	return new ConstantExpr{
+		loc, new BasicType{ BasicKind::LongLongUnsignedInt }, std::to_string( i ) + "ULL",
+		(unsigned long long)i };
+}
+
 ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & str ) {
 	const Type * charType = new BasicType( BasicKind::Char, ast::CV::Const );
Index: src/AST/Expr.hpp
===================================================================
--- src/AST/Expr.hpp	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ src/AST/Expr.hpp	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -464,4 +464,6 @@
 	/// Generates an integer constant of the given unsigned long int.
 	static ConstantExpr * from_ulong( const CodeLocation & loc, unsigned long i );
+	/// Generates an integer constant of the given unsigned long long int.
+	static ConstantExpr * from_ulonglong( const CodeLocation & loc, unsigned long long i );
 	/// Generates a string constant from the given string (char type, unquoted string).
 	static ConstantExpr * from_string( const CodeLocation & loc, const std::string & string );
Index: src/Concurrency/MutexFuncHash.hpp
===================================================================
--- src/Concurrency/MutexFuncHash.hpp	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ src/Concurrency/MutexFuncHash.hpp	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -18,5 +18,4 @@
 #include "AST/Decl.hpp"
 #include "AST/Expr.hpp"
-#include "AST/Type.hpp"
 #include "SymTab/Mangler.hpp"
 
@@ -27,5 +26,5 @@
 // since function pointers may differ for static inline functions.
 static inline uint64_t hashMangle( const ast::DeclWithType * decl ) {
-	std::string name = Mangle::mangle( decl );
+	std::string name = Mangle::mangleType( decl );
 	uint64_t hash = 14695981039346656037ULL; // FNV offset basis
 	for ( char c : name ) {
@@ -36,14 +35,8 @@
 }
 
-// Create a ConstantExpr for the hash with proper ULL suffix to avoid
-// C compiler warnings about large unsigned constants.
-static inline ast::ConstantExpr * hashMangleExpr(
-		const CodeLocation & location, const ast::DeclWithType * decl ) {
-	uint64_t hash = hashMangle( decl );
-	return new ast::ConstantExpr{
-		location,
-		new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt },
-		std::to_string( hash ) + "ull",
-		(unsigned long long)hash };
+// Create a ConstantExpr with the hash of the mangled name.
+static inline ast::ConstantExpr * hashMangleExpr( 
+	const CodeLocation & location, const ast::DeclWithType * decl ) {
+	return ast::ConstantExpr::from_ulonglong( location, hashMangle( decl ) );
 }
 
Index: sts/.expect/linkoncedestructor.txt
===================================================================
--- tests/.expect/linkoncedestructor.txt	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ 	(revision )
@@ -1,1 +1,0 @@
-Destructor called
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ tests/Makefile.am	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -119,5 +119,5 @@
 .PHONY : concurrency list .validate .test_makeflags
 .INTERMEDIATE : .validate .validate.cfa .test_makeflags
-EXTRA_PROGRAMS = array-collections/boxed avl_test linkonce linkoncedestructor linking/mangling/anon .dummy_hack # build but do not install
+EXTRA_PROGRAMS = array-collections/boxed avl_test linkonce concurrency/waitfor/autogen_destructor linking/mangling/anon .dummy_hack # build but do not install
 EXTRA_DIST = test.py \
 	pybin/__init__.py \
@@ -154,5 +154,5 @@
 avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
 linkonce_SOURCES = link-once/main.cfa link-once/partner.cfa
-linkoncedestructor_SOURCES = link-once-destructor/waitfor-destructor.cfa link-once-destructor/nodestructor.cfa
+concurrency_waitfor_autogen_destructor_SOURCES = concurrency/waitfor/autogen_destructor.cfa concurrency/waitfor/nodestructor.cfa
 linking_mangling_anon_SOURCES = linking/mangling/header.hfa linking/mangling/lib.cfa linking/mangling/main.cfa
 # automake doesn't know we still need C/CPP rules so pretend like we have a C program
Index: tests/concurrency/waitfor/.expect/autogen_destructor.txt
===================================================================
--- tests/concurrency/waitfor/.expect/autogen_destructor.txt	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/.expect/autogen_destructor.txt	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,1 @@
+Destructor called
Index: tests/concurrency/waitfor/.expect/static_inline.txt
===================================================================
--- tests/concurrency/waitfor/.expect/static_inline.txt	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/.expect/static_inline.txt	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,2 @@
+Cleaning
+Done
Index: tests/concurrency/waitfor/autogen_destructor.cfa
===================================================================
--- tests/concurrency/waitfor/autogen_destructor.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/autogen_destructor.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,5 @@
+#include "nodestructor.hfa"
+
+int main(int, char*[]) {
+	MyThread t;
+}
Index: tests/concurrency/waitfor/nodestructor.cfa
===================================================================
--- tests/concurrency/waitfor/nodestructor.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/nodestructor.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,8 @@
+#include "nodestructor.hfa"
+
+#include <fstream.hfa>
+
+void main(MyThread &t) {
+	waitfor(^?{} : t);
+	sout | "Destructor called";
+}
Index: tests/concurrency/waitfor/nodestructor.hfa
===================================================================
--- tests/concurrency/waitfor/nodestructor.hfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/nodestructor.hfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,5 @@
+#include <thread.hfa>
+
+thread MyThread {};
+
+void main(MyThread &t);
Index: tests/concurrency/waitfor/static_inline.cfa
===================================================================
--- tests/concurrency/waitfor/static_inline.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
+++ tests/concurrency/waitfor/static_inline.cfa	(revision f1cb1937a0ab02686fc201e2066ee4fc8a157ce6)
@@ -0,0 +1,25 @@
+#include <fstream.hfa>
+#include <thread.hfa>
+
+thread Cleaner {};
+
+static inline void ^?{} ( Cleaner &mutex this ) {}
+
+static inline void cleanup( Cleaner &mutex this ) {}
+
+void main( Cleaner & this ) {
+	waitfor( cleanup : this ) {
+		sout | "Cleaning";
+	}
+
+	waitfor( ^?{} : this ) {
+		sout | "Done";
+	}
+}
+
+int main() {
+    // Creates a thread that will call the destructor
+    // when the thread exits
+	Cleaner c;
+	cleanup( c );
+}
Index: sts/link-once-destructor/nodestructor.cfa
===================================================================
--- tests/link-once-destructor/nodestructor.cfa	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ 	(revision )
@@ -1,8 +1,0 @@
-#include "nodestructor.hfa"
-
-#include <fstream.hfa>
-
-void main(MyThread &t) {
-	waitfor(^?{} : t);
-	sout | "Destructor called";
-}
Index: sts/link-once-destructor/nodestructor.hfa
===================================================================
--- tests/link-once-destructor/nodestructor.hfa	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#include <thread.hfa>
-
-thread MyThread {};
-
-void main(MyThread &t); 
Index: sts/link-once-destructor/waitfor-destructor.cfa
===================================================================
--- tests/link-once-destructor/waitfor-destructor.cfa	(revision a30fceb1a73c4ef2bbee39a2b5406da881f51111)
+++ 	(revision )
@@ -1,8 +1,0 @@
-#include "nodestructor.hfa"
-
-int main(int, char*[]) {
-	MyThread ahhh; // call destructor after
-
-	// waits for its own destructor to be called
-}
-
