Re: [clang] 857bf5d - [FIX] Do not copy an llvm::function_ref if it has to be reused

2020-03-21 Thread David Blaikie via cfe-commits
"a problem" seems a smidge vague - was there a specific explanation for the
kind of problem that was signalled? Or was this fix a bit of a shot in the
dark?

On Sat, Feb 15, 2020 at 10:55 PM Johannes Doerfert via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Johannes Doerfert
> Date: 2020-02-16T00:51:11-06:00
> New Revision: 857bf5da35af8e1f9425e1865dab5f5fce5e38f2
>
> URL:
> https://github.com/llvm/llvm-project/commit/857bf5da35af8e1f9425e1865dab5f5fce5e38f2
> DIFF:
> https://github.com/llvm/llvm-project/commit/857bf5da35af8e1f9425e1865dab5f5fce5e38f2.diff
>
> LOG: [FIX] Do not copy an llvm::function_ref if it has to be reused
>
> Some buildbots signaled a problem in this method when the
> llvm::function_ref was copied and reused after 1228d42ddab8. To
> eliminate the problem we avoid copying the llvm::function_ref and
> instead we pass it as a const reference.
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/OpenMPClause.h
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/AST/OpenMPClause.h
> b/clang/include/clang/AST/OpenMPClause.h
> index a3831fd5950f..453c068bbeb0 100644
> --- a/clang/include/clang/AST/OpenMPClause.h
> +++ b/clang/include/clang/AST/OpenMPClause.h
> @@ -6682,10 +6682,10 @@ struct OMPTraitInfo {
>llvm::SmallVector Sets;
>
>bool anyScoreOrCondition(
> -  llvm::function_ref Cond) {
> -return llvm::any_of(Sets, [Cond](OMPTraitInfo::OMPTraitSet ) {
> +  const llvm::function_ref ) {
> +return llvm::any_of(Sets, [](OMPTraitInfo::OMPTraitSet ) {
>return llvm::any_of(
> -  Set.Selectors, [Cond](OMPTraitInfo::OMPTraitSelector )
> {
> +  Set.Selectors, [](OMPTraitInfo::OMPTraitSelector
> ) {
>  return Cond(Selector.ScoreOrCondition,
>  /* IsScore */ Selector.Kind !=
>  llvm::omp::TraitSelector::user_condition);
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] abd0905 - Revert "Revert "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-03-21 Thread David Blaikie via cfe-commits
Probably worth a bit more detail when recommitting a patch that was
reverted - in the future please include more detail about the reason for
the original revert and the specific changes to the previous version that
address that (so someone who might've reviewed the previous patch can more
quickly examine/assess the new changes compared to the previous version)

On Wed, Feb 12, 2020 at 7:31 AM Melanie Blower via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Melanie Blower
> Date: 2020-02-12T07:30:43-08:00
> New Revision: abd09053bc7aa6144873c196a7d50aa6ce6ca430
>
> URL:
> https://github.com/llvm/llvm-project/commit/abd09053bc7aa6144873c196a7d50aa6ce6ca430
> DIFF:
> https://github.com/llvm/llvm-project/commit/abd09053bc7aa6144873c196a7d50aa6ce6ca430.diff
>
> LOG: Revert "Revert "Change clang option -ffp-model=precise to select
> ffp-contract=on""
>
> This reverts commit 99c5bcbce89f07e68ccd89891a0300346705d013.
> Change clang option -ffp-model=precise to select ffp-contract=on
> Including some small touch-ups to the original commit
>
> Reviewers: rjmccall, Andy Kaylor
>
> Differential Revision: https://reviews.llvm.org/D74436
>
> Added:
>
>
> Modified:
> clang/docs/UsersManual.rst
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/test/CodeGen/ppc-emmintrin.c
> clang/test/CodeGen/ppc-xmmintrin.c
> clang/test/Driver/fp-model.c
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index 856d5e34bbcc..6c8c9f802082 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -1190,8 +1190,50 @@ installed.
>  Controlling Floating Point Behavior
>  ---
>
> -Clang provides a number of ways to control floating point behavior. The
> options
> -are listed below.
> +Clang provides a number of ways to control floating point behavior,
> including
> +with command line options and source pragmas. This section
> +describes the various floating point semantic modes and the corresponding
> options.
> +
> +.. csv-table:: Floating Point Semantic Modes
> +  :header: "Mode", "Values"
> +  :widths: 15, 30, 30
> +
> +  "except_behavior", "{ignore, strict, may_trap}",
> "ffp-exception-behavior"
> +  "fenv_access", "{off, on}", "(none)"
> +  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}",
> "frounding-math"
> +  "contract", "{on, off, fast}", "ffp-contract"
> +  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}",
> "fdenormal-fp-math"
> +  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}",
> "fdenormal-fp-math-fp32"
> +  "support_math_errno", "{on, off}", "fmath-errno"
> +  "no_honor_nans", "{on, off}", "fhonor-nans"
> +  "no_honor_infinities", "{on, off}", "fhonor-infinities"
> +  "no_signed_zeros", "{on, off}", "fsigned-zeros"
> +  "allow_reciprocal", "{on, off}", "freciprocal-math"
> +  "allow_approximate_fns", "{on, off}", "(none)"
> +  "allow_reassociation", "{on, off}", "fassociative-math"
> +
> +
> +This table describes the option settings that correspond to the three
> +floating point semantic models: precise (the default), strict, and fast.
> +
> +
> +.. csv-table:: Floating Point Models
> +  :header: "Mode", "Precise", "Strict", "Fast"
> +  :widths: 25, 15, 15, 15
> +
> +  "except_behavior", "ignore", "strict", "ignore"
> +  "fenv_access", "off", "on", "off"
> +  "rounding_mode", "tonearest", "dynamic", "tonearest"
> +  "contract", "on", "off", "fast"
> +  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
> +  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
> +  "support_math_errno", "on", "on", "off"
> +  "no_honor_nans", "off", "off", "on"
> +  "no_honor_infinities", "off", "off", "on"
> +  "no_signed_zeros", "off", "off", "on"
> +  "allow_reciprocal", "off", "off", "on"
> +  "allow_approximate_fns", "off", "off", "on"
> +  "allow_reassociation", "off", "off", "on"
>
>  .. option:: -ffast-math
>
> @@ -1385,7 +1427,7 @@ Note that floating-point operations performed as
> part of constant initialization
> and ``fast``.
> Details:
>
> -   * ``precise`` Disables optimizations that are not value-safe on
> floating-point data, although FP contraction (FMA) is enabled
> (``-ffp-contract=fast``).  This is the default behavior.
> +   * ``precise`` Disables optimizations that are not value-safe on
> floating-point data, although FP contraction (FMA) is enabled
> (``-ffp-contract=on``).  This is the default behavior.
> * ``strict`` Enables ``-frounding-math`` and
> ``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All
> of the ``-ffast-math`` enablements are disabled.
> * ``fast`` Behaves identically to specifying both ``-ffast-math`` and
> ``ffp-contract=fast``
>
>
> diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp
> b/clang/lib/Driver/ToolChains/Clang.cpp
> index 4424d8e6f72c..a11a5423b0b9 100644
> --- a/clang/lib/Driver/ToolChains/Clang.cpp
> 

Re: [clang] 736385c - EHScopeStack::Cleanup has virtual functions so the destructor should be too.

2020-03-21 Thread David Blaikie via cfe-commits
I've reverted this in b5eafda8d3ef02f9f78e090725564dd28e573322 - the
warning isn't accurate/appropriate - this type is safe as it was previously
written (having a protected non-virtual dtor and derived classes being
final with a non-virtual dtor - so there's no way (well, inside the base
class you could, but that's a very limited scope) to polymorphically
destroy this type accidentally/slicing, etc).

On Mon, Mar 2, 2020 at 7:07 AM Simon Pilgrim via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Simon Pilgrim
> Date: 2020-03-02T15:06:34Z
> New Revision: 736385c0b49d42f398ffa1458883f0d182178ef4
>
> URL:
> https://github.com/llvm/llvm-project/commit/736385c0b49d42f398ffa1458883f0d182178ef4
> DIFF:
> https://github.com/llvm/llvm-project/commit/736385c0b49d42f398ffa1458883f0d182178ef4.diff
>
> LOG: EHScopeStack::Cleanup has virtual functions so the destructor should
> be too.
>
> Fixes cppcheck warning.
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/EHScopeStack.h
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/EHScopeStack.h
> b/clang/lib/CodeGen/EHScopeStack.h
> index 0ed67aabcd62..4dd3da3e90e7 100644
> --- a/clang/lib/CodeGen/EHScopeStack.h
> +++ b/clang/lib/CodeGen/EHScopeStack.h
> @@ -148,7 +148,7 @@ class EHScopeStack {
>  virtual void anchor();
>
>protected:
> -~Cleanup() = default;
> +virtual ~Cleanup() = default;
>
>public:
>  Cleanup(const Cleanup &) = default;
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b5eafda - Revert "EHScopeStack::Cleanup has virtual functions so the destructor should be too."

2020-03-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2020-03-21T21:17:33-07:00
New Revision: b5eafda8d3ef02f9f78e090725564dd28e573322

URL: 
https://github.com/llvm/llvm-project/commit/b5eafda8d3ef02f9f78e090725564dd28e573322
DIFF: 
https://github.com/llvm/llvm-project/commit/b5eafda8d3ef02f9f78e090725564dd28e573322.diff

LOG: Revert "EHScopeStack::Cleanup has virtual functions so the destructor 
should be too."

This type was already well designed - having a protected destructor, and
derived classes being final/public non-virtual destructors, the type
couldn't be destroyed polymorphically & accidentally cause slicing.

This reverts commit 736385c0b49d42f398ffa1458883f0d182178ef4.

Added: 


Modified: 
clang/lib/CodeGen/EHScopeStack.h

Removed: 




diff  --git a/clang/lib/CodeGen/EHScopeStack.h 
b/clang/lib/CodeGen/EHScopeStack.h
index 4dd3da3e90e7..0ed67aabcd62 100644
--- a/clang/lib/CodeGen/EHScopeStack.h
+++ b/clang/lib/CodeGen/EHScopeStack.h
@@ -148,7 +148,7 @@ class EHScopeStack {
 virtual void anchor();
 
   protected:
-virtual ~Cleanup() = default;
+~Cleanup() = default;
 
   public:
 Cleanup(const Cleanup &) = default;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75747: [clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers

2020-03-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

The mention of "C++ object initializers" in the commit message is a typo, yes? 
(it should be "C# object initializers" I assume?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75747/new/

https://reviews.llvm.org/D75747



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 43606ef - Suppress an "unused variable" warning in release build

2020-03-21 Thread David Blaikie via cfe-commits
Does "isIntegerConstantExpr" have side effects that are desired/necessary?
Otherwise please change this to roll the isIntegerConstantExpr into the
assert (so that it is only executed when asserts are enabled)

On Tue, Mar 10, 2020 at 10:11 AM Mikhail Maltsev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Mikhail Maltsev
> Date: 2020-03-10T17:10:52Z
> New Revision: 43606efb6847fc9c79e7d93760a2a6191e8a8539
>
> URL:
> https://github.com/llvm/llvm-project/commit/43606efb6847fc9c79e7d93760a2a6191e8a8539
> DIFF:
> https://github.com/llvm/llvm-project/commit/43606efb6847fc9c79e7d93760a2a6191e8a8539.diff
>
> LOG: Suppress an "unused variable" warning in release build
>
> Added:
>
>
> Modified:
> clang/lib/Sema/SemaChecking.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Sema/SemaChecking.cpp
> b/clang/lib/Sema/SemaChecking.cpp
> index 24d0d9209a1d..8a2b4b019663 100644
> --- a/clang/lib/Sema/SemaChecking.cpp
> +++ b/clang/lib/Sema/SemaChecking.cpp
> @@ -2094,6 +2094,7 @@ bool Sema::CheckARMCoprocessorImmediate(const Expr
> *CoprocArg, bool WantCDE) {
>
>llvm::APSInt CoprocNoAP;
>bool IsICE = CoprocArg->isIntegerConstantExpr(CoprocNoAP, Context);
> +  (void)IsICE;
>assert(IsICE && "Coprocossor immediate is not a constant expression");
>int64_t CoprocNo = CoprocNoAP.getExtValue();
>assert(CoprocNo >= 0 && "Coprocessor immediate must be non-negative");
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 4a0267e - Convert a reachable llvm_unreachable into an assert.

2020-03-21 Thread David Blaikie via cfe-commits
Why the change? this seems counter to LLVM's style which pretty
consistently uses unreachable rather than assert(false), so far as I know?

On Tue, Mar 10, 2020 at 11:22 AM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Aaron Ballman
> Date: 2020-03-10T14:22:21-04:00
> New Revision: 4a0267e3ad8c4d47f267d7d960f127e099fb4818
>
> URL:
> https://github.com/llvm/llvm-project/commit/4a0267e3ad8c4d47f267d7d960f127e099fb4818
> DIFF:
> https://github.com/llvm/llvm-project/commit/4a0267e3ad8c4d47f267d7d960f127e099fb4818.diff
>
> LOG: Convert a reachable llvm_unreachable into an assert.
>
> Added:
>
>
> Modified:
> clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> index 01ac2bc83bb6..99e16752b51a 100644
> --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> @@ -134,9 +134,9 @@ StringRef
> AnalyzerOptions::getCheckerStringOption(StringRef CheckerName,
>  CheckerName = CheckerName.substr(0, Pos);
>} while (!CheckerName.empty() && SearchInParents);
>
> -  llvm_unreachable("Unknown checker option! Did you call
> getChecker*Option "
> -   "with incorrect parameters? User input must've been "
> -   "verified by CheckerRegistry.");
> +  assert(false && "Unknown checker option! Did you call getChecker*Option
> "
> +  "with incorrect parameters? User input must've been "
> +  "verified by CheckerRegistry.");
>
>return "";
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75558: [clang-tidy] Update abseil-duration-unnecessary-conversion check to find more cases.

2020-03-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@ymandel Sorry for this inconvenience, but Phabricator has a bug/missing 
feature where it doesn't send email if a status change (like approving a patch) 
has no user-authored text. In the future, please include some text ("Thanks!", 
"Looks good", etc) in any approval to ensure that approval is reflected on the 
LLVM mailing lists - otherwise it looks like patches are being committed 
without review/approval.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75558/new/

https://reviews.llvm.org/D75558



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76097: improve performance of getSDKName()

2020-03-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@JDevlieghere it's an annoying bug in Phab, but if you approve a patch without 
providing any textual message, Phab doesn't send email to the mailing list - so 
it ends up looking like something's committed without approval (if you're just 
looking at the mailing list). So if possible, please include a message 
("Thanks", "Looks good!" etc) when approving patches with Phab.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76097/new/

https://reviews.llvm.org/D76097



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76189: [Fuchsia] Use -ffile-prefix-map

2020-03-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@leonardchan sorry for the inconvenience, but Phabricator has a bug/missing 
feature where it doesn't send mail for bug updates that contain no 
user-authored text, so approving a patch without writing anything in the text 
box doesn't send an email to the mailing lrist (the mailing list is still 
considered the canonical source of truth for reviews, etc) and thus makes it 
looks like patches are being committed without review. When approving a patch 
through phab, please write something (eg: "Thanks!", "Looks good!", etc) in the 
text box to workaround this bug.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76189/new/

https://reviews.llvm.org/D76189



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] d9b9621 - Reland D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-21 Thread David Blaikie via cfe-commits
Please include the "Differential Revision" line so that Phab picks up
commits like this and ties them into the review (& also makes it
conveniently clickable to jump from the commit mail to the review)

On Thu, Mar 19, 2020 at 5:58 AM Djordje Todorovic via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Djordje Todorovic
> Date: 2020-03-19T13:57:30+01:00
> New Revision: d9b962100942c71a4c26debaa716f7ab0c4ea8a1
>
> URL:
> https://github.com/llvm/llvm-project/commit/d9b962100942c71a4c26debaa716f7ab0c4ea8a1
> DIFF:
> https://github.com/llvm/llvm-project/commit/d9b962100942c71a4c26debaa716f7ab0c4ea8a1.diff
>
> LOG: Reland D73534: [DebugInfo] Enable the debug entry values feature by
> default
>
> The issue that was causing the build failures was fixed with the D76164.
>
> Added:
> llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll
>
> Modified:
> clang/include/clang/Basic/CodeGenOptions.def
> clang/include/clang/Driver/CC1Options.td
> clang/lib/CodeGen/BackendUtil.cpp
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/Frontend/CompilerInvocation.cpp
> clang/test/CodeGen/debug-info-extern-call.c
> clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
> lldb/packages/Python/lldbsuite/test/decorators.py
>
> lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
> llvm/include/llvm/Target/TargetMachine.h
> llvm/include/llvm/Target/TargetOptions.h
> llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
> llvm/lib/CodeGen/CommandFlags.cpp
> llvm/lib/CodeGen/LiveDebugValues.cpp
> llvm/lib/CodeGen/TargetOptionsImpl.cpp
> llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
> llvm/lib/Target/ARM/ARMTargetMachine.cpp
> llvm/lib/Target/X86/X86TargetMachine.cpp
> llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
> llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
> llvm/test/CodeGen/X86/call-site-info-output.ll
> llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll
> llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
> llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
> llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
> llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
>
> llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
>
> llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
> llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
> llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
> llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
> llvm/test/DebugInfo/MIR/X86/callsite-stack-value.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
> llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
> llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
> llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
> llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
> llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
> llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
> llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
> llvm/test/DebugInfo/X86/dbg-value-range.ll
> llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
> llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
> llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
> llvm/test/DebugInfo/X86/loclists-dwp.ll
> llvm/test/tools/llvm-locstats/locstats.ll
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> b/clang/include/clang/Basic/CodeGenOptions.def
> index 3c8b0eeb47a5..e047054447f3 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.def
> +++ b/clang/include/clang/Basic/CodeGenOptions.def
> @@ -63,7 +63,6 @@ CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///<
> Enables the new, experimental
>  CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the
> new
> ///< pass manager.
>  CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is
> enabled.
> -CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter
> dbg info
>  CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the
> case of
> ///< '-g' + 'O>0' level.
>  CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when
> -mno-tls-direct-seg-refs
>
> diff  --git a/clang/include/clang/Driver/CC1Options.td
> b/clang/include/clang/Driver/CC1Options.td
> index 

Re: [clang] bde15de - Revert "Allow remapping the sysroot with -fdebug-prefix-map."

2020-03-21 Thread David Blaikie via cfe-commits
Please include the reason for the revert in the revert message (including
links/quotes from buildbots, etc)

On Fri, Mar 20, 2020 at 4:28 PM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Adrian Prantl
> Date: 2020-03-20T16:27:23-07:00
> New Revision: bde15de3cabff6363008e67a999e6e4559743867
>
> URL:
> https://github.com/llvm/llvm-project/commit/bde15de3cabff6363008e67a999e6e4559743867
> DIFF:
> https://github.com/llvm/llvm-project/commit/bde15de3cabff6363008e67a999e6e4559743867.diff
>
> LOG: Revert "Allow remapping the sysroot with -fdebug-prefix-map."
>
> This reverts commit 6725c4836a5b3c11227869a6f456019a244aa29f.
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/test/CodeGen/debug-prefix-map.c
> llvm/lib/DWARFLinker/DWARFLinker.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index da6cb458982b..a98d82f7152c 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -631,7 +631,7 @@ void CGDebugInfo::CreateCompileUnit() {
>? llvm::DICompileUnit::DebugNameTableKind::None
>: static_cast(
>  CGOpts.DebugNameTable),
> -  CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
> +  CGOpts.DebugRangesBaseAddress, Sysroot, SDK);
>  }
>
>  llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
>
> diff  --git a/clang/test/CodeGen/debug-prefix-map.c
> b/clang/test/CodeGen/debug-prefix-map.c
> index 354110d1b0da..5366e19447ae 100644
> --- a/clang/test/CodeGen/debug-prefix-map.c
> +++ b/clang/test/CodeGen/debug-prefix-map.c
> @@ -2,7 +2,6 @@
>  // RUN: %clang_cc1 -debug-info-kind=standalone
> -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck
> %s -check-prefix CHECK-EVIL
>  // RUN: %clang_cc1 -debug-info-kind=standalone
> -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o -
> -main-file-name debug-prefix-map.c | FileCheck %s
>  // RUN: %clang_cc1 -debug-info-kind=standalone
> -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o -
> -fdebug-compilation-dir %p | FileCheck %s -check-prefix
> CHECK-COMPILATION-DIR
> -// RUN: %clang_cc1 -debug-info-kind=standalone
> -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p
> -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
>  // RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s
> -emit-llvm -o - | FileCheck %s
>  // RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s
> -emit-llvm -o - | FileCheck %s
>
> @@ -41,4 +40,3 @@ void test_rewrite_includes() {
>  // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory:
> "/UNLIKELY_PATH/empty")
>  // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h",
> directory: "/UNLIKELY_PATH/empty")
>  // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
> -// CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "/UNLIKELY_PATH/empty"
>
> diff  --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp
> b/llvm/lib/DWARFLinker/DWARFLinker.cpp
> index fbc3a3e60cc9..8464c04f801e 100644
> --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
> +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
> @@ -1914,15 +1914,6 @@ static uint64_t getDwoId(const DWARFDie ,
> const DWARFUnit ) {
>return 0;
>  }
>
> -static std::string remapPath(std::string Path,
> - const objectPrefixMap ) {
> -  StringRef PathRef(Path);
> -  for (const auto  : ObjectPrefixMap)
> -if (PathRef.startswith(Entry.first))
> -  return (Twine(Entry.second) +
> PathRef.substr(Entry.first.size())).str();
> -  return Path;
> -}
> -
>  bool DWARFLinker::registerModuleReference(
>  DWARFDie CUDie, const DWARFUnit , const DwarfFile ,
>  OffsetsStringPool , UniquingStringPool ,
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76546: [Hexagon] MaxAtomicPromoteWidth, MaxAtomicInlineWidth are not getting set.

2020-03-21 Thread Sid Manning via Phabricator via cfe-commits
sidneym marked an inline comment as done.
sidneym added inline comments.



Comment at: clang/test/Preprocessor/hexagon-predefines.c:117
+
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \

The extra line break?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76546/new/

https://reviews.llvm.org/D76546



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-21 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1125
   const auto *ND = cast(GD.getDecl());
   std::string MangledName = getMangledNameImpl(*this, GD, ND);
 

rnk wrote:
> There are several other callers of getMangledNameImpl. Should they also use 
> this suffix? They mostly have to do with function multiversioning. Those seem 
> like they could be internal and need this treatment.
I moved the suffix append to getMangledNameImpl.  Other mangled name 
manipulations are also done here.  Added tests for multiversioned internal 
linkage symbols.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1135
+llvm::MD5 Md5;
+Md5.update(getModule().getSourceFileName());
+llvm::MD5::MD5Result R;

hubert.reinterpretcast wrote:
> tmsriram wrote:
> > hubert.reinterpretcast wrote:
> > > davidxl wrote:
> > > > rnk wrote:
> > > > > davidxl wrote:
> > > > > > Source filenames are not guaranteed to be unique, or it does 
> > > > > > contain the path as well?
> > > > > It appears to contain the path as the compiler receives it on the 
> > > > > command line. However, it is possible to design a build where this 
> > > > > string is not unique:
> > > > > ```
> > > > > cd foo
> > > > > clang -c name_conflict.c 
> > > > > cd ../bar
> > > > > clang -c name_conflict.c
> > > > > clang foo/name_conflict.o bar/name_conflict.o
> > > > > ```
> > > > > 
> > > > > I don't think we should try to handle this case, but we should 
> > > > > document the limitation somewhere. Some build systems do operate 
> > > > > changing the working directory as they go.
> > > > > 
> > > > > Can you add some to the clang/docs/UsersManual.rst file? I'd expect 
> > > > > it to show up here:
> > > > > https://clang.llvm.org/docs/UsersManual.html#command-line-options
> > > > > 
> > > > > You can elaborate that the unique names are calculated using the 
> > > > > source path passed to the compiler, and in a build system where that 
> > > > > is not unique, the function names may not be unique.
> > > > > 
> > > > > ---
> > > > > 
> > > > > I have also used this construct in the past for building single-file 
> > > > > ABI compatibility test cases:
> > > > > 
> > > > > ```
> > > > > // foo.cpp
> > > > > #ifdef PART1
> > > > > // ...
> > > > > #elif defined(PART2)
> > > > > // ...
> > > > > #endif
> > > > > 
> > > > > $ cc -c foo.cpp -DPART1
> > > > > $ cc -c foo.cpp -DPART2
> > > > > ```
> > > > yes, the first example was the scenario I meant. I agree name conflict 
> > > > due that case should be really rare. If yes, we can always use content 
> > > > based uniqueid -- by appending llvm::getUniqueModuleId -- but that is 
> > > > probably overkill.
> > > > yes, the first example was the scenario I meant. I agree name conflict 
> > > > due that case should be really rare.
> > > Except for projects where it is the rule and not the exception. One 
> > > pattern where this occurs is when each subdirectory implements one class 
> > > and there are multiple classes that implement the same interface. In each 
> > > directory, the implementation of each class is separated into files by 
> > > grouping methods of the class. The set of filenames in one such directory 
> > > may well be the same as the set in another.
> > I am not sure much can be done here other than try using getUniqueModuleId. 
> >  Just to be clear, even if the file names are the same, the actual conflict 
> > happens only when the "make " is done from the leaf directory.  Doing:
> > 
> > cc a/name_conflict.cpp -c
> > cc b/name_conflict.cpp -c 
> > 
> > should still produce unique names.
> Understood. I do happen to have been working on a project that does the whole 
> `$(MAKE) -C a/` thing with such a project layout. Content based hashing is 
> unfortunate for other reasons: The hash would be unstable during the course 
> of maintenance on the codebase. I guess the limitation is okay for the 
> intended use case of the patch.
Acknowledged.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73307/new/

https://reviews.llvm.org/D73307



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-03-21 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 251868.
tmsriram marked 11 inline comments as done.
tmsriram added a comment.

Address @rnk comments:

- Moved implementation to getMangledNameImpl to catch multi-versioned symbols 
and internal linkage globals
- Moved hash computation to consrtuctor
- Renamed option to -funique-internal-linkage-names
- Add documentation to UsersManual.rst and verified with html conversion
- Added tests for MV symbols and static globals, is there anything else? I am 
not too familiar with internal/private symbol possibilites


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73307/new/

https://reviews.llvm.org/D73307

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp
  clang/test/Driver/funique-internal-linkage-names.c

Index: clang/test/Driver/funique-internal-linkage-names.c
===
--- /dev/null
+++ clang/test/Driver/funique-internal-linkage-names.c
@@ -0,0 +1,4 @@
+// RUN: %clang -### -funique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -funique-internal-linkage-names -fno-unique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-funique-internal-linkage-names"
+// CHECK-NOOPT-NOT: "-funique-internal-linkage-names"
Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- /dev/null
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -0,0 +1,46 @@
+// This test checks if internal linkage symbols get unique names with
+// -funique-internal-linkage-names option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+static int glob;
+static int foo() {
+  return 0;
+}
+
+int (*bar())() {
+  return foo;
+}
+
+int getGlob() {
+  return glob;
+}
+
+// Multiversioning symbols
+__attribute__((target("default"))) static int mver() {
+  return 0;
+}
+
+__attribute__((target("sse4.2"))) static int mver() {
+  return 1;
+}
+
+int mver_call() {
+  return mver();
+}
+
+// PLAIN: @_ZL4glob = internal global
+// PLAIN: @_ZL3foov()
+// PLAIN: @_ZL4mverv.resolver()
+// PLAIN: @_ZL4mverv()
+// PLAIN: @_ZL4mverv.sse4.2()
+// UNIQUE-NOT: @_ZL4glob = internal global
+// UNIQUE-NOT: @_ZL3foov()
+// UNIQUE-NOT: @_ZL4mverv.resolver()
+// UNIQUE-NOT: @_ZL4mverv()
+// UNIQUE-NOT: @_ZL4mverv.sse4.2()
+// UNIQUE: @_ZL4glob.{{[0-9a-f]+}} = internal global
+// UNIQUE: @_ZL3foov.{{[0-9a-f]+}}()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.resolver()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.sse4.2()
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -958,6 +958,8 @@
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);
 
+  Opts.UniqueInternalLinkageNames =
+  Args.hasArg(OPT_funique_internal_linkage_names);
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1677,6 +1677,23 @@
on ELF targets when using the integrated assembler. This flag currently
only has an effect on ELF targets.
 
+**-f[no]-unique-internal-linkage-names**
+
+   Controls whether Clang emits a unique (best-effort) symbol name for internal
+   linkage symbols. The unique name is obtained by appending the MD5 hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple
+   functions with the same private linkage name exist in the binary.
+
+   It should be noted that this option cannot guarantee uniqueness and the
+   following is an example where it is not unique:
+
+   .. code-block:: console
+
+ $ cd $P/foo && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
+
 Profile Guided Optimization
 ---
 
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ 

[PATCH] D76545: [clang-tidy] Add a new check group 'experimental-'

2020-03-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm not sold on this being necessary as there is nothing against simply putting 
the check in the right module to begin with, then changing the registerCheck 
call to `experimenal-` as well as the docs. 
Could even do some fancy trickery with the python scripts to add support in 
there for it.
`python add_new_check.py   --experimental`
`python rename_check.py --no-experimental ` // Removes a check from 
experimental when ready for gen use


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76545/new/

https://reviews.llvm.org/D76545



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-21 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg marked 2 inline comments as done.
joerg added inline comments.



Comment at: 
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp:275
+#if TEST_STD_VER >= 11
+const size_t alignment = TEST_ALIGNOF(std::max_align_t) > 16 ?
+16 : TEST_ALIGNOF(std::max_align_t);

ldionne wrote:
> joerg wrote:
> > ldionne wrote:
> > > Can you walk me through why the check for `> 16` is required?
> > If max_align_t is 256bit, we still only expect 128bit alignment (long 
> > double). This test is still checking more than it should, e.g. in principle 
> > a target could legitimately have no natural type larger than 64bit, but 
> > support 256bit vector types and set max_align_t accordingly. The condition 
> > is here because std::min in C++11 is not constexpr.
> Naively, I would have expected the test to be:
> 
> ```
> #if TEST_STD_VER >= 11 // we know max_align_t is provided
>   static_assert(std::alignment_of::value == 
> TEST_ALIGNOF(std::max_align_t), "");
> #else
>   static_assert(std::alignment_of::value >= 
> TEST_ALIGNOF(natural_alignment), "");
> #endif
> ```
> 
> To make sure I understand, you're saying we can't do that because the 
> `std::alignment_of::value == TEST_ALIGNOF(std::max_align_t)` test would 
> sometimes fail if `alignof(std::max_align_t)` is larger than the natural 
> alignment used by `std::aligned_storage`. This also highlights that there's a 
> change in the value of `alignof(std::max_align_t)` with this change. Is that 
> correct?
Yes, the test would have failed before when `max_align_t > 16`. There is no 
change of value in `alignof(max_align_t)`, just seen by review.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73245/new/

https://reviews.llvm.org/D73245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 920d90f - The generated code does not need to check for a null Decl; NFC.

2020-03-21 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-03-21T15:48:28-04:00
New Revision: 920d90f9663f796c4797f7078684f13c96688069

URL: 
https://github.com/llvm/llvm-project/commit/920d90f9663f796c4797f7078684f13c96688069
DIFF: 
https://github.com/llvm/llvm-project/commit/920d90f9663f796c4797f7078684f13c96688069.diff

LOG: The generated code does not need to check for a null Decl; NFC.

It is already assumed to be nonnull by the code calling diagAppertainsToDecl.

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index c7380cd49652..601f186086ec 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3510,7 +3510,7 @@ static void GenerateAppertainsTo(const Record , 
raw_ostream ) {
   // of the declaration).
   OS << "virtual bool diagAppertainsToDecl(Sema , ";
   OS << "const ParsedAttr , const Decl *D) const {\n";
-  OS << "  if (!D || (";
+  OS << "  if (";
   for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
 // If the subject has custom code associated with it, use the generated
 // function for it. The function cannot be inlined into this check (yet)
@@ -3526,7 +3526,7 @@ static void GenerateAppertainsTo(const Record , 
raw_ostream ) {
 if (I + 1 != E)
   OS << " && ";
   }
-  OS << ")) {\n";
+  OS << ") {\n";
   OS << "S.Diag(Attr.getLoc(), diag::";
   OS << (Warn ? "warn_attribute_wrong_decl_type_str" :
"err_attribute_wrong_decl_type_str");



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23934: Add a -ffixed-date-time= flag that sets the initial value of __DATE__, __TIME__, __TIMESTAMP__

2020-03-21 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

Ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D23934/new/

https://reviews.llvm.org/D23934



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

I'm unsure about the `zeroext` and `signext` on the call sites now but other 
than that I think this is good. wait for @reames OK though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76140/new/

https://reviews.llvm.org/D76140



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76549: [clang-tidy] Fix RenamerClangTidy handling qualified TypeLocs

2020-03-21 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Previously if a type was accessed with a qualifier, RenamerClangTidy wouldn't 
rename the TypeLoc, this patch addresses this shortfall by trying to find the 
Unqualified TypeLoc first. Also fixed a broken test case that was dependent on 
this broken behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76549

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
@@ -57,7 +57,7 @@
 inline reference_wrapper
 cref(const Up ) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: declaration uses identifier 
'u', which is not a reserved identifier [bugprone-reserved-identifier]
-  // CHECK-FIXES: {{^}}cref(const Up &__u) noexcept {{{$}}
+  // CHECK-FIXES: {{^}}cref(const _Up &__u) noexcept {{{$}}
   return reference_wrapper(u);
 }
 
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -203,14 +203,15 @@
   }
 
   if (const auto *Loc = Result.Nodes.getNodeAs("typeLoc")) {
+auto Unqual = Loc->getUnqualifiedLoc();
 NamedDecl *Decl = nullptr;
-if (const auto  = Loc->getAs())
+if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
 // further TypeLocs handled below
 


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
@@ -57,7 +57,7 @@
 inline reference_wrapper
 cref(const Up ) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: declaration uses identifier 'u', which is not a reserved identifier [bugprone-reserved-identifier]
-  // CHECK-FIXES: {{^}}cref(const Up &__u) noexcept {{{$}}
+  // CHECK-FIXES: {{^}}cref(const _Up &__u) noexcept {{{$}}
   return reference_wrapper(u);
 }
 
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -203,14 +203,15 @@
   }
 
   if (const auto *Loc = Result.Nodes.getNodeAs("typeLoc")) {
+auto Unqual = Loc->getUnqualifiedLoc();
 NamedDecl *Decl = nullptr;
-if (const auto  = Loc->getAs())
+if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
-else if (const auto  = Loc->getAs())
+else if (const auto  = Unqual.getAs())
   Decl = Ref.getDecl();
 // further TypeLocs handled below
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-21 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 251854.
atmnpatel added a comment.

Fixed linter error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -381,6 +381,7 @@
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1843,11 +1843,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(MatchFinderAPI, matchesDynamic) {
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2812,11 +2812,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isNoneKind) {
@@ -2852,10 +2859,17 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isSharedKind) {
@@ -2891,10 +2905,63 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+}
+
+TEST(OMPDefaultClause, isFirstPrivateKind) {
+  auto Matcher = ompExecutableDirective(
+  hasAnyClause(ompDefaultClause(isFirstPrivateKind(;
+
+  const std::string Source0 = R"(
+void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+  const std::string 

[PATCH] D76547: [WebAssembly] Add wasm-exported function attribute

2020-03-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, hiraditya, 
jgravelle-google, dschuff.
Herald added a project: clang.
sbc100 added reviewers: sunfish, kripken.

This matches the existing export-name attribute but exports that symbol
but its llvm symbol name.  This corresponds directly to the existing
WASM_SYMBOL_EXPORTED symbol flag.

This allows the existing emscripgten macro `EMSCERIPTEN_KEEPALIVE` to be
implemented in terms of this attribute rather then the current
workaround which uses the `used` attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76547

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export.c
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/test/CodeGen/WebAssembly/export.ll

Index: llvm/test/CodeGen/WebAssembly/export.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/export.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define void @test() #0 {
+  ret void
+}
+
+declare void @test2() #1
+
+
+attributes #0 = { "wasm-exported" }
+attributes #1 = { "wasm-exported" }
+
+; CHECK: .export test
+; CHECK: .export test2
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -134,6 +134,12 @@
   }
 }
 
+if (F.hasFnAttribute("wasm-exported")) {
+  auto *Sym = cast(getSymbol());
+  Sym->setExported();
+  getTargetStreamer()->emitExport(Sym);
+}
+
 if (F.hasFnAttribute("wasm-export-name")) {
   auto *Sym = cast(getSymbol());
   StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString();
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
@@ -51,6 +51,8 @@
   /// .export_name
   virtual void emitExportName(const MCSymbolWasm *Sym,
   StringRef ExportName) = 0;
+  /// .export
+  virtual void emitExport(const MCSymbolWasm *Sym) = 0;
 
 protected:
   void emitValueType(wasm::ValType Type);
@@ -72,6 +74,7 @@
   void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
   void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
   void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
+  void emitExport(const MCSymbolWasm *Sym) override;
 };
 
 /// This part is for Wasm object output
@@ -91,6 +94,7 @@
   StringRef ImportName) override {}
   void emitExportName(const MCSymbolWasm *Sym,
   StringRef ExportName) override {}
+  void emitExport(const MCSymbolWasm *Sym) override {}
 };
 
 /// This part is for null output
@@ -108,6 +112,7 @@
   void emitImportModule(const MCSymbolWasm *, StringRef) override {}
   void emitImportName(const MCSymbolWasm *, StringRef) override {}
   void emitExportName(const MCSymbolWasm *, StringRef) override {}
+  void emitExport(const MCSymbolWasm *) override {}
 };
 
 } // end namespace llvm
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
@@ -100,6 +100,10 @@
<< ExportName << '\n';
 }
 
+void WebAssemblyTargetAsmStreamer::emitExport(const MCSymbolWasm *Sym) {
+  OS << "\t.export\t" << Sym->getName() << '\n';
+}
+
 void WebAssemblyTargetAsmStreamer::emitIndIdx(const MCExpr *Value) {
   OS << "\t.indidx  \t" << *Value << '\n';
 }
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -717,6 +717,15 @@
   return expect(AsmToken::EndOfStatement, "EOL");
 }
 
