mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Add IdString const &id_string() const to StaticIdString and IdString
The vast majority of ID(...) uses are in a context that is overloaded for StaticIdString or will cause implicit conversion to an IdString constant reference. For some sufficently overloaded contexts, implicit conversion may fail, so it's useful to have a method to force obtaining a `IdString const &` from an ID(...) use. When turning all literal IdStrings of the codebase into StaticIdStrings this was needed in exactly one place, for which this commit adds an `id_string()` call.
This commit is contained in:
		
							parent
							
								
									3ebecb631c
								
							
						
					
					
						commit
						b6db32873d
					
				
					 2 changed files with 4 additions and 1 deletions
				
			
		|  | @ -121,6 +121,7 @@ namespace RTLIL | |||
| 		constexpr StaticIdString(StaticId id, const IdString &id_str) : id_str(id_str), id(id) {} | ||||
| 		constexpr inline operator const IdString &() const { return id_str; } | ||||
| 		constexpr inline int index() const { return static_cast<short>(id); } | ||||
| 		constexpr inline const IdString &id_string() const { return id_str; } | ||||
| 
 | ||||
| 		const IdString &id_str; | ||||
| 		const StaticId id; | ||||
|  | @ -343,6 +344,8 @@ struct RTLIL::IdString | |||
| 		*this = id; | ||||
| 	} | ||||
| 
 | ||||
| 	constexpr inline const IdString &id_string() const { return *this; } | ||||
| 
 | ||||
| 	inline const char *c_str() const { | ||||
| 		return global_id_storage_.at(index_); | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue