Commit Graph

83916 Commits

Author SHA1 Message Date
Jan Korous 54e91a3c70 Reland "[Analyzer][WebKit] RefCntblBaseVirtualDtorChecker"
This reverts commit 1108f5c737.
2020-05-21 16:41:00 -07:00
Zequan Wu b0a0f01bc1 Revert "Add nomerge function attribute to clang"
This reverts commit 307e853954.
2020-05-21 16:13:18 -07:00
Zequan Wu 307e853954 Add nomerge function attribute to clang 2020-05-21 15:28:27 -07:00
Ben Dunbobbin 9d23b5025d [PS4] Enable relaxed relocations by default
PS4 supports these relocations types; so, we want to enable them by default.

Differential Revision: https://reviews.llvm.org/D79980
2020-05-21 23:05:44 +01:00
Stephen Kelly f85aedc167 Make the ExprMutationAnalyzer explicit about how it traverses the AST
Reviewers: aaron.ballman

Subscribers: baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72532
2020-05-21 22:34:38 +01:00
Stephen Kelly a30d411629 Set traversal explicitly where needed in tests
Reviewers: aaron.ballman, shafik

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72531
2020-05-21 22:34:38 +01:00
Yitzhak Mandelbaum 396bbae416 [libTooling][NFC]Fix typo in comment in RangeSelectors
Fixes transposed names in comment.
2020-05-21 16:13:02 -04:00
Nico Weber 1108f5c737 Revert "[Analyzer][WebKit] RefCntblBaseVirtualDtorChecker"
This reverts commit f7c7e8a523.
Breaks build everywhere.
2020-05-21 15:49:46 -04:00
Jan Korous f7c7e8a523 [Analyzer][WebKit] RefCntblBaseVirtualDtorChecker
Differential Revision: https://reviews.llvm.org/D77177
2020-05-21 11:54:49 -07:00
Yaxun (Sam) Liu 3ef11346f3 Fix DeferredDiagnosticsEmitter for bug#45987
InOMPDeviceContext may be greater than 1. It needs to be clamp to 0 and 1
to be used as index for DoneMap.
2020-05-21 11:01:40 -04:00
Kirstóf Umann 1c8f999e0b [analyzer][CallAndMessage] Add checker options for each bug type
iAs listed in the summary D77846, we have 5 different categories of bugs we're
checking for in CallAndMessage. I think the documentation placed in the code
explains my thought process behind my decisions quite well.

A non-obvious change I had here is removing the entry for
CallAndMessageUnInitRefArg. In fact, I removed the CheckerNameRef typed field
back in D77845 (it was dead code), so that checker didn't really exist in any
meaningful way anyways.

Differential Revision: https://reviews.llvm.org/D77866
2020-05-21 15:31:37 +02:00
Yaxun (Sam) Liu 361e4f14e3 Fix debug info for NoDebug attr
NoDebug attr does not totally eliminate debug info about a function when
inlining is enabled. This is inconsistent with when inlining is disabled.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D79967
2020-05-21 09:02:56 -04:00
Kirstóf Umann eeff1a970a [analyzer][CallAndMessage][NFC] Split up checkPreCall
The patch aims to use CallEvents interface in a more principled manner, and also
to highlight what this checker really does. It in fact checks for 5 different
kinds of errors (from checkPreCall, that is):

 * Invalid function pointer related errors
 * Call of methods from an invalid C++ this object
 * Function calls with incorrect amount of parameters
 * Invalid arguments for operator delete
 * Pass of uninitialized values to pass-by-value parameters

In a previous patch I complained that this checker is responsible for emitting
a lot of different diagnostics all under core.CallAndMessage's name, and this
patch shows where we could start to assign different diagnostics to different
entities.

