Commit Graph

1891 Commits

Author SHA1 Message Date
Adam Balogh da488a65e2 [ASTMatchers] Matchers for new[] operators
Two new matchers for `CXXNewExpr` are added which may be useful e.g. in
`clang-tidy` checkers. One of them is `isArray` which matches `new[]` but not
plain `new`. The other one, `hasArraySize` matches `new[]` for a given size.

llvm-svn: 318909
2017-11-23 12:43:20 +00:00
Peter Collingbourne 048ac83973 CachePruning: Allow limiting the number of files in the cache directory.
The default limit is 1000000 but it can be configured with a cache
policy. The motivation is that some filesystems (notably ext4) have
a limit on the number of files that can be contained in a directory
(separate from the inode limit).

Differential Revision: https://reviews.llvm.org/D40327

llvm-svn: 318857
2017-11-22 18:27:31 +00:00
Malcolm Parsons 72e5d69826 [Docs] Update list of languages clang-format can format
llvm-svn: 318827
2017-11-22 10:47:35 +00:00
Aaron Ballman 5f8980a995 Add an AST matcher for hasDefaultArgument() to match on parameter declarations that have a default value.
Patch by Julie Hockett.

llvm-svn: 318794
2017-11-21 19:22:34 +00:00
Craig Topper 164186617e [Docs] Regenerate the command line option reference.
llvm-svn: 318672
2017-11-20 18:07:43 +00:00
Stephan Bergmann 15b87c6de3 Indent code blocks so they are actually treated as such
llvm-svn: 318530
2017-11-17 16:34:36 +00:00
Dave Lee be39868bfc Make isDefinition matcher support ObjCMethodDecl
Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D39948

llvm-svn: 318152
2017-11-14 14:17:26 +00:00
Gabor Horvath 5cfada60b4 [analyzer] Document the issue hash debugging facility
Differential Revision: https://reviews.llvm.org/D39543

llvm-svn: 318030
2017-11-13 11:13:02 +00:00
Dave Lee bfb990b783 Fix AST matcher documentation typo
llvm-svn: 317993
2017-11-11 23:53:27 +00:00
Dave Lee 0934fdc3a5 Add ObjC exception statement AST matchers
Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally.

Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D39940

llvm-svn: 317992
2017-11-11 22:46:15 +00:00
Krasimir Georgiev d4102df9ad [clang-format] Keep Sphinx happy after r317794
llvm-svn: 317799
2017-11-09 15:54:59 +00:00
Krasimir Georgiev 818da9bb29 [clang-format] Sort using declarations by splitting on '::'
Summary: This patch improves using declarations sorting.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D39786

llvm-svn: 317794
2017-11-09 15:41:23 +00:00
Sam McCall 60d74e4588 [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.
Summary:
This is an alternative to JSONCompilationDatabase for simple projects that
don't use a build system such as CMake.
(You can also drop one in ~, to make your tools use e.g. C++11 by default)

There's no facility for varying flags per-source-file or per-machine.
Possibly this could be accommodated backwards-compatibly using cpp, but even if
not the simplicity seems worthwhile for the cases that are addressed.

Tested with clangd, works great! (requires clangd restart)

Reviewers: klimek

Subscribers: ilya-biryukov, cfe-commits

Differential Revision: https://reviews.llvm.org/D39799

llvm-svn: 317777
2017-11-09 10:37:39 +00:00
Sjoerd Meijer 167f2e34d5 [docs] Add section 'Half-Precision Floating Point'
This documents the differences/interactions between _Float16 and __fp16
and is a companion change for the _Float16 type implementation (r312794).

Differential Revision:  https://reviews.llvm.org/D35295

llvm-svn: 317558
2017-11-07 10:09:45 +00:00
Roman Lebedev d9af8e1f98 [Sema] Document+test the -Wsign-conversion change for enums in C code [NFC]
Basically a regression after r316268.
However the diagnostic is correct, but the test coverage is bad.

So just like rL316500, introduce yet more tests,
and adjust the release notes.

See https://bugs.llvm.org/show_bug.cgi?id=35200

llvm-svn: 317421
2017-11-04 20:27:47 +00:00
Vlad Tsyrklevich 634c601fe3 [CFI] Add CFI-icall pointer type generalization
Summary:
This change allows generalizing pointers in type signatures used for
cfi-icall by enabling the -fsanitize-cfi-icall-generalize-pointers flag.
This works by 1) emitting an additional generalized type signature
metadata node for functions and 2) llvm.type.test()ing for the
generalized type for translation units with the flag specified.

This flag is incompatible with -fsanitize-cfi-cross-dso because it would
require emitting twice as many type hashes which would increase artifact
size.

Reviewers: pcc, eugenis

Reviewed By: pcc

Subscribers: kcc

Differential Revision: https://reviews.llvm.org/D39358

llvm-svn: 317044
2017-10-31 22:39:44 +00:00
Nico Weber 0763ab4d6a Use -fuse-init-array if no gcc installation is found.
clang currently uses .init_array instead of .ctors on Linux if it detects gcc
4.7+. Make it so that it also uses .init_array if no gcc installation is found
at all – if there's no old gcc, there's nothing we need to be compatible with.

icecc for example runs clang in a very small chroot, so before this change
clang would use .ctors if run under icecc. And lld currently silently mislinks
inputs with .ctors sections, so before this clang + icecc + lld would produce
broken binaries. (But this seems like a good change independent of that lld
bug.)

https://reviews.llvm.org/D39317

llvm-svn: 316713
2017-10-26 23:26:29 +00:00
Richard Smith 6631036893 [www] Regenerate diagnostics reference.
llvm-svn: 316701
2017-10-26 21:06:52 +00:00
Dave Lee 55540a0ce7 Add objcCategoryImplDecl matcher
Summary:
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in D30854.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D39293

llvm-svn: 316670
2017-10-26 15:53:37 +00:00
Roman Lebedev 809df34efc [Sema] -Wzero-as-null-pointer-constant: don't warn for system macros other than NULL.
Summary:
The warning was initially introduced in D32914 by @thakis,
and the concerns were raised there, and later in rL302247
and PR33771.

I do believe that it makes sense to relax the diagnostic
e.g. in this case, when the expression originates from the
system header, which can not be modified. This prevents
adoption for the diagnostic for codebases which use pthreads
(`PTHREAD_MUTEX_INITIALIZER`), gtest, etc.

As @malcolm.parsons suggests, it *may* make sense to also
not warn for the template types, but it is not obvious to
me how to do that in here.

Though, it still makes sense to complain about `NULL` macro.

While there, add more tests.

Reviewers: dblaikie, thakis, rsmith, rjmccall, aaron.ballman

Reviewed By: thakis

Subscribers: Rakete1111, hans, cfe-commits, thakis, malcolm.parsons

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38954

llvm-svn: 316662
2017-10-26 13:18:14 +00:00
Roman Lebedev 7ade0173df [Sema] Document+test the -Wsign-compare change for enums in C code [NFC]
rL316268 / D39122 has fixed PR35009, and now when in C,
these three(?) diagnostics properly use the enum's underlying
datatype.

While it was fixed, the test coverage was clearly insufficient,
because the -Wsign-compare change didn't show up in any of the
tests, until it was reported in the post-commit mail for rL316268.

So add the test for the -Wsign-compare diagnostic for enum
for C code, and while there, document this in the release notes.

The fix itself was obviously correct, so unless we want to silence
this new diagnosed case, i deem this commit to be NFC.

