Commits

Arnold Schwaighofer committed 989d554a455
Add support for an assert_configuration builtin function This patch adds support for a builtin function assert_configuration that is replaced by constant progpagation by an appropriate value dependent on a compile time setting. This replacement can also be disabled when serializing sil for a library. Using this mechanism we implement assertions that can be disabled (or whose behavior changes) depending on compile time build settings (Debug, Release, DisableReplacement). In the standard library we can now write one assert function that uses this builtin function to provide different compile time selectable runtime behavior. Example Assert.swift: @transparent func assert<T : LogicValue>( condition: @auto_closure () -> T, message: StaticString = StaticString(), // Do not supply these parameters explicitly; they will be filled in // by the compiler and aren't even present when asserts are disabled file: StaticString = __FILE__, line: UWord = __LINE__ ) { // Only in debug mode. if _isDebug() { assert(condition().getLogicValue(), message, file, line) } } AssertCommon.swift: @transparent func _isDebug() -> Bool { return Int32(Builtin.assert_configuration()) == 0; } rdar://16458612 Swift SVN r16472