[PATCH] D72901: [OpenMP] [DOCS] Update OMP5.0 feature status table [NFC]

2020-01-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/docs/OpenMPSupport.rst:194
 
+--+--+--+---+
-| device extension | requires directive (unified shared memory)
   | :good:`done` | 
  |
+| device extension | requires directive
   | :good:`done` | 
  |
 
+--+--+--+---+

We have support only for unified memory, so must be `partial`



Comment at: clang/docs/OpenMPSupport.rst:210
 
+--+--+--+---+
-| device extension | map(replicate) or map(local) when requires 
unified_shared_me | :part:`worked on`| D55719,D55892
 |
+| device extension | map(local) when requires 
unified_shared_memory   | :part:`worked on`| D55719,D55892  
   |
 
+--+--+--+---+

I assume, it is `done`.



Comment at: clang/docs/OpenMPSupport.rst:216
 
+--+--+--+---+
+| device extension | pointer attachment
   | :none:`unclaimed`| 
  |
++--+--+--+---+

Is this for Fortran?



Comment at: clang/docs/OpenMPSupport.rst:240
++--+--+--+---+
+| misc extension   | prevent new type definitions in clauses   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+

What is this?



Comment at: clang/docs/OpenMPSupport.rst:242
 
+--+--+--+---+
-| misc extensions  | prevent new type definitions in clauses   
   | :none:`unclaimed`| 
  |
+| memory model extension   | memory model update   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+

What kind of memory model update?


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

https://reviews.llvm.org/D72901



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


Re: [clang] b72a8c6 - PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2020-01-17 Thread Hans Wennborg via cfe-commits
cherry-picked in 7a8b8f09daa and fdb501e59f2

Maybe we should expand the release note since this can be a
compatibility problem for some? For example it affected Chromium as it
broke something in Skia:
https://bugs.chromium.org/p/chromium/issues/detail?id=1042470

On Wed, Jan 15, 2020 at 10:18 PM Richard Smith  wrote:
>
> Hi Hans,
>
> This flag flip just missed the branch point; can it be applied to the Clang 
> 10 branch? (You'll also need 388eaa1.) Let me know if that's OK, and I'll 
> remove the changes to the release notes from master. (Otherwise the version 
> number in which this applies needs to be bumped.)
>
> On Wed, 15 Jan 2020 at 13:16, Richard Smith via cfe-commits 
>  wrote:
>>
>>
>> Author: Richard Smith
>> Date: 2020-01-15T13:14:57-08:00
>> New Revision: b72a8c65e4e34779b6bc9e466203f553f5294486
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/b72a8c65e4e34779b6bc9e466203f553f5294486
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/b72a8c65e4e34779b6bc9e466203f553f5294486.diff
>>
>> LOG: PR17164: Change clang's default behavior from 
>> -flax-vector-conversions=all to -flax-vector-conversions=integer.
>>
>> Summary:
>> See proposal on cfe-dev:
>> http://lists.llvm.org/pipermail/cfe-dev/2019-April/062030.html
>>
>> Reviewers: SjoerdMeijer, eli.friedman
>>
>> Subscribers: kristof.beyls, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D67678
>>
>> Added:
>>
>>
>> Modified:
>> clang/docs/CommandGuide/clang.rst
>> clang/docs/ReleaseNotes.rst
>> clang/include/clang/Basic/LangOptions.def
>> clang/test/Headers/altivec-header.c
>> clang/test/Headers/arm-neon-header.c
>> clang/test/Headers/x86-intrinsics-headers.c
>> clang/test/Headers/x86intrin-2.c
>> clang/test/Headers/x86intrin.c
>> clang/test/Sema/vector-assign.c
>> clang/test/Sema/vector-cast.c
>> clang/test/Sema/vector-ops.c
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/docs/CommandGuide/clang.rst 
>> b/clang/docs/CommandGuide/clang.rst
>> index 7b0873600fc3..6947450beb43 100644
>> --- a/clang/docs/CommandGuide/clang.rst
>> +++ b/clang/docs/CommandGuide/clang.rst
>> @@ -278,9 +278,18 @@ Language Selection and Mode Options
>>   Make all string literals default to writable.  This disables uniquing of
>>   strings and other optimizations.
>>
>> -.. option:: -flax-vector-conversions
>> +.. option:: -flax-vector-conversions, -flax-vector-conversions=, 
>> -fno-lax-vector-conversions
>>
>>   Allow loose type checking rules for implicit vector conversions.
>> + Possible values of :
>> +
>> + - ``none``: allow no implicit conversions between vectors
>> + - ``integer``: allow implicit bitcasts between integer vectors of the same
>> +   overall bit-width
>> + - ``all``: allow implicit bitcasts between any vectors of the same
>> +   overall bit-width
>> +
>> +  defaults to ``integer`` if unspecified.
>>
>>  .. option:: -fblocks
>>
>>
>> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
>> index e5b5438216ef..d081c885a0b3 100644
>> --- a/clang/docs/ReleaseNotes.rst
>> +++ b/clang/docs/ReleaseNotes.rst
>> @@ -62,6 +62,15 @@ Non-comprehensive list of changes in this release
>>  -
>>
>>
>> +* Lax vector conversions involving floating-point vectors have been disabled
>> +  by default, and can no longer be enabled with 
>> ``-flax-vector-conversions``.
>> +  This matches the behavior of these flags in GCC, but code relying on 
>> implicit
>> +  vector bitcasts between integer and floating-point types that used to 
>> compile
>> +  with older versions of Clang is no longer accepted by default in Clang 10.
>> +  The old behavior can be restored with ``-flax-vector-conversions=all``.
>> +  In a future release of Clang, we intend to change the default to
>> +  ``-fno-lax-vector-conversions``.
>> +
>>  New Compiler Flags
>>  --
>>
>> @@ -78,6 +87,21 @@ Modified Compiler Flags
>>  ---
>>
>>
>> +- ``-flax-vector-conversions`` has been split into three
>> diff erent levels of
>> +  laxness:
>> +
>> +  - ``-flax-vector-conversions=all``: This is Clang's historical default, 
>> and
>> +permits implicit vector conversions (performed as bitcasts) between any
>> +two vector types of the same overall bit-width.
>> +
>> +  - ``-flax-vector-conversions=integer``: This is Clang's current default,
>> +and permits implicit vector conversions (performed as bitcasts) between
>> +any two integer vector types of the same overall bit-width.
>> +Synonym: ``-flax-vector-conversions``.
>> +
>> +  - ``-flax-vector-conversions=none``: Do not perform any implicit bitcasts
>> +between vector types. Synonym: ``-fno-lax-vector-conversions``.
>> +
>>  New Pragmas in Clang
>>  
>>
>>
>> diff  --git a/clang/include/clang/Basic/LangOptions.def 
>> b/clang/include/clang/Ba

[PATCH] D72903: [HIP] use GetProgramPath for executable discovery

2020-01-17 Thread Holger Wünsche via Phabricator via cfe-commits
DieGoldeneEnte created this revision.
DieGoldeneEnte added reviewers: yaxunl, tra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change replaces the manual building of executable paths using 
llvm::sys::path::append with GetProgramPath. This enables adding other paths in 
case executables reside in different directories and makes the code easier to 
read.

This was previously part of D72806 , but was 
split up for easier review.


Repository:
  rC Clang

https://reviews.llvm.org/D72903

Files:
  clang/lib/Driver/ToolChains/HIP.cpp


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -105,9 +105,8 @@
   CmdArgs.push_back("-o");
   auto OutputFileName = getOutputFileName(C, OutputFilePrefix, "-linked", 
"bc");
   CmdArgs.push_back(OutputFileName);
-  SmallString<128> ExecPath(C.getDriver().Dir);
-  llvm::sys::path::append(ExecPath, "llvm-link");
-  const char *Exec = Args.MakeArgString(ExecPath);
+  const char *Exec =
+  Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
   C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
   return OutputFileName;
 }
@@ -133,9 +132,8 @@
   auto OutputFileName =
   getOutputFileName(C, OutputFilePrefix, "-optimized", "bc");
   OptArgs.push_back(OutputFileName);
-  SmallString<128> OptPath(C.getDriver().Dir);
-  llvm::sys::path::append(OptPath, "opt");
-  const char *OptExec = Args.MakeArgString(OptPath);
+  const char *OptExec =
+  Args.MakeArgString(getToolChain().GetProgramPath("opt"));
   C.addCommand(std::make_unique(JA, *this, OptExec, OptArgs, Inputs));
   return OutputFileName;
 }
@@ -180,9 +178,7 @@
   auto LlcOutputFile =
   getOutputFileName(C, OutputFilePrefix, "", OutputIsAsm ? "s" : "o");
   LlcArgs.push_back(LlcOutputFile);
-  SmallString<128> LlcPath(C.getDriver().Dir);
-  llvm::sys::path::append(LlcPath, "llc");
-  const char *Llc = Args.MakeArgString(LlcPath);
+  const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
   C.addCommand(std::make_unique(JA, *this, Llc, LlcArgs, Inputs));
   return LlcOutputFile;
 }
@@ -196,9 +192,7 @@
   // The output from ld.lld is an HSA code object file.
   ArgStringList LldArgs{
   "-flavor", "gnu", "-shared", "-o", Output.getFilename(), InputFileName};
-  SmallString<128> LldPath(C.getDriver().Dir);
-  llvm::sys::path::append(LldPath, "lld");
-  const char *Lld = Args.MakeArgString(LldPath);
+  const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
   C.addCommand(std::make_unique(JA, *this, Lld, LldArgs, Inputs));
 }
 
@@ -230,9 +224,8 @@
   Args.MakeArgString(std::string("-outputs=").append(OutputFileName));
   BundlerArgs.push_back(BundlerOutputArg);
 
-  SmallString<128> BundlerPath(C.getDriver().Dir);
-  llvm::sys::path::append(BundlerPath, "clang-offload-bundler");
-  const char *Bundler = Args.MakeArgString(BundlerPath);
+  const char *Bundler = Args.MakeArgString(
+  T.getToolChain().GetProgramPath("clang-offload-bundler"));
   C.addCommand(std::make_unique(JA, T, Bundler, BundlerArgs, Inputs));
 }
 


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -105,9 +105,8 @@
   CmdArgs.push_back("-o");
   auto OutputFileName = getOutputFileName(C, OutputFilePrefix, "-linked", "bc");
   CmdArgs.push_back(OutputFileName);
-  SmallString<128> ExecPath(C.getDriver().Dir);
-  llvm::sys::path::append(ExecPath, "llvm-link");
-  const char *Exec = Args.MakeArgString(ExecPath);
+  const char *Exec =
+  Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
   C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
   return OutputFileName;
 }
@@ -133,9 +132,8 @@
   auto OutputFileName =
   getOutputFileName(C, OutputFilePrefix, "-optimized", "bc");
   OptArgs.push_back(OutputFileName);
-  SmallString<128> OptPath(C.getDriver().Dir);
-  llvm::sys::path::append(OptPath, "opt");
-  const char *OptExec = Args.MakeArgString(OptPath);
+  const char *OptExec =
+  Args.MakeArgString(getToolChain().GetProgramPath("opt"));
   C.addCommand(std::make_unique(JA, *this, OptExec, OptArgs, Inputs));
   return OutputFileName;
 }
@@ -180,9 +178,7 @@
   auto LlcOutputFile =
   getOutputFileName(C, OutputFilePrefix, "", OutputIsAsm ? "s" : "o");
   LlcArgs.push_back(LlcOutputFile);
-  SmallString<128> LlcPath(C.getDriver().Dir);
-  llvm::sys::path::append(LlcPath, "llc");
-  const char *Llc = Args.MakeArgString(LlcPath);
+  const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
   C.addCommand(std::make_unique(JA, *this, Llc, LlcArgs, Inputs));
   return LlcOutputFile;
 }
@@ -196,9 +192,7 @@
   // The output from ld.lld is an HSA code object file.
   ArgS

Re: [clang] e8f198d - Fix pack deduction to only deduce the arity of packs that are actually

2020-01-17 Thread Hans Wennborg via cfe-commits
Cherry-picked in e241c8fe6d2e6d83e9fb32bd34da8ffcdc0dd83d. Thanks!