llvm-svn: 316500
2017-10-24 21:05:43 +00:00
Aaron Ballman 2b3bc4ce2b Add release notes for the recent -fdouble-square-bracket-attributes and -fno-double-square-bracket-attributes compiler flags.
llvm-svn: 316269
2017-10-21 16:45:08 +00:00
Roman Lebedev 6de129e710 [Sema] Re-land: Diagnose tautological comparison with type's min/max values
The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. `char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38101

llvm-svn: 315875
2017-10-15 20:13:17 +00:00
Roman Lebedev 6f405dbe5c Revert "[Sema] Diagnose tautological comparison with type's min/max values"
This reverts r315614,r315615,r315621,r315622
Breaks http://bb9.pgr.jp/#/builders/20/builds/59

/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:95:17: error: comparison 'long long' > 9223372036854775807 is always false [-Werror,-Wtautological-constant-compare]
    if (max_sec > Lim::max()) return false;
        ~~~~~~~ ^ ~~~~~~~~~~
/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:124:13: error: comparison 'long long' < -9223372036854775808 is always false [-Werror,-Wtautological-constant-compare]
    if (sec < Lim::min() || sec > Lim::max())   return false;
        ~~~ ^ ~~~~~~~~~~
/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:124:33: error: comparison 'long long' > 9223372036854775807 is always false [-Werror,-Wtautological-constant-compare]
    if (sec < Lim::min() || sec > Lim::max())   return false;
                            ~~~ ^ ~~~~~~~~~~
3 errors generated.
--

I'm not yet sure what is the proper fix.

llvm-svn: 315631
2017-10-12 22:03:20 +00:00
Roman Lebedev bd1fc22043 [Sema] Diagnose tautological comparison with type's min/max values
Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. `char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38101

llvm-svn: 315614
2017-10-12 20:16:51 +00:00
Sylvestre Ledru 3f2b00b7b6 Split the AlignTrailingComments on several lines. The comments were applied to the right columns
llvm-svn: 315568
2017-10-12 08:07:53 +00:00
Haojian Wu eac034b992 Fix small nits in clang-refactor doc.
llvm-svn: 315286
2017-10-10 09:00:56 +00:00
Jan Korous 0e171eab3e Fix typos in documentation
Differential Revision: https://reviews.llvm.org/D38711

llvm-svn: 315252
2017-10-09 23:45:20 +00:00
Reid Kleckner c65f16cec3 [MS] Raise the default value of _MSC_VER to 1911, which is VS 2017
Summary:
This raises our default past 1900, which controls whether char16_t is a
builtin type or not.

Implements PR34243

Reviewers: hans

Subscribers: STL_MSFT, rsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D38646

llvm-svn: 315107
2017-10-06 21:02:28 +00:00
Alex Lorenz 80275fef32 [docs][refactor] Add refactoring engine design documentation
This commit adds a refactoring engine design document that talks about the
design and provides several example of how the engine can be used.

Differential Revision: https://reviews.llvm.org/D37976

llvm-svn: 314509
2017-09-29 12:21:38 +00:00
Sylvestre Ledru a59e654e02 Add the new -Wnull-pointer-arithmetic warnings to the release notes
Differential Revision: https://reviews.llvm.org/D38186

llvm-svn: 314387
2017-09-28 08:00:18 +00:00
Artem Dergachev 4388ffa91d [analyzer] Keep track of design discusions as part of analyzer documentation.
Create a directory to store discussions on potentially useful features that are
not yet implemented in the analyzer.

Fill it with a discussion on representing checker-specific parts of the program
state for C++ object modeling, that occured in D35216.

Differential Revision: https://reviews.llvm.org/D36737

llvm-svn: 314218
2017-09-26 15:49:53 +00:00
Vlad Tsyrklevich 2eccdab308 Allow specifying sanitizers in blacklists
Summary:
This is the follow-up patch to D37924.

This change refactors clang to use the the newly added section headers
in SpecialCaseList to specify which sanitizers blacklists entries
should apply to, like so:

  [cfi-vcall]
  fun:*bad_vcall*
  [cfi-derived-cast|cfi-unrelated-cast]
  fun:*bad_cast*

The SanitizerSpecialCaseList class has been added to allow querying by
SanitizerMask, and SanitizerBlacklist and its downstream users have been
updated to provide that information. Old blacklists not using sections
will continue to function identically since the blacklist entries will
be placed into a '[*]' section by default matching against all
sanitizers.

Reviewers: pcc, kcc, eugenis, vsk

Reviewed By: eugenis

Subscribers: dberris, cfe-commits, mgorny

Differential Revision: https://reviews.llvm.org/D37925

llvm-svn: 314171
2017-09-25 22:11:12 +00:00
Reka Kovacs f616a89d87 [docs] Fix typos in Clang's User's Manual.
llvm-svn: 314061
2017-09-23 12:13:32 +00:00
Alexander Shaposhnikov f681c4e5a9 [clang] Fix isExternC matcher docs
The wording in the documentation for the matcher isExternC 
appears to be misleading since this matcher 
is applicable to functions and variables as well. 
This diff changes the comment and regenerates the html file.

Differential revision: https://reviews.llvm.org/D38151

llvm-svn: 314022
2017-09-22 19:29:38 +00:00
Yi Kong a026eb5f50 [Docs] Document cache pruning support for gold
Differential Revision: https://reviews.llvm.org/D37995

llvm-svn: 313591
2017-09-18 23:24:01 +00:00
Bob Haarman d533d6559a [docs] add Windows examples to ThinLTO.rst
Reviewers: pcc, ruiu

Reviewed By: ruiu

Subscribers: mehdi_amini, eraman, cfe-commits

Differential Revision: https://reviews.llvm.org/D37943

llvm-svn: 313425
2017-09-16 00:16:13 +00:00
Krasimir Georgiev d6ce937f49 [clang-format] New flag - BraceWrapping.AfterExternBlock
Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **"extern C part"**

**Problem:**

Due to the lack of "brace wrapping extern" flag, clang format does parse the block after **extern** keyword moving the opening bracket to the header line always!

**Patch description:**

A new style added, new configuration flag - **BraceWrapping.AfterExternBlock** that allows us to decide whether we want a break before brace or not.

Reviewers: djasper, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D37845

Contributed by @PriMee!

llvm-svn: 313354
2017-09-15 11:23:50 +00:00
Douglas Gregor bae9b8ea2b Fix reStructuredText warning.
llvm-svn: 313320
2017-09-14 23:58:18 +00:00
Douglas Gregor badae3ff04 Minor cleanups to address feedback from Bruno. NFC
llvm-svn: 313318
2017-09-14 23:40:51 +00:00
Douglas Gregor f0b11de279 [Module map] Introduce a private module re-export directive.
Introduce a new "export_as" directive for top-level modules, which
indicates that the current module is a "private" module whose symbols
will eventually be exported through the named "public" module. This is
in support of a common pattern in the Darwin ecosystem where a single
public framework is constructed of several private frameworks, with
(currently) header duplication and some support from the linker.

Addresses rdar://problem/34438420.

llvm-svn: 313316
2017-09-14 23:38:44 +00:00
George Karpenkov 09f613df69 [NFC] [Analyzer] Fix RST markup in documentation.
llvm-svn: 313219
2017-09-14 00:04:56 +00:00
Francis Ricci 8ae4e79a08 [docs] Update LeakSanitizer documentation to reflect OS X support
Reviewers: kcc, alekseyshl, kubamracek, glider

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D37811

llvm-svn: 313179
2017-09-13 19:40:10 +00:00
Vedant Kumar d8ab8c2528 [ubsan] Enable -fsanitize=function on Darwin
https://reviews.llvm.org/D37598

llvm-svn: 313099
2017-09-13 00:04:36 +00:00
Vlad Tsyrklevich b1bb99d66a Fix broken links to the Itanium CXX ABI
llvm-svn: 312986
2017-09-12 00:21:17 +00:00
Vedant Kumar 90c80a3283 [ubsan-minimal] Document the new runtime
Differential Revision: https://reviews.llvm.org/D37647

llvm-svn: 312957
2017-09-11 21:37:05 +00:00
Dave Lee e6d362cea8 Add objcImplementationDecl matcher
Summary:
Add the `objcImplementationDecl` matcher. See related: D30854

Tested with:

```
./tools/clang/unittests/ASTMatchers/ASTMatchersTests
```

Reviewers: aaron.ballman, compnerd, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D37643

llvm-svn: 312889
2017-09-10 21:00:15 +00:00
Peter Collingbourne 052e855e2b COFF: Implement ThinLTO cache and cache pruning support.
Differential Revision: https://reviews.llvm.org/D37607

llvm-svn: 312770
2017-09-08 00:50:50 +00:00
Roman Lebedev 6aa34aadd1 [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
Summary:
This is a first half(?) of a fix for the following bug:
https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)

GCC's -Wtype-limits does warn on comparison of unsigned value
with signed zero (as in, with 0), but clang only warns if the
zero is unsigned (i.e. 0U).

Also, be careful not to double-warn, or falsely warn on
comparison of signed/fp variable and signed 0.

Yes, all these testcases are needed.