+if (DirectiveID.getString() == ".export") {
+  auto SymName = expectIdent();
+  if (SymName.empty())
+return true;
+  auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
+

[PATCH] D76548: docs

2020-03-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, aheejin, dschuff.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76548

Files:
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4170,8 +4170,8 @@
   let Content = [{
 Clang supports the ``__attribute__((exported))``
 attribute for the WebAssembly target. This attribute may be attached to a
-function declaration, where it causes the be exported from the linked
-WebAssembly module.
+function declaration, where it causes the symbol to be exported from the
+linked WebAssembly module.
   }];
 }
 


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4170,8 +4170,8 @@
   let Content = [{
 Clang supports the ``__attribute__((exported))``
 attribute for the WebAssembly target. This attribute may be attached to a
-function declaration, where it causes the be exported from the linked
-WebAssembly module.
+function declaration, where it causes the symbol to be exported from the
+linked WebAssembly module.
   }];
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76546: [Hexagon] MaxAtomicPromoteWidth, MaxAtomicInlineWidth are not getting set.

2020-03-21 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: kparzysz, adasgupt, bcain.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

Seeing errors while building the c++ library:
atomic:2756:16: error: use of undeclared identifier '__libcpp_signed_lock_free'

  typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76546

Files:
  clang/lib/Basic/Targets/Hexagon.h
  clang/test/Preprocessor/hexagon-predefines.c


Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -113,3 +113,20 @@
 // CHECK-LINUX: #define __unix__ 1
 // CHECK-LINUX: #define linux 1
 // CHECK-LINUX: #define unix 1
