Commit Graph

1728 Commits

Author SHA1 Message Date
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