Testing: $ ninja check-clang-sema check-clang-semacxx
Also, no new warnings for clang stage-2 build.

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D37565

llvm-svn: 312750
2017-09-07 22:14:25 +00:00
Daniel Jasper 392c2ba675 [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
The current description of AllowAllParametersOfDeclarationOnNextLine in
the Clang-Format Style Options guide suggests that it is possible to
format function declaration, which fits in a single line (what is not
supported in current clang-format version). Also the example was not
reproducible and mades no sense.

Patch by Lucja Mazur, thank you!

llvm-svn: 312721
2017-09-07 13:45:41 +00:00
Sylvestre Ledru 7372d48c74 Add an usage example of BreakBeforeBraces
Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D37531

llvm-svn: 312717
2017-09-07 12:09:14 +00:00
Sylvestre Ledru 44d1ef140b Refresh the clang format options doc with the recent changes
Summary:
Looks like we are out of sync between the doc and the code.


Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D37558

llvm-svn: 312716
2017-09-07 12:08:49 +00:00
Sylvestre Ledru 31f4fee0c9 add the option IndentPPDirectives to the release notes. Landed in r312125
llvm-svn: 312535
2017-09-05 13:56:40 +00:00
Dmitry Vyukov 7097b4d22d docs: don't say that data flow tracing interface is unstable
We are starting to use data flow tracing in kernel.
The interface is not subject to change anymore.

Reviewed in https://reviews.llvm.org/D37303

llvm-svn: 312232
2017-08-31 11:02:44 +00:00
Boris Kolpackov d30446fd77 [modules] Add ability to specify module name to module file mapping (reapply)
Extend the -fmodule-file option to support the [<name>=]<file> value format.
If the name is omitted, then the old semantics is preserved (the module file
is loaded whether needed or not). If the name is specified, then the mapping
is treated as just another prebuilt module search mechanism, similar to
-fprebuilt-module-path, and the module file is only loaded if actually used
(e.g., via import). With one exception: this mapping also overrides module
file references embedded in other modules (which can be useful if module files
are moved/renamed as often happens during remote compilation).

This override semantics requires some extra work: we now store the module name
in addition to the file name in the serialized AST representation.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D35020

llvm-svn: 312220
2017-08-31 06:26:43 +00:00
Hans Wennborg d878ca8487 docs: typo fix
llvm-svn: 312149
2017-08-30 18:35:44 +00:00
Krasimir Georgiev ad47c90767 clang-format: Add preprocessor directive indentation
Summary:
This is an implementation for [bug 17362](https://bugs.llvm.org/attachment.cgi?bugid=17362) which adds support for indenting preprocessor statements inside if/ifdef/endif. This takes previous work from fmauch (https://github.com/fmauch/clang/tree/preprocessor_indent) and makes it into a full feature.
The context of this patch is that I'm a VMware intern, and I implemented this because VMware needs the feature. As such, some decisions were made based on what VMware wants, and I would appreciate suggestions on expanding this if necessary to use-cases other people may want.

This adds a new enum config option, `IndentPPDirectives`. Values are:

* `PPDIS_None` (in config: `None`):
```
    #if FOO
    #if BAR
    #include <foo>
    #endif
    #endif
```
* `PPDIS_AfterHash` (in config: `AfterHash`):
```
    #if FOO
    #  if BAR
    #    include <foo>
    #  endif
    #endif
```
This is meant to work whether spaces or tabs are used for indentation. Preprocessor indentation is independent of indentation for non-preprocessor lines.

Preprocessor indentation also attempts to ignore include guards with the checks:
1. Include guards cover the entire file
2. Include guards don't have `#else`
3. Include guards begin with
```
#ifndef <var>
#define <var>
```

This patch allows `UnwrappedLineParser::PPBranchLevel` to be decremented to -1 (the initial value is -1) so the variable can be used for indent tracking.

Defects:
* This patch does not handle the case where there's code between the `#ifndef` and `#define` but all other conditions hold. This is because when the #define line is parsed, `UnwrappedLineParser::Lines` doesn't hold the previous code line yet, so we can't detect it. This is out of the scope of this patch.

* This patch does not handle cases where legitimate lines may be outside an include guard. Examples are `#pragma once` and `#pragma GCC diagnostic`, or anything else that does not change the meaning of the file if it's included multiple times.

* This does not detect when there is a single non-preprocessor line in front of an include-guard-like structure where other conditions hold because `ScopedLineState` hides the line.

* Preprocessor indentation throws off `TokenAnnotator::setCommentLineLevels` so the indentation of comments immediately before indented preprocessor lines is toggled on each run. Fixing this issue appears to be a major change and too much complexity for this patch.

Contributed by @euhlmann!

Reviewers: djasper, klimek, krasimir

Reviewed By: djasper, krasimir

Subscribers: krasimir, mzeren-vmw, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D35955

llvm-svn: 312125
2017-08-30 14:34:57 +00:00
Victor Leschuk db68911b07 Revert r312105 [modules] Add ability to specify module name to module file mapping
Looks like it breaks win10 builder.

llvm-svn: 312112
2017-08-30 11:31:56 +00:00
Boris Kolpackov b150d24d7a [docs] Regenerate command line options reference
llvm-svn: 312106
2017-08-30 09:15:53 +00:00
Boris Kolpackov 7a71b4b658 [modules] Add ability to specify module name to module file mapping
Extend the -fmodule-file option to support the [<name>=]<file> value format.
If the name is omitted, then the old semantics is preserved (the module file
is loaded whether needed or not). If the name is specified, then the mapping
is treated as just another prebuilt module search mechanism, similar to
-fprebuilt-module-path, and the module file is only loaded if actually used
(e.g., via import). With one exception: this mapping also overrides module
file references embedded in other modules (which can be useful if module files
are moved/renamed as often happens during remote compilation).

This override semantics requires some extra work: we now store the module name
in addition to the file name in the serialized AST representation.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D35020

llvm-svn: 312105
2017-08-30 08:45:59 +00:00
Sylvestre Ledru 6fd8839ab9 Fix two typos in the doc. Patch by kamleshbhalui on github
llvm-svn: 311854
2017-08-27 17:34:06 +00:00
Kostya Serebryany d3e4b7e24a [sanitizer-coverage] extend fsanitize-coverage=pc-table with flags for every PC
llvm-svn: 311794
2017-08-25 19:29:47 +00:00
Alex Lorenz d9f1284009 [ObjC] Add a -Wobjc-messaging-id warning
-Wobjc-messaging-id is a new, non-default warning that warns about
message sends to unqualified id in Objective-C. This warning is useful
for projects that would like to avoid any potential future compiler
errors/warnings, as the system frameworks might add a method with the same
selector which could make the message send to id ambiguous.

rdar://33303354

llvm-svn: 311779
2017-08-25 16:12:17 +00:00
Kostya Serebryany a38bbe30eb [sanitizer-coverage] document -fsanitize-coverage=pc-table and -fsanitize-coverage=inline-8bit-counters
llvm-svn: 311719
2017-08-24 22:40:03 +00:00
Sylvestre Ledru d23dd6c633 clang-format: add an option -verbose to list the files being processed
Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D34824

llvm-svn: 310778
2017-08-12 15:15:10 +00:00
Yuka Takahashi 9b6b5d5a88 [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes
Summary:
I thought we should add this information to release notes, because we
added a new flag to clang driver.

Reviewers: v.g.vassilev, teemperor, ruiu

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D36567

llvm-svn: 310700
2017-08-11 09:44:42 +00:00
Alexander Potapenko 5241081532 [sanitizer-coverage] Change cmp instrumentation to distinguish const operands
This implementation of SanitizerCoverage instrumentation inserts different
callbacks depending on constantness of operands:

  1. If both operands are non-const, then a usual
     __sanitizer_cov_trace_cmp[1248] call is inserted.
  2. If exactly one operand is const, then a
     __sanitizer_cov_trace_const_cmp[1248] call is inserted. The first
     argument of the call is always the constant one.
  3. If both operands are const, then no callback is inserted.

This separation comes useful in fuzzing when tasks like "find one operand
of the comparison in input arguments and replace it with the other one"
have to be done. The new instrumentation allows us to not waste time on
searching the constant operands in the input.

Patch by Victor Chibotaru.

llvm-svn: 310600
2017-08-10 15:00:13 +00:00
Erik Pilkington 1b00372fad [Availability] Don't make an availability attribute imply default visibility on macOS
Fixes PR33796, rdar://33655115

Differential revision: https://reviews.llvm.org/D36191

llvm-svn: 310382
2017-08-08 17:09:09 +00:00
Yaxun Liu 39195062c2 Add OpenCL 2.0 atomic builtin functions as Clang builtin
OpenCL 2.0 atomic builtin functions have a scope argument which is ideally
represented as synchronization scope argument in LLVM atomic instructions.

Clang supports translating Clang atomic builtin functions to LLVM atomic
instructions. However it currently does not support synchronization scope
of LLVM atomic instructions. Without this, users have to use LLVM assembly
code to implement OpenCL atomic builtin functions.

This patch adds OpenCL 2.0 atomic builtin functions as Clang builtin
functions, which supports generating LLVM atomic instructions with
synchronization scope operand.

Currently only constant memory scope argument is supported. Support of
non-constant memory scope argument will be added later.

Differential Revision: https://reviews.llvm.org/D28691

llvm-svn: 310082
2017-08-04 18:16:31 +00:00
Richard Smith c7baf8073f Revert accidentally-committed files.
llvm-svn: 309976
2017-08-03 19:25:02 +00:00
Richard Smith 5786582052 Don't emit undefined-internal warnings for CXXDeductionGuideDecls.
Patch by ~paul (cynecx on phabricator)! Some test massaging by me.

llvm-svn: 309975
2017-08-03 19:24:27 +00:00
Gabor Horvath fb895e9064 Fix some typos in the documentation.
Patch by: Reka Nikolett Kovacs

llvm-svn: 309948
2017-08-03 15:38:14 +00:00
Vedant Kumar bbfdb7d8c8 [docs] Remove accidental unindent to appease the sphinx bot
Bot failure:
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/12043/steps/docs-clang-html/logs/stdio

llvm-svn: 309852
2017-08-02 18:24:12 +00:00
Vedant Kumar a0c3671b20 [ubsan] Have -fsanitize=vptr emit a null check if -fsanitize=null isn't available
In r309007, I made -fsanitize=null a hard prerequisite for -fsanitize=vptr. I
did not see the need for the two checks to have separate null checking logic
for the same pointer. I expected the two checks to either always be enabled
together, or to be mutually compatible.

In the mailing list discussion re: r309007 it became clear that that isn't the
case. If a codebase is -fsanitize=vptr clean but not -fsanitize=null clean,
it's useful to have -fsanitize=vptr emit its own null check. That's what this
patch does: with it, -fsanitize=vptr can be used without -fsanitize=null.

Differential Revision: https://reviews.llvm.org/D36112

llvm-svn: 309846
2017-08-02 18:10:31 +00:00
Manuel Klimek 696e505278 Unify and simplify the behavior of the hasDeclaration matcher.
Originally, we weren't able to match on Type nodes themselves (only QualType),
so the hasDeclaration matcher was initially written to give what we thought are
reasonable results for QualType matches.

When we chagned the matchers to allow matching on Type nodes, it turned out
that the hasDeclaration matcher was by chance written templated enough to now
allow hasDeclaration to also match on (some) Type nodes.

This patch change the hasDeclaration matcher to:
a) work the same on Type and QualType nodes,
b) be completely explicit about what nodes we can match instead of just allowing
   anything with a getDecl() to match,
c) explicitly control desugaring only one level in very specific instances.
d) adds hasSpecializedTemplate and tagType matchers to allow migrating
  existing use cases that now need more explicit matchers