Differential Revision: https://reviews.llvm.org/D77846
2020-05-21 12:54:56 +02:00
Haojian Wu c2c36c4f4b [clang][index] Fix a crash for accessing a null field decl.
getField() may return a nullptr, we already did that in
BodyIndexer::VisitDesignatedInitExpr, but missed one place.
2020-05-21 09:47:36 +02:00
Jake Merdich 51dbda5438 [clang-format][docfix] Update predefined styles in docs
Summary:
The predefined styles that clang-format supports are listed in two
places, and neither is up-to-date. GNU style isn't mentioned at all!

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80309
2020-05-20 20:03:53 -04:00
Kirstóf Umann 48a8c7dcbf [analyzer] Make buildbots happy 2020-05-21 01:54:50 +02:00
Kirstóf Umann 1d393eac8f [analyzer] Fix a null FunctionDecl dereference bug after D75432 2020-05-21 01:05:15 +02:00
mydeveloperday 6ef45b0426 [clang-format] Added new option IndentExternBlock
Reviewers: MyDeveloperDay, krasimir, klimek, mitchell-stellar, Abpostelnicu

Patch By: MarcusJohnson91

Reviewed By: MyDeveloperDay, Abpostelnicu

Subscribers: sylvestre.ledru, Abpostelnicu, cfe-commits

Tags: #clang, #clang-format, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D75791
2020-05-20 21:27:15 +01:00
mydeveloperday 166ebefd27 [clang-format] Set of unit test to begin to validate that we don't change defaults
Summary:
This revision is to complement {D75791} so we can be sure that we don't change any default behavior.

For now just add rules to cover AfterExternBlock, but in the future we should add cases to cover the other BraceWrapping rules for each style. This will help guard us when we change code inside of the various getXXXStyle() functions to ensure we are not breaking everyone.

Reviewed By: MarcusJohnson91

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https:
2020-05-20 21:11:10 +01:00
Alexey Bataev 414afdf940 [OPENMP]Fix PR45911: Data sharing and lambda capture.
Summary:
No need to generate inlined OpenMP region for variables captured in
lambdas or block decls, only for implicitly captured variables in the
OpenMP region.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, cfe-commits, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79966
2020-05-20 15:01:02 -04:00
Zola Bridges 60ee885990 [clang][asm goto][slh] Warn if asm goto + SLH
Summary:
Asm goto is not supported by SLH. Warn if an instance of asm goto is detected
while SLH is enabled.

Test included.

Reviewed By: jyu2

Differential Revision: https://reviews.llvm.org/D79743
2020-05-20 09:46:18 -07:00
Alexey Bataev c8a869c5e0 [OPENMP][DOCS]Update status of implemented features, NFC. 2020-05-20 10:54:53 -04:00
Melanie Blower 827be690dc [clang] FastMathFlags.allowContract should be initialized only from FPFeatures.allowFPContractAcrossStatement
Summary: Fix bug introduced in D72841 adding support for pragma float_control

Reviewers: rjmccall, Anastasia

Differential Revision: https://reviews.llvm.org/D79903
2020-05-20 06:19:10 -07:00
Artem Dergachev 3f333e0af7 [analyzer] Get scan-view executable from environment.
Fixes "Use of uninitialized value $ScanView in exec" error on systems
with scan-view executable not located in the expected place.

Patch by Oliver Tušla!

Differential Revision: https://reviews.llvm.org/D77880
2020-05-20 14:55:56 +03:00
Balázs Kéri f7c9f77ef3 [Analyzer][StreamChecker] Added support for 'fread' and 'fwrite'.
Summary:
Stream functions `fread` and `fwrite` are evaluated
and preconditions checked.
A new bug type is added for a (non fatal) warning if `fread`
is called in EOF state.

Reviewers: Szelethus, NoQ, dcoughlin, baloghadamsoftware, martong, xazax.hun

Reviewed By: Szelethus

Subscribers: rnkovacs, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gamesh411, Charusso, martong, ASDenysPetrov, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80015
2020-05-20 09:40:57 +02:00
mydeveloperday 807ab2cd0d [clang-format] [PR42164] Add Option to Break before While
Summary:
Its currently not possible to recreate the GNU style using the `BreakBeforeBraces: Custom` style due to a lack of missing `BeforeWhile` in the `BraceWrappingFlags`

The following request was raised to add `BeforeWhile` in a `do..while` context like `BeforeElse` and `BeforeCatch` to give greater control over the positioning of the `while`

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

