Index: src/Common/CodeLocationTools.cpp
===================================================================
--- src/Common/CodeLocationTools.cpp	(revision d6089ad7235866e885b9e6c04142114be024a982)
+++ src/Common/CodeLocationTools.cpp	(revision c9e09916c73ec58be205cc286ab8d8e812ece871)
@@ -27,46 +27,4 @@
 struct has_code_location : public std::is_base_of<ast::ParseNode, node_t> {};
 
-// Fill every location
-class FillCore : public ast::WithGuards {
-	CodeLocation const * parent;
-
-	// This mimics a partially specialized method.
-	template<typename node_t, bool has_location>
-	struct FillNode;
-	template<typename node_t, bool has_location>
-	friend struct FillNode;
-
-	template<typename node_t>
-	struct FillNode<node_t, true> {
-		static node_t const * go( FillCore * core, node_t const * node ) {
-			node_t * newNode = nullptr;
-			if ( node->location.isUnset() ) {
-				// Just hoping that top level nodes are always marked.
-				assert( core->parent );
-				newNode = ast::mutate( node );
-				newNode->location = *core->parent;
-			}
-			core->GuardValue( core->parent );
-			core->parent = &node->location;
-			return (newNode) ? newNode : node;
-		}
-	};
-
-	template<typename node_t>
-	struct FillNode<node_t, false> {
-		static node_t const * go( FillCore *, node_t const * node ) {
-			return node;
-		}
-	};
-public:
-	FillCore() : parent( nullptr ) {}
-
-	template<typename node_t>
-	node_t const * previsit( node_t const * node ) {
-		using Filler = FillNode<node_t, has_code_location<node_t>::value>;
-		return Filler::go( this, node );
-	}
-};
-
 template<typename node_t, bool has_location>
 struct __GetCL;
@@ -74,5 +32,9 @@
 template<typename node_t>
 struct __GetCL<node_t, true> {
-	static CodeLocation const * get( node_t const * node ) {
+	static inline CodeLocation const * get( node_t const * node ) {
+		return &node->location;
+	}
+
+	static inline CodeLocation * get( node_t * node ) {
 		return &node->location;
 	}
@@ -81,5 +43,5 @@
 template<typename node_t>
 struct __GetCL<node_t, false> {
-	static CodeLocation const * get( node_t const * ) {
+	static inline CodeLocation * get( node_t const * ) {
 		return nullptr;
 	}
@@ -90,4 +52,34 @@
 	return __GetCL< node_t, has_code_location< node_t >::value >::get( node );
 }
+
+template<typename node_t>
+CodeLocation * get_code_location( node_t * node ) {
+	return __GetCL< node_t, has_code_location< node_t >::value >::get( node );
+}
+
+// Fill every location with a nearby (parent) location.
+class FillCore : public ast::WithGuards {
+	CodeLocation const * parent;
+public:
+	FillCore() : parent( nullptr ) {}
+
+	template<typename node_t>
+	node_t const * previsit( node_t const * node ) {
+		GuardValue( parent );
+		CodeLocation const * location = get_code_location( node );
+		if ( location && location->isUnset() ) {
+			assert( parent );
+			node_t * newNode = ast::mutate( node );
+			CodeLocation * newLocation = get_code_location( newNode );
+			assert( newLocation );
+			*newLocation = *parent;
+			parent = newLocation;
+			return newNode;
+		} else if ( location ) {
+			parent = location;
+		}
+		return node;
+	}
+};
 
 // Collect pointers to all the nodes with unset code locations.