Note: This patch breaks clang-tools-extra. The corresponding patch there
is approved and will land in a subsequent patch.

Differential Revision: https://reviews.llvm.org/D27104

llvm-svn: 309809
2017-08-02 13:04:44 +00:00
Alex Lorenz dbbe822485 Fix release notes indentation from r309562
The additions in r309562 triggered a docs buildbot failure.

llvm-svn: 309564
2017-07-31 14:22:43 +00:00
Alex Lorenz 5174866b1d Document '-Wpragma-pack' in the release notes
llvm-svn: 309562
2017-07-31 14:08:41 +00:00
Vedant Kumar 10c3102071 [ubsan] Diagnose invalid uses of builtins (clang)
On some targets, passing zero to the clz() or ctz() builtins has undefined
behavior. I ran into this issue while debugging UB in __hash_table from libcxx:
the bug I was seeing manifested itself differently under -O0 vs -Os, due to a
UB call to clz() (see: libcxx/r304617).

This patch introduces a check which can detect UB calls to builtins.

llvm.org/PR26979

Differential Revision: https://reviews.llvm.org/D34590

llvm-svn: 309459
2017-07-29 00:19:51 +00:00
Erich Keane b0c78096a5 Add bitrig removal to release notes
llvm-svn: 309145
2017-07-26 18:04:45 +00:00
Vedant Kumar bbc953fed4 [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)
The instrumentation generated by -fsanitize=vptr does not null check a
user pointer before loading from it. This causes crashes in the face of
UB member calls (this=nullptr), i.e it's causing user programs to crash
only after UBSan is turned on.

The fix is to make run-time null checking a prerequisite for enabling
-fsanitize=vptr, and to then teach UBSan to reuse these run-time null
checks to make -fsanitize=vptr safe.

Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build

Differential Revision: https://reviews.llvm.org/D35735

https://bugs.llvm.org/show_bug.cgi?id=33881

llvm-svn: 309007
2017-07-25 19:34:23 +00:00
Faisal Vali 5156fcc983 [NFC, documentation] Prefer the term expansion instead of macro instantiation
... in the few remaining places where this was not corrected.


  

llvm-svn: 308823
2017-07-22 12:04:37 +00:00
Craig Topper d23254a008 [Docs] Regenerate the command line option reference.
llvm-svn: 308641
2017-07-20 17:52:48 +00:00
Hans Wennborg fbb21e0315 Clear release notes for 6.0.0
llvm-svn: 308478
2017-07-19 14:14:07 +00:00
Hans Wennborg 825c37e4fe Bump docs version to 6.0
llvm-svn: 308466
2017-07-19 13:50:27 +00:00
Hans Wennborg 7f36a9543d Update clang-cl options in the users manual
llvm-svn: 308427
2017-07-19 09:52:24 +00:00
Nico Weber 564004ae78 Fix flag names in @available docs.
llvm-svn: 308048
2017-07-14 18:52:30 +00:00
Nico Weber 11cafc82b7 Add documentation for @available
https://reviews.llvm.org/D35379

llvm-svn: 308044
2017-07-14 18:40:52 +00:00
George Burgess IV 163a8337ad Add release notes for the overloadable attribute
llvm-svn: 307995
2017-07-14 03:23:57 +00:00
Clement Courbet 43bdba4086 [ASTMatchers][NFC] integerLiteral(): Mention negative integers in
documentation.

Trying to match integerLiteral(-1) will silently fail, because an numeric
literal is always positive.
- Update the documentation to explain how to match negative numeric
  literals.
- Add a unit test.

Differential Revision: https://reviews.llvm.org/D35196

llvm-svn: 307663
2017-07-11 15:45:22 +00:00
Evgeniy Stepanov 760a261e1e Update Cross-DSO CFI documentation.
Reviewers: pcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35094

llvm-svn: 307341
2017-07-07 00:48:12 +00:00
Brian Gesiak bb83ce4678 Add docs for -foptimization-record-file=
Summary: The Clang option was previously not included in the User's Manual.

Reviewers: anemet, davidxl, hfinkel

Reviewed By: hfinkel

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D34928

llvm-svn: 307193
2017-07-05 19:55:51 +00:00
Roman Lebedev ba80b8d437 [clang] Implement -Wcast-qual for C++
Summary:
This way, the behavior of that warning flag
more closely resembles that of GCC.

Do note that there is at least one false-negative (see FIXME in tests).

Fixes PR4802.

Testing:
```
ninja check-clang-sema check-clang-semacxx
```

Reviewers: dblaikie, majnemer, rnk

Reviewed By: dblaikie, rnk

Subscribers: mclow.lists, cfe-commits, alexfh, rnk

Differential Revision: https://reviews.llvm.org/D33102