Reviewers: krasimir, mitchell-stellar, sammccall

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79325
2020-05-20 07:48:45 +01:00
mydeveloperday cc918e90c0 [clang-format] [PR33890] Add support for Microsoft C++/CLI non standard for each looping extension
Summary:
https://bugs.llvm.org/show_bug.cgi?id=33890

This revision allow the microsoft `for each(.... in ...` nonstandard C++ extension which can be used in C++/CLI to be handled as a ForEach macro.

This prevents the breaking between the for and each onto a new line

Reviewed By: JakeMerdichAMD

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80228
2020-05-20 07:44:36 +01:00
mydeveloperday b99bf0e08b [clang-format][PR45816] Add AlignConsecutiveBitFields
Summary:
The following revision follows D80115 since @MyDeveloperDay and I apparently both had the same idea at the same time, for https://bugs.llvm.org/show_bug.cgi?id=45816 and my efforts on tooling support for AMDVLK, respectively.

This option aligns adjacent bitfield separators across lines, in a manner similar to AlignConsecutiveAssignments and friends.

Example:
```
struct RawFloat {
  uint32_t sign : 1;
  uint32_t exponent : 8;
  uint32_t mantissa : 23;
};
```
would become
```
struct RawFloat {
  uint32_t sign     : 1;
  uint32_t exponent : 8;
  uint32_t mantissa : 23;
};
```

This also handles c++2a style bitfield-initializers with AlignConsecutiveAssignments.
```
struct RawFloat {
  uint32_t sign     : 1  = 0;
  uint32_t exponent : 8  = 127;
  uint32_t mantissa : 23 = 0;
}; // defaults to 1.0f
```

Things this change does not do:
 - Align multiple comma-chained bitfield variables. None of the other
   AlignConsecutive* options seem to implement that either.
 - Detect bitfields that have a width specified with something other
   than a numeric literal (ie, `int a : SOME_MACRO;`). That'd be fairly
   difficult to parse and is rare.

Patch By:  JakeMerdichAMD

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80176
2020-05-20 07:42:58 +01:00
mydeveloperday e71c537a48 [clang-format] Fix line lengths w/ comments in align
Summary:
https://bugs.llvm.org/show_bug.cgi?id=43845

When a '//comment' trails a consecutive alignment, it adds a whitespace
replacement within the comment token. This wasn't handled correctly in
the alignment code, which treats it as a whole token and thus double
counts it.

This can wrongly trigger the "line too long, it'll wrap" alignment-break
condition with specific lengths, causing the alignment to break for
seemingly no reason.

Patch By:  JakeMerdichAMD

Reviewed By: MyDeveloperDay

Subscribers: kostyakozko, cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79465
2020-05-20 07:22:01 +01:00
Eli Friedman 62f3ef2b53 [CGCall] Annotate references with "align" attribute.
If we're going to assume references are dereferenceable, we should also
assume they're aligned: otherwise, we can't actually dereference them.

See also D80072.

Differential Revision: https://reviews.llvm.org/D80166
2020-05-19 20:21:30 -07:00
Kirstóf Umann 3a6ee4fefe [analyzer][StackAddressEscape] Tie warnings to the diagnostic checkers rather then core.StackAddrEscapeBase
Differential Revision: https://reviews.llvm.org/D78101
2020-05-20 02:26:40 +02:00
Kristóf Umann 392222dd72 [analyzer][NFC][MallocChecker] Convert many parameters into CallEvent
Exactly what it says on the tin! This is clearly not the end of the road in this
direction, the parameters could be merged far more with the use of CallEvent or
a better value type in the CallDescriptionMap, but this was shockingly difficult
enough on its own. I expect that simplifying the file further will be far easier
moving forward.

The end goal is to research how we could create a more mature checker
interaction infrastructure for more complicated C++ modeling, and I'm pretty
sure that being able successfully split up our giants is the first step in this
direction.

Differential Revision: https://reviews.llvm.org/D75432
2020-05-20 02:03:31 +02:00
Kirstóf Umann fe1a3a7e8c [analyzer] Change the default output type to PD_TEXT_MINIMAL in the frontend, error if an output loc is missing for PathDiagConsumers that need it
The title and the included test file sums everything up -- the only thing I'm
mildly afraid of is whether anyone actually depends on the weird behavior of
HTMLDiagnostics pretending to be TextDiagnostics if an output directory is not
supplied. If it is, I guess we would need to resort to tiptoeing around the
compatibility flag.