+
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-ATOMIC
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_INT_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_LONG_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
+
Index: clang/lib/Basic/Targets/Hexagon.h
===
--- clang/lib/Basic/Targets/Hexagon.h
+++ clang/lib/Basic/Targets/Hexagon.h
@@ -57,6 +57,7 @@
 LargeArrayAlign = 64;
 UseBitFieldTypeAlignment = true;
 ZeroLengthBitfieldBoundary = 32;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 
 // These are the default values anyway, but explicitly make sure
 // that the size of the boolean type is 8 bits. Bool vectors are used


Index: clang/test/Preprocessor/hexagon-predefines.c
===
--- clang/test/Preprocessor/hexagon-predefines.c
+++ clang/test/Preprocessor/hexagon-predefines.c
@@ -113,3 +113,20 @@
 // CHECK-LINUX: #define __unix__ 1
 // CHECK-LINUX: #define linux 1
 // CHECK-LINUX: #define unix 1
+
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 -target-feature +hvxv67 \
+// RUN: -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-ATOMIC
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_INT_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_LONG_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
+// CHECK-ATOMIC: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
+
Index: clang/lib/Basic/Targets/Hexagon.h
===
--- clang/lib/Basic/Targets/Hexagon.h
+++ clang/lib/Basic/Targets/Hexagon.h
@@ -57,6 +57,7 @@
 LargeArrayAlign = 64;
 UseBitFieldTypeAlignment = true;
 ZeroLengthBitfieldBoundary = 32;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 
 // These are the default values anyway, but explicitly make sure
 // that the size of the boolean type is 8 bits. Bool vectors are used
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76541: [clang-tidy][NFC] Add missing check group docs and order entries