llvm-svn: 307045
2017-07-03 17:59:22 +00:00
Joerg Sonnenberger c91996817f Add an option group for deprecated warnings. Add the removed
-fslp-vectorize-aggressive and -fno-slp-vectorize-aggressive flags back
under this group and test for the warning. Document the future removal
in the ReleaseNotes.

Differential Revision: https://reviews.llvm.org/D34926

llvm-svn: 306965
2017-07-01 21:36:21 +00:00
Brian Gesiak 562eab97ea Un-revert "[Driver] Add -fdiagnostics-hotness-threshold"
Summary:
Un-revert https://reviews.llvm.org/D34868, but with a slight tweak to the
documentation to fix an error -- I had used the wrong syntax for a link.

llvm-svn: 306948
2017-07-01 05:45:26 +00:00
Brian Gesiak 55e9c111b4 Revert "[Driver] Add -fdiagnostics-hotness-threshold"
Summary:
The commit caused a documentation breakage.

llvm-svn: 306946
2017-07-01 04:54:53 +00:00
Brian Gesiak dc6fa5d1f6 [Driver] Add -fdiagnostics-hotness-threshold
Summary:
Depends on https://reviews.llvm.org/D34867.

Add a Clang frontend option to enable optimization remark hotness
thresholds, which were added to LLVM in https://reviews.llvm.org/D34867.
This prevents diagnostics that do not meet a minimum hotness
threshold from being output. When generating optimization remarks for large
codebases with a ton of cold code paths, this option can be used
to limit the optimization remark output at a reasonable size.
Discussion of this change can be read here:
http://lists.llvm.org/pipermail/llvm-dev/2017-June/114377.html

Reviewers: anemet, davidxl, hfinkel

Reviewed By: anemet

Subscribers: fhahn, cfe-commits

Differential Revision: https://reviews.llvm.org/D34868

llvm-svn: 306945
2017-07-01 04:44:38 +00:00
Sylvestre Ledru 69f49ce83c clang-format - Also reference the list of style option of clang-format in Libformat
llvm-svn: 306266
2017-06-26 03:19:05 +00:00
Sylvestre Ledru 94a21041e7 Fix a typo
llvm-svn: 306261
2017-06-26 02:45:08 +00:00
Peter Collingbourne 8d29223386 Add a ThinLTO cache policy for controlling the maximum cache size in bytes.
This is useful when an upper limit on the cache size needs to be
controlled independently of the amount of the amount of free space.

One use case is a machine with a large number of cache directories
(e.g. a buildbot slave hosting a large number of independent build
jobs). By imposing an upper size limit on each cache directory,
users can more easily estimate the server's capacity.

Differential Revision: https://reviews.llvm.org/D34547

llvm-svn: 306126
2017-06-23 17:05:03 +00:00
Peter Collingbourne 38a02daea4 docs: Add documentation for the ThinLTO cache pruning policy string.
Differential Revision: https://reviews.llvm.org/D34546

llvm-svn: 306125
2017-06-23 16:56:27 +00:00
Krasimir Georgiev ac16a201a6 [clang-format] Add a SortUsingDeclaration option and enable it by default
Summary:
This patch adds a `SortUsingDeclaration` style option and enables it for llvm
style.

Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D34453

llvm-svn: 306094
2017-06-23 11:46:03 +00:00
Krasimir Georgiev 90b4ce38cb [clang-format] Update dump_format_style.py to indent nested fields
Summary:
This updates the format options documentation script to indent the
documentation of nested fields. The previous format caused some problems,
as when a bulleted list ends with a multiline comment. See the buildbot failure
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/10020/steps/docs-clang-html/logs/stdio

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D34552

llvm-svn: 306093
2017-06-23 11:29:40 +00:00
Krasimir Georgiev 575b25f2c0 [clang-format] Update style documentation, NFC
Summary: Style documentation is generated automatically by `docs/tools/dump_format_style.py`. This hasn't been ran for a while.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D34457

llvm-svn: 306089
2017-06-23 08:48:00 +00:00
Vedant Kumar 1c5f312c70 [docs] Coverage: Improve the wording a bit
llvm-svn: 305745
2017-06-19 21:26:04 +00:00
Vedant Kumar 82cd770914 [docs] Coverage: document issue with the BFD linker
llvm-svn: 305743
2017-06-19 21:22:05 +00:00
Aaron Ballman 7f2876a68b Typo fix: appropo -> apropos. NFC.
llvm-svn: 305738
2017-06-19 20:08:20 +00:00
Daniel Jasper 271dd0603e clang-format: Add capability to format the diff on save in vim.
With this patch, one can configure a BufWrite hook that will make the
clang-format integration compute a diff of the current buffer with the file
that's on disk and format all changed lines. This should create a
zero-overhead auto-format solution that doesn't require the file to
already be clang-format clean to avoid spurious diffs.

Review: https://reviews.llvm.org/D32429
llvm-svn: 305665
2017-06-19 07:30:04 +00:00
Vedant Kumar e42e5cf8bd [ubsan] docs: Add a note about pointers to volatile
llvm-svn: 305568
2017-06-16 18:38:43 +00:00
Eric Fiselier 1571faea62 Correct documentation about the AfterClass clang-format option
llvm-svn: 305450
2017-06-15 03:38:08 +00:00
Vedant Kumar 840c2c758d [docs] Add some ubsan changes to the release notes
llvm-svn: 305269
2017-06-13 02:52:31 +00:00
Roman Lebedev 5806d9f205 Revert "[clang] Implement -Wcast-qual for C++"
Breaks -Werror builders.

llvm-svn: 305148
2017-06-10 17:49:23 +00:00
Roman Lebedev b0120740c4 [clang] Implement -Wcast-qual for C++
Summary:
This way, the behavior of that warning flag
more closely resembles that of GCC.

Do note that there is at least one false-negative (see FIXME in tests).

Fixes PR4802.

Testing:
```
ninja check-clang-sema check-clang-semacxx
```

Reviewers: dblaikie, majnemer, rnk

Reviewed By: dblaikie, rnk

Subscribers: cfe-commits, alexfh, rnk

Differential Revision: https://reviews.llvm.org/D33102

llvm-svn: 305147
2017-06-10 17:19:19 +00:00
Peter Wu a9244b57ff [ASTMatchers] Add clang-query support for equals matcher
Summary:
This allows the clang-query tool to use matchers like
"integerLiteral(equals(32))". For this to work, an overloaded function
is added for each possible parameter type.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D33094

llvm-svn: 305022
2017-06-08 22:00:58 +00:00
Sylvestre Ledru 121224d4a4 Fix a mistake in the clang format documentation (BreakBeforeTernaryOperators)
Patch sent through github by Jason Hsu

llvm-svn: 304776
2017-06-06 07:26:19 +00:00
Javed Absar 2a67c9ee39 Add support for #pragma clang section
This patch provides a means to specify section-names for global variables, 
functions and static variables, using #pragma directives. 
This feature is only defined to work sensibly for ELF targets.
One can specify section names as:
#pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText"
One can "unspecify" a section name with empty string e.g.
#pragma clang section bss="" data="" text="" rodata=""

Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner
Differential Revision: https://reviews.llvm.org/D33412

llvm-svn: 304705
2017-06-05 10:11:57 +00:00
Richard Smith 040e12662a Support lazy stat'ing of files referenced by module maps.
This patch adds support for a `header` declaration in a module map to specify
certain `stat` information (currently, size and mtime) about that header file.
This has two purposes:

- It removes the need to eagerly `stat` every file referenced by a module map.
  Instead, we track a list of unresolved header files with each size / mtime
  (actually, for simplicity, we track submodules with such headers), and when
  attempting to look up a header file based on a `FileEntry`, we check if there
  are any unresolved header directives with that `FileEntry`'s size / mtime and
  perform deferred `stat`s if so.

- It permits a preprocessed module to be compiled without the original files
  being present on disk. The only reason we used to need those files was to get
  the `stat` information in order to do header -> module lookups when using the
  module. If we're provided with the `stat` information in the preprocessed
  module, we can avoid requiring the files to exist.

Unlike most `header` directives, if a `header` directive with `stat`
information has no corresponding on-disk file the enclosing module is *not*
marked unavailable (so that behavior is consistent regardless of whether we've
resolved a header directive, and so that preprocessed modules don't get marked
unavailable). We could actually do this for all `header` directives: the only
reason we mark the module unavailable if headers are missing is to give a
diagnostic slightly earlier (rather than waiting until we actually try to build
the module / load and validate its .pcm file).

