summaryrefslogtreecommitdiffstats
path: root/docs/LanguageExtensions.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/LanguageExtensions.html')
-rw-r--r--docs/LanguageExtensions.html120
1 files changed, 114 insertions, 6 deletions
diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html
index 68f0afc..eac3c69 100644
--- a/docs/LanguageExtensions.html
+++ b/docs/LanguageExtensions.html
@@ -91,18 +91,24 @@
<li><a href="#objc_arc">Automatic reference counting</a></li>
<li><a href="#objc_fixed_enum">Enumerations with a fixed underlying type</a></li>
<li><a href="#objc_lambdas">Interoperability with C++11 lambdas</a></li>
- <li><a href="#object-literals-subscripting">Object Literals and Subscripting</a></li>
+ <li><a href="#objc_object_literals_subscripting">Object Literals and Subscripting</a></li>
</ul>
</li>
<li><a href="#overloading-in-c">Function Overloading in C</a></li>
<li><a href="#complex-list-init">Initializer lists for complex numbers in C</a></li>
<li><a href="#builtins">Builtin Functions</a>
<ul>
+ <li><a href="#__builtin_readcyclecounter">__builtin_readcyclecounter</a></li>
<li><a href="#__builtin_shufflevector">__builtin_shufflevector</a></li>
<li><a href="#__builtin_unreachable">__builtin_unreachable</a></li>
<li><a href="#__sync_swap">__sync_swap</a></li>
</ul>
</li>
+<li><a href="#non-standard-attributes">Non-standard C++11 Attributes</a>
+<ul>
+ <li><a href="#clang__fallthrough">The <tt>clang::fallthrough</tt> attribute</a></li>
+</ul>
+</li>
<li><a href="#targetspecific">Target-Specific Extensions</a>
<ul>
<li><a href="#x86-specific">X86/X86-64 Language Extensions</a></li>
@@ -655,7 +661,7 @@ framework search path. For consistency, we recommend that such files never be
included in installed versions of the framework.</p>
<!-- ======================================================================= -->
-<h2 id="availability">Availability attribute</h2
+<h2 id="availability">Availability attribute</h2>
<!-- ======================================================================= -->
<p>Clang introduces the <code>availability</code> attribute, which can
@@ -937,8 +943,8 @@ is enabled.</p>
<p>Use <tt>__has_feature(c_atomic)</tt> or <tt>__has_extension(c_atomic)</tt>
to determine if support for atomic types using <tt>_Atomic</tt> is enabled.
Clang also provides <a href="#__c11_atomic">a set of builtins</a> which can be
-used to implement the <tt>&lt;stdatomic.h&gt;</tt> operations on _Atomic
-types.</p>
+used to implement the <tt>&lt;stdatomic.h&gt;</tt> operations on
+<tt>_Atomic</tt> types.</p>
<h4 id="c_generic_selections">C11 generic selections</h4>
@@ -1183,10 +1189,28 @@ in Objective-C++, and not in C++ with blocks, due to its use of
Objective-C memory management (autorelease).</p>
<!-- ======================================================================= -->
-<h2 id="object-literals-subscripting">Object Literals and Subscripting</h2>
+<h2 id="objc_object_literals_subscripting">Object Literals and Subscripting</h2>
+<!-- ======================================================================= -->
+
+<p>Clang provides support for <a href="ObjectiveCLiterals.html">Object Literals
+and Subscripting</a> in Objective-C, which simplifies common Objective-C
+programming patterns, makes programs more concise, and improves the safety of
+container creation. There are several feature macros associated with object
+literals and subscripting: <code>__has_feature(objc_array_literals)</code>
+tests the availability of array literals;
+<code>__has_feature(objc_dictionary_literals)</code> tests the availability of
+dictionary literals; <code>__has_feature(objc_subscripting)</code> tests the
+availability of object subscripting.</p>
+
+<!-- ======================================================================= -->
+<h2 id="objc_default_synthesize_properties">Objective-C Autosynthesis of Properties</h2>
<!-- ======================================================================= -->
-<p>Clang provides support for <a href="ObjectiveCLiterals.html">Object Literals and Subscripting</a> in Objective-C, which simplifies common Objective-C programming patterns, makes programs more concise, and improves the safety of container creation. There are several feature macros associated with object literals and subscripting: <code>__has_feature(objc_array_literals)</code> tests the availability of array literals; <code>__has_feature(objc_dictionary_literals)</code> tests the availability of dictionary literals; <code>__has_feature(objc_subscripting)</code> tests the availability of object subscripting.</p>
+<p> Clang provides support for autosynthesis of declared properties. Using this
+feature, clang provides default synthesis of those properties not declared @dynamic
+and not having user provided backing getter and setter methods.
+<code>__has_feature(objc_default_synthesize_properties)</code> checks for availability
+of this feature in version of clang being used.</p>
<!-- ======================================================================= -->
<h2 id="overloading-in-c">Function Overloading in C</h2>
@@ -1344,6 +1368,42 @@ vector support</a> instead of builtins, in order to reduce the number of
builtins that we need to implement.</p>
<!-- ======================================================================= -->
+<h3><a name="__builtin_readcyclecounter">__builtin_readcyclecounter</a></h3>
+<!-- ======================================================================= -->
+
+<p><tt>__builtin_readcyclecounter</tt> is used to access the cycle counter
+register (or a similar low-latency, high-accuracy clock) on those targets that
+support it.
+</p>
+
+<p><b>Syntax:</b></p>
+
+<pre>
+__builtin_readcyclecounter()
+</pre>
+
+<p><b>Example of Use:</b></p>
+
+<pre>
+unsigned long long t0 = __builtin_readcyclecounter();
+do_something();
+unsigned long long t1 = __builtin_readcyclecounter();
+unsigned long long cycles_to_do_something = t1 - t0; // assuming no overflow
+</pre>
+
+<p><b>Description:</b></p>
+
+<p>The __builtin_readcyclecounter() builtin returns the cycle counter value,
+which may be either global or process/thread-specific depending on the target.
+As the backing counters often overflow quickly (on the order of
+seconds) this should only be used for timing small intervals. When not
+supported by the target, the return value is always zero. This builtin
+takes no arguments and produces an unsigned long long result.
+</p>
+
+<p>Query for this feature with __has_builtin(__builtin_readcyclecounter).</p>
+
+<!-- ======================================================================= -->
<h3><a name="__builtin_shufflevector">__builtin_shufflevector</a></h3>
<!-- ======================================================================= -->
@@ -1489,6 +1549,54 @@ with a <tt>__c11_</tt> prefix. The supported operations are:</p>
<li><tt>__c11_atomic_fetch_xor</tt></li>
</ul>
+<!-- ======================================================================= -->
+<h2 id="non-standard-attributes">Non-standard C++11 Attributes</h2>
+<!-- ======================================================================= -->
+
+<p>Clang supports one non-standard C++11 attribute. It resides in the
+<tt>clang</tt> attribute namespace.</p>
+
+<!-- ======================================================================= -->
+<h3 id="clang__fallthrough">The <tt>clang::fallthrough</tt> attribute</h3>
+<!-- ======================================================================= -->
+
+<p>The <tt>clang::fallthrough</tt> attribute is used along with the
+<tt>-Wimplicit-fallthrough</tt> argument to annotate intentional fall-through
+between switch labels. It can only be applied to a null statement placed at a
+point of execution between any statement and the next switch label. It is common
+to mark these places with a specific comment, but this attribute is meant to
+replace comments with a more strict annotation, which can be checked by the
+compiler. This attribute doesn't change semantics of the code and can be used
+wherever an intended fall-through occurs. It is designed to mimic
+control-flow statements like <tt>break;</tt>, so it can be placed in most places
+where <tt>break;</tt> can, but only if there are no statements on the execution
+path between it and the next switch label.</p>
+<p>Here is an example:</p>
+<pre>
+// compile with -Wimplicit-fallthrough
+switch (n) {
+case 33:
+ f();
+case 44: // warning: unannotated fall-through
+ g();
+ <b>[[clang::fallthrough]];</b>
+case 55: // no warning
+ if (x) {
+ h();
+ break;
+ }
+ else {
+ i();
+ <b>[[clang::fallthrough]];</b>
+ }
+case 66: // no warning
+ p();
+ <b>[[clang::fallthrough]];</b> // warning: fallthrough annotation does not directly precede case label
+ q();
+case 77: // warning: unannotated fall-through
+ r();
+}
+</pre>
<!-- ======================================================================= -->
<h2 id="targetspecific">Target-Specific Extensions</h2>
OpenPOWER on IntegriCloud