Differential Revision: https://reviews.llvm.org/D76510
2020-05-20 01:36:06 +02:00
Kirstóf Umann f2be30def3 [analyzer][NFC] Merge checkNewAllocator's paramaters into CXXAllocatorCall
Party based on this thread:
http://lists.llvm.org/pipermail/cfe-dev/2020-February/064754.html.

This patch merges two of CXXAllocatorCall's parameters, so that we are able to
supply a CallEvent object to check::NewAllocatorCall (see the description of
D75430 to see why this would be great).

One of the things mentioned by @NoQ was the following:

  I think at this point we might actually do a good job sorting out this
  check::NewAllocator issue because we have a "separate" "Environment" to hold
  the other SVal, which is "objects under construction"! - so we should probably
  simply teach CXXAllocatorCall to extract the value from the
  objects-under-construction trait of the program state and we're good.

I had MallocChecker in my crosshair for now, so I admittedly threw together
something as a proof of concept. Now that I know that this effort is worth
pursuing though, I'll happily look for a solution better then demonstrated in
this patch.

Differential Revision: https://reviews.llvm.org/D75431
2020-05-20 00:56:10 +02:00
Kirstóf Umann 3d0d2fefc0 analyzer][CallAndMessage][NFC] Change old callbacks to rely on CallEvent
The following series of patches has something similar in mind with D77474, with
the same goal to finally end incorrect checker names for good. Despite
CallAndMessage not suffering from this particular issue, it is a dependency for
many other checkers, which is problematic, because we don't really want
dependencies to also emit diagnostics (reasoning for this is also more detailed
in D77474).

CallAndMessage also has another problem, namely that it is responsible for a lot
of reports. You'll soon learn that this isn't really easy to solve for
compatibility reasons, but that is the topic of followup patches.

