Commit Graph

51 Commits

Author SHA1 Message Date
Paul Robinson
5b17b4ea2b Explicitly describe '///' versus '//' comment delimiters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226750 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 00:19:56 +00:00
Peter Collingbourne
7c9c49b330 Introduce Go coding standards for LLVM.
Rather than define our own standards, we adopt a set of best practices that
are already in use by the Go community.

Differential Revision: http://reviews.llvm.org/D5761

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219646 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14 00:40:53 +00:00
Duncan P. N. Exon Smith
2788345a9b CodingStandards: Document std::equal misbehaviour
I should have included this as part of r215986, which worked around this
corner by changing ArrayRef::equals() not to use std::equal.  Alas.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215988 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 16:49:40 +00:00
Reid Kleckner
6dfd006fcf Remove the recommendation against using std::function
Clang-cl supports MSVC-style RTTI now, and we can even compile
typeid(...) with /GR-.  Just don't instantiate std::function with a
polymorphic type, or bad things will happen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212148 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 00:42:07 +00:00
Richard Smith
64cd55a126 Update programmers manual to cover llvm::function_ref, and add a note to the
coding standard suggesting using it instead of the (unavailable) std::function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208067 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 07:45:39 +00:00
Richard Smith
2efa833c4e Revert accidentally-committed files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208034 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 01:46:26 +00:00
Richard Smith
36ecb2ee9d Re-commit r208025, reverted in r208030, with a fix for a conformance issue
which GCC detects and Clang does not!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208033 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 01:44:26 +00:00
Duncan P. N. Exon Smith
dd0f0d6a9d C++11: Compatibility with (C++03 => MSVC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206481 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-17 18:02:36 +00:00
Duncan P. N. Exon Smith
5bcd7106b5 C++11: Document some limitations imposed by MSVC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206480 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-17 18:02:34 +00:00
Sean Silva
0a50cec3cb [docs] Fix up some links to the preferred style.
:doc:`...` and :ref:`...` links help Sphinx keep track the dependencies
between documents and ensure that they are not pointing to nowhere.

Raw HTML links work just fine and are easier for people less familiar
with reST/Sphinx. They are easy to change over to the :doc:/:ref: style
after the fact so this is not a problem.

This commit doesn't fix all of them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205792 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-08 21:06:22 +00:00
Duncan P. N. Exon Smith
feed88059f C++11: Remove const from in auto guidelines
Using const is orthogonal to guidelines on using auto& and auto*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 18:06:15 +00:00
Duncan P. N. Exon Smith
fc9031cdff C++11: Copy pointers with const auto *
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203254 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 17:23:29 +00:00
Reid Kleckner
739dd523e6 Avoid std::function until PR19030 is fixed
We'd like to keep the clang-cl self-host working until we implement
MSVC-compatible RTTI.

Differential Revision: http://llvm-reviews.chandlerc.com/D2930

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202758 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 21:12:13 +00:00
Peter Collingbourne
c3835ccef9 Document that std::initializer_list is not always available.
Differential Revision: http://llvm-reviews.chandlerc.com/D2923

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202750 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 19:54:42 +00:00
Duncan P. N. Exon Smith
59a4517759 C++11: Beware unnecessary copies with auto
It's easy to copy unintentionally when using 'auto', particularly inside
range-based for loops.  Best practise is to use 'const&' unless there's
a good reason not to.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202729 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 16:48:47 +00:00
Duncan P. N. Exon Smith
653638bea4 Clarify struct usage guidelines
The current coding standards restrict the use of struct to PODs, but no
one has been following them.  This patch updates the standards to
clarify when structs are dangerous and describe common practice in LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202728 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 16:48:44 +00:00
Chandler Carruth
bab807eaa1 [C++11] Suggest placing callable arguments as the last argument to
facilitate the nice formatting of lambdas passed there. Suggested by
Chris during review of my lambda additions, and something I strongly
agree with.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202622 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-02 09:13:39 +00:00
Chandler Carruth
cfbdd4df6d [C++11] Update the coding standards to provide some important guidance
about a few constructs in C++11 that are worth starting off in
a consistent manner within the codebase.

This will be matched with a change to clang-format's LLVM style which
will switch the options to support C++11 and use these conventions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202620 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-02 08:38:35 +00:00
Sean Silva
aede1c9884 [docs] Fix some Sphinx warnings.
The docs now build cleanly. Yay!

The following warnings were fixed:

/home/sean/pg/llvm/llvm/docs/HowToReleaseLLVM.rst:364: WARNING: Enumerated list ends without a blank line; unexpected unindent.
/home/sean/pg/llvm/llvm/docs/InAlloca.rst:: WARNING: document isn't included in any toctree

/home/sean/pg/llvm/llvm/docs/CodingStandards.rst:85: WARNING: Title underline too short.

Supported C++11 Language and Library Features
-------------------------------------------
/home/sean/pg/llvm/llvm/docs/CodingStandards.rst:85: WARNING: Title underline too short.

Supported C++11 Language and Library Features
-------------------------------------------
/home/sean/pg/llvm/llvm/docs/GettingStarted.rst:185: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/home/sean/pg/llvm/llvm/docs/GettingStarted.rst:565: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/home/sean/pg/llvm/llvm/docs/GettingStarted.rst:567: WARNING: Block quote ends without a blank line; unexpected unindent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202603 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-02 00:21:42 +00:00
Chandler Carruth
f468dea807 [docs] Update the docs to remove my hedging about C++98 vs. C++11. =]
The switch has been thrown. While I'm still watching for any failures or
problems with this, the documentation can go ahead and move forward.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202566 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-01 02:48:03 +00:00
Chandler Carruth
e6a2102aa2 [docs] Clarify that there isn't much to be done other than watch build
bots when using the standard library facilities. The missing pieces here
aren't always in useful discreet chunks.