2020-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76541/new/

https://reviews.llvm.org/D76541



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76541: [clang-tidy][NFC] Add missing check group docs and order entries

2020-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D76541#1935163 , @njames93 wrote:

> Forgive me if I'm wrong, but these kinds of changes typically don't require a 
> review.


NFC changes don't typically require a review, but  you're still welcome to ask 
for a review just the same.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76541/new/

https://reviews.llvm.org/D76541



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76541: [clang-tidy][NFC] Add missing check group docs and order entries

2020-03-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Forgive me if I'm wrong, but these kinds of changes typically don't require a 
review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76541/new/

https://reviews.llvm.org/D76541



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76534: [clang/docs] Fix various sphinx warnings/errors in docs.

2020-03-21 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG684ee2057f5d: [clang/docs] Fix various sphinx 
warnings/errors in docs. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76534/new/

https://reviews.llvm.org/D76534

Files:
  clang/docs/InternalsManual.rst
  clang/docs/LanguageExtensions.rst
  clang/docs/OpenMPSupport.rst
  clang/docs/analyzer/checkers.rst
  clang/docs/analyzer/developer-docs/DebugChecks.rst
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td

Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1176,7 +1176,7 @@
 the token limit, which can be set in three ways:
 
 1. As a limit at a specific point in a file, using the ``clang max_tokens_here``
-  pragma:
+   pragma:
 
.. code-block: c++
   #pragma clang max_tokens_here 1234
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3373,8 +3373,8 @@
   let Heading = "#pragma omp declare variant";
   let Content = [{
 The `declare variant` directive declares a specialized variant of a base
- function and specifies the context in which that specialized variant is used.
- The declare variant directive is a declarative directive.
+function and specifies the context in which that specialized variant is used.
+The declare variant directive is a declarative directive.
 The syntax of the `declare variant` construct is as follows:
 
   .. code-block:: none
@@ -3391,7 +3391,7 @@
 match(context-selector-specification)
 
 and where `variant-func-id` is the name of a function variant that is either a
- base language identifier or, for C++, a template-id.
+base language identifier or, for C++, a template-id.
 
   }];
 }
@@ -4076,8 +4076,8 @@
   including calling the ``+initialize`` method if present.
 
 - The implicit ``_cmd`` parameter containing the method's selector is still defined.
- In order to minimize code-size costs, the implementation will not emit a reference
- to the selector if the parameter is unused within the method.
+  In order to minimize code-size costs, the implementation will not emit a reference
+  to the selector if the parameter is unused within the method.
 
 Symbols for direct method implementations are implicitly given hidden
 visibility, meaning that they can only be called within the same linkage unit.
@@ -4633,7 +4633,7 @@
 The attribute ``[[gsl::Owner(T)]]`` applies to structs and classes that own an
 object of type ``T``:
 