Differential Revision: https://reviews.llvm.org/D33703

llvm-svn: 304515
2017-06-02 01:55:39 +00:00
Vedant Kumar a125eb55cb [ubsan] Add a check for pointer overflow UB
Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

  - It introduces the EmitCheckedInBoundsGEP utility which inserts
    checks when the pointer overflow check is enabled.

  - It does some constant-folding to reduce instrumentation overhead.

  - It does not check some GEPs in CGExprCXX. I'm not sure that
    inserting checks here, or in CGClass, would catch many bugs.

Possible future directions for this check:

  - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
    accessing structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.

Differential Revision: https://reviews.llvm.org/D33305

llvm-svn: 304459
2017-06-01 19:22:18 +00:00
Peter Collingbourne 6d007c9747 docs: Document LLD's cache dir argument.
llvm-svn: 304385
2017-06-01 03:48:12 +00:00
Richard Smith 567b81a042 [modules] Minor documentation clarification for behavior of requires-declaration.
llvm-svn: 304253
2017-05-30 23:05:23 +00:00
Eric Fiselier e38cea026b [coroutines] Support "coroutines" feature in module map requires clause
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33538

llvm-svn: 304107
2017-05-28 21:07:22 +00:00
Eric Fiselier 9208dd63ef Revert "[coroutines] Support "coroutines" feature in module map requires clause"
This reverts commit r304054.

llvm-svn: 304057
2017-05-27 03:04:51 +00:00
Eric Fiselier 0bb3bcd0ef [coroutines] Support "coroutines" feature in module map requires clause
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33538

llvm-svn: 304054
2017-05-27 02:46:17 +00:00
Tom Stellard 9c52dfebfe docs: Fix Sphinx detection with out-of-tree builds
Adapt to changes made in r302499.