Fortunately, the missing pieces are few and far between, and we can
emulate most of them in our headers as needed.

Based on feedback from Lang and Dave.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202548 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 21:59:51 +00:00
Richard Smith
80883b6a27 Add more whitespace to fix more bullets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202538 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 21:14:25 +00:00
Richard Smith
27f41a3736 Add whitespace to try to fix bulleted list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202537 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 21:11:28 +00:00
Ben Langmuir
640da197ae Fix some links to C++11 feature papers in the Coding Standards
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202532 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 19:37:20 +00:00
Chandler Carruth
2dc637fce3 [docs] Add a section to the coding standards about languages and such.
A lot of this is writing down common knowledge and things often
communicated on mailing lists and in discussions. It could live in the
Programmer's Manual alternatively, but that felt slightly less
well-fitting.

It also includes (and was motivated by) the section on the relevant
language standards for LLVM and the specific features that will be
enabled with the switch to C++11.

With this, all of the documentation for the C++11 switch is, I think, in
place. I plan to flip the switch RSN. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202497 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 13:35:54 +00:00
Chandler Carruth
72667d1447 [docs] A slight tweak to the intro for the golden rule in the coding
standards.

It claims the document intentionally doesn't give fixed standards for
brace placement or spacing, and then the document goes on to do
precisely that in several places. Instead, try to highlight that even
these rules are simply *guidance* which may be trumped by some other
circumstance or the local conventions of code.

I'm not trying to change the thrust of this part of the document, and if
folks think this does so, I'm happy to re-wordsmith it. I just don't
want it to be so self-contradicting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202495 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 12:24:18 +00:00
Chandler Carruth
70662820ee Revert my commit in r199620 that added sections about namespaces to the
coding standards, and instead fix the existing section.

Thanks to Daniel Jasper for pointing out we already had a section
devoted to this topic. Instead of adding sections, just hack on this
section some. Also fix the example in the anonymous namespace section
below it to agree with the new advice.