-.. code-block:: c++
+.. code::
 
   class [[gsl::Owner(int)]] IntOwner {
   private:
@@ -4659,7 +4659,7 @@
 The attribute ``[[gsl::Pointer(T)]]`` applies to structs and classes that behave
 like pointers to an object of type ``T``:
 
-.. code-block:: c++
+.. code::
 
   class [[gsl::Pointer(int)]] IntPointer {
   private:
@@ -4718,7 +4718,7 @@
   let Category = DocCatFunction;
   let Content = [{
 .. Note:: This attribute is not yet fully implemented, it is validated but has
-no effect on the generated code.
+  no effect on the generated code.
 
 The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
 except it is specific to the body of a function. The attribute may also be
Index: clang/docs/analyzer/developer-docs/DebugChecks.rst
===
--- clang/docs/analyzer/developer-docs/DebugChecks.rst
+++ clang/docs/analyzer/developer-docs/DebugChecks.rst
@@ -281,7 +281,7 @@
   This is useful in tests, where we don't want to issue warning for all tainted
   expressions but only check for certain expressions.
   This would help to reduce the *noise* that the `TaintTest` debug checker would
-  introduce and let you focus on the `expected-warning`s that you really care
+  introduce and let you focus on the `expected-warning`'s that you really care
   about.
 
   Example usage::
Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1934,14 +1934,14 @@
 alpha.security.cert
 ^^^
 
-SEI CERT checkers which tries to find errors based on their `C coding rules`_.
+SEI CERT checkers which tries to find errors based on their `C coding rules `_.
 
 .. _alpha-security-cert-pos-checkers:
 
 alpha.security.cert.pos
 ^^^
 
-SEI CERT checkers of POSIX `C coding rules`_.
+SEI CERT checkers of `POSIX C coding rules 

[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-21 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 251847.
atmnpatel added a comment.

Comment fixes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -381,6 +381,7 @@
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1843,11 +1843,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(MatchFinderAPI, matchesDynamic) {
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2812,11 +2812,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isNoneKind) {
@@ -2852,10 +2859,17 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isSharedKind) {
@@ -2891,10 +2905,63 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+}
+
+TEST(OMPDefaultClause, isFirstPrivateKind) {
+  auto Matcher = ompExecutableDirective(
+  hasAnyClause(ompDefaultClause(isFirstPrivateKind(;
+
+  const std::string Source0 = R"(
+void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+  const std::string Source1 

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-21 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 251846.
MarcusJohnson91 added a comment.

Rebased on master


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75791/new/

https://reviews.llvm.org/D75791

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2460,14 +2460,14 @@
 }
 
 TEST_F(FormatTest, FormatsExternC) {
-  verifyFormat("extern \"C\" {\nint a;");
+  verifyFormat("extern \"C\" {\nint a; /*2.1*/");
   verifyFormat("extern \"C\" {}");
   verifyFormat("extern \"C\" {\n"
-   "int foo();\n"
+   "int FormatsExternC_1();\n"
"}");
-  verifyFormat("extern \"C\" int foo() {}");
-  verifyFormat("extern \"C\" int foo();");
-  verifyFormat("extern \"C\" int foo() {\n"
+  verifyFormat("extern \"C\" int FormatsExternC_2() {}");
+  verifyFormat("extern \"C\" int FormatsExternC_3();");
+  verifyFormat("extern \"C\" int FormatsExternC_4() {\n"
"  int i = 42;\n"
"  return i;\n"
"}");
@@ -2475,9 +2475,9 @@
   FormatStyle Style = getLLVMStyle();
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterFunction = true;
-  verifyFormat("extern \"C\" int foo() {}", Style);
-  verifyFormat("extern \"C\" int foo();", Style);
-  verifyFormat("extern \"C\" int foo()\n"
+  verifyFormat("extern \"C\" int FormatsExternC_5() {}", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_6();", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_7()\n"
"{\n"
"  int i = 42;\n"
"  return i;\n"
@@ -2486,16 +2486,41 @@
 
   Style.BraceWrapping.AfterExternBlock = true;
   Style.BraceWrapping.SplitEmptyRecord = false;
-  verifyFormat("extern \"C\"\n"
-   "{}",
-   Style);
-  verifyFormat("extern \"C\"\n"
-   "{\n"
-   "  int foo();\n"
+  verifyFormat("extern \"C\"\n{}", Style);
+  verifyFormat("extern \"C\"\n{\nint FormatsExternC_8();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "int FormatsExternC_9();\n"
"}",
Style);
 }
 
+TEST_F(FormatTest, FormatsExternBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentWidth = 2;
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_1();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_2();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_3();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_4();\n}", Style);
+}
+
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
   verifyFormat("asm(\"nop\" ::: \"memory\");");
@@ -12660,6 +12685,7 @@
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(IndentExternBlock);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1112,11 +1112,21 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
+if (Style.BraceWrapping.AfterExternBlock == true &&
+Style.IndentExternBlock == true) {
   addUnwrappedLine();
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == false) {
   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == true) {
+  

[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-21 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel marked 3 inline comments as done.
atmnpatel added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5102
   Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable)
   << P.first << P.second->getSourceRange();
   Diag(DSAStack->getDefaultDSALocation(), diag::note_omp_default_dsa_none);

jdoerfert wrote:
> atmnpatel wrote:
> > fghanim wrote:
> > > Why is `firstprivate` throwing this error? isn't the purpose of 
> > > specifying it as `default` is if a variable is not specified as anything, 
> > > then it is automatically handled as `firstprivate`? or am I 
> > > misunderstanding something?
> > My understanding is that if that line isn't there then errors won't be 
> > thrown in the special cases where firstprivate explicitly requires a data 
> > sharing attribute to be specified - such as for static variable within a 
> > namespace/global scope as per the C/C++ restrictions in the technical 
> > report.
> Do we have a test for that or can we add one, please. (If you remove this and 
> an error we expect in the existing tests is not shown anymore that is 
> sufficient.)
There are tests with expected-errors from failing to explicitly declare the 
data-sharing attributes for those variables.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-21 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1786
+// i386
+case CK_i386:
+// Netburst

craig.topper wrote:
> zoecarver wrote:
> > craig.topper wrote:
> > > I found the documentation for the 82385 cache controller chip for the 
> > > 386. It's a bit weird. The tags for the cache are based on 16 byte lines, 
> > > but there are valid bits for every 2 bytes within that line. So its 
> > > possible for only a portion of a line to be valid.
> > Interesting. Does this mean that we should be returning a different value?
> I think we should make 386 return 16.
Alright. I'll update it. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 684ee20 - [clang/docs] Fix various sphinx warnings/errors in docs.

2020-03-21 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-03-21T16:06:33Z
New Revision: 684ee2057f5d695832314c2b0d7d4c1f2d30dab5

URL: 
https://github.com/llvm/llvm-project/commit/684ee2057f5d695832314c2b0d7d4c1f2d30dab5
DIFF: 
https://github.com/llvm/llvm-project/commit/684ee2057f5d695832314c2b0d7d4c1f2d30dab5.diff

LOG: [clang/docs] Fix various sphinx warnings/errors in docs.

There are a few places with unexpected indents that trip over sphinx and
other syntax errors.

Also, the C++ syntax highlighting does not work for
class [[gsl::Owner(int)]] IntOwner {

Use a regular code:: block instead.

There are a few other warnings errors remaining, of the form
'Duplicate explicit target name: "cmdoption-clang--prefix"'. They seem
to be caused by the following
  .. option:: -B, --prefix , --prefix=

I am no Restructured Text expert, but it seems like sphinx 1.8.5
tries to generate the same target for the --prefix  and
--prefix=. This pops up in a lot of places and I am not sure how to
best resolve it

Reviewers: jfb, Bigcheese, dexonsmith, rjmccall

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/docs/InternalsManual.rst
clang/docs/LanguageExtensions.rst
clang/docs/OpenMPSupport.rst
clang/docs/analyzer/checkers.rst
clang/docs/analyzer/developer-docs/DebugChecks.rst
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticGroups.td

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index 4f1c8a584c67..3681675a3244 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -2296,7 +2296,7 @@ are created implicitly. The following spellings are 
accepted:
 placement.
   ``CXX11`` Spelled with a C++-style ``[[attr]]`` syntax with an optional
 vendor-specific namespace.
-  ``C2x``   Spelled with a C-style ``[[attr]]` syntax with an optional
+  ``C2x``   Spelled with a C-style ``[[attr]]`` syntax with an optional
 vendor-specific namespace.
   ``Declspec``  Spelled with a Microsoft-style ``__declspec(attr)`` syntax.
   ``Keyword``   The attribute is spelled as a keyword, and required custom

diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 4c7af39e93e2..aee0b82880ba 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1259,7 +1259,7 @@ ASM Goto with Output Constraints
 
 
 In addition to the functionality provided by `GCC's extended
-assembly``_, clang
+assembly `_, clang
 supports output constraints with the `goto` form.
 
 The goto form of GCC's extended assembly allows the programmer to branch to a C

diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index ecdf73871833..209a77440537 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -179,9 +179,9 @@ implementation.
 
+--+--+--+---+
 | device extension | clause: device_type   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| device extension | clause: extended device   
   | :good:`done` | 
   |
+| device extension | clause: extended device   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| device extension | clause: uses_allocators clause
   | :none:`claimed`  | 
   |
+| device extension | clause: uses_allocators clause
   | :none:`claimed`  | 
  |
 
+--+--+--+---+
 | device extension | clause: 

[PATCH] D76496: [clang-tidy] StringFindStartswith should ignore 3-arg find()

2020-03-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm not hugely familiar with the abseil library, but from what I can see 
`absl::StartsWith` takes `absl::string_view` as args. Therefore surely it makes 
sense to handle the 3rd arg for `str::find` by explicitly constructing the 
`absl::string_view` from the pointer and size.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76496/new/

https://reviews.llvm.org/D76496



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-21 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: 
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp:275
+#if TEST_STD_VER >= 11
+const size_t alignment = TEST_ALIGNOF(std::max_align_t) > 16 ?
+16 : TEST_ALIGNOF(std::max_align_t);

joerg wrote:
> ldionne wrote:
> > Can you walk me through why the check for `> 16` is required?
> If max_align_t is 256bit, we still only expect 128bit alignment (long 
> double). This test is still checking more than it should, e.g. in principle a 
> target could legitimately have no natural type larger than 64bit, but support 
> 256bit vector types and set max_align_t accordingly. The condition is here 
> because std::min in C++11 is not constexpr.
Naively, I would have expected the test to be:

```
#if TEST_STD_VER >= 11 // we know max_align_t is provided
  static_assert(std::alignment_of::value == TEST_ALIGNOF(std::max_align_t), 
"");
#else
  static_assert(std::alignment_of::value >= 
TEST_ALIGNOF(natural_alignment), "");
#endif
```

To make sure I understand, you're saying we can't do that because the 
`std::alignment_of::value == TEST_ALIGNOF(std::max_align_t)` test would 
sometimes fail if `alignof(std::max_align_t)` is larger than the natural 
alignment used by `std::aligned_storage`. This also highlights that there's a 
change in the value of `alignof(std::max_align_t)` with this change. Is that 
correct?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73245/new/

https://reviews.llvm.org/D73245



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-03-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Fantastic :-)

@rsmith and others: would appreciate feedback on giving this a feature-flag (to 
decouple from LangOpts.CPlusPlus):

- whether it's OK to have one
- whether it should be cc1-only
- the name `-f[no]recovery-ast`




Comment at: clang/include/clang/AST/Expr.h:5920
+///
+/// RecoveryExpr is type-, value- and instantiation-dependent to take advantage
+/// of existing machinery to deal with dependent code in C++, e.g. RecoveryExpr

AIUI this should be "for now" with the goal of eliminating the use of template 
dependence concepts, right?



Comment at: clang/include/clang/AST/Expr.h:5935
+  SourceLocation EndLoc, ArrayRef 
SubExprs);
+  static RecoveryExpr *CreateEmpty(ASTContext , unsigned NumStmts);
+

nit: NumStmts -> NumSubExprs?



Comment at: clang/lib/AST/ComputeDependence.cpp:460
+ExprDependence clang::computeDependence(RecoveryExpr *E) {
+  auto D = ExprDependence::TypeValueInstantiation | ExprDependence::Error;
+  for (auto *S : E->subExpressions())

Probably worth echoing with a FIXME: drop type+value+instantiation once Error 
is sufficient to suppress checks.



Comment at: clang/lib/Sema/SemaExpr.cpp:18401
+  // FIXME: use containsErrors() to suppress unwanted diags in C.
+  if (!Context.getLangOpts().CPlusPlus)
+return ExprError();

I think we should strongly consider a LangOption with an associated flag. (e.g. 
LangOptions.RecoveryAST, -f[no]recovery-ast).
If we're going to pay tho cost of letting expr creation fail, we might as well 
use it
Use cases:
 - Control rollout: we can check this in without (yet) flipping the flag on for 
all tools at once, if desired. If we flip the default and it causes problems 
for particular tools, we can turn it off for that tool rather than rolling the 
whole thing back.
 - turn on and off in lit tests to precisely test behavior and avoid dependence 
on defaults
 - allow incremental work on recovery in !CPlusPlus mode

If this makes sense to you, I'd suggest setting the default to off in this 
patch (and including some tests that pass `-frecovery-ast`), and then 
immediately following up with a patch that flips the default to on-for-C++.
This separation makes like easier for everyone if turning this on breaks 
something.

A bunch of the updates to existing tests would be deferred until that patch.



Comment at: clang/lib/Sema/TreeTransform.h:9470
+ExprResult TreeTransform::TransformRecoveryExpr(RecoveryExpr *E) {
+  return E;
+}

rsmith wrote:
> ilya-biryukov wrote:
> > rsmith wrote:
> > > We should either transform the subexpressions or just return 
> > > `ExprError()` here. With this approach, we can violate AST invariants 
> > > (eg, by having the same `Expr` reachable through two different code paths 
> > > in the same function body, or by retaining `DeclRefExpr`s referring to 
> > > declarations from the wrong context, etc).
> > Thanks, I just blindly copied what TypoExpr was doing without considering 
> > the consequences here.
> > 
> > 
> > Added the code to rebuild `RecoveryExpr`.
> > 
> > Any good way to test this?
> Hmm, testing that the old failure mode doesn't happen seems a bit tricky; any 
> test for that is going to be testing second-order effects of the code under 
> test, so will be fragile. But you can test that we're substituting into the 
> `RecoveryExpr` easily enough: put some expression for which substitution will 
> fail into a context where we'll build a `RecoveryExpr` inside a context that 
> we'll `TreeTransform`. For example, maybe:
> 
> ```
> template int *p = (T::error); // should produce "cannot take 
> address of void"
> int *q = p; // should produce "'int' cannot be used prior to '::'" in 
> instantiation
> ```
@hokein I don't think this test was added yet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69330/new/

https://reviews.llvm.org/D69330



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check

2020-03-21 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 251841.
whisperity retitled this revision from "[clang-tidy] Add 
'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check" to 
"[clang-tidy] Add 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check".
whisperity edited the summary of this revision.
whisperity set the repository for this revision to rG LLVM Github Monorepo.
whisperity added a comment.

- Renamed check to 
**`experimental-`**`cppcoreguidelines-avoid-adjacent-`**`parameters`**`-of-`**`the`**`-same-type`.
- `s/argument/parameter/g` in the code and output where appropriate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69560/new/

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-default.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-verbose.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.MinimumLength, value: 2}, \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN:   ]}' --
+
+struct T {};
+
+void memcpy(struct T *restrict dest, const struct T *restrict src) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'memcpy' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:63: note: last parameter in the adjacent range
+// CHECK-MESSAGES: :[[@LINE-3]]:38: note: at a call site, 'const struct T * restrict' might bind with same force as 'struct T *restrict'
+
+void merge(struct T *dst, const struct T *src1, const struct T *src2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 3 adjacent parameters for 'merge' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:65: note: last parameter in the adjacent range
+// CHECK-MESSAGES: :[[@LINE-3]]:27: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+// CHECK-MESSAGES: :[[@LINE-4]]:49: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+
+int equals(struct T a, struct T b) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters for 'equals' of similar type ('struct T') are
+// CHECK-MESSAGES: :[[@LINE-2]]:33: note: last parameter in the adjacent range
+
+typedef struct {
+  int x;
+} S;
+
+int equals2(S l, S r) { return l.x == r.x; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'equals2' of similar type ('S') are
+// CHECK-MESSAGES: :[[@LINE-2]]:20: note: last parameter in the adjacent range
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-verbose.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-verbose.cpp
@@ -0,0 +1,432 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.MinimumLength, value: 2}, \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN:   ]}' --
+
+void library(void *vp, void *vp2, void *vp3, int n, int m);
+// NO-WARN: The user has no chance to change only declared (usually library)
+// functions, so no diagnostic is made.

[PATCH] D76541: [clang-tidy][NFC] Add missing check group docs and order entries