Differential Revision: https://reviews.llvm.org/D77845
2020-05-20 00:37:59 +02:00
Kirstóf Umann 66224d309d [analyzer][ObjCGenerics] Don't emit diagnostics under the name core.DynamicTypePropagation
Differential Revision: https://reviews.llvm.org/D78124
2020-05-20 00:19:20 +02:00
Kirstóf Umann b47d1baa53 [analyzer][NSOrCFError] Don't emit diagnostics under the name osx.NSOrCFErrorDerefChecker
Differential Revision: https://reviews.llvm.org/D78123
2020-05-20 00:05:49 +02:00
Dávid Bolvanský 47650dcbee Revert "[clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation"
This reverts commit 6d2b75e088.
2020-05-19 23:20:54 +02:00
Dávid Bolvanský 6d2b75e088 [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation 2020-05-19 23:12:08 +02:00
Erich Keane 74ef6a1147 Fix X86_64 complex-returns for regcall.
D35259 introduced a case where complex types of non-long-double would
result in FI.getReturnInfo() to not be initialized properly.  This
resulted in a crash under some very specific circumstances when
dereferencing the LLVMContext.

This patch makes sure that these types have the intended getReturnInfo
initialization.
2020-05-19 13:21:15 -07:00
Benjamin Kramer 350dadaa8a Give helpers internal linkage. NFC. 2020-05-19 22:16:37 +02:00
Artem Dergachev e42e5e4d0f [analyzer] Move apiModeling.StdCLibraryFunctionArgs to alpha.
It was enabled by default accidentally; still missing some important
features. Also it needs a better package because it doesn't boil down to
API modeling.

Differential Revision: https://reviews.llvm.org/D80213
2020-05-19 23:05:49 +03:00
Thomas Lively 3181273be7 [WebAssembly] Implement i64x2.mul and remove i8x16.mul
Summary:
This reflects changes in the spec proposal made since basic arithmetic
was first implemented.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D80174
2020-05-19 12:50:44 -07:00
Erich Keane 81a73fde5c Fix aux-target diagnostics for certain builtins
When I fixed the targets specific builtins to make sure that aux-targets
are checked, it seems I didn't consider cases where the builtins check
the target info for further info.  This patch bubbles the target-info
down to the individual checker functions to ensure that they validate
against the aux-target as well.

For non-aux-target invocations, this is an NFC.
2020-05-19 10:49:45 -07:00
mydeveloperday 5d82cb3c3a [clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format
Summary:
https://twitter.com/lefticus/status/1262392152950288384?s=20

Jason Turner's (@lefticus) most recent C++ weekly explains the usage of [[likely]] and [[unlikely]] in an 'if/else' context in C++ 20

clang-format leaves the code a little messy afterwards..

```
if (argc > 5)
  [[unlikely]] {
    // ...
  }
else if (argc < 0)
  [[likely]] {
    // ...
  }
else
  [[likely]] {
    // ...
  }
```

try to improve the situation

```
if (argc > 5) [[unlikely]] {
  // ...
} else if (argc < 0) [[likely]] {
  // ...
} else [[likely]] {
  // ...
}
```

Reviewed By: JakeMerdichAMD

Subscribers: cfe-commits, lefticus

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80144
2020-05-19 16:50:24 +01:00
mydeveloperday 575c59cf6a [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon
Summary:
https://bugs.llvm.org/show_bug.cgi?id=45614

`[[nodiscard]]` after a macro doesn't behave the same as an __attribute__ resulting in incorrect indentation

This revision corrects that behavior

See original Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1629756

Before:

```
class FooWidget : public nsBaseWidget {
public:
  FooWidget();

  NS_DECL_ISUPPORTS_INHERITED

      [[nodiscard]] nsresult
      FunctionOne();
  [[nodiscard]] nsresult FunctionTwo();
};
```

After:
```
class FooWidget : public nsBaseWidget {
public:
  FooWidget();

  NS_DECL_ISUPPORTS_INHERITED

  [[nodiscard]] nsresult FunctionOne();
  [[nodiscard]] nsresult FunctionTwo();
};
```

Reviewed By: Abpostelnicu

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79990
2020-05-19 16:47:38 +01:00
mydeveloperday 07740dd08b [clang-format] [PR44476] Add space between template and attribute
Summary:
https://bugs.llvm.org/show_bug.cgi?id=44476

```template <typename T> [[nodiscard]] int a() { return 1; }```

gets incorrectly formatted to be

```template <typename T>[[nodiscard]] int a() { return 1; }```

This revision ensure there is a space between the template and the attribute

Reviewed By: JakeMerdichAMD

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79905
2020-05-19 16:43:50 +01:00
mydeveloperday 6189dd06ad [clang-format] [PR45942] [[nodiscard]] causes && to be miss interpreted as BinaryOperators
Summary:
https://bugs.llvm.org/show_bug.cgi?id=45942

With Chromium style (although that is not important) its just it defines PointerAligmment: Left

The following arguments `S&&` are formatted differently depending on if the class has an attribute between it and the class identifier

```
class S {
  S(S&&) = default;
};

class [[nodiscard]] S {
  S(S &&) = default;
};
```

The prescense of [[nodiscard]] between the `class/struct` and the `{` causes the `{` to be incorrectly seen as a `TT_FunctionLBrace` which in turn transforms all the && to be `TT_BinaryOperators` rather than `TT_PointerOrReference`, as binary operators other spacing rules come into play causing a miss format

This revision resolves this by allowing the parseRecord to consider the [[nodisscard]]

Reviewed By: Abpostelnicu

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80008
2020-05-19 16:41:50 +01:00
Kirstóf Umann e4e1080a58 [analyzer][Nullability] Don't emit under the checker name NullabilityBase
Differential Revision: https://reviews.llvm.org/D78122
2020-05-19 17:04:06 +02:00
jasonliu 7f5d91d3ff [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX
Summary:
Created AIXABIInfo and AIXTargetCodeGenInfo for AIX ABI.

Reviewed By: Xiangling_L, ZarkoCA

Differential Revision: https://reviews.llvm.org/D79035
2020-05-19 15:00:48 +00:00