diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-05-31 23:54:55 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-05-31 23:54:55 +0000 |
commit | fb75d42faadfd7e0a56e106a0d291efbe3ef5f9a (patch) | |
tree | 71a6cf9051352d4b029bd1374e113d267a452bd8 /llvm/docs/CodingStandards.html | |
parent | 09efde0ae70bef8a65d881369831c76f702cda90 (diff) | |
download | bcm5719-llvm-fb75d42faadfd7e0a56e106a0d291efbe3ef5f9a.tar.gz bcm5719-llvm-fb75d42faadfd7e0a56e106a0d291efbe3ef5f9a.zip |
Add a standard for control-flow unreachable assertions in functions that return
values, so as to avoid warnings on some platforms.
llvm-svn: 51831
Diffstat (limited to 'llvm/docs/CodingStandards.html')
-rw-r--r-- | llvm/docs/CodingStandards.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/docs/CodingStandards.html b/llvm/docs/CodingStandards.html index 3a7f8b3d1e9..a99e46e5b58 100644 --- a/llvm/docs/CodingStandards.html +++ b/llvm/docs/CodingStandards.html @@ -623,6 +623,29 @@ assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!" <p>You get the idea...</p> +<p>Please be aware when adding assert statements that not all compilers are aware of +the semantics of the assert. In some places, asserts are used to indicate a piece of +code that should not be reached. These are typically of the form:</p> + +<div class="doc_code"> +<pre> +assert(0 && "Some helpful error message"); +</pre> +</div> + +<p>When used in a function that returns a value, they should be followed with a return +statement and a comment indicating that this line is never reached. This will prevent +a compiler which is unable to deduce that the assert statement never returns from +generating a warning.</p> + +<div class="doc_code"> +<pre> +assert(0 && "Some helpful error message"); +// Not reached +return 0; +</pre> +</div> + </div> <!-- _______________________________________________________________________ --> |