As a re-cap, this switches the LLVM preferred style to never indent
namespaces. Having two approaches just led to endless (and utterly
pointless) debates about what was "small enough". This wasn't helping
anyone. The no-indent rule is easy to understand and doesn't really make
anything harder to read. Moreover, with tools like clang-format it is
considerably nicer to have simple consistent rules.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199637 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 10:15:32 +00:00
Chandler Carruth
5d696a91c8 Add some wording to the coding standards to say how to indent namespaces
(and to mention namespace ending comments). This is based on a quick
discussion on the developer mailing list where there was essentially no
objections to a simple and consistent rule. This should avoid future
debates about whether or not a namespace is "big enough" to indent. It
also matches clang-format's current behavior with LLVM source code which
hasn't really seen any opposition in code reviews that I spot checked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199620 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 01:40:43 +00:00
Alp Toker
087ab613f4 Correct word hyphenations
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities and contractions in nearby lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196471 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 05:44:44 +00:00
Chris Lattner
eecd9b1d52 Revert r189704, which removed the guidance about not duplicating doc comments.
This is under active discussion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189730 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-01 15:48:08 +00:00
Chris Lattner
af069a8920 Remove the suggestion to not duplicate comments in header and
implementation files.  While doc generation systems don't need this,
humans do benefit from it.  Not everyone reads all code through doxygen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189704 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30 23:06:20 +00:00
Rafael Espindola
f4c2104d00 Add the common begin/end naming convention to the coding standard.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187902 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-07 19:34:37 +00:00
Dmitri Gribenko
b7978cf701 Coding standards: don't use `inline` when defining a function in a class
definition

Current practice is not to use 'inline' in:

  class Foo {
  public:
    inline void bar() {
      // ...
    }
  };


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174317 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04 10:24:58 +00:00
Joel Jones
1d10898ab5 Fix spelling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173103 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 23:20:47 +00:00
Sean Silva
a7aec400a7 docs: Fix long standing linking antipattern.
Before we learned about :doc:, we used :ref: and put a dummy link at the
top of each page. Don't do that anymore.

This fixes PR14891 as a special case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172162 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 02:28:08 +00:00
Chandler Carruth
afcc374524 Simplify the coding standards for #include ordering. The ordering is now
trivially achievable with an editor. I'll likely check in a silly python
script to help with this too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169107 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-02 11:53:27 +00:00
Sean Silva
5d6d89544d docs: CodingStandards should follow the coding standards.
Some variables in code examples were not LikeThis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168275 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 23:25:33 +00:00
Sean Silva
107aa1c219 docs: Add link to HowToSetUpLLVMStyleRTTI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168271 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 21:01:44 +00:00
Jordan Rose
715672c643 Suggest llvm_unreachable over assert(0).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166821 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-26 22:08:46 +00:00
Dmitri Gribenko
b8f2d82403 Document current Doxygen use practices in Coding Standards. Mostly it is
obvious stuff and most new code being committed conforms to that.  Some old
code does not; this might cause confusion and this is the motivation to
document the correct guidelines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166378 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-20 13:27:43 +00:00
Michael J. Spencer
06d9981d27 [Docs] Update File Headers section to cover doxygen style file level docs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164964 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-01 19:59:21 +00:00
Jakub Staszak
bfa43c0422 Fix && to && in Coding Standards.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164920 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-30 20:42:13 +00:00
David Blaikie
b890e9fc66 Add missing 'to' and rephrase an explanation of GCC's assumptions.
Wordsmithing by Matt Beaumont-Gay in response to r164389.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164395 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 18:03:02 +00:00
David Blaikie
67bf429a6a Document "do not use defaults in covered switch-over-enum" coding standard.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164389 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-21 17:47:36 +00:00
Andrew Trick
e9f59888d4 Fix function names in coding style examples
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164311 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 17:02:04 +00:00
Andrew Trick
331e8fb760 Fix static function names in CodingStandards examples.
Try not to violate conventions immediately before explaining them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164278 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 02:01:06 +00:00
Dmitri Gribenko
e3f1459b7d Coding standards: fix typo: '= deleted' -> '= delete'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164126 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 14:00:58 +00:00
Craig Topper
88b5a2bf34 Add LLVM_DELETED_FUNCTION to coding standards.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164101 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 04:43:40 +00:00
Meador Inge
e3c9ccd312 Put space after "code-block::".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158880 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 23:57:00 +00:00
Meador Inge
d65ebceeba Removed some left over HTML tags and a '}'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158877 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 23:48:01 +00:00