2020-03-21 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 251839.
whisperity retitled this revision from "[clang-tidy][docs][NFC] Check group doc 
line was missing from darwin & linuxkernel" to "[clang-tidy][NFC] Add missing 
check group docs and order entries".
whisperity edited the summary of this revision.
whisperity added a comment.

`ClangTidyForceLinker.h` also contained the entries without alphabetic order.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76541/new/

https://reviews.llvm.org/D76541

Files:
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -62,11 +62,13 @@
 ``boost-`` Checks related to Boost library.
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
-``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
+``linuxkernel-``   Checks related to the Linux Kernel coding conventions.
 ``llvm-``  Checks related to the LLVM coding conventions.
 ``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
===
--- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -15,16 +15,16 @@
 namespace clang {
 namespace tidy {
 
-// This anchor is used to force the linker to link the CERTModule.
-extern volatile int CERTModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
-CERTModuleAnchorSource;
-
 // This anchor is used to force the linker to link the AbseilModule.
 extern volatile int AbseilModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
 AbseilModuleAnchorSource;
 
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
 // This anchor is used to force the linker to link the BoostModule.
 extern volatile int BoostModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
@@ -35,20 +35,10 @@
 static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination =
 BugproneModuleAnchorSource;
 
-// This anchor is used to force the linker to link the LinuxKernelModule.
-extern volatile int LinuxKernelModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
-LinuxKernelModuleAnchorSource;
-
-// This anchor is used to force the linker to link the LLVMModule.
-extern volatile int LLVMModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
-LLVMModuleAnchorSource;
-
-// This anchor is used to force the linker to link the LLVMLibcModule.
-extern volatile int LLVMLibcModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
-LLVMLibcModuleAnchorSource;
+// This anchor is used to force the linker to link the CERTModule.
+extern volatile int CERTModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
+CERTModuleAnchorSource;
 
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
@@ -70,10 +60,25 @@
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
-// This anchor is used to force the linker to link the AndroidModule.
-extern volatile int AndroidModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
-AndroidModuleAnchorSource;
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LinuxKernelModule.
+extern volatile int LinuxKernelModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
+LinuxKernelModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int 

[PATCH] D76545: [clang-tidy] Add a new check group 'experimental-'

2020-03-21 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added a reviewer: aaron.ballman.
whisperity added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, martong, gamesh411, Szelethus, arphaman, 
dkrupp, rnkovacs, xazax.hun, mgorny.
Herald added a project: clang.
whisperity added a parent revision: D76541: [clang-tidy][NFC] Add missing check 
group docs and order entries.
whisperity added a child revision: D69560: [clang-tidy] Add 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check.

As discussed in D69560  with @aaron.ballman, 
sometimes checks might not approximate the rule they target the best due to a 
variety of reasons. This new group should house checks that are //working// 
(i.e. no crashes and stupid outputs) but might not yet exactly match the rule 
we are trying to "sell them" as.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76545

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
  clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -65,6 +65,8 @@
 ``clang-analyzer-``Clang Static Analyzer checks.
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``darwin-``Checks related to Darwin coding conventions.
+``experimental-``  Experimental checks that will eventually move to other
+   groups.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
Index: clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
@@ -0,0 +1,45 @@
+//===-- ExperimentalTidyModule.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+namespace clang {
+namespace tidy {
+namespace experimental {
+
+/// A module containing checks that are experimental versions of future checks
+/// that belong to other modules.
+class ExperimentalModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+
+  }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap  = Options.CheckOptions;
+
+return Options;
+  }
+};
+
+// Register the LLVMTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add
+X("experimental-module",
+  "Adds checks for that are experimental versions of future checks.");
+
+} // namespace experimental
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the ExperimentalModule.
+volatile int ExperimentalModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyExperimentalModule
+  ExperimentalTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  clangTooling
+  )
Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
===
--- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -50,6 +50,11 @@
 static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
 DarwinModuleAnchorSource;
 
+// This anchor is used to force the linker to link the ExperimentalModule.
+extern volatile int ExperimentalModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ExperimentalModuleAnchorDestination =
+ExperimentalModuleAnchorSource;
+
 // This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
Index: clang-tools-extra/clang-tidy/CMakeLists.txt

[PATCH] D69560: [clang-tidy] Add 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

2020-03-21 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

@aaron.ballman I've gone over LLVM (and a few other projects). Some general 
observations:

- Length of `2` **is vile**. I understand that the C++CG rule says even lengths 
of 2 should be matched, but that is industrially infeasible unless one 
introduces such a rule incrementally to their project. Findings of length 2 are 
**, in general,** an order of magnitude more than... basically the rest of the 
findings.
  - On big projects, even the current "default" of "length `3`" seems to be too 
low. In reality, one should consider (this is likely to be out of scope for 
Tidy) how often these functions are called, and various other metrics on how 
serious an offender is.
  - LLVM: **7206** len-2 findings, 767 len-3, 194 len-4, 59 len-5, etc.)
  - OpenCV: **4391** len-2, 987 len-3, 507, 115, ...
- I did not manually evaluate OpenCV, and I think OpenCV is a project on 
which - due to their seeming design principle of type erasure - this check is 
useless.
- (Similar could be said about LLVM, we are cutting a lot of corners on 
"niceness" for absolute bleeding-edge performance!)
- Most of the findings come from low-level types, such as `bool` or `int` or 
`unsigned` or some project or library-specific (such as a few cases of `SDVal` 
in LLVM) types.
- Strings and string-like types (such as `StringRef`, `char *`, etc.) are also 
huge offenders.
  - Some of these offenders can be side-stepped with semantic typedefs (D66148 
)
- Further heuristics are definitely needed, but this patch is huge enough as 
is, I'd introduce further heuristics in future patches:
  - Allow the user to configure the set of ignored types and variable names 
from the command-line (I think this already exists as a //FIXME// in the code 
as of now)
  - Relatedness check for parameter names (more or less like in D20689 
!) //if// we can fetch parameter names -- I am 
thinking about trying to parse the variable names to find if they have a common 
prefix and number.
  - If the parameters have a //sufficient// (question is, what is sufficient) 
common ancestor in the AST (like as @zporky mentioned, assignment, comparison, 
etc., but also should consider passing them to the same function -- this would 
ignore forwarding and factory methods nicely on the first run --), they should 
be silenced.
- Forwarding and trampoline functions I've put into the //False-positive// 
category, as they will be ignored once such a heuristic is complete.
- This contributed a huge chunk of the false-positive ratio. Due to the 
trampolines and factories, and "forwarding overloads", it's around 40% on 
Xerces and LLVM. Without it, around 15%.
  - This more or less follows naturally, one offending function is one true 
positive, but every trampoline, pimple, overload, etc. on it is basically an 
additional false positive.
- Making decisions on code you're not familiar with is hard ;)

This is most likely not possible purely from Tidy as this requires the wrangler 
tooling support, but I believe people who wish to use this check should be 
encouraged to **only** take the introduced differences 

 into consideration on their project.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69560/new/

https://reviews.llvm.org/D69560



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76504: [clang] Fix crash during template sema checking

2020-03-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd260a10d98df: [clang] Fix crash during template sema 
checking (authored by gchatelet).

Changed prior to commit:
  https://reviews.llvm.org/D76504?vs=251780=251837#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76504/new/

https://reviews.llvm.org/D76504

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtins-memcpy-inline.c
  clang/test/Sema/builtins-memcpy-inline.cpp


Index: clang/test/Sema/builtins-memcpy-inline.cpp
===
--- clang/test/Sema/builtins-memcpy-inline.cpp
+++ clang/test/Sema/builtins-memcpy-inline.cpp
@@ -30,3 +30,9 @@
 void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned 
size) {
   __builtin_memcpy_inline(dst, src, size); // expected-error {{argument to 
'__builtin_memcpy_inline' must be a constant integer}}
 }
+
+template 
+void test_memcpy_inline_template(void *dst, const void *src) {
+  // we do not try to evaluate size in non intantiated templates.
+  __builtin_memcpy_inline(dst, src, size);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1649,11 +1649,16 @@
   case Builtin::BI__builtin_nontemporal_store:
 return SemaBuiltinNontemporalOverloaded(TheCallResult);
   case Builtin::BI__builtin_memcpy_inline: {
-// __builtin_memcpy_inline size argument is a constant by definition.
-if (TheCall->getArg(2)->EvaluateKnownConstInt(Context).isNullValue())
+clang::Expr *SizeOp = TheCall->getArg(2);
+// We warn about copying to or from `nullptr` pointers when `size` is
+// greater than 0. When `size` is value dependent we cannot evaluate its
+// value so we bail out.
+if (SizeOp->isValueDependent())
   break;
-CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
-CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+if (!SizeOp->EvaluateKnownConstInt(Context).isNullValue()) {
+  CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+  CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+}
 break;
   }
 #define BUILTIN(ID, TYPE, ATTRS)


Index: clang/test/Sema/builtins-memcpy-inline.cpp
===
--- clang/test/Sema/builtins-memcpy-inline.cpp
+++ clang/test/Sema/builtins-memcpy-inline.cpp
@@ -30,3 +30,9 @@
 void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned size) {
   __builtin_memcpy_inline(dst, src, size); // expected-error {{argument to '__builtin_memcpy_inline' must be a constant integer}}
 }
+
+template 
+void test_memcpy_inline_template(void *dst, const void *src) {
+  // we do not try to evaluate size in non intantiated templates.
+  __builtin_memcpy_inline(dst, src, size);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1649,11 +1649,16 @@
   case Builtin::BI__builtin_nontemporal_store:
 return SemaBuiltinNontemporalOverloaded(TheCallResult);
   case Builtin::BI__builtin_memcpy_inline: {
-// __builtin_memcpy_inline size argument is a constant by definition.
-if (TheCall->getArg(2)->EvaluateKnownConstInt(Context).isNullValue())
+clang::Expr *SizeOp = TheCall->getArg(2);
+// We warn about copying to or from `nullptr` pointers when `size` is
+// greater than 0. When `size` is value dependent we cannot evaluate its
+// value so we bail out.
+if (SizeOp->isValueDependent())
   break;
-CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
-CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+if (!SizeOp->EvaluateKnownConstInt(Context).isNullValue()) {
+  CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+  CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+}
 break;
   }
 #define BUILTIN(ID, TYPE, ATTRS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d260a10 - [clang] Fix crash during template sema checking

2020-03-21 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2020-03-21T12:42:06+01:00
New Revision: d260a10d98dff6e34d081e570df1f7c0a50b9a73

URL: 
https://github.com/llvm/llvm-project/commit/d260a10d98dff6e34d081e570df1f7c0a50b9a73
DIFF: 
https://github.com/llvm/llvm-project/commit/d260a10d98dff6e34d081e570df1f7c0a50b9a73.diff

LOG: [clang] Fix crash during template sema checking

Summary: If the size parameter of `__builtin_memcpy_inline` comes from an 
un-instantiated template parameter current code would crash.

Reviewers: efriedma, courbet

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/Sema/builtins-memcpy-inline.cpp

Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 
clang/test/Sema/builtins-memcpy-inline.c



diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8a2b4b019663..c3e168c1e736 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1649,11 +1649,16 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_nontemporal_store:
 return SemaBuiltinNontemporalOverloaded(TheCallResult);
   case Builtin::BI__builtin_memcpy_inline: {
-// __builtin_memcpy_inline size argument is a constant by definition.
-if (TheCall->getArg(2)->EvaluateKnownConstInt(Context).isNullValue())
+clang::Expr *SizeOp = TheCall->getArg(2);
+// We warn about copying to or from `nullptr` pointers when `size` is
+// greater than 0. When `size` is value dependent we cannot evaluate its
+// value so we bail out.
+if (SizeOp->isValueDependent())
   break;
-CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
-CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+if (!SizeOp->EvaluateKnownConstInt(Context).isNullValue()) {
+  CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+  CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+}
 break;
   }
 #define BUILTIN(ID, TYPE, ATTRS)

diff  --git a/clang/test/Sema/builtins-memcpy-inline.c 
b/clang/test/Sema/builtins-memcpy-inline.cpp
similarity index 86%
rename from clang/test/Sema/builtins-memcpy-inline.c
rename to clang/test/Sema/builtins-memcpy-inline.cpp
index 6d0edce92a11..5e03a975a71b 100644
--- a/clang/test/Sema/builtins-memcpy-inline.c
+++ b/clang/test/Sema/builtins-memcpy-inline.cpp
@@ -30,3 +30,9 @@ void 
test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {
 void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned 
size) {
   __builtin_memcpy_inline(dst, src, size); // expected-error {{argument to 
'__builtin_memcpy_inline' must be a constant integer}}
 }