On Thu, Jan 16, 2020 at 1:22 AM Richard Smith  wrote:
>
> Hi Hans,
>
> Please consider this bugfix for the Clang 10 release branch.
>
> On Wed, 15 Jan 2020 at 16:21, Richard Smith via cfe-commits 
>  wrote:
>>
>>
>> Author: Richard Smith
>> Date: 2020-01-15T16:21:08-08:00
>> New Revision: e8f198dd9e9dabed8d50276465906e7c8827cada
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/e8f198dd9e9dabed8d50276465906e7c8827cada
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/e8f198dd9e9dabed8d50276465906e7c8827cada.diff
>>
>> LOG: Fix pack deduction to only deduce the arity of packs that are actually
>> expanded by the deduced pack.
>>
>> We recently started also deducing the arity of separately-expanded packs
>> that are merely mentioned within the pack in question, which is
>> incorrect.
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/Sema/SemaTemplateDeduction.cpp
>> clang/test/SemaTemplate/deduction.cpp
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
>> b/clang/lib/Sema/SemaTemplateDeduction.cpp
>> index 1b9f1b2144d1..048a50a741e4 100644
>> --- a/clang/lib/Sema/SemaTemplateDeduction.cpp
>> +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
>> @@ -724,38 +724,48 @@ class PackDeductionScope {
>>  // Compute the set of template parameter indices that correspond to
>>  // parameter packs expanded by the pack expansion.
>>  llvm::SmallBitVector SawIndices(TemplateParams->size());
>> +llvm::SmallVector ExtraDeductions;
>>
>>  auto AddPack = [&](unsigned Index) {
>>if (SawIndices[Index])
>>  return;
>>SawIndices[Index] = true;
>>addPack(Index);
>> +
>> +  // Deducing a parameter pack that is a pack expansion also constrains 
>> the
>> +  // packs appearing in that parameter to have the same deduced arity. 
>> Also,
>> +  // in C++17 onwards, deducing a non-type template parameter deduces 
>> its
>> +  // type, so we need to collect the pending deduced values for those 
>> packs.
>> +  if (auto *NTTP = dyn_cast(
>> +  TemplateParams->getParam(Index))) {
>> +if (auto *Expansion = dyn_cast(NTTP->getType()))
>> +  ExtraDeductions.push_back(Expansion->getPattern());
>> +  }
>> +  // FIXME: Also collect the unexpanded packs in any type and template
>> +  // parameter packs that are pack expansions.
>>  };
>>
>> -// First look for unexpanded packs in the pattern.
>> -SmallVector Unexpanded;
>> -S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
>> -for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
>> -  unsigned Depth, Index;
>> -  std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]);
>> -  if (Depth == Info.getDeducedDepth())
>> -AddPack(Index);
>> -}
>> +auto Collect = [&](TemplateArgument Pattern) {
>> +  SmallVector Unexpanded;
>> +  S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
>> +  for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
>> +unsigned Depth, Index;
>> +std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]);
>> +if (Depth == Info.getDeducedDepth())
>> +  AddPack(Index);
>> +  }
>> +};
>> +
>> +// Look for unexpanded packs in the pattern.
>> +Collect(Pattern);
>>  assert(!Packs.empty() && "Pack expansion without unexpanded packs?");
>>
>>  unsigned NumNamedPacks = Packs.size();
>>
>> -// We can also have deduced template parameters that do not actually
>> -// appear in the pattern, but can be deduced by it (the type of a 
>> non-type
>> -// template parameter pack, in particular). These won't have prevented 
>> us
>> -// from partially expanding the pack.
>> -llvm::SmallBitVector Used(TemplateParams->size());
>> -MarkUsedTemplateParameters(S.Context, Pattern, /*OnlyDeduced*/true,
>> -   Info.getDeducedDepth(), Used);
>> -for (int Index = Used.find_first(); Index != -1;
>> - Index = Used.find_next(Index))
>> -  if (TemplateParams->getParam(Index)->isParameterPack())
>> -AddPack(Index);
>> +// Also look for unexpanded packs that are indirectly deduced by 
>> deducing
>> +// the sizes of the packs in this pattern.
>> +while (!ExtraDeductions.empty())
>> +  Collect(ExtraDeductions.pop_back_val());
>>
>>  return NumNamedPacks;
>>}
>>
>> diff  --git a/clang/test/SemaTemplate/deduction.cpp 
>> b/clang/test/SemaTemplate/deduction.cpp
>> index 1f1c30a8b4ab..7268912dd6c5 100644
>> --- a/clang/test/SemaTemplate/deduction.cpp
>> +++ b/clang/test/SemaTemplate/deduction.cpp
>> @@ -546,3 +546,21 @@ namespace designators {
>>
>>static_assert(f({.a = 1, .b = 2}) == 3, ""); // expected-error {{no 
>> matching function}}
>>  }
>> +
>> +namespace nested_packs {
>> +

[clang] d293417 - Add __warn_memset_zero_len builtin as a workaround for glibc issue

2020-01-17 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-01-17T09:58:32+01:00
New Revision: d293417931d3a9d46799b42795988ca3b5cfd766

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

LOG: Add __warn_memset_zero_len builtin as a workaround for glibc issue

Glibc issue: https://sourceware.org/bugzilla/show_bug.cgi?id=25399
The fix consist in considering the missing function as a builtin lowered to a 
nop.

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

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index d388afe7fae6..1a6c85ce2dd3 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -788,6 +788,9 @@ BUILTIN(__builtin_abort, "v", "Fnr")
 BUILTIN(__builtin_index, "c*cC*i", "Fn")
 BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
 
+// ignored glibc builtin, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+BUILTIN(__warn_memset_zero_len, "v", "nU")
+
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4decaa593a59..9986ea4cb94c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3222,6 +3222,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Builder.CreateZExt(EmitSignBit(*this, EmitScalarExpr(E->getArg(0))),
ConvertType(E->getType(;
   }
+  case Builtin::BI__warn_memset_zero_len:
+return RValue::getIgnored();
   case Builtin::BI__annotation: {
 // Re-encode each wide string to UTF8 and make an MDString.
 SmallVector Strings;

diff  --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 591416d00cc7..9f2a74f6c873 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -453,6 +453,13 @@ void test_builtin_launder(int *p) {
   int *d = __builtin_launder(p);
 }
 
+// __warn_memset_zero_len should be NOP, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+// CHECK-LABEL: define void @test___warn_memset_zero_len
+void test___warn_memset_zero_len() {
+  // CHECK-NOT: @__warn_memset_zero_len
+  __warn_memset_zero_len();
+}
+
 // Behavior of __builtin_os_log 
diff ers between platforms, so only test on X86
 #ifdef __x86_64__
 



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


[clang] d437fba - Reapply Allow system header to provide their own implementation of some builtin

2020-01-17 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-01-17T09:58:32+01:00
New Revision: d437fba8ef626b6d8b7928540f630163a9b04021

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

LOG: Reapply Allow system header to provide their own implementation of some 
builtin

This reverts commit 3d210ed3d1880c615776b07d1916edb400c245a6.

See https://reviews.llvm.org/D71082 for the patch and discussion that make it
possible to reapply this patch.

Added: 
clang/test/CodeGen/memcpy-nobuiltin.c
clang/test/CodeGen/memcpy-nobuiltin.inc

Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 620ab4b089db..43c6c7b85db4 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2309,6 +2309,9 @@ class FunctionDecl : public DeclaratorDecl,
   /// true through IsAligned.
   bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) const;
 
+  /// Determine if this function provides an inline implementation of a 
builtin.
+  bool isInlineBuiltinDeclaration() const;
+
   /// Determine whether this is a destroying operator delete.
   bool isDestroyingOperatorDelete() const;
 

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index be59d88b73f1..0d30f64b992e 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3046,6 +3046,14 @@ bool 
FunctionDecl::isReplaceableGlobalAllocationFunction(bool *IsAligned) const
   return Params == FPT->getNumParams();
 }
 
+bool FunctionDecl::isInlineBuiltinDeclaration() const {
+  if (!getBuiltinID())
+return false;
+
+  const FunctionDecl *Definition;
+  return hasBody(Definition) && Definition->isInlineSpecified();
+}
+
 bool FunctionDecl::isDestroyingOperatorDelete() const {
   // C++ P0722:
   //   Within a class C, a single object deallocation function with signature

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b23d9df5f4ba..8e0604181fb1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4621,8 +4621,15 @@ RValue CodeGenFunction::EmitSimpleCallExpr(const 
CallExpr *E,
 }
 
 static CGCallee EmitDirectCallee(CodeGenFunction &CGF, const FunctionDecl *FD) 
{
+
   if (auto builtinID = FD->getBuiltinID()) {
-return CGCallee::forBuiltin(builtinID, FD);
+// Replaceable builtin provide their own implementation of a builtin. 
Unless
+// we are in the builtin implementation itself, don't call the actual
+// builtin. If we are in the builtin implementation, avoid trivial infinite
+// recursion.
+if (!FD->isInlineBuiltinDeclaration() ||
+CGF.CurFn->getName() == FD->getName())
+  return CGCallee::forBuiltin(builtinID, FD);
   }
 
   llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, FD);

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e347f3b6f7e0..4b9d56e6ab00 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1840,6 +1840,11 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   else if (const auto *SA = FD->getAttr())
  F->setSection(SA->getName());
 
+  if (FD->isInlineBuiltinDeclaration()) {
+F->addAttribute(llvm::AttributeList::FunctionIndex,
+llvm::Attribute::NoBuiltin);
+  }
+
   if (FD->isReplaceableGlobalAllocationFunction()) {
 // A replaceable global allocation function does not act like a builtin by
 // default, only if it is invoked by a new-expression or delete-expression.

diff  --git a/clang/test/CodeGen/memcpy-nobuiltin.c 
b/clang/test/CodeGen/memcpy-nobuiltin.c
new file mode 100644
index ..fb51d87413a1
--- /dev/null
+++ b/clang/test/CodeGen/memcpy-nobuiltin.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S -DWITH_DECL | 
FileCheck --check-prefix=CHECK-WITH-DECL %s
+// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S -UWITH_DECL | 
FileCheck --check-prefix=CHECK-NO-DECL %s
+// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S 
-DWITH_SELF_REFERENCE_DECL | FileCheck --check-prefix=CHECK-SELF-REF-DECL %s
+//
+// CHECK-WITH-DECL-NOT: @llvm.memcpy
+// CHECK-NO-DECL: @llvm.memcpy
+// CHECK-SELF-REF-DECL: @llvm.memcpy
+//
+#include 
+void test(void *dest, void const *from, size_t n) {
+  memcpy(dest, from, n);
+
+  static char buffer[1];
+  memcpy(buffer, from, 2); // expected-warning {{'memcpy' will always 
overflow; destination buffer has size 1, but size argument is 2}}
+}

diff  --git a/clang/test/CodeGen/memcpy-nobuiltin.inc 
b/clang/test/CodeGen/memcpy-nobuiltin.inc
new file mode 100644
index 00

Re: [clang] 45d7080 - PR42694 Support explicit(bool) in older language modes as an extension.

2020-01-17 Thread Hans Wennborg via cfe-commits
Cherry-picked in 0a08d2c4e7830a1b2428c2c77f205ac74fa29899 and
2d2d057ae23036baecb5a2a4a7f929626f46921a. Thanks!

On Fri, Jan 17, 2020 at 3:14 AM Richard Smith  wrote:
>
> Also b78e8e0d79c47a6698a0abc10a37b8a253cb6064 which has an extra test file 
> that I forgot to git add.
>
> On Wed, 15 Jan 2020 at 18:52, Richard Smith  wrote:
>>
>> Hans, could this change be ported to the Clang 10 branch? In PR42694 the 
>> MSVC stdlib developers requested that Clang support this because their 
>> standard library will soon rely on it.
>>
>> On Wed, 15 Jan 2020 at 18:50, Richard Smith via cfe-commits 
>>  wrote:
>>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-01-15T18:38:23-08:00
>>> New Revision: 45d70806f4386adfb62b0d75949a8aad58e0576f
>>>
>>> URL: 
>>> https://github.com/llvm/llvm-project/commit/45d70806f4386adfb62b0d75949a8aad58e0576f
>>> DIFF: 
>>> https://github.com/llvm/llvm-project/commit/45d70806f4386adfb62b0d75949a8aad58e0576f.diff
>>>
>>> LOG: PR42694 Support explicit(bool) in older language modes as an extension.
>>>
>>> This needs somewhat careful disambiguation, as C++2a explicit(bool) is a
>>> breaking change. We only enable it in cases where the source construct
>>> could not possibly be anything else.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/include/clang/Basic/DiagnosticParseKinds.td
>>> clang/include/clang/Parse/Parser.h
>>> clang/lib/Parse/ParseDecl.cpp
>>> clang/lib/Parse/ParseTentative.cpp
>>> clang/lib/Parse/Parser.cpp
>>> clang/test/SemaCXX/cxx2a-explicit-bool.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
>>> b/clang/include/clang/Basic/DiagnosticParseKinds.td
>>> index cc6a74ac3e6d..41f788e7d9bd 100644
>>> --- a/clang/include/clang/Basic/DiagnosticParseKinds.td
>>> +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
>>> @@ -33,10 +33,6 @@ def err_asm_goto_cannot_have_output : Error<
>>>
>>>  let CategoryName = "Parse Issue" in {
>>>
>>> -def warn_cxx2a_compat_explicit_bool : Warning<
>>> -  "this expression will be parsed as explicit(bool) in C++2a">,
>>> -  InGroup, DefaultIgnore;
>>> -
>>>  def ext_empty_translation_unit : Extension<
>>>"ISO C requires a translation unit to contain at least one declaration">,
>>>InGroup>;
>>> @@ -684,6 +680,15 @@ def err_ms_property_expected_comma_or_rparen : Error<
>>>  def err_ms_property_initializer : Error<
>>>"property declaration cannot have an in-class initializer">;
>>>
>>> +def warn_cxx2a_compat_explicit_bool : Warning<
>>> +  "this expression will be parsed as explicit(bool) in C++2a">,
>>> +  InGroup, DefaultIgnore;
>>> +def warn_cxx17_compat_explicit_bool : Warning<
>>> +  "explicit(bool) is incompatible with C++ standards before C++2a">,
>>> +  InGroup, DefaultIgnore;
>>> +def ext_explicit_bool : ExtWarn<"explicit(bool) is a C++2a extension">,
>>> +  InGroup;
>>> +
>>>  /// C++ Templates
>>>  def err_expected_template : Error<"expected template">;
>>>  def err_unknown_template_name : Error<
>>>
>>> diff  --git a/clang/include/clang/Parse/Parser.h 
>>> b/clang/include/clang/Parse/Parser.h
>>> index e320c9647818..b7bed4713992 100644
>>> --- a/clang/include/clang/Parse/Parser.h
>>> +++ b/clang/include/clang/Parse/Parser.h
>>> @@ -806,6 +806,16 @@ class Parser : public CodeCompletionHandler {
>>>   bool IsNewScope);
>>>bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
>>>
>>> +  bool MightBeCXXScopeToken() {
>>> +return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
>>> +   (Tok.is(tok::annot_template_id) &&
>>> +NextToken().is(tok::coloncolon)) ||
>>> +   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
>>> +  }
>>> +  bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
>>> +return MightBeCXXScopeToken() && 
>>> TryAnnotateCXXScopeToken(EnteringContext);
>>> +  }
>>> +
>>>  private:
>>>enum AnnotatedNameKind {
>>>  /// Annotation has failed and emitted an error.
>>> @@ -2395,6 +2405,11 @@ class Parser : public CodeCompletionHandler {
>>>/// rather than a less-than expression.
>>>TPResult isTemplateArgumentList(unsigned TokensToSkip);
>>>
>>> +  /// Determine whether an '(' after an 'explicit' keyword is part of a 
>>> C++20
>>> +  /// 'explicit(bool)' declaration, in earlier language modes where that 
>>> is an
>>> +  /// extension.
>>> +  TPResult isExplicitBool();
>>> +
>>>/// Determine whether an identifier has been tentatively declared as a
>>>/// non-type. Such tentative declarations should not be found to name a 
>>> type
>>>/// during a tentative parse, but also should not be annotated as a 
>>> non-type.
>>>
>>> diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
>>> index 69a3ed9cbad7..d8c5a0ab02d3 100644
>>> --- a/clang/lib/Parse/ParseDecl.cpp
>>> +++ b/clang/lib/Parse/ParseDecl.

[PATCH] D72806: [HIP] fix paths for executables not in clang bin directory

2020-01-17 Thread Holger Wünsche via Phabricator via cfe-commits
DieGoldeneEnte updated this revision to Diff 238708.
DieGoldeneEnte added a comment.

This patch now only adds the executable dirs to the program path, the code to 
search them is now in D72903 .


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

https://reviews.llvm.org/D72806

Files:
  clang/CMakeLists.txt
  clang/lib/Driver/ToolChains/HIP.cpp


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -277,6 +277,16 @@
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);
+
+// add llvm binaries in case they are not in the driver directory
+#if defined(LLVM_TOOLS_BINARY_DIR)
+  getProgramPaths().push_back(LLVM_TOOLS_BINARY_DIR);
+#endif
+
+// add lld binary in case they are not in the driver directory
+#if defined(LLD_BINARY_DIR)
+  getProgramPaths().push_back(LLD_BINARY_DIR);
+#endif
 }
 
 void HIPToolChain::addClangTargetOptions(
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -866,6 +866,24 @@
   llvm_distribution_add_targets()
 endif()
 
+# add LLVM_TOOLS_BINARY_DIR to Defines to make llc, llvm-link and opt available
+# for HIP toolchain
+if(DEFINED LLVM_TOOLS_BINARY_DIR)
+  add_definitions( -DLLVM_TOOLS_BINARY_DIR="${LLVM_TOOLS_BINARY_DIR} " )
+  message(STATUS "found llvm executable dir: ${LLVM_TOOLS_BINARY_DIR}")
+endif()
+
+# add LLD_BINARY_DIR to Defines to make lld available for HIP toolchain
+find_program(LLD_BINARY NAMES lld)
+if(NOT LLD_BINARY MATCHES "-NOTFOUND" AND NOT DEFINED LLD_BINARY_DIR)
+  message(STATUS "found lld executable: ${LLD_BINARY}")
+  get_filename_component(LLD_BINARY_DIR ${LLD_BINARY} DIRECTORY)
+endif()
+if(DEFINED LLD_BINARY)
+  add_definitions( -DLLD_BINARY_DIR="${LLD_BINARY_DIR} " )
+endif()
+
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)


Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -277,6 +277,16 @@
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);
+
+// add llvm binaries in case they are not in the driver directory
+#if defined(LLVM_TOOLS_BINARY_DIR)
+  getProgramPaths().push_back(LLVM_TOOLS_BINARY_DIR);
+#endif
+
+// add lld binary in case they are not in the driver directory
+#if defined(LLD_BINARY_DIR)
+  getProgramPaths().push_back(LLD_BINARY_DIR);
+#endif
 }
 
 void HIPToolChain::addClangTargetOptions(
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -866,6 +866,24 @@
   llvm_distribution_add_targets()
 endif()
 
+# add LLVM_TOOLS_BINARY_DIR to Defines to make llc, llvm-link and opt available
+# for HIP toolchain
+if(DEFINED LLVM_TOOLS_BINARY_DIR)
+  add_definitions( -DLLVM_TOOLS_BINARY_DIR="${LLVM_TOOLS_BINARY_DIR} " )
+  message(STATUS "found llvm executable dir: ${LLVM_TOOLS_BINARY_DIR}")
+endif()
+
+# add LLD_BINARY_DIR to Defines to make lld available for HIP toolchain
+find_program(LLD_BINARY NAMES lld)
+if(NOT LLD_BINARY MATCHES "-NOTFOUND" AND NOT DEFINED LLD_BINARY_DIR)
+  message(STATUS "found lld executable: ${LLD_BINARY}")
+  get_filename_component(LLD_BINARY_DIR ${LLD_BINARY} DIRECTORY)
+endif()
+if(DEFINED LLD_BINARY)
+  add_definitions( -DLLD_BINARY_DIR="${LLD_BINARY_DIR} " )
+endif()
+
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72869: Add __warn_memset_zero_len builtin as a workaround for glibc issue

2020-01-17 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd293417931d3: Add __warn_memset_zero_len builtin as a 
workaround for glibc issue (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72869

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c


Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -453,6 +453,13 @@
   int *d = __builtin_launder(p);
 }
 
+// __warn_memset_zero_len should be NOP, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+// CHECK-LABEL: define void @test___warn_memset_zero_len
+void test___warn_memset_zero_len() {
+  // CHECK-NOT: @__warn_memset_zero_len
+  __warn_memset_zero_len();
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3222,6 +3222,8 @@
 Builder.CreateZExt(EmitSignBit(*this, EmitScalarExpr(E->getArg(0))),
ConvertType(E->getType(;
   }
+  case Builtin::BI__warn_memset_zero_len:
+return RValue::getIgnored();
   case Builtin::BI__annotation: {
 // Re-encode each wide string to UTF8 and make an MDString.
 SmallVector Strings;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -788,6 +788,9 @@
 BUILTIN(__builtin_index, "c*cC*i", "Fn")
 BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
 
+// ignored glibc builtin, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+BUILTIN(__warn_memset_zero_len, "v", "nU")
+
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)


Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -453,6 +453,13 @@
   int *d = __builtin_launder(p);
 }
 
+// __warn_memset_zero_len should be NOP, see https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+// CHECK-LABEL: define void @test___warn_memset_zero_len
+void test___warn_memset_zero_len() {
+  // CHECK-NOT: @__warn_memset_zero_len
+  __warn_memset_zero_len();
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3222,6 +3222,8 @@
 Builder.CreateZExt(EmitSignBit(*this, EmitScalarExpr(E->getArg(0))),
ConvertType(E->getType(;
   }
+  case Builtin::BI__warn_memset_zero_len:
+return RValue::getIgnored();
   case Builtin::BI__annotation: {
 // Re-encode each wide string to UTF8 and make an MDString.
 SmallVector Strings;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -788,6 +788,9 @@
 BUILTIN(__builtin_index, "c*cC*i", "Fn")
 BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
 
+// ignored glibc builtin, see https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+BUILTIN(__warn_memset_zero_len, "v", "nU")
+
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

I've added tests and a fix for try/catch and if/else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72827



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


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

In D72827#1823895 , @krasimir wrote:

> How about `if` and `try`? Is there a list somewhere for all such valid 
> identifiers?


This is a bit annoying - generally speaking, we should parse all keywords in 
declaration locations as simple names. However `UnwrappedLineParser` isn't 
really structured to support that, nor is it precise enough to reliably detect 
these situations :-/ So I think the best we can do is incrementally detect 
these issues and fix as they come up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72827



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


[PATCH] D72848: Remove some SVN-specific code.

2020-01-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Basic/Version.cpp:33
 #else
-  StringRef URL("");
+  return "";
 #endif

Eugene.Zelenko wrote:
> return {} should be better.
Why? I think "" is clearer for a string.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72848



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


[clang] 0734fb2 - clang-format: [JS] Handle more keyword-named methods.

2020-01-17 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-17T10:10:16+01:00
New Revision: 0734fb21ed5e267dda1a91e5f8b82f653ac3562d

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

LOG: clang-format: [JS] Handle more keyword-named methods.

Summary:
Including `do`, `for`, and `while`, `if`, `else`, `try`, `catch`, in
addition to the previously handled fields. The unit test explicitly uses
methods, but this code path handles both fields and methods.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index ead6b4743207..18b4cc5306f5 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1011,13 +1011,22 @@ void UnwrappedLineParser::parseStructuralElement() {
   parseAccessSpecifier();
 return;
   case tok::kw_if:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseIfThenElse();
 return;
   case tok::kw_for:
   case tok::kw_while:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseForOrWhileLoop();
 return;
   case tok::kw_do:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseDoWhile();
 return;
   case tok::kw_switch:
@@ -1045,6 +1054,9 @@ void UnwrappedLineParser::parseStructuralElement() {
 return;
   case tok::kw_try:
   case tok::kw___try:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseTryCatch();
 return;
   case tok::kw_extern:
@@ -1290,6 +1302,12 @@ void UnwrappedLineParser::parseStructuralElement() {
   // element continues.
   break;
 case tok::kw_try:
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  Line->MustBeDeclaration) {
+// field/method declaration.
+nextToken();
+break;
+  }
   // We arrive here when parsing function-try blocks.
   if (Style.BraceWrapping.AfterFunction)
 addUnwrappedLine();

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index f5be0d7a4ab1..0150b43a0787 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -358,6 +358,22 @@ TEST_F(FormatTestJS, ReservedWordsMethods) {
   "x();\n"
   "  }\n"
   "}\n");
+  verifyFormat("class KeywordNamedMethods {\n"
+   "  do() {\n"
+   "  }\n"
+   "  for() {\n"
+   "  }\n"
+   "  while() {\n"
+   "  }\n"
+   "  if() {\n"
+   "  }\n"
+   "  else() {\n"
+   "  }\n"
+   "  try() {\n"
+   "  }\n"
+   "  catch() {\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsParenthesized) {



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


[PATCH] D72827: clang-format: [JS] Handle keyword-named methods.

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0734fb21ed5e: clang-format: [JS] Handle more keyword-named 
methods. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D72827?vs=238442&id=238713#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72827

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -358,6 +358,22 @@
   "x();\n"
   "  }\n"
   "}\n");
+  verifyFormat("class KeywordNamedMethods {\n"
+   "  do() {\n"
+   "  }\n"
+   "  for() {\n"
+   "  }\n"
+   "  while() {\n"
+   "  }\n"
+   "  if() {\n"
+   "  }\n"
+   "  else() {\n"
+   "  }\n"
+   "  try() {\n"
+   "  }\n"
+   "  catch() {\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsParenthesized) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1011,13 +1011,22 @@
   parseAccessSpecifier();
 return;
   case tok::kw_if:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseIfThenElse();
 return;
   case tok::kw_for:
   case tok::kw_while:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseForOrWhileLoop();
 return;
   case tok::kw_do:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseDoWhile();
 return;
   case tok::kw_switch:
@@ -1045,6 +1054,9 @@
 return;
   case tok::kw_try:
   case tok::kw___try:
+if (Style.Language == FormatStyle::LK_JavaScript && 
Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseTryCatch();
 return;
   case tok::kw_extern:
@@ -1290,6 +1302,12 @@
   // element continues.
   break;
 case tok::kw_try:
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  Line->MustBeDeclaration) {
+// field/method declaration.
+nextToken();
+break;
+  }
   // We arrive here when parsing function-try blocks.
   if (Style.BraceWrapping.AfterFunction)
 addUnwrappedLine();


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -358,6 +358,22 @@
   "x();\n"
   "  }\n"
   "}\n");
+  verifyFormat("class KeywordNamedMethods {\n"
+   "  do() {\n"
+   "  }\n"
+   "  for() {\n"
+   "  }\n"
+   "  while() {\n"
+   "  }\n"
+   "  if() {\n"
+   "  }\n"
+   "  else() {\n"
+   "  }\n"
+   "  try() {\n"
+   "  }\n"
+   "  catch() {\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, ReservedWordsParenthesized) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1011,13 +1011,22 @@
   parseAccessSpecifier();
 return;
   case tok::kw_if:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseIfThenElse();
 return;
   case tok::kw_for:
   case tok::kw_while:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseForOrWhileLoop();
 return;
   case tok::kw_do:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseDoWhile();
 return;
   case tok::kw_switch:
@@ -1045,6 +1054,9 @@
 return;
   case tok::kw_try:
   case tok::kw___try:
+if (Style.Language == FormatStyle::LK_JavaScript && Line->MustBeDeclaration)
+  // field/method declaration.
+  break;
 parseTryCatch();
 return;
   case tok::kw_extern:
@@ -1290,6 +1302,12 @@
   // element continues.
   break;
 case tok::kw_try:
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  Line->MustBeDeclaration) {
+// 

Re: [clang] 6b29aa2 - Revert "[OPENMP]Do not use RTTI by default for NVPTX devices."

2020-01-17 Thread Hans Wennborg via cfe-commits
Cherry-picked to 10.x in 572c7f6fe7b55ce5f7591fb7a445dea27329074a.

On Wed, Jan 15, 2020 at 11:42 PM Alexey Bataev via cfe-commits
 wrote:
>
>
> Author: Alexey Bataev
> Date: 2020-01-15T17:42:26-05:00
> New Revision: 6b29aa21180cf14bfb619d38fc4826913cabfb66
>
> URL: 
> https://github.com/llvm/llvm-project/commit/6b29aa21180cf14bfb619d38fc4826913cabfb66
> DIFF: 
> https://github.com/llvm/llvm-project/commit/6b29aa21180cf14bfb619d38fc4826913cabfb66.diff
>
> LOG: Revert "[OPENMP]Do not use RTTI by default for NVPTX devices."
>
> This reverts commit 23058f9dd4d7e18239fd63b6da52549514b45fda. It breaks
> builds of cuda code somehow in some cases.
>
> Added:
>
>
> Modified:
> clang/lib/Driver/ToolChain.cpp
>
> Removed:
> clang/test/Driver/openmp-offload-gpu.cpp
>
>
> 
> diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
> index 3ebbd30195b3..cab97b1a601a 100644
> --- a/clang/lib/Driver/ToolChain.cpp
> +++ b/clang/lib/Driver/ToolChain.cpp
> @@ -68,8 +68,7 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList 
> &Args,
>}
>
>// -frtti is default, except for the PS4 CPU.
> -  return (Triple.isPS4CPU() || Triple.isNVPTX()) ? ToolChain::RM_Disabled
> - : ToolChain::RM_Enabled;
> +  return (Triple.isPS4CPU()) ? ToolChain::RM_Disabled : 
> ToolChain::RM_Enabled;
>  }
>
>  ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
>
> diff  --git a/clang/test/Driver/openmp-offload-gpu.cpp 
> b/clang/test/Driver/openmp-offload-gpu.cpp
> deleted file mode 100644
> index 9da7308506ae..
> --- a/clang/test/Driver/openmp-offload-gpu.cpp
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -///
> -/// Perform several driver tests for OpenMP offloading
> -///
> -
> -// REQUIRES: clang-driver
> -// REQUIRES: x86-registered-target
> -// REQUIRES: powerpc-registered-target
> -// REQUIRES: nvptx-registered-target
> -
> -/// 
> ###
> -
> -/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
> using OpenMP
> -/// Check that the flag is passed when -fopenmp-relocatable-target is used.
> -// RUN:   %clangxx -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
> \
> -// RUN:  -save-temps -no-canonical-prefixes %s -x c++ -c 2>&1 \
> -// RUN:   | FileCheck -check-prefix=CHK-RTTI %s
> -
> -// CHK-RTTI: clang{{.*}}" "-triple" "nvptx64-nvidia-cuda"
> -// CHK-RTTI-SAME: "-fno-rtti"
> -
>
>
>
> ___
> 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] 4456076 - Revert "Further implement CWG 2292"

2020-01-17 Thread Hans Wennborg via cfe-commits
(Note to self: I double checked that the "Further implement CWG 2292"
patch landed just after the 10.x branch, so this revert doesn't need
to be cherry-picked there.)

On Thu, Jan 16, 2020 at 12:46 AM Amy Huang via cfe-commits
 wrote:
>
>
> Author: Amy Huang
> Date: 2020-01-15T15:46:07-08:00
> New Revision: 44560762c62d72a103bdceff49ffa70451efd5f8
>
> URL: 
> https://github.com/llvm/llvm-project/commit/44560762c62d72a103bdceff49ffa70451efd5f8
> DIFF: 
> https://github.com/llvm/llvm-project/commit/44560762c62d72a103bdceff49ffa70451efd5f8.diff
>
> LOG: Revert "Further implement CWG 2292"
>
> This reverts commit ee0f1f1edc3ec0d4e698d50cc3180217448802b7 because it
> causes an error on valid code.
> See https://reviews.llvm.org/rGee0f1f1edc3ec0d4e698d50cc3180217448802b7.
>
> Added:
>
>
> Modified:
> clang/lib/Sema/SemaExprCXX.cpp
>
> Removed:
> clang/test/SemaCXX/pseudo-destructor-name.cpp
>
>
> 
> diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
> index 96e18105df78..a73e6906fceb 100644
> --- a/clang/lib/Sema/SemaExprCXX.cpp
> +++ b/clang/lib/Sema/SemaExprCXX.cpp
> @@ -192,10 +192,8 @@ ParsedType Sema::getDestructorName(SourceLocation 
> TildeLoc,
>AlreadySearched = true;
>LookupCtx = DC;
>isDependent = false;
> -} else if (auto *RD = dyn_cast_or_null(DC)) {
> -  if ((RD->hasDefinition() && RD->hasSimpleDestructor()) ||
> -  !RD->hasDefinition())
> -LookAtPrefix = false;
> +} else if (DC && isa(DC)) {
> +  LookAtPrefix = false;
>LookInScope = true;
>  }
>
>
> diff  --git a/clang/test/SemaCXX/pseudo-destructor-name.cpp 
> b/clang/test/SemaCXX/pseudo-destructor-name.cpp
> deleted file mode 100644
> index cc7c22b8dc4d..
> --- a/clang/test/SemaCXX/pseudo-destructor-name.cpp
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
> -// expected-no-diagnostics
> -
> -struct AAA
> -{
> -struct BBB
> -{
> -~BBB() {}
> -};
> -
> -typedef BBB BBB_alias;
> -};
> -
> -typedef AAA::BBB BBB_alias2;
> -
> -int
> -main()
> -{
> -AAA::BBB_alias *ptr1 = new AAA::BBB_alias();
> -AAA::BBB_alias *ptr2 = new AAA::BBB_alias();
> -
> -ptr1->AAA::BBB_alias::~BBB_alias(); // Now OK
> -ptr2->AAA::BBB_alias::~BBB();   // OK
> -ptr1->~BBB_alias2();// OK
> -return 0;
> -}
>
>
>
> ___
> 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] 3d210ed - Revert "Allow system header to provide their own implementation of some builtin"

2020-01-17 Thread Hans Wennborg via cfe-commits
Cherry-picked to 10.x in 9007f06af0e009f41b876ae30e6b1ca96feee02e

On Thu, Jan 16, 2020 at 12:04 AM Amy Huang via cfe-commits
 wrote:
>
>
> Author: Amy Huang
> Date: 2020-01-15T15:03:45-08:00
> New Revision: 3d210ed3d1880c615776b07d1916edb400c245a6
>
> URL: 
> https://github.com/llvm/llvm-project/commit/3d210ed3d1880c615776b07d1916edb400c245a6
> DIFF: 
> https://github.com/llvm/llvm-project/commit/3d210ed3d1880c615776b07d1916edb400c245a6.diff
>
> LOG: Revert "Allow system header to provide their own implementation of some 
> builtin"
>
> This reverts commit 921f871ac438175ca8fcfcafdfcfac4d7ddf3905 because it
> causes libc++ code to trigger __warn_memset_zero_len.
>
> See https://reviews.llvm.org/D71082.
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/Decl.h
> clang/lib/AST/Decl.cpp
> clang/lib/CodeGen/CGExpr.cpp
> clang/lib/CodeGen/CodeGenModule.cpp
>
> Removed:
> clang/test/CodeGen/memcpy-nobuiltin.c
> clang/test/CodeGen/memcpy-nobuiltin.inc
>
>
> 
> diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
> index 43c6c7b85db4..620ab4b089db 100644
> --- a/clang/include/clang/AST/Decl.h
> +++ b/clang/include/clang/AST/Decl.h
> @@ -2309,9 +2309,6 @@ class FunctionDecl : public DeclaratorDecl,
>/// true through IsAligned.
>bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) 
> const;
>
> -  /// Determine if this function provides an inline implementation of a 
> builtin.
> -  bool isInlineBuiltinDeclaration() const;
> -
>/// Determine whether this is a destroying operator delete.
>bool isDestroyingOperatorDelete() const;
>
>
> diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
> index 0d30f64b992e..be59d88b73f1 100644
> --- a/clang/lib/AST/Decl.cpp
> +++ b/clang/lib/AST/Decl.cpp
> @@ -3046,14 +3046,6 @@ bool 
> FunctionDecl::isReplaceableGlobalAllocationFunction(bool *IsAligned) const
>return Params == FPT->getNumParams();
>  }
>
> -bool FunctionDecl::isInlineBuiltinDeclaration() const {
> -  if (!getBuiltinID())
> -return false;
> -
> -  const FunctionDecl *Definition;
> -  return hasBody(Definition) && Definition->isInlineSpecified();
> -}
> -
>  bool FunctionDecl::isDestroyingOperatorDelete() const {
>// C++ P0722:
>//   Within a class C, a single object deallocation function with signature
>
> diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
> index 8e0604181fb1..b23d9df5f4ba 100644
> --- a/clang/lib/CodeGen/CGExpr.cpp
> +++ b/clang/lib/CodeGen/CGExpr.cpp
> @@ -4621,15 +4621,8 @@ RValue CodeGenFunction::EmitSimpleCallExpr(const 
> CallExpr *E,
>  }
>
>  static CGCallee EmitDirectCallee(CodeGenFunction &CGF, const FunctionDecl 
> *FD) {
> -
>if (auto builtinID = FD->getBuiltinID()) {
> -// Replaceable builtin provide their own implementation of a builtin. 
> Unless
> -// we are in the builtin implementation itself, don't call the actual
> -// builtin. If we are in the builtin implementation, avoid trivial 
> infinite
> -// recursion.
> -if (!FD->isInlineBuiltinDeclaration() ||
> -CGF.CurFn->getName() == FD->getName())
> -  return CGCallee::forBuiltin(builtinID, FD);
> +return CGCallee::forBuiltin(builtinID, FD);
>}
>
>llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, FD);
>
> diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
> b/clang/lib/CodeGen/CodeGenModule.cpp
> index 57beda26677c..038078bbe88d 100644
> --- a/clang/lib/CodeGen/CodeGenModule.cpp
> +++ b/clang/lib/CodeGen/CodeGenModule.cpp
> @@ -1840,11 +1840,6 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl 
> GD, llvm::Function *F,
>else if (const auto *SA = FD->getAttr())
>   F->setSection(SA->getName());
>
> -  if (FD->isInlineBuiltinDeclaration()) {
> -F->addAttribute(llvm::AttributeList::FunctionIndex,
> -llvm::Attribute::NoBuiltin);
> -  }
> -
>if (FD->isReplaceableGlobalAllocationFunction()) {
>  // A replaceable global allocation function does not act like a builtin 
> by
>  // default, only if it is invoked by a new-expression or 
> delete-expression.
>
> diff  --git a/clang/test/CodeGen/memcpy-nobuiltin.c 
> b/clang/test/CodeGen/memcpy-nobuiltin.c
> deleted file mode 100644
> index fb51d87413a1..
> --- a/clang/test/CodeGen/memcpy-nobuiltin.c
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S -DWITH_DECL | 
> FileCheck --check-prefix=CHECK-WITH-DECL %s
> -// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S -UWITH_DECL | 
> FileCheck --check-prefix=CHECK-NO-DECL %s
> -// RUN: %clang_cc1 -verify -S -emit-llvm -o- %s -isystem %S 
> -DWITH_SELF_REFERENCE_DECL | FileCheck --check-prefix=CHECK-SELF-REF-DECL %s
> -//
> -// CHECK-WITH-DECL-NOT: @llvm.memcpy
> -// CHECK-NO-DECL: @llvm.memcpy
> -// CHECK-SELF-REF-DECL: @llvm.memcpy
> -//
> -#include 
> -void test(vo

[PATCH] D72907: clang-format: [JS] pragmas for tslint, tsc.

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
mprobst added a project: clang.

tslint and tsc (the TypeScript compiler itself) use comment pragmas of
the style:

  // tslint:disable-next-line:foo
  // @ts-ignore

These must not be wrapped and must stay on their own line, in isolation.
For tslint, this required adding it to the pragma regexp. The comments
starting with `@` are already left alone, but this change adds test
coverage for them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72907

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2168,6 +2168,38 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, TslintComments) {
+  // tslint uses pragma comments that must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line");
+}
+
+TEST_F(FormatTestJS, TscComments) {
+  // As above, @ts-ignore and @ts-check comments must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-ignore",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-ignore");
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-check",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-check");
+}
+
 TEST_F(FormatTestJS, RequoteStringsSingle) {
   verifyFormat("var x = 'foo';", "var x = \"foo\";");
   verifyFormat("var x = 'fo\\'o\\'';", "var x = \"fo'o'\";");
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -939,9 +939,9 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, triple slash directives (`/// <...`), @see, which is commonly
-// followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|@see)";
+// taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
+// commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2168,6 +2168,38 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, TslintComments) {
+  // tslint uses pragma comments that must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line");
+}
+
+TEST_F(FormatTestJS, TscComments) {
+  // As above, @ts-ignore and @ts-check comments must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-ignore",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-ignore");
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. T

[PATCH] D72906: [X86] Improve X86 cmpps/cmppd/cmpss/cmpsd intrinsics with strictfp

2020-01-17 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

> The constrained fcmp intrinsics don't allow the TRUE/FALSE predicates.

Hmm, maybe they should then?   The only reason I didn't add them initially was 
that I wasn't sure they were useful for anything; if they are, it should be 
straightforward to add them back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72906



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


[PATCH] D72910: Fix a bug with clang with object destructor creation, while skipping object initialization - make clang crash

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre created this revision.
ykfre added a project: clang.
Herald added a subscriber: cfe-commits.

The following code crashes clang:

extern int g;

class A
{
public:
A() {};
~A() {};
};

void b()
{
if(g)
{

goto clean_up;

}
A a;

  int i = 0;

clean_up:
return;
}

with

1> #0 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e96a72 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e8c649
1> #1 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e95c08 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e92890
1> #2 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e95c08 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2e848f1
1> #3 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x2e78c88 
C:\Program Files\LLVM\bin\clang-cl.exe 0x2d55688
1> #4 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x284c373 
C:\Program Files\LLVM\bin\clang-cl.exe 0x29b2353
1> #5 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x27e0271 
C:\Program Files\LLVM\bin\clang-cl.exe 0x276351e
1> #6 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x27a6c62 
C:\Program Files\LLVM\bin\clang-cl.exe 0x276289b
1> #7 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x276222c 
C:\Program Files\LLVM\bin\clang-cl.exe 0x27610c3
1> #8 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x275f602 
C:\Program Files\LLVM\bin\clang-cl.exe 0x275b44e
1> #9 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x1cb3492 
C:\Program Files\LLVM\bin\clang-cl.exe 0x1c771cf
1>#10 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x1d09c87 
C:\Program Files\LLVM\bin\clang-cl.exe 0x6e87
1>#11 0x7ff6e6716a72 C:\Program Files\LLVM\bin\clang-cl.exe 0x4564 
C:\Program Files\LLVM\bin\clang-cl.exe 0x33dda20
1>#12 0x7ff6e6716a72 (C:\Program Files\LLVM\bin\clang-cl.exe+0x2e96a72)
1>#13 0x7ff6e670c649 (C:\Program Files\LLVM\bin\clang-cl.exe+0x2e8c649)
1>0x7FF6E6716A72 (0x7FF6E6709BA1 0x001E 0x02A9CC1695B0 
0x02A9CC1665E8)
1>0x7FF6E670C649 (0x02A9CC047FA0 0x7FF6E6794E62 0x02A9CC1762B0 
0x3A857DAE5EDC)
1>0x7FF6E6715C08 (0x 0x02A9CC168780 0x0001 
0x7FF6E6703CAF)
1>0x7FF6E6712890 (0x02A9CC176060 0x7FF6E6703A01 0x0050 
0x3A857DAE5B9C)
1>0x7FF6E6715C08 (0x7A696C616974696E 0x026E6F697461 0x02A9CC028820 
0x7FF6E7D6A2E0)
1>0x7FF6E67048F1 (0x02A9CC1665E8 0x02A9CC0BBCE0 0x0001 
0x7FF6005C)
1>0x7FF6E66F8C88 (0x3A857DAE50AC 0x02A9CC166AF0 0x 
0x02A9CC029710)
1>0x7FF6E65D5688 (0x3A857DAE2FDC 0x00C804D8C360 0x00C804D8C310 
0x0004)
1>0x7FF6E60CC373 (0x02A9CC1648E8 0x02A9CC0BDDF0 0x 
0x02A9CC1665E8)
1>0x7FF6E6232353 (0x02A9CC1665E8 0x7FF6E6273AEC 0x 
0x02A9CC0B97E0)
1>0x7FF6E6060271 (0x 0x7FF6E600C3FA 0x7FF6E6A61724 
0x02A9)
1>0x7FF6E5FE351E (0x02A9CC03E658 0x00C804D8CB28 0x0041 
0x00C804D8CB20)
1>0x7FF6E6026C62 (0x02A9CC0C02B4 0x 0x0050 
0x02A9CC0C0CC0)
1>0x7FF6E5FE289B (0x02A9CC143DD0 0x02A9CC03A330 0x0001 
0x7FF6E679978F)
1>0x7FF6E5FE222C (0x3A857DAE3BAC 0x00C804D8D918 0x02A9CC0377B0 
0x0001)
1>0x7FF6E5FE10C3 (0x02A9CBFE5FD0 0x7FF6E6C4974E 0x00C804D8F960 
0x00C804D8DA30)
1>0x7FF6E5FDF602 (0x00C804D8DB38 0x00C804D8DB48 0x00C804D8DB78 
0x7FF6E54F42AA)
1>0x7FF6E5FDB44E (0x02A9CC023500 0x3A857DAE3BFC 0x 
0x000F)
1>0x7FF6E5533492 (0x02A9CBFF7990 0x7FF6 0x00C0 
0x003404D8DB68)
1>0x7FF6E54F71CF (0x7FF6E6C61901 0x02A9 0x00C804D8EA01 
0x)
1>0x7FF6E5589C87 (0x0200 0x02A9CC021FA0 0x02A9CBFCEE40 
0x0101)
1>0x7FF6E3886E87 (0x 0x00A8 0x06B0 
0x)
1>0x7FF6E3884564 (0x 0x 0x 
0x)
1>0x7FF6E6C5DA20 (0x 0x 0x 
0x)
1>0x7FFCF9027BD4 (0x 0x 0x 
0x), BaseThreadInitThunk() + 0x14 bytes(s)
1>0x7FFCF992CED1 (0x 0x 0x 
0x), RtlUserThreadStart() + 0x21 bytes(s)
1>clang-cl : error : clang frontend command failed due to signal (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72910

Files:
  clang/lib/Analysis/CFG.cpp


Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/li

[PATCH] D72910: Fix a bug with clang with object destructor, while skipping object initialization - make clang crash

2020-01-17 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Eh, no it does not crash clang, at least not here?  Instead it gives you a 
compile error, as it should:

  cleanup.cpp:15:5: error: cannot jump from this goto statement to its label
  goto clean_up;
  ^
  cleanup.cpp:20:7: note: jump bypasses variable initialization
int i = 0;
^
  cleanup.cpp:18:4: note: jump bypasses variable initialization
  A a;
^
  1 error generated.

(This is with clang 9.0.1 on FreeBSD. I haven't tried on Windows.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72910



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


[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-17 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kmclaughlin marked an inline comment as done.
Closed by commit rGfe3bb8ec9683: [AArch64][SVE] Add ImmArg property to 
intrinsics with immediates (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72612

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td

Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1646,12 +1646,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
 }
 
 
@@ -1694,12 +1694,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
 }
 
 //===--===//
@@ -1785,10 +1785,10 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b:$idx, complexrotateop:$imm)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -1949,7 +1949,7 @@
 multiclass sve2_fp_mla_long_by_indexed_elem opc, string asm,
 SDPatternOperator op> {
   def NAME : sve2_fp_mla_long_by_indexed_elem;
-  def : SVE_4_Op_Imm_Pat(NAME)>;
+  def : SVE_4_Op_Imm_Pat(NAME)>;
 }
 
 //===--===//
@@ -2479,23 +2479,23 @@
 
 multiclass sve_intx_dot_by_indexed_elem {
-  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
+  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
+  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
 bits<1> iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16} = Zm;

[clang-tools-extra] 25afe91 - Fix Wparentheses warning. NFCI.

2020-01-17 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-17T11:26:25Z
New Revision: 25afe91fd1b8e26258471007a24f856a0d4b14db

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

LOG: Fix Wparentheses warning. NFCI.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
index 969927fedc3d..1d0b85b9c4ce 100644
--- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
@@ -34,8 +34,9 @@ llvm::Optional findQualToken(const VarDecl *Decl, 
Qualifier Qual,
   // sure that we have a consistent `CharSourceRange`, located entirely in the
   // source file.
 
-  assert(Qual == Qualifier::Const || Qual == Qualifier::Volatile ||
- Qual == Qualifier::Restrict && "Invalid Qualifier");
+  assert((Qual == Qualifier::Const || Qual == Qualifier::Volatile ||
+  Qual == Qualifier::Restrict) &&
+ "Invalid Qualifier");
 
   SourceLocation BeginLoc = Decl->getQualifierLoc().getBeginLoc();
   if (BeginLoc.isInvalid())



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


[PATCH] D72910: Fix a bug with clang with object destructor, while skipping object initialization - make clang crash

2020-01-17 Thread ido via Phabricator via cfe-commits
ykfre added a comment.

In D72910#1826108 , @dim wrote:

> Eh, no it does not crash clang, at least not here?  Instead it gives you a 
> compile error, as it should:
>
>   cleanup.cpp:15:5: error: cannot jump from this goto statement to its label
>   goto clean_up;
>   ^
>   cleanup.cpp:20:7: note: jump bypasses variable initialization
> int i = 0;
> ^
>   cleanup.cpp:18:4: note: jump bypasses variable initialization
>   A a;
> ^
>   1 error generated.
>
>
> (This is with clang 9.0.1 on FreeBSD. I haven't tried on Windows.)


Actually I see it only crashes clang-cl, and not clang, probably clang-cl fucks 
something up.
The command line is -

1. Original command:  "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" "-cc1" 
"-triple" "i386-pc-windows-msvc19.24.28314" "-emit-obj" "-mrelax-all" 
"-mincremental-linker-compatible" "-disable-free" "-disable-llvm-verifier" 
"-discard-value-names" "-main-file-name" "main2.cpp" "-mrelocation-model" 
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-relaxed-aliasing" 
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-target-cpu" "pentium4" 
"-mllvm" "-x86-asm-syntax=intel" "-D_DEBUG" "-D_MT" "-D_DLL" 
"--dependent-lib=msvcrtd" "--dependent-lib=oldnames" "-fms-volatile" 
"-fdefault-calling-conv=cdecl" "-fdiagnostics-format" "msvc" "-gcodeview" 
"-debug-info-kind=limited" "-v" "-coverage-notes-file" 
"C:\\Users\\IDO\\source\\repos\\Project11\\Project11\\main2.gcno" 
"-resource-dir" "C:\\Program Files\\LLVM\\lib\\clang\\9.0.0" "-D" "_DEBUG" "-D" 
"_CONSOLE" "-D" "_UNICODE" "-D" "UNICODE" "-internal-isystem" "C:\\Program 
Files\\LLVM\\lib\\clang\\9.0.0\\include" "-internal-isystem" "C:\\Program Files 
(x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.24.28314\\include" 
"-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.24.28314\\atlmfc\\include" 
"-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Enterprise\\VC\\Auxiliary\\VS\\include" "-internal-isystem" 
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" 
"-internal-isystem" "C:\\Program Files (x86)\\Windows 
Kits\\10\\Include\\10.0.18362.0\\um" "-internal-isystem" "C:\\Program Files 
(x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared" "-internal-isystem" 
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\winrt" 
"-internal-isystem" "C:\\Program Files (x86)\\Windows 
Kits\\10\\Include\\10.0.18362.0\\cppwinrt" "-internal-isystem" "C:\\Program 
Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\Include\\um" "-O0" "-WCL4" "-Werror" 
"-fdeprecated-macro" "-fdebug-compilation-dir" 
"C:\\Users\\IDO\\source\\repos\\Project11\\Project11" "-ferror-limit" "19" 
"-fmessage-length" "0" "-fno-use-cxa-atexit" "-fms-extensions" 
"-fms-compatibility" "-fms-compatibility-version=19.24.28314" "-std=c++14" 
"-fdelayed-template-parsing" "-fobjc-runtime=gcc" "-fno-caret-diagnostics" 
"-fdiagnostics-show-option" "-faddrsig" "-o" "Debug\\main2.obj" "-x" "c++" 
"main2.cpp"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72910



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


[PATCH] D72906: [X86] Improve X86 cmpps/cmppd/cmpss/cmpsd intrinsics with strictfp

2020-01-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D72906#1826061 , @uweigand wrote:

> > The constrained fcmp intrinsics don't allow the TRUE/FALSE predicates.
>
> Hmm, maybe they should then?   The only reason I didn't add them initially 
> was that I wasn't sure they were useful for anything; if they are, it should 
> be straightforward to add them back.


What would we lower it to on a target that doesn’t support it natively?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72906



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


[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir added a reviewer: mprobst.

Revision a75f8d98d7ac9e557b238a229a9a2647c71feed1 
 fixed 
spacing for operators,
but caused the const and non-const versions to diverge:

  // With Style.PointerAlignment = FormatStyle::PAS_Left:
  
  struct A {
operator char*() { return ""; }
operator const char *() const { return ""; }
  };

The code was checking if the type specifier was directly preceded by `operator`.
However there could be comments and `const/volatile` in between.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2706,12 +2706,26 @@
   if (Right.is(tok::star) && Left.is(tok::l_paren))
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
-return (Style.PointerAlignment != FormatStyle::PAS_Left);
+  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier())) {
+// Space between the type and the * in:
+//   operator void*()
+//   operator void*()
+//   operator char*()
+//   operator /*comment*/ const char*()
+//   operator volatile /*comment*/ char*()
+//   operator Foo*()
+// dependant on PointerAlignment style.
+
+// Here, Left points to the type specifier. Skip back over const and
+// volatile, looking for `operator`.
+FormatToken *Before = Left.getPreviousNonComment();
+while (Before && Before->isOneOf(tok::kw_const, tok::kw_volatile)) {
+  Before = Before->getPreviousNonComment();
+}
+if (Before && Before->is(tok::kw_operator)) {
+  return (Style.PointerAlignment != FormatStyle::PAS_Left);
+}
+  }
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
 return Style.SpacesInContainerLiterals ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2706,12 +2706,26 @@
   if (Right.is(tok::star) && Left.is(tok::l_paren))
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
-return (Style.PointerAlignment != FormatStyle::PAS_Left);
+  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier())) {
+// Space between the type and the * in:
+//   operator void*()
+//   operator void*()
+//   operator char*()
+//   operator /*comment*/ const char*()
+//   operator volatile /*comment*/ char*()
+//   operator Foo*()
+// dependant on PointerAlignment style.
+
+// Here, Left points to the type specifier. Skip back

[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 238738.
krasimir added a comment.

- Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2706,12 +2706,26 @@
   if (Right.is(tok::star) && Left.is(tok::l_paren))
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
-return (Style.PointerAlignment != FormatStyle::PAS_Left);
+  (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier())) {
+// Space between the type and the * in:
+//   operator void*()
+//   operator void*()
+//   operator char*()
+//   operator /*comment*/ const char*()
+//   operator volatile /*comment*/ char*()
+//   operator Foo*()
+// dependant on PointerAlignment style.
+
+// Here, Left points to the type specifier. Skip back over const and
+// volatile, looking for `operator`.
+FormatToken *Before = Left.getPreviousNonComment();
+while (Before && Before->isOneOf(tok::kw_const, tok::kw_volatile)) {
+  Before = Before->getPreviousNonComment();
+}
+if (Before && Before->is(tok::kw_operator)) {
+  return (Style.PointerAlignment != FormatStyle::PAS_Left);
+}
+  }
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
 return Style.SpacesInContainerLiterals ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat(

[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
mprobst accepted this revision.
mprobst added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2717
+//   operator Foo*()
+// dependant on PointerAlignment style.
+

typo dependent



Comment at: clang/lib/Format/TokenAnnotator.cpp:2722
+FormatToken *Before = Left.getPreviousNonComment();
+while (Before && Before->isOneOf(tok::kw_const, tok::kw_volatile)) {
+  Before = Before->getPreviousNonComment();

how many const and volatile may be there, and is their order fixed?

We also have the `endsSequence` helper on FormatToken that might express the 
concept better (`Left.endsSequence(tok::kw_const, tok::kw_volatile) || ...`). 
YMMV, with the tokens being optional that might lead to too many alternates to 
check for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911



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


[PATCH] D72553: [clang-tidy] Add performance-prefer-preincrement check

2020-01-17 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 238740.
njames93 added a comment.

- Streamlined replacement application


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72553

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/PreferPreIncrementCheck.cpp
  clang-tools-extra/clang-tidy/performance/PreferPreIncrementCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-pre-increment.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-prefer-pre-increment.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment-disable-cpp-opcalls.cpp
  clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
  
clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp
@@ -0,0 +1,82 @@
+// RUN: %check_clang_tidy %s performance-prefer-pre-increment %t
+
+template 
+class Iterator {
+  T *Current;
+
+public:
+  Iterator(T *Pointer) : Current(Pointer) {}
+  T &operator*() const { return *Current; }
+  Iterator &operator++() { return ++Current, *this; }
+  Iterator operator++(int) {
+Iterator Copy = *this;
+++Current;
+return Copy;
+  }
+  Iterator &operator--() { return --Current, *this; }
+  Iterator operator--(int) {
+Iterator Copy = *this;
+--Current;
+return Copy;
+  }
+};
+
+template 
+class PostfixIterator {
+  T *Current;
+
+public:
+  PostfixIterator(T *Pointer) : Current(Pointer) {}
+  T &operator*() const { return *Current; }
+  PostfixIterator operator++(int) {
+PostfixIterator Copy = *this;
+++Current;
+return Copy;
+  }
+  PostfixIterator operator--(int) {
+PostfixIterator Copy = *this;
+--Current;
+return Copy;
+  }
+};
+
+void foo() {
+  int Array[32];
+  Iterator It(&Array[0]);
+  It++;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-increment instead of Post-increment
+  // CHECK-FIXES: {{^}}  ++It;
+  It--;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-decrement instead of Post-decrement
+  // CHECK-FIXES: {{^}}  --It;
+  (*It)++;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-increment instead of Post-increment
+  // CHECK-FIXES: {{^}}  ++(*It);
+  (*It)--;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-decrement instead of Post-decrement
+  // CHECK-FIXES: {{^}}  --(*It);
+
+  *It++;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-increment instead of Post-increment
+  *It--;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-decrement instead of Post-decrement
+
+  PostfixIterator PfIt(&Array[0]);
+  PfIt++;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-increment instead of Post-increment
+  // CHECK-FIXES-NOT: {{^}}  ++PfIt;
+  PfIt--;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-decrement instead of Post-decrement
+  // CHECK-FIXES-NOT: {{^}}  --PfIt;
+  (*PfIt)++;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-increment instead of Post-increment
+  // CHECK-FIXES: {{^}}  ++(*PfIt);
+  (*PfIt)--;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use Pre-decrement instead of Post-decrement
+  // CHECK-FIXES: {{^}}  --(*PfIt);
+
+  *PfIt++;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-increment instead of Post-increment
+  *PfIt--;
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-decrement instead of Post-decrement
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
@@ -0,0 +1,123 @@
+// RUN: %check_clang_tidy %s performance-prefer-pre-increment %t
+
+#define INC(X) X++
+#define DEC(X) X--
+
+void foo(int A) {
+  for (int I = 0; I < 10; I++) {
+// CHECK-MESSAGES: [[@LINE-1]]:27: warning: Use Pre-increment instead of Post-increment
+// CHECK-FIXES: {{^}}  for (int I = 0; I < 10; ++I) {
+  }
+  for (int I = 0; I < 10; ++I) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-increment instead of Post-increment
+  }
+  for (int I = 0; I < 10; A = I++) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use Pre-increment instead of Post-increment
+  }
+
+  for (int I = 10; I < 0; I--) {
+// CHECK-MESSAGES: [[@LINE-1]]:27: warning: Use Pre-decrement instead of Post-decrement
+// CHECK-FIXES: {{^}}  for (int I = 10; I < 0; --I)

[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 238743.
krasimir added a comment.

- Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,18 @@
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
   (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
+  // Space between the type and the * in:
+  //   operator void*()
+  //   operator void*()
+  //   operator char*()
+  //   operator /*comment*/ const char*()
+  //   operator volatile /*comment*/ char*()
+  //   operator Foo*()
+  // dependent on PointerAlignment style.
+  Left.Previous &&
+  (Left.Previous->endsSequence(tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
 return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
=

[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 238741.
krasimir added a comment.

- Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,18 @@
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
   (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
+  // Space between the type and the * in:
+  //   operator void*()
+  //   operator void*()
+  //   operator char*()
+  //   operator /*comment*/ const char*()
+  //   operator volatile /*comment*/ char*()
+  //   operator Foo*()
+  // dependant on PointerAlignment style.
+  Left.Previous &&
+  (Left.Previous->endsSequence(tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
 return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
==

[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked 3 inline comments as done.
krasimir added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2722
+FormatToken *Before = Left.getPreviousNonComment();
+while (Before && Before->isOneOf(tok::kw_const, tok::kw_volatile)) {
+  Before = Before->getPreviousNonComment();

mprobst wrote:
> how many const and volatile may be there, and is their order fixed?
> 
> We also have the `endsSequence` helper on FormatToken that might express the 
> concept better (`Left.endsSequence(tok::kw_const, tok::kw_volatile) || ...`). 
> YMMV, with the tokens being optional that might lead to too many alternates 
> to check for.
Thank you! I think const and volatile can only appear once, and not both at the 
same time.
There are 3 cases to check for with `endsSequence` which is ok, and it's less 
code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911



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


[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 238746.
krasimir added a comment.

- Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,17 @@
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
   (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
+  // Space between the type and the * in:
+  //   operator void*()
+  //   operator char*()
+  //   operator /*comment*/ const char*()
+  //   operator volatile /*comment*/ char*()
+  //   operator Foo*()
+  // dependent on PointerAlignment style.
+  Left.Previous &&
+  (Left.Previous->endsSequence(tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
 return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/

[PATCH] D72553: [clang-tidy] Add performance-prefer-preincrement check

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61943 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72553



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


[clang] 33463cf - clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2020-01-17T13:33:41+01:00
New Revision: 33463cfba2be7c8d6c08e666123cc34f114a1f3e

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

LOG: clang-format: fix spacing in `operator const char*()`

Summary:
Revision a75f8d98d7ac9e557b238a229a9a2647c71feed1 fixed spacing for operators,
but caused the const and non-const versions to diverge:
```
// With Style.PointerAlignment = FormatStyle::PAS_Left:

struct A {
  operator char*() { return ""; }
  operator const char *() const { return ""; }
};

```
The code was checking if the type specifier was directly preceded by `operator`.
However there could be comments and `const/volatile` in between.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d5d394e61926..21a2184bf1d8 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,17 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
   (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
+  // Space between the type and the * in:
+  //   operator void*()
+  //   operator char*()
+  //   operator /*comment*/ const char*()
+  //   operator volatile /*comment*/ char*()
+  //   operator Foo*()
+  // dependent on PointerAlignment style.
+  Left.Previous &&
+  (Left.Previous->endsSequence(tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
 return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 2d67b9759d7f..d689658f99b6 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@ TEST_F(FormatTest, OperatorSpacing) {
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@ TEST_F(FormatTest, OperatorSpacing) {
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@ TEST_F(FormatTest, OperatorSpacing) {
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);



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


[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33463cfba2be: clang-format: fix spacing in `operator const 
char*()` (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,17 @@
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
   (Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
-  Left.Previous && Left.Previous->is(tok::kw_operator))
-// Space between the type and the *
-// operator void*(), operator char*(), operator Foo*() dependant
-// on PointerAlignment style.
+  // Space between the type and the * in:
+  //   operator void*()
+  //   operator char*()
+  //   operator /*comment*/ const char*()
+  //   operator volatile /*comment*/ char*()
+  //   operator Foo*()
+  // dependent on PointerAlignment style.
+  Left.Previous &&
+  (Left.Previous->endsSequence(tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+   Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
 return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator/*comment*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
 
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
   verifyFormat("Foo::operator()(void&);", Style);
   verifyFormat("Foo::operator&(void&);", Style);
   verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
 
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+  verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
   verifyFormat("Foo::operator()(void&&);", Style);
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/T

[clang] 9835cf1 - clang-format: [JS] pragmas for tslint, tsc.

2020-01-17 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-17T13:39:05+01:00
New Revision: 9835cf159014f40e8ea655d0bb3a341ef7ec34f7

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

LOG: clang-format: [JS] pragmas for tslint, tsc.

Summary:
tslint and tsc (the TypeScript compiler itself) use comment pragmas of
the style:

  // tslint:disable-next-line:foo
  // @ts-ignore

These must not be wrapped and must stay on their own line, in isolation.
For tslint, this required adding it to the pragma regexp. The comments
starting with `@` are already left alone, but this change adds test
coverage for them.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f12bca48c630..cce9458cf22f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -939,9 +939,9 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, triple slash directives (`/// <...`), @see, which is commonly
-// followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|@see)";
+// taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
+// commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 0150b43a0787..ffeb53d9a33c 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2168,6 +2168,38 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, TslintComments) {
+  // tslint uses pragma comments that must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line");
+}
+
+TEST_F(FormatTestJS, TscComments) {
+  // As above, @ts-ignore and @ts-check comments must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-ignore",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-ignore");
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-check",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-check");
+}
+
 TEST_F(FormatTestJS, RequoteStringsSingle) {
   verifyFormat("var x = 'foo';", "var x = \"foo\";");
   verifyFormat("var x = 'fo\\'o\\'';", "var x = \"fo'o'\";");



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


[PATCH] D72907: clang-format: [JS] pragmas for tslint, tsc.

2020-01-17 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9835cf159014: clang-format: [JS] pragmas for tslint, tsc. 
(authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72907

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2168,6 +2168,38 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, TslintComments) {
+  // tslint uses pragma comments that must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line");
+}
+
+TEST_F(FormatTestJS, TscComments) {
+  // As above, @ts-ignore and @ts-check comments must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-ignore",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-ignore");
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-check",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-check");
+}
+
 TEST_F(FormatTestJS, RequoteStringsSingle) {
   verifyFormat("var x = 'foo';", "var x = \"foo\";");
   verifyFormat("var x = 'fo\\'o\\'';", "var x = \"fo'o'\";");
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -939,9 +939,9 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, triple slash directives (`/// <...`), @see, which is commonly
-// followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|@see)";
+// taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
+// commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2168,6 +2168,38 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, TslintComments) {
+  // tslint uses pragma comments that must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// tslint:disable-next-line:must-be-on-own-line");
+}
+
+TEST_F(FormatTestJS, TscComments) {
+  // As above, @ts-ignore and @ts-check comments must be on their own line.
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-ignore",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+   "// @ts-ignore");
+  verifyFormat("// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs\n"
+   "// wrapping. Trailing line.\n"
+   "// @ts-check",
+   "// Comment that needs wrapping. Comment that needs wrapping. "
+   "Comment that needs wrapping.\n"
+   "// Trailing line.\n"
+

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:620
+  if (llvm::dyn_cast(E->getMemberDecl()))
+NameLocation = E->getEndLoc();
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),

kbobyrev wrote:
> kadircet wrote:
> > instead of patching the source location for destructors. we should probably 
> > not report anything for them in here, as they will be reported correctly as 
> > typelocs.
> > 
> > So you can check for `E->getMemberNameInfo().getNamedTypoInfo()` and bail 
> > out if its non-null, which means this is a constructor/destructor/operator 
> > with a typeloc that will be visited separately and result in the same ref. 
> > That way we would also get rid of duplicate refs being reported by 
> > `findExplicitReferences`, API doesn't mention anything about those but most 
> > of the callers would fail in the presence of duplicates, therefore I think 
> > we shouldn't be reporting duplicates. (for example the main visitor 
> > actually makes sure typelocs are not visited twice).
> > 
> > also could you add unittests for constructor and operator cases as well to 
> > make sure we get exactly one reference for those as well.
> > instead of patching the source location for destructors. we should probably 
> > not report anything for them in here, as they will be reported correctly as 
> > typelocs.
> 
> Yes, I thought about that, but I decided against it because IIUC this would 
> prevent destructors/ctors from appearing in x-refs which might be a 
> regression. Also, this might be incorrect for cases like this one:
> 
> ```
> class Bar {};
> 
> class Foo {
> public:
>   operator Bar() const { return Bar(); }
> };
> 
> int main() {
>   Foo foo;
>   Bar bar = foo.operator Bar();
> }
> ```
> 
> Here, if we bail out on `foo.operator Bar()` we would miss the reference to 
> the `operator Bar()` which we might want to preserve.
> 
> Actually, looking at the `FindTargets` unittests, there is something 
> interesting happening: references to constructor have the constructor as the 
> target, but destructor references target typename itself.
> 
> Another thing that is happening is that the following code has two references 
> of bar at the same location:
> 
> ```
> class Foo {
> public:
>   operator $0^$1^Bar() const { return Bar(); }
> };
> ```
> 
> I'm on it right now.
> 
> > also could you add unittests for constructor and operator cases as well to 
> > make sure we get exactly one reference for those as well.
> 
> Sure!
+1 on not reporting these locations (we also don't report destructor decls in 
`refInDecl`).

> because IIUC this would prevent destructors/ctors from appearing in x-refs 
> which might be a regression.

we don't use findExplicitReferences in XRefs, so it should be ok.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:601
+  // visited separately.
+  if (llvm::dyn_cast(E->getMemberDecl()))
+return;

I think we should use `E->getFoundDecl()` here, could you add a test case for  
calling base destructor explicitly, e.g. `derived->base::~base()`?



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:882
 "10: targets = {ns}\n"},
+   // CXX Constructor, destructor and operators.
+   {R"cpp(

could we simplify the newly-added test? I think a test only for explicit 
destructor calls is sufficient, I think.

```
void foo () {
  class Foo { ~Foo(); };
 Foo f;
 f.~Foo();
}
```



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:900
+   $8^Foo $9^f;
+   int $10^fourtyTwo = $11^f.$12^operator int();
+   $13^f.~ /*...*/ $14^Foo();

kbobyrev wrote:
> `$12` would not be captured if we simply do
> 
> ```
> if (E->getMemberNameInfo().getNamedTypeInfo())
>   return;
> ```
If we want to keep the test for operator int, just create a new test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D72380: [DataFlow] Factor two worklist implementations out

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

Thank you for factoring our this library!

I briefly read the UninitializedValues analysis and I also think that this 
change is a no-op.




Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h:59
+
+/// A worklist implementation for forward data-flow analysis. The enqueued
+/// blocks will be dequeued in reverse post order. The worklist cannot contain

s/data-flow/dataflow/ I think.


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

https://reviews.llvm.org/D72380



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-17 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 238753.
njames93 added a comment.

- added few more functions, fix format error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial &operator=(const NonTrivial &Other) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial &Other) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial &Other) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial &Other) {
+  Trivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(&Data, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial &Other) {
+  NonTrivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(&Data, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial &Other) {
+  NonTrivial Data;
+  mymemset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is undefined
+  mymemcpy(&Data, &Other, sizeof(Data));
+  

[PATCH] D72910: Fix a bug with clang with object destructor, while skipping object initialization - make clang crash

2020-01-17 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Aha, which version of clang-cl are you using?  With the released version of 
clang-cl 9.0.1, I get a warning instead of an error:

  cleanup.cpp(15,5): warning: jump from this goto statement to its label is a 
Microsoft extension [-Wmicrosoft-goto]
  goto clean_up;
  ^
  cleanup.cpp(20,7): note: jump bypasses variable initialization
int i = 0;
^
  cleanup.cpp(18,4): note: jump bypasses variable initialization
  A a;
^
  1 warning generated.

So apparently another code path is activated when the target is Microsoft.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72910



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61941 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Since I seem to be in the minority about thinking that this check does not pull 
its weight, I reviewed the code, and will LGTM and push once the few small 
issues are fixed.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp:36
+
+  return FixItHint::CreateReplacement(
+  Outer->getSourceRange(),

We usually try to make the replacement as small as possible. In the case of 
this checker, the replacement should move the closing parenthesis or the 
closing bracket after the RHS of the binary expression.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp:73
+  const auto CXXConstructorWithSingleIntArg =
+cxxConstructExpr(argumentCountIs(1), hasArgument(0, IntExpr));
+

It does not have to be a single argument, the same typo can happen with the 
last argument of the constructor:

```
A *ptr = new A(a, b, c) + 1; // as written
A *ptr = new A(a, b, c + 1); // should have been
```



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c:12
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied 
to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: {{^  char \*p = \(char \*\)malloc\(n}} + 10{{\);$}}
+

I don't think the check lines in this file need regexes. You can match literal 
text and avoid having to escape special characters:

CHECK-FIXES: char *p = ...;


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

https://reviews.llvm.org/D71001



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


Re: [clang] 4456076 - Revert "Further implement CWG 2292"

2020-01-17 Thread Aaron Ballman via cfe-commits
On Fri, Jan 17, 2020 at 4:40 AM Hans Wennborg via cfe-commits
 wrote:
>
> (Note to self: I double checked that the "Further implement CWG 2292"
> patch landed just after the 10.x branch, so this revert doesn't need
> to be cherry-picked there.)

Can confirm. I did the commit after the branch point.

Thank you Amy for catching the regression!

~Aaron

>
> On Thu, Jan 16, 2020 at 12:46 AM Amy Huang via cfe-commits
>  wrote:
> >
> >
> > Author: Amy Huang
> > Date: 2020-01-15T15:46:07-08:00
> > New Revision: 44560762c62d72a103bdceff49ffa70451efd5f8
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/44560762c62d72a103bdceff49ffa70451efd5f8
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/44560762c62d72a103bdceff49ffa70451efd5f8.diff
> >
> > LOG: Revert "Further implement CWG 2292"
> >
> > This reverts commit ee0f1f1edc3ec0d4e698d50cc3180217448802b7 because it
> > causes an error on valid code.
> > See https://reviews.llvm.org/rGee0f1f1edc3ec0d4e698d50cc3180217448802b7.
> >
> > Added:
> >
> >
> > Modified:
> > clang/lib/Sema/SemaExprCXX.cpp
> >
> > Removed:
> > clang/test/SemaCXX/pseudo-destructor-name.cpp
> >
> >
> > 
> > diff  --git a/clang/lib/Sema/SemaExprCXX.cpp 
> > b/clang/lib/Sema/SemaExprCXX.cpp
> > index 96e18105df78..a73e6906fceb 100644
> > --- a/clang/lib/Sema/SemaExprCXX.cpp
> > +++ b/clang/lib/Sema/SemaExprCXX.cpp
> > @@ -192,10 +192,8 @@ ParsedType Sema::getDestructorName(SourceLocation 
> > TildeLoc,
> >AlreadySearched = true;
> >LookupCtx = DC;
> >isDependent = false;
> > -} else if (auto *RD = dyn_cast_or_null(DC)) {
> > -  if ((RD->hasDefinition() && RD->hasSimpleDestructor()) ||
> > -  !RD->hasDefinition())
> > -LookAtPrefix = false;
> > +} else if (DC && isa(DC)) {
> > +  LookAtPrefix = false;
> >LookInScope = true;
> >  }
> >
> >
> > diff  --git a/clang/test/SemaCXX/pseudo-destructor-name.cpp 
> > b/clang/test/SemaCXX/pseudo-destructor-name.cpp
> > deleted file mode 100644
> > index cc7c22b8dc4d..
> > --- a/clang/test/SemaCXX/pseudo-destructor-name.cpp
> > +++ /dev/null
> > @@ -1,26 +0,0 @@
> > -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
> > -// expected-no-diagnostics
> > -
> > -struct AAA
> > -{
> > -struct BBB
> > -{
> > -~BBB() {}
> > -};
> > -
> > -typedef BBB BBB_alias;
> > -};
> > -
> > -typedef AAA::BBB BBB_alias2;
> > -
> > -int
> > -main()
> > -{
> > -AAA::BBB_alias *ptr1 = new AAA::BBB_alias();
> > -AAA::BBB_alias *ptr2 = new AAA::BBB_alias();
> > -
> > -ptr1->AAA::BBB_alias::~BBB_alias(); // Now OK
> > -ptr2->AAA::BBB_alias::~BBB();   // OK
> > -ptr1->~BBB_alias2();// OK
> > -return 0;
> > -}
> >
> >
> >
> > ___
> > 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D72746#1821097 , @kbobyrev wrote:

> The patch could be shorter and slightly less confusing if I preserved 1:1 
> `RefKind::Implicit` <-> `index::SymbolKind::Implicit` relation, but I thought 
> we might want to keep `RefKind` being 1 byte so that we don't waste 
> unnecessary memory.


I think it is time to create our own `Declaration`, `Definition` in our 
`RefKind` (rather than reusing the enums in libindex).

> Also, since we might want to start using `findExplicitReferences` (or 
> something else we come up with) for indexing, it shouldn't be critical. Let 
> me know if you think it's unnecessary.

Yeah, we may have a plan in the future, but I don't think switching to 
`findExplicitReferences` is trivial, there are a few things we need to figure 
out carefully, e.g. how to support macros, implicit references.




Comment at: clang-tools-extra/clangd/index/Ref.h:33
   Reference = static_cast(index::SymbolRole::Reference),
-  All = Declaration | Definition | Reference,
+  // This corresponds to index::SymbolRole::Implicit. In order to save memory
+  // and keep RefKind occupying 1 byte, the original value is modified to the

I'm skeptical about definition of `index::SymbolRole::Implicit`.

I think the `implicit` we want here is references that are spelled/written as 
the same as the named decls, so it is more likely to align with 
`index::SymbolRole::NameReferences`.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:309
+  if (Name.isIdentifier() && Name.getAsString() != Spelling)
+Roles |= static_cast(index::SymbolRole::Implicit);
+

kadircet wrote:
> It seems like we are only checking for `syntactic` occurence of a symbol. Can 
> we make use of `Spelled` Rather than `Implicit` (which has some semantic 
> meaning) to make that clear?
+1, `Implicit` is ambiguous, maybe `Named`, `Explicit` (this reflects to the 
`findExplicitReferences`)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked 2 inline comments as done.
serge-sans-paille added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2910
+
+  if (Arg *A = Args.getLastArg(options::OPT_fnostack_clash_protection,
+   options::OPT_fstack_clash_protection)) {

craig.topper wrote:
> I think this can use Args.hasFlag(options::OPT_fstack_clash_protection, 
> options::OPT_fnostack_clash_protection, false) and then you don't need the 
> 'if'
I wasn't aware of that API, thanks for pointing this out o/



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:31080
+
+  BuildMI(blockMBB, DL, TII->get(IsLP64 ? X86::SUB64ri32 : X86::SUB32ri),
+  physSPReg)

craig.topper wrote:
> This uses physSPReg, but doesn't match the condition for when physSPReg is a 
> 64-bit register. Same at several places below.
Sorry, I don't understand your remark. Can you elaborate?



Comment at: llvm/lib/Target/X86/X86InstrCompiler.td:130
+ (X86ProbedAlloca GR64:$size))]>,
+Requires<[In64BitMode]>;
 }

craig.topper wrote:
> Why is this In64BitMode, but above is NotLP64. Shouldn't they be opposites? 
> Looks like this was just copied from SEG_ALLOCA above?
Yeah, these intrinsics are just the same as the one above, except they have a 
different name. And they get lowered differently. I'm not familiar with that 
part of LLVM, can you suggest a better approach?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 238758.
serge-sans-paille marked 5 inline comments as done.
serge-sans-paille added a comment.

Take into account some of the reviews


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll
  llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Index: llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg);
+
+define void @foo() local_unnamed_addr #0 {
+
+;CHECK-LABEL: foo:
+;CHECK: # %bb.0:
+;CHECK-NEXT:	subq	$4096, %rsp # imm = 0x1000
+; it's important that we don't use the call as a probe here
+;CHECK-NEXT:	movq	$0, (%rsp)
+;CHECK-NEXT:	subq	$3912, %rsp # imm = 0xF48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8016
+;CHECK-NEXT:	movq	%rsp, %rdi
+;CHECK-NEXT:	movl	$8000, %edx # imm = 0x1F40
+;CHECK-NEXT:	xorl	%esi, %esi
+;CHECK-NEXT:	callq	memset
+;CHECK-NEXT:	addq	$8008, %rsp # imm = 0x1F48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8
+;CHECK-NEXT:	retq
+
+  %a = alloca i8, i64 8000, align 16
+  call void @llvm.memset.p0i8.i64(i8* align 16 %a, i8 0, i64 8000, i1 false)
+  ret void
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-med

[PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

2020-01-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the new checker -- I've committed on your behalf in 
42a0355816d3bc125d59cbd07052c8886e78ca86 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72378



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-17 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

This follows the reasoning that we discussed in the earlier discussion, but 
after re-reading the gcc comment in particular, I'm wondering whether this is 
what we really want to do...
If __FAST_MATH__ is purely here for compatibility with gcc, then should we 
mimic gcc behavior in setting that macro even if we think it's buggy? 
Ie, when we translate these settings to LLVM's FMF, we can still override the 
-ffast-math flag by checking the -ffp-contract flag (if I'm seeing it 
correctly, the existing code will pass that alongside -ffast-math when contract 
is set to on/off).




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2763
 
+  // If -ffp-contract=off has been specified on the command line, then we must
+  // suppress the emission of -ffast-math and -menable-unsafe-fp-math to cc1.

This comment doesn't match the code any more. Should be "If 
-ffp-contract=off/on, then..."



Comment at: clang/test/Driver/fast-math.c:184
+// -ffp-contract=off and -ffp-contract=on must disable the fast-math umbrella,
+// and the unsafe-fp-math umbrella (-ffp-conteact=fast leaves them enabled).
+// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \

typo: conteact


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

https://reviews.llvm.org/D72675



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


[clang-tools-extra] 42a0355 - Add `bugprone-reserved-identifier`

2020-01-17 Thread Aaron Ballman via cfe-commits

Author: Logan Smith
Date: 2020-01-17T08:44:21-05:00
New Revision: 42a0355816d3bc125d59cbd07052c8886e78ca86

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

LOG: Add `bugprone-reserved-identifier`

This patch adds bugprone-reserved-identifier, which flags uses of __names _Like
::_this, which are reserved for the implementation. The check can optionally be
inverted, i.e. configured to flag any names that are _not_ reserved, which may
be useful for e.g. standard library implementors.

Added: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-reserved-identifier.rst
clang-tools-extra/docs/clang-tidy/checks/cert-dcl37-c.rst
clang-tools-extra/docs/clang-tidy/checks/cert-dcl51-cpp.rst

clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-reserved-identifier/system/system-header.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-reserved-identifier/user-header.h
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-c.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 771cfc18a6ba..831f5f4e3b62 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -36,6 +36,7 @@
 #include "NotNullTerminatedResultCheck.h"
 #include "ParentVirtualCallCheck.h"
 #include "PosixReturnCheck.h"
+#include "ReservedIdentifierCheck.h"
 #include "SignedCharMisuseCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
@@ -120,6 +121,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-parent-virtual-call");
 CheckFactories.registerCheck(
 "bugprone-posix-return");
+CheckFactories.registerCheck(
+"bugprone-reserved-identifier");
 CheckFactories.registerCheck(
 "bugprone-signed-char-misuse");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 2cb28f4e8f19..efb97a5318bb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -28,6 +28,7 @@ add_clang_library(clangTidyBugproneModule
   NotNullTerminatedResultCheck.cpp
   ParentVirtualCallCheck.cpp
   PosixReturnCheck.cpp
+  ReservedIdentifierCheck.cpp
   SignedCharMisuseCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
new file mode 100644
index ..699f46dd2722
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -0,0 +1,178 @@
+//===--- ReservedIdentifierCheck.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 "ReservedIdentifierCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+static const char DoubleUnderscoreTag[] = "du";
+static const char UnderscoreCapitalTag[] = "uc";
+static const char GlobalUnderscoreTag[] = "global-under";
+static const char NonReservedTag[] = "non-reserved";
+
+static const char Message[] =
+"declaration uses identifier '%0', which is %select{a reserved "
+"identifier|not a reserved identifier|reserved in the global namespace}1";
+
+static int getMessageSelectIndex(StringRef Tag) {
+  if (Tag == NonReservedTag)
+return 1;
+  if (Tag == GlobalUnderscoreTag)
+return 2;
+  return 0;
+}
+
+ReservedIdentifierCheck::ReservedIdentifierCheck(StringRef Name,
+ ClangTidyContext *Context)
+: RenamerClangTidyCheck(Name, 

[PATCH] D72717: [CMake] Disable libc++ filesystem tests in CrossWinToARMLinux cache file

2020-01-17 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

In D72717#1824858 , @vvereschaka wrote:

> I think it is optimal to pass this parameter directly in the builder 
> configuration only for libcxx as '-DLLVM_LIT_ARGS="--param 
> enable_filesystem=False"'.


You mean, instead of `ninja check-cxx` just invoke LIT directly and pass this 
argument?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72717



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-17 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added reviewers: efriedma, scanon, arsenm, echristo, RKSimon.
spatel added a comment.
Herald added a subscriber: wdng.

Adding potential FP reviewers for question of gcc- (potentially-buggy-) 
compatibility.


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

https://reviews.llvm.org/D72675



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


[PATCH] D72635: Add "context" capability to Thread Safety Analysis

2020-01-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72635#1825219 , @aaronpuchert 
wrote:

> Hmm, I have been wondering about this as well. The way I see it, all of these 
> things are what we call //capabilities//, and we treat them all the same. The 
> names are just meant to make warning messages more readable, because what the 
> analysis considers a capability, the user might know as a //mutex//, or 
> //role//, or //sequence//.


Yup, that was intentional. We started out with thread safety analysis using 
"lock" terminology everywhere, but then switched to "capability" analysis which 
is roughly the same thing using more generic terms.

> I think I'll read a bit of code to see if this is really true and there are 
> no functional differences between the differently named capabilities, but 
> other than that I've no objections to allowing arbitrary names. I'm trying to 
> come up with potential problems caused by opening the flood gates, but 
> frankly I don't see any.
> 
> Edit: I've gone through `ThreadSafety.cpp` and `AnalysisBasedWarnings.cpp` 
> and it seems that we indeed only write the name into the diagnostic.

Thank you for double-checking -- I had come to the same conclusion myself.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72635



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 61960 tests passed, 3 failed 
and 783 were skipped.

  failed: Clang.CodeGen/stack-clash-protection.c
  failed: Clang.Driver/stack-clash-protection.c
  failed: Clang.Misc/warning-flags.c

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D71980: [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

2020-01-17 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9c46229e4ac: [clang-tidy] Disable Checks on If constexpr 
statements in template… (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71980

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-constexpr-if-templates.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-constexpr-if-templates.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-constexpr-if-templates.cpp
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -- -std=c++17
+
+void handle(bool);
+
+template 
+void shouldFail() {
+  if constexpr (branch)
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: statement should be inside braces [readability-braces-around-statements]
+handle(true);
+  else
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: statement should be inside braces [readability-braces-around-statements]
+handle(false);
+}
+
+template 
+void shouldPass() {
+  if constexpr (branch) {
+handle(true);
+  } else {
+handle(false);
+  }
+}
+
+void shouldFailNonTemplate() {
+  constexpr bool branch = false;
+  if constexpr (branch)
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: statement should be inside braces [readability-braces-around-statements]
+handle(true);
+  else
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: statement should be inside braces [readability-braces-around-statements]
+handle(false);
+}
+
+void shouldPass() {
+  constexpr bool branch = false;
+  if constexpr (branch) {
+handle(true);
+  } else {
+handle(false);
+  }
+}
+
+void run() {
+shouldFail();
+shouldFail();
+shouldPass();
+shouldPass();
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
@@ -0,0 +1,58 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t -- -- -std=c++17
+
+void handle(int);
+
+template 
+void shouldFail() {
+  if constexpr (Index == 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: repeated branch in conditional chain [bugprone-branch-clone]
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(0);
+  }
+}
+
+template 
+void shouldPass() {
+  if constexpr (Index == 0) {
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(2);
+  }
+}
+
+void shouldFailNonTemplate() {
+  constexpr unsigned Index = 1;
+  if constexpr (Index == 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: repeated branch in conditional chain [bugprone-branch-clone]
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(0);
+  }
+}
+
+void shouldPassNonTemplate() {
+  constexpr unsigned Index = 1;
+  if constexpr (Index == 0) {
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(2);
+  }
+}
+
+void run() {
+shouldFail<0>();
+shouldFail<1>();
+shouldFail<2>();
+shouldPass<0>();
+shouldPass<1>();
+shouldPass<2>();
+}
Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -123,7 +123,10 @@
 }
 
 void BracesAroundStatementsCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(ifStmt().bind("if"), this);
+  Finder->addMatcher(
+  ifStmt(unless(allOf(isConstexpr(), isInTemplateInstantiation(
+  .bind("if"),
+  this);
   Finder->addMatcher(whileStmt().bind("while"), this);
   Finder->addMatcher(doStmt().bind("do"), this);
   Finder->addMatcher(forStmt().bind("for"), this);
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -59,7 +59,8 @@
 
 void BranchCloneCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-  ifStmt(stmt().bind("if"),
+  ifStmt(unless(allOf(isConstexpr(), isInTemplateInstantiation())),
+ stmt().bind("if"),
  hasParent(stmt

[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a subscriber: mikhail.ramalho.
NoQ added a comment.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, a.sidorin, 
rnkovacs, szepet, baloghadamsoftware.

@mikhail.ramalho brought this up in pr41809 
 so let's revisit this.

Like, the patch looks great, the idea looks great, but i'd like to make super 
duper sure that the behavior without Z3 remains the same, because we are in no 
position to give up on the no-Z3 mode yet.




Comment at: test/Analysis/PR3991.m:63
+#else
+  BOOL doGetDir = self.directoryPathComponents != 0 && 
self.currentPathComponentIndex < [self.directoryPathComponents count]; // 
expected-warning{{Assignment of a non-Boolean value}}
+#endif

This looks like a regression to me. Even though `BoolAssignment` is an alpha 
checker, it's definitely one of the good ones, which i want to enable by 
default sooner rather than later, so can we try not to regress it too much?



Comment at: test/Analysis/std-c-library-functions.c:149
   if (isgraph(y))
-clang_analyzer_eval(isprint(x)); // expected-warning{{TRUE}}
+clang_analyzer_eval(isprint(y)); // expected-warning{{TRUE}}
 }

Why did this //have// to change? I don't remember all the details of how these 
functions work, but as far as i remember the only character that is printable 
but not graphical is the space character (32) which converts between `int` and 
`char` just fine.


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

https://reviews.llvm.org/D28955



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


[PATCH] D72448: [clang-tidy] readability-redundant-string-init now flags redundant initialisation in Field Decls and Constructor Initialisers

2020-01-17 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 238764.
njames93 added a comment.

- Updated to trunk, fix release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72448

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -34,6 +34,12 @@
   std::string d(R"()");
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
   // CHECK-FIXES: std::string d;
+  std::string e{""};
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string e;
+  std::string f = {""};
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string f;
 
   std::string u = "u";
   std::string w("w");
@@ -227,3 +233,53 @@
   other::wstring e = L"";
   other::wstring f(L"");
 }
+
+class Foo {
+  std::string A = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES:  std::string A;
+  std::string B;
+  std::string C;
+  std::string D;
+  std::string E = "NotEmpty";
+
+public:
+  // Check redundant constructor where Field has a redundant initializer.
+  Foo() : A("") {}
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: redundant string initialization
+  // CHECK-FIXES:  Foo()  {}
+
+  // Check redundant constructor where Field has no initializer.
+  Foo(char) : B("") {}
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(char)  {}
+
+  // Check redundant constructor where Field has a valid initializer.
+  Foo(long) : E("") {}
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(long) : E() {}
+
+  // Check how it handles removing 1 initializer, and defaulting the other.
+  Foo(int) : B(""), E("") {}
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:21: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(int) :  E() {}
+
+  Foo(short) : B{""} {}
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(short)  {}
+
+  Foo(float) : A{""}, B{""} {}
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(float)  {}
+
+
+  // Check how it handles removing some redundant initializers while leaving
+  // valid initializers intact.
+  Foo(std::string Arg) : A(Arg), B(""), C("NonEmpty"), D(R"()"), E("") {}
+  // CHECK-MESSAGES: [[@LINE-1]]:34: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:56: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-3]]:66: warning: redundant string initialization
+  // CHECK-FIXES:  Foo(std::string Arg) : A(Arg),  C("NonEmpty"),  E() {}
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,6 +91,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:`readability-redundant-string-init
+  ` check now supports a
+  `StringNames` option enabling its application to custom string classes. The 
+  check now detects in class initializers and constructor initializers which 
+  are deemed to be redundant.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -20,6 +20,30 @@
 
 const char DefaultStringNames[] = "::std::basic_string";
 
+static const CXXConstructExpr *
+getConstructExpr(const CXXCtorInitializer &CtorInit) {
+  const Expr *InitExpr = CtorInit.getInit();
+  if (const auto *CleanUpExpr = dyn_cast(InitExpr))
+InitExpr = CleanUpExpr->getSubExpr();
+  return dyn_cast(InitExpr);
+}
+
+static llvm::Optional
+getConstructExprArgRange(const CXXConstructExpr &Construct) {
+  SourceLocation B, E;
+  for (const Expr *Arg : Construct.arguments()) {
+if (B.isInvalid()) {
+  B = Arg->getBeginLoc();
+}
+if (Arg->getEndLoc().isValid()) {
+  E = Arg->getEndLoc();
+}
+  }
+  if (B.isInvalid() || E.isInvalid())
+return llvm::None;
+  return SourceR

[clang-tools-extra] f9c4622 - [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

2020-01-17 Thread via cfe-commits

Author: Nathan
Date: 2020-01-17T14:21:38Z
New Revision: f9c46229e4ac29053747c96e08c574c6c48d544b

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

LOG: [clang-tidy] Disable Checks on If constexpr statements in template 
Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

Summary: fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32203 | 
readability-braces-around-statements broken for if constexpr]] and [[ 
https://bugs.llvm.org/show_bug.cgi?id=44229 | bugprone-branch-clone false 
positive with template functions and constexpr ]] by disabling the relevant 
checks on if constexpr statements while inside an instantiated template. This 
is due to how the else branch of an if constexpr statement is folded away to a 
null statement if the condition evaluates to false

Reviewers: alexfh, hokein, aaron.ballman, xazax.hun

Reviewed By: aaron.ballman, xazax.hun

Subscribers: rnkovacs, JonasToth, Jim, lebedev.ri, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-constexpr-if-templates.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index eb54aaa99445..e40b27585d3d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -59,7 +59,8 @@ namespace bugprone {
 
 void BranchCloneCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-  ifStmt(stmt().bind("if"),
+  ifStmt(unless(allOf(isConstexpr(), isInTemplateInstantiation())),
+ stmt().bind("if"),
  hasParent(stmt(unless(ifStmt(hasElse(equalsBoundNode("if")),
  hasElse(stmt().bind("else"))),
   this);

diff  --git 
a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index 117ef36d78fe..da0bef32c091 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -123,7 +123,10 @@ void BracesAroundStatementsCheck::storeOptions(
 }
 
 void BracesAroundStatementsCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(ifStmt().bind("if"), this);
+  Finder->addMatcher(
+  ifStmt(unless(allOf(isConstexpr(), isInTemplateInstantiation(
+  .bind("if"),
+  this);
   Finder->addMatcher(whileStmt().bind("while"), this);
   Finder->addMatcher(doStmt().bind("do"), this);
   Finder->addMatcher(forStmt().bind("for"), this);

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
new file mode 100644
index ..382330139c8c
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-if-constexpr-template.cpp
@@ -0,0 +1,58 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t -- -- -std=c++17
+
+void handle(int);
+
+template 
+void shouldFail() {
+  if constexpr (Index == 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: repeated branch in 
conditional chain [bugprone-branch-clone]
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(0);
+  }
+}
+
+template 
+void shouldPass() {
+  if constexpr (Index == 0) {
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(2);
+  }
+}
+
+void shouldFailNonTemplate() {
+  constexpr unsigned Index = 1;
+  if constexpr (Index == 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: repeated branch in 
conditional chain [bugprone-branch-clone]
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(0);
+  }
+}
+
+void shouldPassNonTemplate() {
+  constexpr unsigned Index = 1;
+  if constexpr (Index == 0) {
+handle(0);
+  } else if constexpr (Index == 1) {
+handle(1);
+  } else {
+handle(2);
+  }
+}
+
+void run() {
+shouldFail<0>();
+shouldFail<1>();
+shouldFail<2>();
+shouldPass<0>();
+shouldPass<1>();
+shouldPass<2>();
+}

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-constexpr-if-templates.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/

[PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

2020-01-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this isn't building on Windows: 
http://45.33.8.238/win/6039/step_4.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72378



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


[PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

2020-01-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

cl.exe prints a different error: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/13716/steps/stage%201%20build/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72378



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


Re: [PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

2020-01-17 Thread Aaron Ballman via cfe-commits
On Fri, Jan 17, 2020 at 9:49 AM Nico Weber via Phabricator
 wrote:
>
> thakis added a comment.
>
> Looks like this isn't building on Windows: 
> http://45.33.8.238/win/6039/step_4.txt

Yup, I'm already investigating a fix.

~Aaron

>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D72378/new/
>
> https://reviews.llvm.org/D72378
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] bcda877 - Fix a compile error to get bots back to green.

2020-01-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-01-17T09:56:04-05:00
New Revision: bcda877b43093459dc52747d35abe0019f8e22e0

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

LOG: Fix a compile error to get bots back to green.

Fixes http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/13716

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 699f46dd2722..4f49aea1c9ba 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -130,12 +130,12 @@ getFailureInfoImpl(StringRef Name, bool 
IsInGlobalNamespace,
   .getValueOr(Name);
 };
 if (auto Fixup = getDoubleUnderscoreFixup(InProgressFixup(), LangOpts))
-  AppendFailure(DoubleUnderscoreTag, *std::move(Fixup));
+  AppendFailure(DoubleUnderscoreTag, std::move(*Fixup));
 if (auto Fixup = getUnderscoreCapitalFixup(InProgressFixup()))
-  AppendFailure(UnderscoreCapitalTag, *std::move(Fixup));
+  AppendFailure(UnderscoreCapitalTag, std::move(*Fixup));
 if (auto Fixup = getUnderscoreGlobalNamespaceFixup(InProgressFixup(),
IsInGlobalNamespace))
-  AppendFailure(GlobalUnderscoreTag, *std::move(Fixup));
+  AppendFailure(GlobalUnderscoreTag, std::move(*Fixup));
 
 return Info;
   }



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


[PATCH] D72448: [clang-tidy] readability-redundant-string-init now flags redundant initialisation in Field Decls and Constructor Initialisers

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61955 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72448



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


[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-17 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 238769.
pengfei marked 7 inline comments as done.
pengfei added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/IR/ConstrainedOps.def
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
  llvm/test/TableGen/GlobalISelEmitter-input-discard.td

Index: llvm/test/TableGen/GlobalISelEmitter-input-discard.td
===
--- llvm/test/TableGen/GlobalISelEmitter-input-discard.td
+++ llvm/test/TableGen/GlobalISelEmitter-input-discard.td
@@ -15,7 +15,7 @@
 // GISEL-NEXT: GIM_CheckType, /*MI*/0, /*Op*/2, /*Type*/GILLT_s32,
 // GISEL-NEXT: GIM_CheckType, /*MI*/0, /*Op*/3, /*Type*/GILLT_s32,
 // GISEL-NEXT: GIM_CheckRegBankForClass, /*MI*/0, /*Op*/0, /*RC*/MyTarget::GPR32RegClassID,
-// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 248:{ *:[iPTR] }, srcvalue:{ *:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] }), GPR32:{ *:[i32] }:$src1)
+// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 249:{ *:[iPTR] }, srcvalue:{ *:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] }), GPR32:{ *:[i32] }:$src1)
 // GISEL-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,
 // GISEL-NEXT: GIR_BuildMI, /*InsnID*/1, /*Opcode*/TargetOpcode::IMPLICIT_DEF,
 // GISEL-NEXT: GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/0, /*TempRegFlags*/RegState::Define,
Index: llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
===
--- llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
+++ llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
@@ -3,6 +3,104 @@
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA
 
+; Verify constrained fmul and fadd aren't fused.
+define float @f11(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f11:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f11:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulss %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+entry:
+  %3 = call float @llvm.experimental.constrained.fmul.f32(float %0, float %1,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  %4 = call float @llvm.experimental.constrained.fadd.f32(float %3, float %2,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %4
+}
+
+; Verify constrained fmul and fadd aren't fused.
+define double @f12(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f12:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulsd %xmm1, %xmm0
+; NOFMA-NEXT:addsd %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f12:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulsd %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddsd %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+entry:
+  %3 = call double @llvm.experimental.constrained.fmul.f64(double %0, double %1,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  %4 = call double @llvm.experimental.constrained.fadd.f64(double %3, double %2,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret double %4
+}
+
+; Verify that fmuladd(3.5) isn't simplified when the rounding mode is
+; unknown.
+define float @f15() #0 {
+; NOFMA-LABEL: f15:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; NOFMA-NEXT:movaps %xmm1, %xmm0
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm1, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f15:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm0
+; FMA-NEXT:retq
+entry:
+  %result = call float @llvm.experimental.constrained.fmuladd.f32(
+   float 3.5,
+   float 3.5,
+   float 3.5,
+

[PATCH] D72274: [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

The only functional change that I see in this patch is in 
`clang/lib/Tooling/Transformer/Stencil.cpp`. However, I don't understand how 
that change in the (deprecated) selection() stencil can affect other stencils.




Comment at: clang/unittests/Tooling/StencilTest.cpp:375
+  double foo(double d);
+  foo(MACRO);)cpp";
+

"foo(MACRO);" will fail parsing at the top level, it should be within a 
function, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72274



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


[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-17 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 238770.
pengfei added a comment.

Remove unnecessary comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/IR/ConstrainedOps.def
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
  llvm/test/TableGen/GlobalISelEmitter-input-discard.td

Index: llvm/test/TableGen/GlobalISelEmitter-input-discard.td
===
--- llvm/test/TableGen/GlobalISelEmitter-input-discard.td
+++ llvm/test/TableGen/GlobalISelEmitter-input-discard.td
@@ -15,7 +15,7 @@
 // GISEL-NEXT: GIM_CheckType, /*MI*/0, /*Op*/2, /*Type*/GILLT_s32,
 // GISEL-NEXT: GIM_CheckType, /*MI*/0, /*Op*/3, /*Type*/GILLT_s32,
 // GISEL-NEXT: GIM_CheckRegBankForClass, /*MI*/0, /*Op*/0, /*RC*/MyTarget::GPR32RegClassID,
-// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 248:{ *:[iPTR] }, srcvalue:{ *:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] }), GPR32:{ *:[i32] }:$src1)
+// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 249:{ *:[iPTR] }, srcvalue:{ *:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] }), GPR32:{ *:[i32] }:$src1)
 // GISEL-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,
 // GISEL-NEXT: GIR_BuildMI, /*InsnID*/1, /*Opcode*/TargetOpcode::IMPLICIT_DEF,
 // GISEL-NEXT: GIR_AddTempRegister, /*InsnID*/1, /*TempRegID*/0, /*TempRegFlags*/RegState::Define,
Index: llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
===
--- llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
+++ llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
@@ -3,6 +3,104 @@
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA
 
+; Verify constrained fmul and fadd aren't fused.
+define float @f11(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f11:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f11:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulss %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+entry:
+  %3 = call float @llvm.experimental.constrained.fmul.f32(float %0, float %1,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  %4 = call float @llvm.experimental.constrained.fadd.f32(float %3, float %2,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %4
+}
+
+; Verify constrained fmul and fadd aren't fused.
+define double @f12(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f12:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulsd %xmm1, %xmm0
+; NOFMA-NEXT:addsd %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f12:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulsd %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddsd %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+entry:
+  %3 = call double @llvm.experimental.constrained.fmul.f64(double %0, double %1,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  %4 = call double @llvm.experimental.constrained.fadd.f64(double %3, double %2,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret double %4
+}
+
+; Verify that fmuladd(3.5) isn't simplified when the rounding mode is
+; unknown.
+define float @f15() #0 {
+; NOFMA-LABEL: f15:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; NOFMA-NEXT:movaps %xmm1, %xmm0
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm1, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f15:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm0
+; FMA-NEXT:retq
+entry:
+  %result = call float @llvm.experimental.constrained.fmuladd.f32(
+   float 3.5,
+   float 3.5,
+   float 3.5,
+   metadata !"r

[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-17 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei marked an inline comment as done.
pengfei added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3381
+ Addend->getType()),
+{MulOp0, MulOp1, Addend, MulOp->getOperand(2), MulOp->getOperand(3)});
+  else

andrew.w.kaylor wrote:
> You shouldn't just assume that MulOp is a constrained intrinsic. Cast to 
> ConstrainedFPIntrinsic and use ConstrainedFPIntrinsic::getRoundingMode() and 
> ConstrainedFPIntrinsic::getExceptionBehavior(). The cast will effectively 
> assert that MulOp is a constrained intrisic. I think that should always be 
> true.
I prefer to reuse the operands from the fmul intrinsic here. 1). fmuladd always 
has the same exception/rounding mode with fmul. 2). the function 
getRoundingMode/getExceptionBehavior just return a enum value. We need more 
code to turn them into Value type.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3423
 
+  if (Builder.getIsFPConstrained()) {
+if (auto *LHSBinOp = dyn_cast(op.LHS)) {

andrew.w.kaylor wrote:
> I don't think we should ever non-constrained create FMul instructions if 
> Builder is in FP constrained mode, but you should assert that somewhere 
> above. Maybe move this block above line 3409 and add:
> 
> assert(LHSBinOp->getOpcode() != llvm::Instruction::FMul && 
> RHSBinOp->getOpcode() != llvm::Instruction::FMul);
Add assertion in line 3380. We only need to check once there.



Comment at: llvm/test/TableGen/GlobalISelEmitter-input-discard.td:18
 // GISEL-NEXT: GIM_CheckRegBankForClass, /*MI*/0, /*Op*/0, 
/*RC*/MyTarget::GPR32RegClassID,
-// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 248:{ *:[iPTR] }, srcvalue:{ 
*:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] 
}), GPR32:{ *:[i32] }:$src1)
+// GISEL-NEXT: // (intrinsic_w_chain:{ *:[i32] } 249:{ *:[iPTR] }, srcvalue:{ 
*:[i32] }, i32:{ *:[i32] }:$src1)  =>  (FOO:{ *:[i32] } (IMPLICIT_DEF:{ *:[i32] 
}), GPR32:{ *:[i32] }:$src1)
 // GISEL-NEXT: GIR_MakeTempReg, /*TempRegID*/0, /*TypeID*/GILLT_s32,

It's strange the number is affected. I haven't found any cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820



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


[PATCH] D72463: [Driver][X86] Add -malign-branch* and -malign-branch-within-32B-boundaries

2020-01-17 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.

@MaskRay Did you merge it to LLVM 10 branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72463



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


[clang-tools-extra] 7f4e744 - Another speculative fix for the Windows bots.

2020-01-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-01-17T10:23:45-05:00
New Revision: 7f4e744b90ec7a5cd8067cac7032ef36607aa4b8

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

LOG: Another speculative fix for the Windows bots.

Hopefully fixes: http://45.33.8.238/win/6040/step_4.txt

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 4f49aea1c9ba..aad0ad94456a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include 
+#include 
 
 using namespace clang::ast_matchers;
 



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-17 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 238775.
njames93 marked an inline comment as done.
njames93 added a comment.

- Fix If stmt and optimise building function name list


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial &operator=(const NonTrivial &Other) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial &Other) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial &Other) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial &Other) {
+  Trivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(&Data, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial &Other) {
+  NonTrivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(&Data, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial &Other) {
+  NonTrivial Data;
+  mymemset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is un

[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

I don't have the time to rebase and retest this currently, so it might be 
better for someone else to take over this patch. Unfortunately, it's been long 
enough that I don't remember the details of these changes.


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

https://reviews.llvm.org/D28955



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


[PATCH] D72875: [clang][cmake] Include generated rst files in html built by docs-clang-html target

2020-01-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this, I think this is a great improvement. I am not 
super qualified to review the cmake, but it looks eminently reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72875



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61956 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D72875: [clang][cmake] Include generated rst files in html built by docs-clang-html target

2020-01-17 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Besides the mentioned misindent, the CMake code looks correct. Could you test 
whether it works with standalone (out-of-LLVM) builds as well?




Comment at: clang/docs/CMakeLists.txt:113
+  add_custom_target(copy-clang-rst-docs
+   COMMAND ${CMAKE_COMMAND} -E copy_directory
+   ${CMAKE_CURRENT_SOURCE_DIR}

Looks like misindent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72875



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


[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).

2020-01-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D65761#1814968 , @ajpaverd wrote:

> The CFGuard library shouldn't be needed for targets other than ARM, AArch64, 
> and X86, and it's only being built for these targets. However, it looks like 
> `llvm-build` is also including it in the `LibraryDependencies.inc` file for 
> other targets, such as PowerPC, which I think is causing this error. I'm not 
> sure how to indicate that the library is only needed for a specified subset 
> of targets. @rnk or @hans  any suggestions?


Is the CFGuard library meaningful to provide for the other targets? Is 
consistency in the availability of the library (e.g., in case of hardcoded `-l` 
in the Makefile of some LLVM-dependent project) desired? It may make sense to 
treat the library as not target-specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65761



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


[PATCH] D72705: [clang][checkers] Added new checker 'alpha.unix.ErrorReturn'.

2020-01-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 238781.
balazske added a comment.

A better (?) implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,323 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+/*
+Functions from CERT ERR33-C that should be checked for error:
+https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors
+
+void *aligned_alloc( size_t alignment, size_t size );
+errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr);
+int at_quick_exit( void (*func)(void) );
+int atexit( void (*func)(void) );
+void* bsearch( const void *key, const void *ptr, size_t count, size_t size,
+   int (*comp)(const void*, const void*) );
+void* bsearch_s( const void *key, const void *ptr, rsize_t count, rsize_t size,
+ int (*comp)(const void *, const void *, void *),
+ void *context );
+wint_t btowc( int c );
+size_t c16rtomb( char * restrict s, char16_t c16, mbstate_t * restrict ps );
+size_t c32rtomb( char * restrict s, char32_t c32, mbstate_t * restrict ps );
+void* calloc( size_t num, size_t size );
+clock_t clock(void);
+int cnd_broadcast( cnd_t *cond );
+int cnd_init( cnd_t* cond );
+int cnd_signal( cnd_t *cond );
+int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex,
+   const struct timespec* restrict time_point );
+int cnd_wait( cnd_t* cond, mtx_t* mutex );
+errno_t ctime_s(char *buffer, rsize_t bufsz, const time_t *time);
+int fclose( FILE *stream );
+int fflush( FILE *stream );
+int fgetc( FILE *stream );
+int fgetpos( FILE *restrict stream, fpos_t *restrict pos );
+char *fgets( char *restrict str, int count, FILE *restrict stream );
+wint_t fgetwc( FILE *stream );
+FILE *fopen( const char *restrict filename, const char *restrict mode );
+errno_t fopen_s(FILE *restrict *restrict streamptr,
+const char *restrict filename,
+const char *restrict mode);
+int fprintf( FILE *restrict stream, const char *restrict format, ... );
+int fprintf_s(FILE *restrict stream, const char *restrict format, ...);
+int fputc( int ch, FILE *stream );
+int fputs( const char *restrict str, FILE *restrict stream );
+wint_t fputwc( wchar_t ch, FILE *stream );
+int fputws( const wchar_t * restrict str, FILE * restrict stream );
+size_t fread( void *restrict buffer, size_t size, size_t count,
+  FILE *restrict stream );
+FILE *freopen( const char *restrict filename, const char *restrict mode,
+   FILE *restrict stream );
+errno_t freopen_s(FILE *restrict *restrict newstreamptr,
+  const char *restrict filename, const char *restrict mode,
+  FILE *restrict stream);
+int fscanf( FILE *restrict stream, const char *restrict format, ... );
+int fscanf_s(FILE *restrict stream, const char *restrict format, ...);
+int fseek( FILE *stream, long offset, int origin );
+int fsetpos( FILE *stream, const fpos_t *pos );
+long ftell( FILE *stream );
+int fwprintf( FILE *restrict stream,
+  const wchar_t *restrict format, ... );
+int fwprintf_s( FILE *restrict stream,
+const wchar_t *restrict format, ...);
+size_t fwrite( const void *restrict buffer, size_t size, size_t count,
+   FILE *restrict stream ); // more exact error return: < count
+int fwscanf( FILE *restrict stream,
+ const wchar_t *restrict format, ... );
+int fwscanf_s( FILE *restrict stream,
+   const wchar_t *restrict format, ...);
+int getc( FILE *stream );
+int getchar(void);
+char *getenv( const char *name );
+errno_t getenv_s( size_t *restrict len, char *restrict value,
+  rsize_t valuesz, const char *restrict name );
+char *gets_s( char *str, rsize_t n );
+wint_t getwc( FILE *stream );
+wint_t getwchar(void);
+struct tm *gmtime( const time_t *time );
+struct tm *gmtime_s(const time_t *restrict time, struct tm *restrict result);
+struct tm *localtime( const time_t *time );
+struct tm *localtime_s(const time_t *restrict time, struct tm *restrict result);
+void* malloc( size_t size );
+int mblen( const char* s, size_t n );
+size_t mbrlen( const char *restrict s, size_t n, mbstate_t *restrict ps );
+size_t mbrtoc16( char16_t * restrict pc16, const char * restrict s,
+ size_t n, mbstate_t * restrict ps );
+size_t mbrtoc32( char32_t restrict * pc32, const char * restrict

[PATCH] D72635: Allow arbitrary capability name in Thread Safety Analysis

2020-01-17 Thread Etienne Pierre-Doray via Phabricator via cfe-commits
eti-p-doray updated this revision to Diff 238782.
eti-p-doray retitled this revision from "Add "context" capability to Thread 
Safety Analysis" to "Allow arbitrary capability name in Thread Safety Analysis".
eti-p-doray added a comment.

Allow arbitrary capability


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

https://reviews.llvm.org/D72635

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-capabilities.c


Index: clang/test/Sema/attr-capabilities.c
===
--- clang/test/Sema/attr-capabilities.c
+++ clang/test/Sema/attr-capabilities.c
@@ -8,9 +8,6 @@
 union __attribute__((capability("mutex"))) MutexUnion { int a; char* b; };
 typedef union { int a; char* b; } __attribute__((capability("mutex"))) 
MutexUnion2;
 
-// Test an invalid capability name
-struct __attribute__((capability("wrong"))) IncorrectName {}; // 
expected-warning {{invalid capability name 'wrong'; capability name must be 
'mutex' or 'role'}}
-
 int Test1 __attribute__((capability("test1")));  // expected-error 
{{'capability' attribute only applies to structs, unions, classes, and 
typedefs}}
 int Test2 __attribute__((shared_capability("test2"))); // expected-error 
{{'shared_capability' attribute only applies to structs, unions, classes, and 
typedefs}}
 int Test3 __attribute__((acquire_capability("test3")));  // expected-warning 
{{'acquire_capability' attribute only applies to functions}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6199,11 +6199,6 @@
   !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc))
 return;
 
-  // Currently, there are only two names allowed for a capability: role and
-  // mutex (case insensitive). Diagnose other capability names.
-  if (!N.equals_lower("mutex") && !N.equals_lower("role"))
-S.Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
-
   D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N));
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3195,9 +3195,6 @@
   InGroup>;
 
 // Thread Safety Attributes
-def warn_invalid_capability_name : Warning<
-  "invalid capability name '%0'; capability name must be 'mutex' or 'role'">,
-  InGroup, DefaultIgnore;
 def warn_thread_attribute_ignored : Warning<
   "ignoring %0 attribute because its argument is invalid">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2562,10 +2562,6 @@
   let Accessors = [Accessor<"isShared",
 [Clang<"shared_capability", 0>]>];
   let Documentation = [Undocumented];
-  let AdditionalMembers = [{
-bool isMutex() const { return getName().equals_lower("mutex"); }
-bool isRole() const { return getName().equals_lower("role"); }
-  }];
 }
 
 def AssertCapability : InheritableAttr {


Index: clang/test/Sema/attr-capabilities.c
===
--- clang/test/Sema/attr-capabilities.c
+++ clang/test/Sema/attr-capabilities.c
@@ -8,9 +8,6 @@
 union __attribute__((capability("mutex"))) MutexUnion { int a; char* b; };
 typedef union { int a; char* b; } __attribute__((capability("mutex"))) MutexUnion2;
 
-// Test an invalid capability name
-struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}}
-
 int Test1 __attribute__((capability("test1")));  // expected-error {{'capability' attribute only applies to structs, unions, classes, and typedefs}}
 int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs, unions, classes, and typedefs}}
 int Test3 __attribute__((acquire_capability("test3")));  // expected-warning {{'acquire_capability' attribute only applies to functions}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6199,11 +6199,6 @@
   !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc))
 return;
 
-  // Currently, there are only two names allowed for a capability: role and
-  // mutex (case insensitive). Diagnose other capability names.
-  if (!N.equals_lower("mutex") && !N.equals_lower("role"))
-S.Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
-
   D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N));
 }
 
Index: clang/inc

[clang] 05c7dc6 - [DataFlow] Factor two worklist implementations out

2020-01-17 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2020-01-17T08:11:15-08:00
New Revision: 05c7dc66480999574a599ac34d99a4c192d51ba7

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

LOG: [DataFlow] Factor two worklist implementations out

Right now every dataflow algorithm uses its own worklist implementation.
This is a first step to reduce this duplication. Some upcoming
algorithms such as the lifetime analysis is going to use the factored
out implementations.

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

Added: 
clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h

Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
clang/lib/Analysis/LiveVariables.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/unittests/Analysis/CFGBuildResult.h
clang/unittests/Analysis/CFGTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
index 709753339eb5..68d935c6a400 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
@@ -168,4 +168,4 @@ class DataflowValues {
 };
 
 } // end namespace clang
-#endif
+#endif // LLVM_CLANG_ANALYSES_DATAFLOW_VALUES

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
new file mode 100644
index ..90095735ad3d
--- /dev/null
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
@@ -0,0 +1,94 @@
+//===- DataflowWorklist.h ---*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+//
+// A simple and reusable worklist for flow-sensitive analyses.
+//
+//===--===//
+#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWWORKLIST_H
+#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWWORKLIST_H
+
+#include "clang/Analysis/Analyses/PostOrderCFGView.h"
+#include "clang/Analysis/CFG.h"
+#include "llvm/ADT/PriorityQueue.h"
+
+namespace clang {
+/// A worklist implementation where the enqueued blocks will be dequeued based
+/// on the order defined by 'Comp'.
+template  class DataflowWorklistBase {
+  llvm::BitVector EnqueuedBlocks;
+  PostOrderCFGView *POV;
+  llvm::PriorityQueue, Comp>
+  WorkList;
+
+public:
+  DataflowWorklistBase(const CFG &Cfg, PostOrderCFGView *POV, Comp C)
+  : EnqueuedBlocks(Cfg.getNumBlockIDs()), POV(POV), WorkList(C) {}
+
+  const PostOrderCFGView *getCFGView() const { return POV; }
+
+  void enqueueBlock(const CFGBlock *Block) {
+if (Block && !EnqueuedBlocks[Block->getBlockID()]) {
+  EnqueuedBlocks[Block->getBlockID()] = true;
+  WorkList.push(Block);
+}
+  }
+
+  const CFGBlock *dequeue() {
+if (WorkList.empty())
+  return nullptr;
+const CFGBlock *B = WorkList.top();
+WorkList.pop();
+EnqueuedBlocks[B->getBlockID()] = false;
+return B;
+  }
+};
+
+struct ReversePostOrderCompare {
+  PostOrderCFGView::BlockOrderCompare Cmp;
+  bool operator()(const CFGBlock *lhs, const CFGBlock *rhs) const {
+return Cmp(rhs, lhs);
+  }
+};
+
+/// A worklist implementation for forward dataflow analysis. The enqueued
+/// blocks will be dequeued in reverse post order. The worklist cannot contain
+/// the same block multiple times at once.
+struct ForwardDataflowWorklist
+: DataflowWorklistBase {
+  ForwardDataflowWorklist(const CFG &Cfg, AnalysisDeclContext &Ctx)
+  : DataflowWorklistBase(
+Cfg, Ctx.getAnalysis(),
+ReversePostOrderCompare{
+Ctx.getAnalysis()->getComparator()}) {}
+
+  void enqueueSuccessors(const CFGBlock *Block) {
+for (auto B : Block->succs())
+  enqueueBlock(B);
+  }
+};
+
+/// A worklist implementation for backward dataflow analysis. The enqueued
+/// block will be dequeued in post order. The worklist cannot contain the same
+/// block multiple times at once.
+struct BackwardDataflowWorklist
+: DataflowWorklistBase {
+  BackwardDataflowWorklist(const CFG &Cfg, AnalysisDeclContext &Ctx)
+  : DataflowWorklistBase(
+Cfg, Ctx.getAnalysis(),
+Ctx.getAnalysis()->getComparator()) {}
+
+  void enqueuePredecessors(const CFGBlock *Block) {
+for (auto B : Block->preds())
+  enqueueBlock(B);
+  }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H

diff  --git a/clang/lib/Analysis/LiveVariables.cpp 

[clang] 0406b4f - Renamed traverseDecl to TraverseDecl in a test

2020-01-17 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-01-17T17:12:23+01:00
New Revision: 0406b4fab94658381ea58db890b07c1a30ff0ae4

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

LOG: Renamed traverseDecl to TraverseDecl in a test

RecursiveASTVisitor expects TraverseDecl to be implemented by
subclasses.

Added: 


Modified: 
clang/unittests/Tooling/QualTypeNamesTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp 
b/clang/unittests/Tooling/QualTypeNamesTest.cpp
index ff6b78c2666d..c820b6162285 100644
--- a/clang/unittests/Tooling/QualTypeNamesTest.cpp
+++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp
@@ -17,7 +17,7 @@ struct TypeNameVisitor : TestVisitor {
 
   // ValueDecls are the least-derived decl with both a qualtype and a
   // name.
-  bool traverseDecl(Decl *D) {
+  bool TraverseDecl(Decl *D) {
 return true;  // Always continue
   }
 



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


[PATCH] D72635: Allow arbitrary capability name in Thread Safety Analysis

2020-01-17 Thread Etienne Pierre-Doray via Phabricator via cfe-commits
eti-p-doray added a comment.

Thank you for checking! I updated the changes to lift the restriction. PTAnL?


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

https://reviews.llvm.org/D72635



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


[PATCH] D72274: [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added a comment.

In D72274#1826477 , @gribozavr2 wrote:

> The only functional change that I see in this patch is in 
> `clang/lib/Tooling/Transformer/Stencil.cpp`. However, I don't understand how 
> that change in the (deprecated) selection() stencil can affect other stencils.


Good point. Actually, `selection` and `text` are still used internally. See, 
for example, lines 301-303 in Stencil.cpp.  We deprecated their use for clients.




Comment at: clang/unittests/Tooling/StencilTest.cpp:375
+  double foo(double d);
+  foo(MACRO);)cpp";
+

gribozavr2 wrote:
> "foo(MACRO);" will fail parsing at the top level, it should be within a 
> function, I think.
`matchStmt` *(below) handles wrapping the snippet in a function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72274



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


[PATCH] D72736: [AIX] Add improved interface for retrieving load module paths

2020-01-17 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Provided that you have squashed all changes into the latest commit in your 
branch, `git diff HEAD^ -U1` should emit the context you need. Adjust the 
number of lines of context accordingly to fit the size of your files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72736



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


[PATCH] D72380: [DataFlow] Factor two worklist implementations out

2020-01-17 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05c7dc664809: [DataFlow] Factor two worklist implementations 
out (authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D72380?vs=238592&id=238785#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72380

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowValues.h
  clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
  clang/lib/Analysis/LiveVariables.cpp
  clang/lib/Analysis/UninitializedValues.cpp
  clang/unittests/Analysis/CFGBuildResult.h
  clang/unittests/Analysis/CFGTest.cpp

Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -7,10 +7,14 @@
 //===--===//
 
 #include "CFGBuildResult.h"
+#include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 
@@ -73,14 +77,14 @@
 EXPECT_EQ(IsLinear, B.getCFG()->isLinear());
   };
 
-  expectLinear(true,  "void foo() {}");
-  expectLinear(true,  "void foo() { if (true) return; }");
-  expectLinear(true,  "void foo() { if constexpr (false); }");
+  expectLinear(true, "void foo() {}");
+  expectLinear(true, "void foo() { if (true) return; }");
+  expectLinear(true, "void foo() { if constexpr (false); }");
   expectLinear(false, "void foo(bool coin) { if (coin) return; }");
   expectLinear(false, "void foo() { for(;;); }");
   expectLinear(false, "void foo() { do {} while (true); }");
-  expectLinear(true,  "void foo() { do {} while (false); }");
-  expectLinear(true,  "void foo() { foo(); }"); // Recursion is not our problem.
+  expectLinear(true, "void foo() { do {} while (false); }");
+  expectLinear(true, "void foo() { foo(); }"); // Recursion is not our problem.
 }
 
 TEST(CFG, ElementRefIterator) {
@@ -216,6 +220,54 @@
   EXPECT_EQ(++(CMainBlock->rref_begin()), CMainBlock->rref_begin() + 1);
 }
 
+TEST(CFG, Worklists) {
+  const char *Code = "int f(bool cond) {\n"
+ "  int a = 5;\n"
+ "  if (cond)\n"
+ "a += 1;\n"
+ "  return a;\n"
+ "}\n";
+  BuildResult B = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, B.getStatus());
+  const FunctionDecl *Func = B.getFunc();
+  AnalysisDeclContext AC(nullptr, Func);
+  auto *CFG = AC.getCFG();
+
+  std::vector ReferenceOrder;
+  for (const auto *B : *AC.getAnalysis())
+ReferenceOrder.push_back(B);
+
+  {
+ForwardDataflowWorklist ForwardWorklist(*CFG, AC);
+for (const auto *B : *CFG)
+  ForwardWorklist.enqueueBlock(B);
+
+std::vector ForwardNodes;
+while (const CFGBlock *B = ForwardWorklist.dequeue())
+  ForwardNodes.push_back(B);
+
+EXPECT_EQ(ForwardNodes.size(), ReferenceOrder.size());
+EXPECT_TRUE(std::equal(ReferenceOrder.begin(), ReferenceOrder.end(),
+   ForwardNodes.begin()));
+  }
+
+  std::reverse(ReferenceOrder.begin(), ReferenceOrder.end());
+
+  {
+BackwardDataflowWorklist BackwardWorklist(*CFG, AC);
+for (const auto *B : *CFG)
+  BackwardWorklist.enqueueBlock(B);
+
+std::vector BackwardNodes;
+while (const CFGBlock *B = BackwardWorklist.dequeue())
+  BackwardNodes.push_back(B);
+
+EXPECT_EQ(BackwardNodes.size(), ReferenceOrder.size());
+EXPECT_TRUE(std::equal(ReferenceOrder.begin(), ReferenceOrder.end(),
+   BackwardNodes.begin()));
+  }
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: clang/unittests/Analysis/CFGBuildResult.h
===
--- clang/unittests/Analysis/CFGBuildResult.h
+++ clang/unittests/Analysis/CFGBuildResult.h
@@ -23,18 +23,21 @@
 BuiltCFG,
   };
 
-  BuildResult(Status S, std::unique_ptr Cfg = nullptr,
+  BuildResult(Status S, const FunctionDecl *Func = nullptr,
+  std::unique_ptr Cfg = nullptr,
   std::unique_ptr AST = nullptr)
-  : S(S), Cfg(std::move(Cfg)), AST(std::move(AST)) {}
+  : S(S), Cfg(std::move(Cfg)), AST(std::move(AST)), Func(Func) {}
 
   Status getStatus() const { return S; }
   CFG *getCFG() const { return Cfg.get(); }
   ASTUnit *getAST() const { return AST.get(); }
+  const FunctionDecl *getFunc() const { return Func; }
 
 private:
   Status S;
   std::unique_ptr Cfg;
   std::unique_ptr AST;
+  const FunctionDecl *Func;
 };
 
 class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
@@ -54,7 +57,8 @@
 Options.AddImplicitDtors = true;
 if 

[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-17 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 3 inline comments as done.
mibintc added a comment.

@sepavloff Thanks a lot for your comments. I added a few replies and I have one 
question, added inline.




Comment at: clang/lib/Parse/ParsePragma.cpp:2522
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  PragmaFloatControlDecl::FloatControlKind Kind =
+llvm::StringSwitch(

sepavloff wrote:
> Does such treatment allow a pragma like:
> 
> #pragma #pragma float_control(except, on), push
> 
> The comment to `PragmaFloatControlHandler::HandlePragma` says it is valid.
Yes, #pragma float_control(except, on, push) is allowed. That's inherited from 
the Microsoft pragma of the same name. I need to change the .rst documentation 
about this. #pragma float_control(push) or #pragma float_control(pop) is also 
supported. Here's a link to the Microsoft doc, 
https://docs.microsoft.com/en-us/cpp/preprocessor/float-control?view=vs-2019 



Comment at: clang/lib/Sema/SemaAttr.cpp:430
+break;
+  case PragmaFloatControlDecl::FC_Push:
+  case PragmaFloatControlDecl::FC_Pop:

sepavloff wrote:
> `push` cannot be combined with `precise`?
Yes it can be combined: #pragma float_control(precise, push); the "push" is 
coded into the Action, the action can be either "set" or "push". I'm using 
pre-existing code in clang which provides support for microsoft-style pragma 
push/pop/set.  For example, clang supports the Microsoft pragma code_seg which 
supports a stack of code segment names. 



Comment at: clang/lib/Sema/SemaExpr.cpp:13129
 if (FunctionDecl *F = dyn_cast(CurContext)) {
+  // If the expression occurs inside an internal global_var_init_function
+  // then the FunctionDecl is not availble

sepavloff wrote:
> The standard says that static initializers execute in default FP mode.
> The standard says ...
Are you sure about this one?  Can you please provide the standards reference so 
I can study it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D72274: [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

In D72274#1826614 , @ymandel wrote:

> In D72274#1826477 , @gribozavr2 
> wrote:
>
> > The only functional change that I see in this patch is in 
> > `clang/lib/Tooling/Transformer/Stencil.cpp`. However, I don't understand 
> > how that change in the (deprecated) selection() stencil can affect other 
> > stencils.
>
>
> Good point. Actually, `selection` and `text` are still used internally. See, 
> for example, lines 301-303 in Stencil.cpp.  We deprecated their use for 
> clients.


Oh, that explains everything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72274



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


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/Ref.h:36
+  // one below.
+  Implicit = 1 << 3,
+  All = Declaration | Definition | Reference | Implicit,

kadircet wrote:
> kadircet wrote:
> > instead of doing that, could we rather de-couple two enums completely and 
> > have a `symbolRoleToRefKind`(and vice-versa) method instead(we already have 
> > some customization in `toRefKind` now) ?
> > 
> > as current change increases the risk of overlapping in future(e.g. someone 
> > might change symbolrole::declaration and cause failures/regressions in 
> > clangd)
> note that this would also require a bump to version of `on-disk` index in 
> clangd/index/Serialization.cpp, as old information regarding `RefKind` won't 
> be usable anymore.
> instead of doing that, could we rather de-couple two enums completely and 
> have a symbolRoleToRefKind(and vice-versa) method instead(we already have 
> some customization in toRefKind now) ?
> as current change increases the risk of overlapping in future(e.g. someone 
> might change symbolrole::declaration and cause failures/regressions in clangd)

Makes sense, will do!

> note that this would also require a bump to version of on-disk index in 
> clangd/index/Serialization.cpp, as old information regarding RefKind won't be 
> usable anymore.

I checked the Serialization code and the serialization code should be OK as 
long as `RefKind` stays one byte. Can you please elaborate on this?

Do you mean that the index should be generated again after this change because 
it would no longer be valid? (this one I understand)
Or do you mean there should be some other change in the code for me to do to 
land this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 238786.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Address alsmost all comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746

Files:
  clang-tools-extra/clangd/index/Ref.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -33,7 +33,7 @@
 // Convert a Range to a Ref.
 Ref refWithRange(const clangd::Range &Range, const std::string &URI) {
   Ref Result;
-  Result.Kind = RefKind::Reference;
+  Result.Kind = RefKind::Reference | RefKind::Spelled;
   Result.Location.Start.setLine(Range.start.line);
   Result.Location.Start.setColumn(Range.start.character);
   Result.Location.End.setLine(Range.end.line);
@@ -837,7 +837,7 @@
   {
   // variables.
   R"cpp(
-  static const int [[VA^R]] = 123;
+static const int [[VA^R]] = 123;
   )cpp",
   R"cpp(
 #include "foo.h"
@@ -868,6 +868,22 @@
 }
   )cpp",
   },
+  {
+  // Implicit references in macro expansions.
+  R"cpp(
+class [[Fo^o]] {};
+#define FooFoo Foo
+#define FOO Foo
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void bar() {
+  [[Foo]] x;
+  FOO y;
+  FooFoo z;
+}
+  )cpp",
+  },
   };
 
   for (const auto& T : Cases) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -296,6 +296,8 @@
   bool HasMore = Index.refs(RQuest, [&](const Ref &R) {
 if (AffectedFiles.size() > MaxLimitFiles)
   return;
+if (!static_cast(R.Kind & RefKind::Spelled))
+  return;
 if (auto RefFilePath = filePath(R.Location, /*HintFilePath=*/MainFile)) {
   if (*RefFilePath != MainFile)
 AffectedFiles[*RefFilePath].push_back(toRange(R.Location));
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -28,6 +28,7 @@
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/USRGeneration.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -180,7 +181,16 @@
 }
 
 RefKind toRefKind(index::SymbolRoleSet Roles) {
-  return static_cast(static_cast(RefKind::All) & Roles);
+  RefKind Result = RefKind::Unknown;
+  if (Roles & static_cast(index::SymbolRole::Declaration))
+Result |= RefKind::Declaration;
+  if (Roles & static_cast(index::SymbolRole::Definition))
+Result |= RefKind::Definition;
+  if (Roles & static_cast(index::SymbolRole::Reference))
+Result |= RefKind::Reference;
+  if (!(Roles & static_cast(index::SymbolRole::Implicit)))
+Result |= RefKind::Spelled;
+  return Result;
 }
 
 bool shouldIndexRelation(const index::SymbolRelation &R) {
@@ -291,7 +301,7 @@
   // occurrence inside the base-specifier.
   processRelations(*ND, *ID, Relations);
 
-  bool CollectRef = static_cast(Opts.RefFilter) & Roles;
+  bool CollectRef = static_cast(Opts.RefFilter & toRefKind(Roles));
   bool IsOnlyRef =
   !(Roles & (static_cast(index::SymbolRole::Declaration) |
  static_cast(index::SymbolRole::Definition)));
@@ -578,10 +588,22 @@
   }
   // Populate Refs slab from DeclRefs.
   if (auto MainFileURI = GetURI(SM.getMainFileID())) {
-for (const auto &It : DeclRefs) {
-  if (auto ID = getSymbolID(It.first)) {
-for (const auto &LocAndRole : It.second)
+for (auto &DeclAndRef : DeclRefs) {
+  if (auto ID = getSymbolID(DeclAndRef.first)) {
+for (auto &LocAndRole : DeclAndRef.second) {
+  // Check if the referenced symbol is spelled exactly the same way the
+  // corresponding NamedDecl is. If it isn't, mark this reference as
+  // implicit.  An example of implicit references would be a macro
+  // expansion.
+  llvm::SmallString<16> Buffer;
+  const auto Spelling = Lexer::getSpelling(LocAndRole.first, Buffer, SM,
+   ASTCtx->getLangOpts());
+  DeclarationName Name = DeclAndRef.first->getDeclName();
+  if (Name.isIdentifier() && Name.getAsString() != Spelling)
+LocAndRole.second |=
+static_cast(index::SymbolRole::Implici

[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Need to make use of the `TokenBuffer`, ran into some difficulties when lexing 
some files and triggering assertions in the process. Will figure it out and 
update the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D72274: [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

Thanks for the review!

In D72274#1826634 , @gribozavr2 wrote:

> In D72274#1826614 , @ymandel wrote:
>
> > In D72274#1826477 , @gribozavr2 
> > wrote:
> >
> > > The only functional change that I see in this patch is in 
> > > `clang/lib/Tooling/Transformer/Stencil.cpp`. However, I don't understand 
> > > how that change in the (deprecated) selection() stencil can affect other 
> > > stencils.
> >
> >
> > Good point. Actually, `selection` and `text` are still used internally. 
> > See, for example, lines 301-303 in Stencil.cpp.  We deprecated their use 
> > for clients.
>
>
> Oh, that explains everything.


I have to clean up that implementation file...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72274



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


[PATCH] D69840: [Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-01-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping^4


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

https://reviews.llvm.org/D69840



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


[PATCH] D72153: [libTooling] Add function to determine associated text of a declaration.

2020-01-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:128
+  // First, lex to the current token (which is the last token of the range that
+  // we know to be deleted. Then, we process the first token separately from 
the
+  // rest based on conditions that hold specifically for that first token.

Parenthetical is not closed.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:169
+  if (contains(Terminators, Tok))
+Terminated = true;
+  End = Tok.getEndLoc();

What if the token is not a terminator? It seems like the loop will keep looking 
for a terminator, but I don't understand why -- based on the doc comment, it 
seems like the intent is that this function will only extend the range with 
extra terminators.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:196
+case tok::semi:
+case tok::comma:
+  if (contains(Terminators, Tok)) {

I don't understand this case. We can only reach this loop if we already found 
one terminator. If semicolon is a terminator, fine, we can consume an extra 
one. However, if comma is a terminator, if we enter this "case tok::comma", it 
means we found two commas in a row, which is probably a syntax error.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:294
+Range.setBegin(T->getBeginLoc());
+  }
+

Please add tests for templates. (In particular, out-of-line definitions of 
member templates, which have two template argument lists.)



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:312
+//   other entities the comment could refer to), and
+// * it is not a IfThisThenThat lint check.
+if (SM.isBeforeInTranslationUnit(Comment->getBeginLoc(),

Need tests for cases described by this comment.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:352
+// If we didn't see '[[' or '__attribute' it's probably coming from a
+// macro expansion which is already handled by getExpansionRange(),
+// below.

s/getExpansionRange/makeFileCharRange/? Although I don't think it does that, 
because its comment says "... the function will fail because the range overlaps 
with only a part of the macro".





Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:150
+  struct VarDeclsVisitor : TestVisitor {
+llvm::Annotations Code;
+

If you feel motivated, it could be beneficial to lift this member into 
TestVisitor itself (and change RunOver to accept llvm::Annotations).



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:164
+
+  // Includes newline.
+  Visitor.Code = llvm::Annotations("$r[[int x = 4;]]");

s/newline/semicolon/



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:211
+}
+bool runOverWithComments(StringRef Code) {
+  std::vector Args = {"-std=c++11", "-fparse-all-comments"};

It assumes that it is invoked with the code that corresponds to this->Code. 
Therefore the argument is redundant, I think.



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:231
+  // Includes comments even in the presence of trailing whitespace.
+  Visitor.Code = llvm::Annotations("$r[[// Comment.\nint x = 4;]]  ");
+  Visitor.runOverWithComments(Visitor.Code.code());

But there's no whitespace.



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:258
+  // Does not include comments when either decl or comment are inside macros
+  // (unless both are in the same macro).
+  // FIXME: Change code to allow this.

"Does not include comments when only the decl or the comment come from a macro."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72153



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:882
 "10: targets = {ns}\n"},
+   // CXX Constructor, destructor and operators.
+   {R"cpp(

hokein wrote:
> could we simplify the newly-added test? I think a test only for explicit 
> destructor calls is sufficient, I think.
> 
> ```
> void foo () {
>   class Foo { ~Foo(); };
>  Foo f;
>  f.~Foo();
> }
> ```
Simplified the test a bit. I don't think it hurts to have more coverage though 
(if this is not duplication).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 238791.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@
 }
   )cpp",
 
+  // Destructor explicit call.
+  R"cpp(
+class [[F^oo]] {
+public:
+  ~[[^Foo]]();
+};
+
+[[Foo^]]::~[[^Foo]]() {}
+
+int main() {
+  [[Fo^o]] f;
+  f.~/*something*/[[^Foo]]();
+  f.~[[^Foo]]();
+}
+  )cpp",
+
+  // Derived destructor explicit call.
+  R"cpp(
+class [[Bas^e]] {};
+class Derived : public [[Bas^e]] {}
+
+int main() {
+  [[Bas^e]] *foo = new Derived();
+  foo->[[^Base]]::~[[^Base]]();
+}
+  )cpp",
+
   // CXXConstructor initializer list.
   R"cpp(
 class Baz {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,50 @@
 "8: targets = {INT2}, decl\n"
 "9: targets = {NS}, decl\n"
 "10: targets = {ns}\n"},
+   // User-defined conversion operator.
+   {R"cpp(
+void foo() {
+   class $0^Foo {
+   public:
+ $1^operator int();
+   };
+
+   $2^Foo $3^f;
+   $4^f.$5^operator int();
+}
+)cpp",
+"0: targets = {Foo}, decl\n"
+"1: targets = {foo()::Foo::operator int}, decl\n"
+"2: targets = {Foo}\n"
+"3: targets = {f}, decl\n"
+"4: targets = {f}\n"
+"5: targets = {foo()::Foo::operator int}\n"},
+   // Destructor.
+   {R"cpp(
+ void foo() {
+   class $0^Foo {
+   public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+   this->~$3^Foo();
+ }
+   };
+
+   $4^Foo $5^f;
+   $6^f.~ /*...*/ $7^Foo();
+ }
+   )cpp",
+"0: targets = {Foo}, decl\n"
+// FIXME: Should this target destructor instead of the type itself
+// (similar to constructor)?
+"1: targets = {Foo}\n"
+"2: targets = {foo()::Foo::destructMe}, decl\n"
+"3: targets = {Foo}\n"
+"4: targets = {Foo}\n"
+"5: targets = {f}, decl\n"
+"6: targets = {f}\n"
+"7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
  class Base {};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -596,6 +596,10 @@
 }
 
 void VisitMemberExpr(const MemberExpr *E) {
+  // Skip destructor calls to avoid duplication: TypeLoc within will be
+  // visited separately.
+  if (llvm::dyn_cast(E->getFoundDecl().getDecl()))
+return;
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
   E->getMemberNameInfo().getLoc(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61855 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-17 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added reviewers: rsmith, rjmccall.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This patch resumes the work of D16586 .
According to the AAPCS, volatile bit-fields should
be accessed using containers of the widht of their
declarative type. In such case:

  struct S1 {
short a : 1;
  }

should be accessed using load and stores of the width
(sizeof(short)), where now the compiler does only load
the minimum required width (char in this case).
However, as discussed in D16586 ,
that could overwrite non-volatile bit-fields, which
conflicted with C and C++ object models by creating
data race conditions that are not part of the bit-field,
e.g.

  struct S2 {
short a;
int  b : 16;
  }

Accessing `S2.b` would also access `S2.a`.

The AAPCS Release 2019Q1.1
(https://static.docs.arm.com/ihi0042/g/aapcs32.pdf)
section 8.1 Data Types, page 35, "Volatile bit-fields -
preserving number and width of container accesses" has been
updated to avoid conflict with the C++ Memory Model.
Now it reads in the note:

  This ABI does not place any restrictions on the access widths
  of bit-fields where the container overlaps with a non-bit-field member.
   This is because the C/C++ memory model defines these as being separate
  memory locations, which can be accessed by two threads
   simultaneously. For this reason, compilers must be permitted to use a
  narrower memory access width (including splitting the access
   into multiple instructions) to avoid writing to a different memory location.

I've updated the patch D16586  to follow such 
behavior by verifying that we
only change volatile bit-field access when:

- it won't overlap with any other non-bit-field member
- we only access memory inside the bounds of the record

Regarding the number of memory accesses, that should be preserved, that will
be implemented by D67399 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72932

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aapcs-bitfield.c

Index: clang/test/CodeGen/aapcs-bitfield.c
===
--- clang/test/CodeGen/aapcs-bitfield.c
+++ clang/test/CodeGen/aapcs-bitfield.c
@@ -151,19 +151,19 @@
 
 // LE-LABEL: @st3_check_load(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// LE-NEXT:[[BF_SHL:%.*]] = shl i8 [[BF_LOAD]], 1
-// LE-NEXT:[[BF_ASHR:%.*]] = ashr exact i8 [[BF_SHL]], 1
-// LE-NEXT:[[CONV:%.*]] = sext i8 [[BF_ASHR]] to i32
+// LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// LE-NEXT:[[BF_SHL:%.*]] = shl i16 [[BF_LOAD]], 9
+// LE-NEXT:[[BF_ASHR:%.*]] = ashr exact i16 [[BF_SHL]], 9
+// LE-NEXT:[[CONV:%.*]] = sext i16 [[BF_ASHR]] to i32
 // LE-NEXT:ret i32 [[CONV]]
 //
 // BE-LABEL: @st3_check_load(
 // BE-NEXT:  entry:
-// BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// BE-NEXT:[[BF_ASHR:%.*]] = ashr i8 [[BF_LOAD]], 1
-// BE-NEXT:[[CONV:%.*]] = sext i8 [[BF_ASHR]] to i32
+// BE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// BE-NEXT:[[BF_ASHR:%.*]] = ashr i16 [[BF_LOAD]], 9
+// BE-NEXT:[[CONV:%.*]] = sext i16 [[BF_ASHR]] to i32
 // BE-NEXT:ret i32 [[CONV]]
 //
 int st3_check_load(struct st3 *m) {
@@ -172,20 +172,20 @@
 
 // LE-LABEL: @st3_check_store(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// LE-NEXT:[[BF_CLEAR:%.*]] = and i8 [[BF_LOAD]], -128
-// LE-NEXT:[[BF_SET:%.*]] = or i8 [[BF_CLEAR]], 1
-// LE-NEXT:store volatile i8 [[BF_SET]], i8* [[TMP0]], align 2
+// LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// LE-NEXT:[[BF_CLEAR:%.*]] = and i16 [[BF_LOAD]], -128
+// LE-NEXT:[[BF_SET:%.*]] = or i16 [[BF_CLEAR]], 1
+// LE-NEXT:store volatile i16 [[BF_SET]], i16* [[TMP0]], align 2
 // LE-NEXT:ret void
 //
 // BE-LABEL: @st3_check_store(
 // BE-NEXT:  entry:
-// BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// BE-NEXT:[[BF_CLEAR:%.*]] = an

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-17 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[clang] b9d2bf3 - [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-01-17T12:11:25-05:00
New Revision: b9d2bf38e86e6dd8a2f188d9a24f546aa67de8af

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

LOG: [libTooling] Fix bug in Stencil handling of macro ranges

Summary: Currently, an attempt to rewrite source code inside a macro expansion 
succeeds, but results in empty text, rather than failing with an error.  This 
patch restructures to the code to explicitly validate ranges before attempting 
to edit them.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/SourceCode.h
clang/lib/Tooling/Transformer/SourceCode.cpp
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Tooling/SourceCodeTest.cpp
clang/unittests/Tooling/StencilTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/SourceCode.h 
b/clang/include/clang/Tooling/Transformer/SourceCode.h
index bc9cc3d2a258..1b92a117f44c 100644
--- a/clang/include/clang/Tooling/Transformer/SourceCode.h
+++ b/clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -73,13 +73,18 @@ StringRef getExtendedText(const T &Node, tok::TokenKind 
Next,
   return getText(getExtendedRange(Node, Next, Context), Context);
 }
 
-// Attempts to resolve the given range to one that can be edited by a rewrite;
-// generally, one that starts and ends within a particular file. It supports
-// a limited set of cases involving source locations in macro expansions.
+/// Determines whether \p Range is one that can be edited by a rewrite;
+/// generally, one that starts and ends within a particular file.
+llvm::Error validateEditRange(const CharSourceRange &Range,
+  const SourceManager &SM);
+
+/// Attempts to resolve the given range to one that can be edited by a rewrite;
+/// generally, one that starts and ends within a particular file. It supports a
+/// limited set of cases involving source locations in macro expansions. If a
+/// value is returned, it satisfies \c validateEditRange.
 llvm::Optional
 getRangeForEdit(const CharSourceRange &EditRange, const SourceManager &SM,
 const LangOptions &LangOpts);
-
 inline llvm::Optional
 getRangeForEdit(const CharSourceRange &EditRange, const ASTContext &Context) {
   return getRangeForEdit(EditRange, Context.getSourceManager(),

diff  --git a/clang/lib/Tooling/Transformer/SourceCode.cpp 
b/clang/lib/Tooling/Transformer/SourceCode.cpp
index 836401d1e605..5c1f8b46fe42 100644
--- a/clang/lib/Tooling/Transformer/SourceCode.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -11,9 +11,13 @@
 
//===--===//
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/Support/Errc.h"
 
 using namespace clang;
 
+using llvm::errc;
+using llvm::StringError;
+
 StringRef clang::tooling::getText(CharSourceRange Range,
   const ASTContext &Context) {
   return Lexer::getSourceText(Range, Context.getSourceManager(),
@@ -30,6 +34,34 @@ CharSourceRange 
clang::tooling::maybeExtendRange(CharSourceRange Range,
   return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation());
 }
 
+llvm::Error clang::tooling::validateEditRange(const CharSourceRange &Range,
+  const SourceManager &SM) {
+  if (Range.isInvalid())
+return llvm::make_error(errc::invalid_argument,
+ "Invalid range");
+
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return llvm::make_error(
+errc::invalid_argument, "Range starts or ends in a macro expansion");
+
+  if (SM.isInSystemHeader(Range.getBegin()) ||
+  SM.isInSystemHeader(Range.getEnd()))
+return llvm::make_error(errc::invalid_argument,
+ "Range is in system header");
+
+  std::pair BeginInfo = 
SM.getDecomposedLoc(Range.getBegin());
+  std::pair EndInfo = SM.getDecomposedLoc(Range.getEnd());
+  if (BeginInfo.first != EndInfo.first)
+return llvm::make_error(
+errc::invalid_argument, "Range begins and ends in 
diff erent files");
+
+  if (BeginInfo.second > EndInfo.second)
+return llvm::make_error(
+errc::invalid_argument, "Range's begin is past its end");
+
+  return llvm::Error::success();
+}
+
 llvm::Optional
 clang::tooling::getRangeForEdit(const CharSourceRange &EditRange,
 const SourceManager &SM,
@@ -46,20 +78,9 @@ clang::tooling::getRangeForEdit(const CharSourceRange 
&EditRange,
   //foo(DO_NOTHING(6))
   // Decide whether the current behavior is de

[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:13129
 if (FunctionDecl *F = dyn_cast(CurContext)) {
+  // If the expression occurs inside an internal global_var_init_function
+  // then the FunctionDecl is not availble

mibintc wrote:
> sepavloff wrote:
> > The standard says that static initializers execute in default FP mode.
> > The standard says ...
> Are you sure about this one?  Can you please provide the standards reference 
> so I can study it?
>> The standard says ...
> Are you sure about this one? Can you please provide the standards reference 
> so I can study it?

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, F.8.5:
```
... All computation for initialization of objects that have static or thread 
storage duration is done (as if) at translation time.
```
F.8.2:
```
During translation the IEC 60559 default modes are in effect:
— The rounding direction mode is rounding to nearest.
— The rounding precision mode (if supported) is set so that results are not 
shortened.
— Trapping or stopping (if supported) is disabled on all floating-point 
exceptions.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D72274: [libTooling] Fix bug in Stencil handling of macro ranges

2020-01-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9d2bf38e86e: [libTooling] Fix bug in Stencil handling of 
macro ranges (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72274

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -368,6 +368,21 @@
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfInvalidRangeFails) {
+  StringRef Snippet = R"cpp(
+#define MACRO (3.77)
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), Failed());
+}
+
 TEST(StencilToStringTest, RawTextOp) {
   auto S = cat("foo bar baz");
   StringRef Expected = R"("foo bar baz")";
Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -10,16 +10,20 @@
 #include "TestVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include 
 #include 
 
 using namespace clang;
 
+using llvm::Failed;
+using llvm::Succeeded;
 using llvm::ValueIs;
 using tooling::getExtendedText;
 using tooling::getRangeForEdit;
 using tooling::getText;
+using tooling::validateEditRange;
 
 namespace {
 
@@ -200,4 +204,116 @@
   Visitor.runOver(Code.code());
 }
 
+TEST(SourceCodeTest, EditRangeWithMacroExpansionsIsValid) {
+  // The call expression, whose range we are extracting, includes two macro
+  // expansions.
+  llvm::StringRef Code = R"cpp(
+#define M(a) a * 13
+int foo(int x, int y);
+int a = foo(M(1), M(2));
+)cpp";
+
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
+EXPECT_THAT_ERROR(validateEditRange(Range, Context->getSourceManager()),
+  Succeeded());
+  };
+  Visitor.runOver(Code);
+}
+
+TEST(SourceCodeTest, SpellingRangeOfMacroArgIsValid) {
+  llvm::StringRef Code = R"cpp(
+#define FOO(a) a + 7.0;
+int a = FOO(10);
+)cpp";
+
+  IntLitVisitor Visitor;
+  Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
+SourceLocation ArgLoc =
+Context->getSourceManager().getSpellingLoc(Expr->getBeginLoc());
+// The integer literal is a single token.
+auto ArgRange = CharSourceRange::getTokenRange(ArgLoc);
+EXPECT_THAT_ERROR(validateEditRange(ArgRange, Context->getSourceManager()),
+  Succeeded());
+  };
+  Visitor.runOver(Code);
+}
+
+TEST(SourceCodeTest, InvalidEditRangeIsInvalid) {
+  llvm::StringRef Code = "int c = 10;";
+
+  // We use the visitor just to get a valid context.
+  IntLitVisitor Visitor;
+  Visitor.OnIntLit = [](IntegerLiteral *, ASTContext *Context) {
+CharSourceRange Invalid;
+EXPECT_THAT_ERROR(validateEditRange(Invalid, Context->getSourceManager()),
+  Failed());
+  };
+  Visitor.runOver(Code);
+}
+
+TEST(SourceCodeTest, InvertedEditRangeIsInvalid) {
+  llvm::StringRef Code = R"cpp(
+int foo(int x);
+int a = foo(2);
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+auto InvertedRange = CharSourceRange::getTokenRange(
+SourceRange(Expr->getEndLoc(), Expr->getBeginLoc()));
+EXPECT_THAT_ERROR(
+validateEditRange(InvertedRange, Context->getSourceManager()),
+Failed());
+  };
+  Visitor.runOver(Code);
+}
+
+TEST(SourceCodeTest, MacroArgIsInvalid) {
+  llvm::StringRef Code = R"cpp(
+#define FOO(a) a + 7.0;
+int a = FOO(10);
+)cpp";
+
+  IntLitVisitor Visitor;
+  Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
+auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
+EXPECT_THAT_ERROR(validateEditRange(Range, Context->getSourceManager()),
+  Failed());
+  };
+  Visitor.runOver(Code);
+}
+
+TEST(SourceCodeTest, EditWholeMacroExpansionIsInvalid) {
+  llvm::StringRef Code = R"cpp(
+#define FOO 10
+int a = FOO;
+)cpp";
+
+  IntLitVisitor Visitor;
+  Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
+auto Range = C

  1   2   >