llvm-svn: 302500
2017-05-09 01:42:33 +00:00
Daniel Jasper 7fdbb3feda [clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding
DontAlign

This converts the clang-format option AlignEscapedNewlinesLeft from a
boolean to an enum, named AlignEscapedNewlines, with options Left (prev.
true), Right (prev. false), and a new option DontAlign.

When set to DontAlign, the backslashes are placed just after the last token in each line:
  #define EXAMPLE \
    do { \
        int x = aaaaa; \
        int b; \
        int dddddddddd; \
    } while (0)

Patch by jtbandes. Thank you!

llvm-svn: 302428
2017-05-08 15:08:00 +00:00
Aaron Ballman b6d8070205 Correct the attribute spelling for guarded_var and pt_guarded_var.
Patch by Roman Lebedev.

llvm-svn: 302419
2017-05-08 12:39:17 +00:00
Eric Fiselier d3ff21cf42 Update LanguageExtensions doc to refer to C++14 instead of C++1y
llvm-svn: 302364
2017-05-06 23:26:04 +00:00
Kostya Serebryany 50fb618b93 [sanitizer-coverage] implement -fsanitize-coverage=no-prune,... instead of a hidden -mllvm flag. clang part.
llvm-svn: 302320
2017-05-05 23:28:18 +00:00
Jakub Kuderski 64b6c78e94 Add cxxStdInitializerListExpr AST matcher
Summary:
This adds a new ASTMatcher for CXXStdInitializerListExprs that matches C++ initializer list expressions.

The primary motivation is to use it to fix [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]] (review here [[ https://reviews.llvm.org/D32767 | D32767 ]]).

Reviewers: alexfh, Prazek, aaron.ballman

Reviewed By: alexfh, aaron.ballman

Subscribers: malcolm.parsons, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D32810

llvm-svn: 302287
2017-05-05 21:01:12 +00:00
Aaron Ballman 05fd05ac52 Do not redefine the THREAD_ANNOTATION_ATTRIBUTE__ macro in the documentation.
Patch by Roman Lebedev.

llvm-svn: 302275
2017-05-05 19:56:09 +00:00
Vedant Kumar ee9c6ba1f6 Revert "[docs] UBSan: Mention that print_stacktrace=1 is unsupported on Darwin"
This reverts commit r300295.

It's no longer true, print_stacktrace=1 is supported on Darwin/Windows
as of r301839.

llvm-svn: 301960
2017-05-02 18:51:41 +00:00
Kostya Serebryany 2a451c504f [sanitizer-coverage] update the SanitizerCoverage docs to reflect the current state
llvm-svn: 301888
2017-05-02 00:32:57 +00:00
Kostya Serebryany 4a27c79a95 [sanitizer-coverage] add a deprecation note to coverage_direct=1
llvm-svn: 301824
2017-05-01 19:52:01 +00:00
Craig Topper cadadabb76 [Docs] Correct the path to the clang-format-diff.py script to include the clang-format directory.
llvm-svn: 301202
2017-04-24 17:39:35 +00:00
Vassil Vassilev 65f1d52ce6 PR19260: Teach doxygen to spell correctly the include paths.
Currently we have #include <Sema.h> in the doxygen page documenting Sema. The
patch changes it ot #include "clang/Sema/Sema.h" which is what we would spell if
we need to include it in a real codebase.

Patch by Yuka Takahashi (D32113)!

llvm-svn: 300825
2017-04-20 08:57:41 +00:00
Kostya Serebryany a1ef90ab9c [sanitizer-coverage] trim down the docs
llvm-svn: 300776
2017-04-19 22:25:30 +00:00
Kostya Serebryany 9d1ed13b53 [sanitizer-coverage] deprecate some of the stale coverage variants
llvm-svn: 300738
2017-04-19 19:57:16 +00:00
Alex Lorenz 9e7bf161ea Add #pragma clang attribute
This is a recommit of r300539 that was reverted in r300543 due to test failures.
The original commit message is displayed below:

The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

Differential Revision: https://reviews.llvm.org/D30009

llvm-svn: 300556
2017-04-18 14:33:39 +00:00
Alex Lorenz 3bfe962afa Revert r300539 - Add #pragma clang attribute
Some tests fail on the Windows buildbots. I will have to investigate more.
This commit reverts r300539, r300540 and r300542.

llvm-svn: 300543
2017-04-18 10:46:41 +00:00
Alex Lorenz 0a849f47d2 Add #pragma clang attribute
The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

Differential Revision: https://reviews.llvm.org/D30009

llvm-svn: 300539
2017-04-18 09:41:47 +00:00
Vedant Kumar 4bb4e2c912 [docs] UBSan: Mention that print_stacktrace=1 is unsupported on Darwin
Printing out stack traces along with UBSan diagnostics is unsupported on
Darwin. That's because it isn't possible to use the fast unwinder or the
slow unwinder.

Apparently, it's inappropriate to use the fast unwinder for UBSan
issues. I'm not exactly sure why (see the comment in ubsan_diag.cc).
Forcing use of the fast unwinder produces decent results, AFAICT.

Darwin also does not appear to have a slow unwinder suitable for use
with the sanitizers. Apparently that's because of PR20800 [1][2]. But
that bug has been fixed. I'm not sure if there is anything preventing
use of the slow unwinder now.

Currently, passing UBSAN_OPTIONS=print_stacktrace=1 does nothing on
Darwin. This isn't good, but it might be a while before we can fix the
situation, so we should at least document it.

[1] https://github.com/google/sanitizers/issues/137
"We can't use the slow unwinder on OSX now, because Clang produces
incorrect unwind info for the ASan runtime functions on OSX
(http://llvm.org/PR20800)."

[2] https://bugs.llvm.org/show_bug.cgi?id=20800
Bug 20800 - Invalid compact unwind info generated for a function without
frame pointers on OSX

llvm-svn: 300295
2017-04-14 01:59:44 +00:00
Richard Smith 9a016602e9 [docs] Regenerate diagnostics reference.
llvm-svn: 300271
2017-04-13 22:44:22 +00:00
Richard Smith 78e23fded4 [docs] Fix a couple of typos in command line flag help text and regenerate documentation.
llvm-svn: 300270
2017-04-13 22:39:49 +00:00
Eric Fiselier 0736066b0b [Sema] Add __is_aggregate type-trait
Summary:
[LWG 2911](http://cplusplus.github.io/LWG/lwg-defects.html#2911) adds `std::is_aggregate` to the library, which requires a new builtin trait. This patch implements `__is_aggregate`.


Reviewers: rsmith, majnemer, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: STL_MSFT, cfe-commits

Differential Revision: https://reviews.llvm.org/D31513

llvm-svn: 300116
2017-04-12 22:12:15 +00:00
Bruno Cardoso Lopes 52dfe71645 [Driver] Add compiler option to generate a reproducer
One way to currently test the reproducers is to setup
"FORCE_CLANG_DIAGNOSTICS_CRASH=1" before invoking clang. This simulates
a crash and produces the same contents needed by the reproducers.  The
reproducers are specially useful when triaging Modules issues, not only
on crashes, but also for reproducing misleading warnings, errors, etc.

Add a '-gen-reproducer' driver option to clang (or any similar name) and
give users a flag option.

Note that clang already has a -fno-crash-diagnostics, which disables the
crash reproducers. I've decided not to propose "-fcrash-diagnostics"
since it doesn't convey the ideia of reproduction despite a crash.

rdar://problem/24114619

Differential Revision: https://reviews.llvm.org/D27604

llvm-svn: 300109
2017-04-12 21:46:20 +00:00
Sylvestre Ledru de09824dc4 Add more examples to clang-format configuration
Reviewers: djasper

Reviewed By: djasper

Subscribers: Eugene.Zelenko, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D31408

llvm-svn: 299919
2017-04-11 07:07:05 +00:00
Peter Collingbourne 99c8e0153d docs: Use the term "whole-program devirtualization" instead of "virtual function call optimization".
The former term is probably more familiar to users. Also add references to
the command line flags used to enable the features described in the doc.

llvm-svn: 299902
2017-04-10 23:54:28 +00:00
Nico Weber dc06518ff4 clang-format: Support formatting utf-8 character literals in C++11+ mode.
clang-format <<END
auto c1 = u8'a';
auto c2 = u'a';
END

Before:
  auto c1 = u8 'a';
  auto c2 = u'a';

Now:
  auto c1 = u8'a';
  auto c2 = u'a';

Patch from Denis Gladkikh <llvm@denis.gladkikh.email>!

llvm-svn: 299574
2017-04-05 18:10:42 +00:00
Adam Nemet d7f9511041 Another attempt to fix the sphinx warning from r299470
llvm-svn: 299488
2017-04-04 23:46:34 +00:00
Adam Nemet e73e00c9b2 Fix sphinx warning from r299470
llvm-svn: 299481
2017-04-04 22:45:20 +00:00
Adam Nemet 60d3264d5f Add #pragma clang fp
This adds the new pragma and the first variant, contract(on/off/fast).

The pragma has the same block scope rules as STDC FP_CONTRACT, i.e. it can be
placed at the beginning of a compound statement or at file scope.

Similarly to STDC FP_CONTRACT there is no need to use attributes.  First an
annotate token is inserted with the parsed details of the pragma.  Then the
annotate token is parsed in the proper contexts and the Sema is updated with
the corresponding FPOptions using the shared ActOn function with STDC
FP_CONTRACT.

After this the FPOptions from the Sema is propagated into the AST expression
nodes.  There is no change here.

I was going to add a 'default' option besides 'on/off/fast' similar to STDC
FP_CONTRACT but then decided against it. I think that we'd have to make option
uppercase then to avoid using 'default' the keyword.  Also because of the
scoped activation of pragma I am not sure there is really a need a for this.

Differential Revision: https://reviews.llvm.org/D31276

llvm-svn: 299470
2017-04-04 21:18:36 +00:00
Eric Liu 285f804282 [ASTMatchers] add typeAliasTemplateDecl matcher.
Reviewers: hokein, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D28671

llvm-svn: 298912
2017-03-28 12:56:47 +00:00
Stephan Bergmann b6ae528de0 Add LibreOffice Clang plugin to ExternalClangExamples.rst
Reviewers: rsmith, rizsotto.mailinglist

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31133

llvm-svn: 298490
2017-03-22 08:45:49 +00:00
Eric Christopher 758aad76d8 Remove the -faltivec alias option and replace it with -maltivec everywhere.
The alias was only ever used on darwin and had some issues there,
and isn't used in practice much. Also fixes a problem with -mno-altivec
not turning off -maltivec.

Also add a diagnostic for faltivec/fno-altivec that directs users to use
maltivec options and include the altivec.h file explicitly.

llvm-svn: 298449
2017-03-21 22:06:18 +00:00
Vedant Kumar 3cbce5d278 [docs] Clarify sanitizer flag behavior
PR32346 suggests that UBSan's docs about the -fsanitize,
-fno-sanitize-recover, and -fsanitize-trap options are not explicit
enough. Try to improve the wording.

llvm-svn: 298310
2017-03-20 21:40:58 +00:00
Kostya Serebryany 6abb1d6bd8 Proposal: Backward-edge CFI for return statements (RCFI)
Summary: Proposal: Backward-edge CFI for return statements (RCFI)

Reviewers: pcc, eugenis, krasin

Reviewed By: eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31112

llvm-svn: 298303
2017-03-20 20:42:00 +00:00
Jonathan Roelofs 335777b79b Fix some sphinx -Werror's
... mostly having to do with code blocks which the syntax highlighter chokes on

llvm-svn: 298275
2017-03-20 17:07:49 +00:00
Sylvestre Ledru 35b392d069 Add more examples to clang-format configuration
Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D30990

llvm-svn: 298245
2017-03-20 12:56:40 +00:00
Bruno Cardoso Lopes 448d4289b0 [Modules] Add documentation on private frameworks
Expand a bit on private modules with some guidance on how to write
them in the context of frameworks.

rdar://problem/24758771

llvm-svn: 298012
2017-03-16 23:18:55 +00:00
Aaron Ballman 9fd6ee6a78 Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl, and ObjCPropertyDecl.
Patch by Dave Lee.

llvm-svn: 297882
2017-03-15 20:14:25 +00:00
Krasimir Georgiev 18f4aedae8 Add more clang-format changes to the 5.0 release notes
llvm-svn: 297730
2017-03-14 10:34:39 +00:00
Sylvestre Ledru 72e3fa7e2c describe the recent changes in clang-format in the 5.0 release notes
llvm-svn: 297721
2017-03-14 09:43:55 +00:00
Vedant Kumar 42c17ec5ac [ubsan] Add a nullability sanitizer
Teach UBSan to detect when a value with the _Nonnull type annotation
assumes a null value. Call expressions, initializers, assignments, and
return statements are all checked.

Because _Nonnull does not affect IRGen, the new checks are disabled by
default. The new driver flags are:

  -fsanitize=nullability-arg      (_Nonnull violation in call)
  -fsanitize=nullability-assign   (_Nonnull violation in assignment)
  -fsanitize=nullability-return   (_Nonnull violation in return stmt)
  -fsanitize=nullability          (all of the above)

This patch builds on top of UBSan's existing support for detecting
violations of the nonnull attributes ('nonnull' and 'returns_nonnull'),
and relies on the compiler-rt support for those checks. Eventually we
will need to update the diagnostic messages in compiler-rt (there are
FIXME's for this, which will be addressed in a follow-up).

One point of note is that the nullability-return check is only allowed
to kick in if all arguments to the function satisfy their nullability
preconditions. This makes it necessary to emit some null checks in the
function body itself.

Testing: check-clang and check-ubsan. I also built some Apple ObjC
frameworks with an asserts-enabled compiler, and verified that we get
valid reports.

Differential Revision: https://reviews.llvm.org/D30762

llvm-svn: 297700
2017-03-14 01:56:34 +00:00
Sylvestre Ledru 7d21a3d2c3 [clang-format] Add more examples and fix a bug in the py generation script
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D30860

llvm-svn: 297623
2017-03-13 14:42:47 +00:00
Andi-Bogdan Postelnicu 0ef8ee19f8 [clang-format] Add option to break before inheritance separation operator in class declaration.
Differential Revision: https://reviews.llvm.org/D30487

llvm-svn: 297467
2017-03-10 15:10:37 +00:00
Sylvestre Ledru f3e295a781 Remove a useless subsitution in doxygen2rst which was incorrectly replacing * by \*
Summary: For example, "int\* a;" is displayed instead of "int* a;"

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D30740

llvm-svn: 297363
2017-03-09 06:41:08 +00:00
Anna Zaks 37faed97c1 [analyzer] Improve usability of ExprInspectionChecker
Some of the magic functions take arguments of arbitrary type. However,
for semantic correctness, the compiler still requires a declaration
of these functions with the correct type. Since C does not have
argument-type-overloaded function, this made those functions hard to
use in C code. Improve this situation by allowing arbitrary suffixes
in the affected magic functions' names, thus allowing the user to
create different declarations for different types.

A patch by Keno Fischer!

Differential Revision: https://reviews.llvm.org/D30589

llvm-svn: 297325
2017-03-09 00:01:10 +00:00
Sylvestre Ledru 0385ccb34a Add more examples to clang-format configuration
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D30734

llvm-svn: 297275
2017-03-08 13:24:46 +00:00
Sylvestre Ledru d1eff2f022 Add examples to clang-format configuration
Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: krasimir, kimgr, cfe-commits

Differential Revision: https://reviews.llvm.org/D30532

llvm-svn: 297025
2017-03-06 16:35:28 +00:00
Krasimir Georgiev 32eaa864e3 [clang-format] Add a new flag FixNamespaceComments to FormatStyle
Summary:
This patch enables namespace end comments under a new flag FixNamespaceComments,
which is enabled for the LLVM and Google styles.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D30405

llvm-svn: 296632
2017-03-01 15:35:39 +00:00
Nico Weber 614e60de1c UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.
https://reviews.llvm.org/D27455

llvm-svn: 296387
2017-02-27 21:27:07 +00:00
Kevin Funk 83143a8e3e Add clazy to external Clang examples page
Reviewers: silvas, rizsotto.mailinglist, sergio.martins

Reviewed By: rizsotto.mailinglist

Differential Revision: https://reviews.llvm.org/D30252

llvm-svn: 296098
2017-02-24 08:29:46 +00:00
Ismail Donmez cb17fbb00b Update Bugzilla URLs in docs
llvm-svn: 295433
2017-02-17 08:26:54 +00:00
Anastasia Stulova b376bee642 [OpenCL][Doc] Added OpenCL vendor extension description to user manual doc
Added description of a new feature that allows to specify
vendor extension in flexible way using compiler pragma instead
of modifying source code directly (committed in clang@r289979).

Review: D29829
llvm-svn: 295313
2017-02-16 12:49:29 +00:00
Saleem Abdulrasool 5b1f0edf2d docs: update docs for objc_storeStrong behaviour
objc_storeStrong does not return a value.

llvm-svn: 294855
2017-02-11 17:24:09 +00:00
Hans Wennborg 189f1f3dae Don't try to link to the 4.0 release notes
llvm-svn: 294658
2017-02-09 23:26:34 +00:00
Amjad Aboud 546bc1103b [DebugInfo] Added support to Clang FE for generating debug info for preprocessor macros.
Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info.
Added CC1 "-debug-info-macro" flag that enables emitting macro debug info.

Differential Revision: https://reviews.llvm.org/D16135

llvm-svn: 294637
2017-02-09 22:07:24 +00:00
Vedant Kumar 6eed0d5bb5 [docs] coverage: Clarify which flags enable gcov-style profiling (NFC)
Point out that --coverage and -ftest-coverage, which is what most people
are used to, do not enable clang's frontend based coverage pass.

Suggested by Benn Bolay!

llvm-svn: 294626
2017-02-09 21:33:21 +00:00
Mike Aizatsky 9afa12bbc5 [sancov] pc_guard_init is called at least once per DSO.
Summary: Documentation update for https://reviews.llvm.org/D29662

Differential Revision: https://reviews.llvm.org/D29722

llvm-svn: 294522
2017-02-08 21:28:39 +00:00
Craig Topper d2bf7b03e5 [X86] Add -mprefetchwt1/-mno-prefetchwt1 command line options and __PREFETCHWT1__ define to match gcc.
llvm-svn: 294424
2017-02-08 08:23:40 +00:00
Craig Topper 204ecffdb4 [X86] Add -msgx/-mno-sgx command line options and __SGX__ define to match gcc.
llvm-svn: 294423
2017-02-08 08:23:17 +00:00
Craig Topper 177a57ceb3 [X86] Update command line documentation for -mclwb and -mmovbe which I forgot in my previous commits.
llvm-svn: 294420
2017-02-08 07:57:01 +00:00
Craig Topper b16cb82c93 [X86] Add -mmpx/-mno-mpx command line options and __MPX__ define to match gcc.
llvm-svn: 294419
2017-02-08 07:56:42 +00:00
Craig Topper 78b4787593 [X86] Add -mclflushopt/-mno-clflushopt command line support and __CLFLUSHOPT__ define to match gcc.
llvm-svn: 294411
2017-02-08 06:48:58 +00:00
Asiri Rathnayake b0bbb7decc Improve docs: Add missing #pragma push directive.
NFC.

llvm-svn: 293877
2017-02-02 10:35:18 +00:00
Richard Smith c5b2e00d06 [docs] Add help text and refine grouping for various options.
Also accept -G= (and -msmall-data-threshold=) as an alias for -G on MIPS as well as Hexagon.

llvm-svn: 293254
2017-01-27 02:08:37 +00:00
Richard Smith b2c82a6970 Improve workaround for Sphinx's lack of support for command line options containing '+', '.' etc. to be more stable as the set of options changes.
llvm-svn: 293252
2017-01-27 01:54:42 +00:00
Nico Weber b1706ca107 Clarify how to forward-declare __llvm_profile symbols.
llvm-svn: 293065
2017-01-25 16:01:32 +00:00
Richard Smith 081ad4d3e5 [docs] Add TableGen-based generator for command line argument documentation,
and generate documentation for all (non-hidden) options supported by the
'clang' driver.

llvm-svn: 292968
2017-01-24 19:39:46 +00:00
Kostya Serebryany 4b2ff07c11 [sanitizer-coverage] emit __sanitizer_cov_trace_pc_guard w/o a preceding 'if' by default. Update the docs, also add deprecation notes around other parts of sanitizer coverage
llvm-svn: 292862
2017-01-24 00:57:31 +00:00
Richard Smith 0abb11c5c7 Fix documentation typo from r292558.
llvm-svn: 292811
2017-01-23 18:17:46 +00:00
Richard Smith cf9f422ba1 [docs] Regenerate DiagnosticsReference.rst. We don't have automatic generation of this set up server-side yet.
llvm-svn: 292637
2017-01-20 19:27:09 +00:00
Malcolm Parsons def8f90e67 Fix documentation typo.
llvm-svn: 292595
2017-01-20 09:54:26 +00:00
Richard Smith 90854c4ad0 Fix documentation typo.
llvm-svn: 292559
2017-01-20 01:08:15 +00:00
Richard Smith 67d484bc82 Add documentation for constexpr string builtin support.
llvm-svn: 292558
2017-01-20 00:57:59 +00:00
Malcolm Parsons 207a68985b [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing
Summary:
Docs for clang::Decl and clang::TemplateSpecializationType have
not been generated since LLVM_ALIGNAS was added to them.

Tell Doxygen to expand LLVM_ALIGNAS to nothing as described at
https://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html

Reviewers: aaron.ballman, klimek, alexfh

Subscribers: ioeric, cfe-commits

Differential Revision: https://reviews.llvm.org/D28850

llvm-svn: 292477
2017-01-19 09:27:45 +00:00
Hans Wennborg f6d61d4f39 UsersManual.rst: add missing newline
llvm-svn: 292265
2017-01-17 21:31:57 +00:00
Aaron Ballman 37ff16f951 Replace non-ASCII ellipsis with "..." to silence Sphinx warnings.
llvm-svn: 292115
2017-01-16 13:42:21 +00:00
Piotr Padlewski eb9dd5aec8 Add -fstrict-vtable-pointers to UsersManual
Summary: Add missing flag to UsersManual
It would be good to merge it to 4.0 branch.

Reviewers: hans

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28727

llvm-svn: 292112
2017-01-16 13:20:08 +00:00
Sylvestre Ledru e86ee6b0a8 fix a few typo in the doc but also in the clang messages
llvm-svn: 292015
2017-01-14 11:41:45 +00:00
Malcolm Parsons c6e4583dbb Remove unused lambda captures. NFC
llvm-svn: 291939
2017-01-13 18:55:32 +00:00