+
+template 
+void test_memcpy_inline_template(void *dst, const void *src) {
+  // we do not try to evaluate size in non intantiated templates.
+  __builtin_memcpy_inline(dst, src, size);
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 770df90 - [clang-tidy] my work: fix sphinx docs

2020-03-21 Thread via cfe-commits

Author: abelkocsis
Date: 2020-03-21T12:29:39+01:00
New Revision: 770df9045124d9f9a3e904a7afaa6e9301254829

URL: 
https://github.com/llvm/llvm-project/commit/770df9045124d9f9a3e904a7afaa6e9301254829
DIFF: 
https://github.com/llvm/llvm-project/commit/770df9045124d9f9a3e904a7afaa6e9301254829.diff

LOG: [clang-tidy] my work: fix sphinx docs

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
index 54fecfc2e90d..7d74e05cf64d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
@@ -1,6 +1,6 @@
 .. title:: clang-tidy - cert-con36-c
 .. meta::
-:http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html
+   :http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html

 cert-con36-c
 

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
index 3dbe89517474..f74bc4496219 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
@@ -1,6 +1,6 @@
 .. title:: clang-tidy - cert-con54-cpp
 .. meta::
-:http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html
+   :http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html

 cert-con54-cpp
 ==



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a678724 - Fix Wdocumentation warning. NFCI.

2020-03-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-21T11:23:52Z
New Revision: a678724401088997f1ed594f30935c6660bf0ac0

URL: 
https://github.com/llvm/llvm-project/commit/a678724401088997f1ed594f30935c6660bf0ac0
DIFF: 
https://github.com/llvm/llvm-project/commit/a678724401088997f1ed594f30935c6660bf0ac0.diff

LOG: Fix Wdocumentation warning. NFCI.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 37a5be48b97b..b65dc5c6427b 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6322,7 +6322,6 @@ static bool canPassInRegisters(Sema , CXXRecordDecl *D,
 ///
 /// \param DiagID the primary error to report.
 /// \param MD the overriding method.
-/// \param OEK which overrides to include as notes.
 static bool
 ReportOverrides(Sema , unsigned DiagID, const CXXMethodDecl *MD,
 llvm::function_ref Report) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2020-03-21 Thread Kocsis Ábel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f4c70dd3ec6: [clang-tidy] Add spuriously-wake-up-functions 
check (authored by abelkocsis).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70876/new/

https://reviews.llvm.org/D70876

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
+#define NULL 0
+
+namespace std {
+using intmax_t = int;
+
+template 
+class ratio {
+public:
+  static constexpr intmax_t num = 0;
+  static constexpr intmax_t den = 0;
+  typedef ratio type;
+};
+typedef ratio<1, 1000> milli;
+namespace chrono {
+
+template >
+class duration {
+public:
+  using rep = Rep;
+  using period = Period;
+
+public:
+  constexpr duration() = default;
+  template 
+  constexpr explicit duration(const Rep2 );
+  template 
+  constexpr duration(const duration );
+  ~duration() = default;
+  duration(const duration &) = default;
+};
+
+template 
+class time_point {
+public:
+  using clock = Clock;
+  using duration = Duration;
+
+public:
+  constexpr time_point();
+  constexpr explicit time_point(const duration );
+  template 
+  constexpr time_point(const time_point );
+};
+
+using milliseconds = duration;
+
+class system_clock {
+public:
+  typedef milliseconds duration;
+  typedef duration::rep rep;
+  typedef duration::period period;
+  typedef chrono::time_point time_point;
+
+  static time_point now() noexcept;
+};
+} // namespace chrono
+
+class mutex;
+template 
+class unique_lock {
+public:
+  typedef Mutex mutex_type;
+
+  unique_lock() noexcept;
+  explicit unique_lock(mutex_type );
+};
+
+class mutex {
+public:
+  constexpr mutex() noexcept;
+  ~mutex();
+  mutex(const mutex &) = delete;
+  mutex =(const mutex &) = delete;
+};
+
+enum class cv_status {
+  no_timeout,
+  timeout
+};
+
+class condition_variable {
+public:
+  condition_variable();
+  ~condition_variable();
+  condition_variable(const condition_variable &) = delete;
+
+  void wait(unique_lock );
+  template 
+  void wait(unique_lock , Predicate pred);
+  template 
+  cv_status wait_until(unique_lock ,
+   const chrono::time_point _time){};
+  template 
+  bool wait_until(unique_lock ,
+  const chrono::time_point _time,
+  Predicate pred){};
+  template 
+  cv_status wait_for(unique_lock ,
+ const chrono::duration _time){};
+  template 
+  bool wait_for(unique_lock ,
+const chrono::duration _time,
+Predicate pred){};
+};
+
+} // namespace std
+
+struct Node1 {
+  void *Node1;
+  struct Node1 *next;
+};
+
+static Node1 list;
+static std::mutex m;
+static std::condition_variable condition;
+
+void consume_list_element(std::condition_variable ) {
+  std::unique_lock lk(m);
+
+  if (list.next == nullptr) {
+condition.wait(lk);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+
+  while (list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  do {
+condition.wait(lk);
+  } while (list.next == nullptr);
+
+  for (;; list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  if (list.next == nullptr) {
+while (list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+
+  if (list.next == nullptr) {
+do {
+  condition.wait(lk);
+} while (list.next == nullptr);
+  }
+
+  if (list.next == nullptr) {
+for (;; list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+  using durtype = std::chrono::duration;
+  durtype dur = std::chrono::duration();
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_for' should be placed inside a while statement or used with a conditional parameter 

[clang-tools-extra] 0f4c70d - [clang-tidy] Add spuriously-wake-up-functions check

2020-03-21 Thread via cfe-commits

Author: abelkocsis
Date: 2020-03-21T12:04:03+01:00
New Revision: 0f4c70dd3ec6d7ee831f868e3e483273daec18f0

URL: 
https://github.com/llvm/llvm-project/commit/0f4c70dd3ec6d7ee831f868e3e483273daec18f0
DIFF: 
https://github.com/llvm/llvm-project/commit/0f4c70dd3ec6d7ee831f868e3e483273daec18f0.diff

LOG: [clang-tidy] Add spuriously-wake-up-functions check

Summary:
According to
https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON54-CPP.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
and
https://wiki.sei.cmu.edu/confluence/display/c/CON36-C.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
misc-spuriously-wake-up-functions check is created. The check finds
`cnd_wait` or `wait` function calls in an `IfStmt` and  warns the user to
replace it with a `WhileStmt` or use it with a lambda parameter.

Reviewers: aaron.ballman, alexfh, hokein, jfb, Charusso

Reviewed By: aaron.ballman

Subscribers: sylvestre.ledru, whisperity, Eugene.Zelenko, mgorny, dexonsmith, 
cfe-commits, gerazo, xazax.hun, steakhal, Charusso

Tags: #clang-tools-extra, #clang

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

Added: 
clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst
clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 9dcb315a257a..d010c3ce7e52 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -41,6 +41,7 @@
 #include "SignedCharMisuseCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
+#include "SpuriouslyWakeUpFunctionsCheck.h"
 #include "StringConstructorCheck.h"
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
@@ -133,6 +134,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-sizeof-container");
 CheckFactories.registerCheck(
 "bugprone-sizeof-expression");
+CheckFactories.registerCheck(
+"bugprone-spuriously-wake-up-functions");
 CheckFactories.registerCheck(
 "bugprone-string-constructor");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index a24f3bc7eb0d..4aa3b325ce24 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -33,6 +33,7 @@ add_clang_library(clangTidyBugproneModule
   SignedCharMisuseCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp
+  SpuriouslyWakeUpFunctionsCheck.cpp
   StringConstructorCheck.cpp
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
new file mode 100644
index ..844d672f121f
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
@@ -0,0 +1,108 @@
+//===--- SpuriouslyWakeUpFunctionsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SpuriouslyWakeUpFunctionsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {
+
+  auto hasUniqueLock = hasDescendant(declRefExpr(
+  
hasDeclaration(varDecl(hasType(recordDecl(classTemplateSpecializationDecl(
+  hasName("::std::unique_lock"),
+  hasTemplateArgument(
+  0, templateArgument(refersToType(qualType(hasDeclaration(
+ cxxRecordDecl(hasName("::std::mutex"));

[PATCH] D76541: [clang-tidy][docs][NFC] Check group doc line was missing from darwin & linuxkernel

2020-03-21 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added a reviewer: aaron.ballman.
whisperity added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, martong, gamesh411, Szelethus, arphaman, 
dkrupp, rnkovacs, xazax.hun.
Herald added a project: clang.

Two directories for Tidy checks were missing the appropriate documentation 
entries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76541

Files:
  clang-tools-extra/docs/clang-tidy/index.rst


Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -62,11 +62,13 @@
 ``boost-`` Checks related to Boost library.
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
-``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
+``linuxkernel-``   Checks related to the Linux Kernel coding conventions.
 ``llvm-``  Checks related to the LLVM coding conventions.
 ``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.


Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -62,11 +62,13 @@
 ``boost-`` Checks related to Boost library.
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
-``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
+``linuxkernel-``   Checks related to the Linux Kernel coding conventions.
 ``llvm-``  Checks related to the LLVM coding conventions.
 ``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76533: [clangd] Skip ClangdVFSTest.TestStackOverflow when address sanitizer is used

2020-03-21 Thread Bjorn Pettersson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6d799156a0a: [clangd] Skip ClangdVFSTest.TestStackOverflow 
when address sanitizer is used (authored by bjope).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76533/new/

https://reviews.llvm.org/D76533

Files:
  clang-tools-extra/clangd/unittests/ClangdTests.cpp


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1083,6 +1083,9 @@
 Field(::Scope, "ns::";
 }
 
+// Tests fails when built with asan due to stack overflow. So skip running the
+// test as a workaround.
+#if !defined(__has_feature) || !__has_feature(address_sanitizer)
 TEST_F(ClangdVFSTest, TestStackOverflow) {
   MockFSProvider FS;
   ErrorCheckingCallbacks DiagConsumer;
@@ -1103,6 +1106,7 @@
   // overflow
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 }
+#endif
 
 } // namespace
 } // namespace clangd


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1083,6 +1083,9 @@
 Field(::Scope, "ns::";
 }
 
+// Tests fails when built with asan due to stack overflow. So skip running the
+// test as a workaround.
+#if !defined(__has_feature) || !__has_feature(address_sanitizer)
 TEST_F(ClangdVFSTest, TestStackOverflow) {
   MockFSProvider FS;
   ErrorCheckingCallbacks DiagConsumer;
@@ -1103,6 +1106,7 @@
   // overflow
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 }
+#endif
 
 } // namespace
 } // namespace clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76443: Use ConstantExpr cached APValues if present for code generation

2020-03-21 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1871
+llvm::Constant *CodeGenModule::EmitConstantValue(const APValue ,
+ QualType DestType,
+ CodeGenFunction *CGF) {

this looks like it is doing the same thing as `llvm::Constant 
*ConstantEmitter::tryEmitAbstract(const APValue , QualType T)` how is it 
different ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76443/new/

https://reviews.llvm.org/D76443



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] c6d7991 - [clangd] Skip ClangdVFSTest.TestStackOverflow when address sanitizer is used

2020-03-21 Thread Bjorn Pettersson via cfe-commits

Author: Bjorn Pettersson
Date: 2020-03-21T11:07:45+01:00
New Revision: c6d799156a0a351370dd428bd0fff83d467cec47

URL: 
https://github.com/llvm/llvm-project/commit/c6d799156a0a351370dd428bd0fff83d467cec47
DIFF: 
https://github.com/llvm/llvm-project/commit/c6d799156a0a351370dd428bd0fff83d467cec47.diff

LOG: [clangd] Skip ClangdVFSTest.TestStackOverflow when address sanitizer is 
used

Summary:
The ClangdVFSTest.TestStackOverflow unittest does not seem to work
when building the test with address sanitizer activated. Afaict the
goal is to get a constexpr depth error, rather than stack overflow.
But with asan instrumentation we do get stack overflow complaints
from asan. As a workaround this patch simply disables the test case,
when being built with address sanitizer activated.

Reviewers: sammccall, Dmitry.Kozhevnikov

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ClangdTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index 7ac75b8b4e29..1e5fcf3d97e1 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1083,6 +1083,9 @@ TEST_F(ClangdVFSTest, 
FallbackWhenWaitingForCompileCommand) {
 Field(::Scope, "ns::";
 }
 
+// Tests fails when built with asan due to stack overflow. So skip running the
+// test as a workaround.
+#if !defined(__has_feature) || !__has_feature(address_sanitizer)
 TEST_F(ClangdVFSTest, TestStackOverflow) {
   MockFSProvider FS;
   ErrorCheckingCallbacks DiagConsumer;
@@ -1103,6 +1106,7 @@ TEST_F(ClangdVFSTest, TestStackOverflow) {
   // overflow
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 }
+#endif
 
 } // namespace
 } // namespace clangd



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2020-03-21 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 251829.
abelkocsis added a comment.

Format fix


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70876/new/

https://reviews.llvm.org/D70876

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
+#define NULL 0
+
+namespace std {
+using intmax_t = int;
+
+template 
+class ratio {
+public:
+  static constexpr intmax_t num = 0;
+  static constexpr intmax_t den = 0;
+  typedef ratio type;
+};
+typedef ratio<1, 1000> milli;
+namespace chrono {
+
+template >
+class duration {
+public:
+  using rep = Rep;
+  using period = Period;
+
+public:
+  constexpr duration() = default;
+  template 
+  constexpr explicit duration(const Rep2 );
+  template 
+  constexpr duration(const duration );
+  ~duration() = default;
+  duration(const duration &) = default;
+};
+
+template 
+class time_point {
+public:
+  using clock = Clock;
+  using duration = Duration;
+
+public:
+  constexpr time_point();
+  constexpr explicit time_point(const duration );
+  template 
+  constexpr time_point(const time_point );
+};
+
+using milliseconds = duration;
+
+class system_clock {
+public:
+  typedef milliseconds duration;
+  typedef duration::rep rep;
+  typedef duration::period period;
+  typedef chrono::time_point time_point;
+
+  static time_point now() noexcept;
+};
+} // namespace chrono
+
+class mutex;
+template 
+class unique_lock {
+public:
+  typedef Mutex mutex_type;
+
+  unique_lock() noexcept;
+  explicit unique_lock(mutex_type );
+};
+
+class mutex {
+public:
+  constexpr mutex() noexcept;
+  ~mutex();
+  mutex(const mutex &) = delete;
+  mutex =(const mutex &) = delete;
+};
+
+enum class cv_status {
+  no_timeout,
+  timeout
+};
+
+class condition_variable {
+public:
+  condition_variable();
+  ~condition_variable();
+  condition_variable(const condition_variable &) = delete;
+
+  void wait(unique_lock );
+  template 
+  void wait(unique_lock , Predicate pred);
+  template 
+  cv_status wait_until(unique_lock ,
+   const chrono::time_point _time){};
+  template 
+  bool wait_until(unique_lock ,
+  const chrono::time_point _time,
+  Predicate pred){};
+  template 
+  cv_status wait_for(unique_lock ,
+ const chrono::duration _time){};
+  template 
+  bool wait_for(unique_lock ,
+const chrono::duration _time,
+Predicate pred){};
+};
+
+} // namespace std
+
+struct Node1 {
+  void *Node1;
+  struct Node1 *next;
+};
+
+static Node1 list;
+static std::mutex m;
+static std::condition_variable condition;
+
+void consume_list_element(std::condition_variable ) {
+  std::unique_lock lk(m);
+
+  if (list.next == nullptr) {
+condition.wait(lk);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+
+  while (list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  do {
+condition.wait(lk);
+  } while (list.next == nullptr);
+
+  for (;; list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  if (list.next == nullptr) {
+while (list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+
+  if (list.next == nullptr) {
+do {
+  condition.wait(lk);
+} while (list.next == nullptr);
+  }
+
+  if (list.next == nullptr) {
+for (;; list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+  using durtype = std::chrono::duration;
+  durtype dur = std::chrono::duration();
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_for' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur, [] { return 1; });
+  }
+ 

[PATCH] D76533: [clangd] Skip ClangdVFSTest.TestStackOverflow when address sanitizer is used

2020-03-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

This makes sense to me. We set the thread stack size to 
`clang::DesiredStackSize` which is an empirical hardcoded number tuned for a 
regular build, not asan.

Thanks, and sorry for the problems!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76533/new/

https://reviews.llvm.org/D76533



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76538: [WebAssembly] Add SIMD integer abs builtins

2020-03-21 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde6cd3e836e1: [WebAssembly] Add SIMD integer abs builtins 
(authored by tlively).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76538/new/

https://reviews.llvm.org/D76538

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c


Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -338,6 +338,30 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 abs_i8x16(i8x16 v) {
+  return __builtin_wasm_abs_i8x16(v);
+  // WEBASSEMBLY: %neg = sub <16 x i8> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <16 x i8> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <16 x i1> %abscond, <16 x i8> %neg, <16 x i8> 
%v
+  // WEBASSEMBLY: ret <16 x i8> %abs
+}
+
+i16x8 abs_i16x8(i16x8 v) {
+  return __builtin_wasm_abs_i16x8(v);
+  // WEBASSEMBLY: %neg = sub <8 x i16> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <8 x i16> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <8 x i1> %abscond, <8 x i16> %neg, <8 x i16> %v
+  // WEBASSEMBLY: ret <8 x i16> %abs
+}
+
+i32x4 abs_i32x4(i32x4 v) {
+  return __builtin_wasm_abs_i32x4(v);
+  // WEBASSEMBLY: %neg = sub <4 x i32> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <4 x i32> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <4 x i1> %abscond, <4 x i32> %neg, <4 x i32> %v
+  // WEBASSEMBLY: ret <4 x i32> %abs
+}
+
 i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_min_s_i8x16(x, y);
   // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15050,6 +15050,15 @@
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_abs_i8x16:
+  case WebAssembly::BI__builtin_wasm_abs_i16x8:
+  case WebAssembly::BI__builtin_wasm_abs_i32x4: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+Value *Neg = Builder.CreateNeg(Vec, "neg");
+Constant *Zero = llvm::Constant::getNullValue(Vec->getType());
+Value *ICmp = Builder.CreateICmpSLT(Vec, Zero, "abscond");
+return Builder.CreateSelect(ICmp, Neg, Vec, "abs");
+  }
   case WebAssembly::BI__builtin_wasm_min_s_i8x16:
   case WebAssembly::BI__builtin_wasm_min_u_i8x16:
   case WebAssembly::BI__builtin_wasm_max_s_i8x16:
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -98,6 +98,10 @@
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 
+TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_abs_i32x4, "V4iV4i", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16cV16cV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16cV16cV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_s_i8x16, "V16cV16cV16c", "nc", "simd128")


Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -338,6 +338,30 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 abs_i8x16(i8x16 v) {
+  return __builtin_wasm_abs_i8x16(v);
+  // WEBASSEMBLY: %neg = sub <16 x i8> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <16 x i8> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <16 x i1> %abscond, <16 x i8> %neg, <16 x i8> %v
+  // WEBASSEMBLY: ret <16 x i8> %abs
+}
+
+i16x8 abs_i16x8(i16x8 v) {
+  return __builtin_wasm_abs_i16x8(v);
+  // WEBASSEMBLY: %neg = sub <8 x i16> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <8 x i16> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <8 x i1> %abscond, <8 x i16> %neg, <8 x i16> %v
+  // WEBASSEMBLY: ret <8 x i16> %abs
+}
+
+i32x4 abs_i32x4(i32x4 v) {
+  return __builtin_wasm_abs_i32x4(v);
+  // WEBASSEMBLY: %neg = sub <4 x i32> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <4 x i32> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <4 x i1> %abscond, <4 x i32> %neg, <4 x i32> %v
+  // WEBASSEMBLY: ret <4 x i32> %abs
+}
+
 i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_min_s_i8x16(x, y);
   // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y
Index: clang/lib/CodeGen/CGBuiltin.cpp

[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1786
+// i386
+case CK_i386:
+// Netburst

zoecarver wrote:
> craig.topper wrote:
> > I found the documentation for the 82385 cache controller chip for the 386. 
> > It's a bit weird. The tags for the cache are based on 16 byte lines, but 
> > there are valid bits for every 2 bytes within that line. So its possible 
> > for only a portion of a line to be valid.
> Interesting. Does this mean that we should be returning a different value?
I think we should make 386 return 16.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] de6cd3e - [WebAssembly] Add SIMD integer abs builtins

2020-03-21 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-03-21T00:21:24-07:00
New Revision: de6cd3e836e10ca1b893459d38e7052b7513d55e

URL: 
https://github.com/llvm/llvm-project/commit/de6cd3e836e10ca1b893459d38e7052b7513d55e
DIFF: 
https://github.com/llvm/llvm-project/commit/de6cd3e836e10ca1b893459d38e7052b7513d55e.diff

LOG: [WebAssembly] Add SIMD integer abs builtins

Summary:
Since the conditional operator cannot be used with vector conditions
in C, we need a builtin to be able to express this operation in C
source.

Reviewers: aheejin

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

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 86d17fc952ec..5fb7a603fe17 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -98,6 +98,10 @@ TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, 
"V16cV16cV16c", "nc", "simd1
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 
+TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_abs_i32x4, "V4iV4i", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16cV16cV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16cV16cV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_s_i8x16, "V16cV16cV16c", "nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 413dbf95f1b9..8d86424c60a9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15050,6 +15050,15 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_abs_i8x16:
+  case WebAssembly::BI__builtin_wasm_abs_i16x8:
+  case WebAssembly::BI__builtin_wasm_abs_i32x4: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+Value *Neg = Builder.CreateNeg(Vec, "neg");
+Constant *Zero = llvm::Constant::getNullValue(Vec->getType());
+Value *ICmp = Builder.CreateICmpSLT(Vec, Zero, "abscond");
+return Builder.CreateSelect(ICmp, Neg, Vec, "abs");
+  }
   case WebAssembly::BI__builtin_wasm_min_s_i8x16:
   case WebAssembly::BI__builtin_wasm_min_u_i8x16:
   case WebAssembly::BI__builtin_wasm_max_s_i8x16:

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 0d70ea601d79..8b497d95298c 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -338,6 +338,30 @@ i8x16 sub_saturate_u_i8x16(i8x16 x, i8x16 y) {
   // WEBASSEMBLY-NEXT: ret
 }
 
+i8x16 abs_i8x16(i8x16 v) {
+  return __builtin_wasm_abs_i8x16(v);
+  // WEBASSEMBLY: %neg = sub <16 x i8> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <16 x i8> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <16 x i1> %abscond, <16 x i8> %neg, <16 x i8> 
%v
+  // WEBASSEMBLY: ret <16 x i8> %abs
+}
+
+i16x8 abs_i16x8(i16x8 v) {
+  return __builtin_wasm_abs_i16x8(v);
+  // WEBASSEMBLY: %neg = sub <8 x i16> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <8 x i16> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <8 x i1> %abscond, <8 x i16> %neg, <8 x i16> %v
+  // WEBASSEMBLY: ret <8 x i16> %abs
+}
+
+i32x4 abs_i32x4(i32x4 v) {
+  return __builtin_wasm_abs_i32x4(v);
+  // WEBASSEMBLY: %neg = sub <4 x i32> zeroinitializer, %v
+  // WEBASSEMBLY: %abscond = icmp slt <4 x i32> %v, zeroinitializer
+  // WEBASSEMBLY: %abs = select <4 x i1> %abscond, <4 x i32> %neg, <4 x i32> %v
+  // WEBASSEMBLY: ret <4 x i32> %abs
+}
+
 i8x16 min_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_min_s_i8x16(x, y);
   // WEBASSEMBLY: %0 = icmp slt <16 x i8> %x, %y



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

What should the behavior of the builtin be if the calling function has its own 
target cpu like __attribute__((target("arch=sandybridge"))) and that CPU has a 
different size than the CPU that was passed on the command line?




Comment at: clang/include/clang/Basic/Builtins.def:1483
 BUILTIN(__builtin_preserve_access_index, "v.", "t")
+BUILTIN(__builtin_get_cpu_cache_line_size, "z", "nctu")
 

Can this be "zv" and drop the "tu" from the second string?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76525/new/

https://reviews.llvm.org/D76525



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits