Re: r357340 - Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.

2019-04-11 Thread Anton Afanasyev via cfe-commits
Hi Nico,
yes, you are right, current implementation is mostly focused on frontend.
Yes, I can impove BE time output after getting feedback like yours one. Do
you need detailed info about BE passes times? Btw, did you try
-ftime-report option? It could give you detailed info on BE passes
bottlenecks, though its implementation is a little bit messy for now (as
Aras noted here:
http://aras-p.info/blog/2019/01/12/Investigating-compile-times-and-Clang-ftime-report/
).
  Thanks,
   Anton

пт, 12 апр. 2019 г. в 00:22, Nico Weber :

> I tried using this to see why X86ISelLowering.cpp takes so long to build
> on my system. The output json produced by this flag is at
> http://s000.tinyupload.com/?file_id=00019982161870973700
>
> It looks like this produces lots of useful information for frontend time,
> but in this case most time is spent in the backend, where this doesn't
> produce very useful output. Are there any plans to improve output for
> backend time?
>
> On Sat, Mar 30, 2019 at 9:38 AM Anton Afanasyev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: anton-afanasyev
>> Date: Sat Mar 30 01:42:48 2019
>> New Revision: 357340
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=357340&view=rev
>> Log:
>> Adds `-ftime-trace` option to clang that produces Chrome
>> `chrome://tracing` compatible JSON profiling output dumps.
>>
>> This change adds hierarchical "time trace" profiling blocks that can be
>> visualized in Chrome, in a "flame chart" style. Each profiling block can
>> have a "detail" string that for example indicates the file being processed,
>> template name being instantiated, function being optimized etc.
>>
>> This is taken from GitHub PR:
>> https://github.com/aras-p/llvm-project-20170507/pull/2
>>
>> Patch by Aras Pranckevičius.
>>
>> Differential Revision: https://reviews.llvm.org/D58675
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/CodeGenOptions.def
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/include/clang/Frontend/FrontendOptions.h
>> cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Frontend/CompilerInstance.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/lib/Parse/ParseAST.cpp
>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> cfe/trunk/lib/Parse/ParseTemplate.cpp
>> cfe/trunk/lib/Sema/Sema.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
>> cfe/trunk/tools/driver/cc1_main.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=357340&r1=357339&r2=357340&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original)
>> +++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Sat Mar 30 01:42:48
>> 2019
>> @@ -224,6 +224,7 @@ CODEGENOPT(FineGrainedBitfieldAccesses,
>>  CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum
>> definition.
>>  CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict
>> vtable pointers
>>  CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report is
>> enabled.
>> +CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is
>> enabled.
>>  CODEGENOPT(UnrollLoops   , 1, 0) ///< Control whether loops are
>> unrolled.
>>  CODEGENOPT(RerollLoops   , 1, 0) ///< Control whether loops are
>> rerolled.
>>  CODEGENOPT(NoUseJumpTables   , 1, 0) ///< Set when -fno-jump-tables is
>> enabled.
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=357340&r1=357339&r2=357340&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Sat Mar 30 01:42:48 2019
>> @@ -1745,6 +1745,7 @@ def Wframe_larger_than_EQ : Joined<["-"]
>>  def : Flag<["-"], "fterminated-vtables">, Alias;
>>  def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">,
>> Group;
>>  def ftime_report : Flag<["-"], "ftime-report">, Group,
>> Flags<[CC1Option]>;
>> +def ftime_trace : Flag<["-"], "ftime-trace">, Group,
>> Flags<[CC1Option]>;
>>  def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group,
>> Flags<[CC1Option]>;
>>  def ftrapv : Flag<["-"], "ftrapv">, Group, Flags<[CC1Option]>,
>>HelpText<"Trap on integer overflow">;
>>
>> Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=357340&r1=357339&r2=357340&view=diff
>>
>> 

[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D60573#1463641 , @riccibruno wrote:

> In D60573#1463569 , @rjmccall wrote:
>
> > Hmm.  Does this never impact code that's just using a locally-defined type 
> > within its scope?  I guess if ADL is involved, unqualified lookup must have 
> > reached the scope of the innermost namespace, and so it would be searching 
> > that namespace anyway.
> >
> > In that case, I think I'm mollified that the source-compatibility risk is 
> > low and we should just unconditionally apply the new rule.  LGTM.
>
>
> I am not sure about what you mean. It is certainly possible to construct a 
> piece of C++11 code which breaks with this patch.


Yes, but these examples are contrived, so it's easy to rationalize that the 
source impact is low.  The typical use-pattern of a local type is that you only 
use it locally, so the most important question would be whether it is possible 
to change the semantics of, say,

  void test() {
struct A { ... };
foo(A{});
  }

But I think the answer is "no", for the reasons I explained.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573



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


[PATCH] D59756: [clangd] Support dependent bases in type hierarchy

2019-04-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/unittests/clangd/TypeHierarchyTests.cpp:405
+  *Result,
+  AllOf(WithName("S"), WithKind(SymbolKind::Struct),
+Parents(AllOf(WithName("S"), WithKind(SymbolKind::Struct),

sammccall wrote:
> nridge wrote:
> > sammccall wrote:
> > > Sorry, I realize this isn't related to this patch, but I didn't see the 
> > > final form of the previous one.
> > > 
> > > This should be `WithName("S<0>"), ... Parents(AllOf(WithName("S<1>")), 
> > > ...)`. S is the name of the template, not the name of the type.
> > > 
> > > Can you add a fixme?
> > (I looked into what it would take to fix this, and it seems like we need 
> > D59639, so I'm going to wait for that.)
> AFAICS D59639 is something subtly different - it prints the args of 
> *specializations* as written in the source code, not instantiations. i.e. if 
> you try to use this for `vector`, it won't work as there's no 
> specialization, you'll get `vector` instead.
I had another look, and you're right; I didn't appreciate that distinction.

I filed [an issue](https://github.com/clangd/clangd/issues/31) to track 
implementing your suggestion. I plan to work on it.

In the meantime, could we get this patch committed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59756



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


[PATCH] D58749: [index-while-building] IndexRecordHasher

2019-04-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

We did performance tests of alternative approach - just hashing the serialized 
bit code representation. There's a performance regression in the sense that 
while the current implementation costs approx. extra 2.2% in build time the 
alternative approach costs 3.8%.

We are not happy about the regression but the best way to fix the current 
implementation seems to be using the alternative approach as a temporary 
solution. The plan is to move on with upstreaming the rest of the 
index-while-building so we can optimize the hasher after i-w-b lands - possibly 
using the ODR violation hasher.

This means the whole implementation will become just:

  hash_code RecordHash = hash_combine_range(State.Buffer.begin(), 
State.Buffer.end());

where

  SmallString<512> Buffer;

Due to necessary change in interface of `IndexRecordWriter` I'll abandon this 
patch and land the new hasher later.


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

https://reviews.llvm.org/D58749



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


[PATCH] D60541: [clang-format] Use SpacesBeforeTrailingComments for "option" directive

2019-04-11 Thread Donald Chai via Phabricator via cfe-commits
dchai removed a subscriber: cfe-commits.
dchai added a comment.

Can someone please merge this for me?  I don't have commit access.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60541



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


r358245 - Enable frame pointer elimination for OpenBSD on x86 and mips64.

2019-04-11 Thread Brad Smith via cfe-commits
Author: brad
Date: Thu Apr 11 18:29:18 2019
New Revision: 358245

URL: http://llvm.org/viewvc/llvm-project?rev=358245&view=rev
Log:
Enable frame pointer elimination for OpenBSD on x86 and mips64.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/frame-pointer-elim.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=358245&r1=358244&r2=358245&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Apr 11 18:29:18 2019
@@ -534,6 +534,18 @@ static bool useFramePointerForTargetByDe
 return !areOptimizationsEnabled(Args);
   }
 
+  if (Triple.isOSOpenBSD()) {
+switch (Triple.getArch()) {
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  return !areOptimizationsEnabled(Args);
+default:
+  return true;
+}
+  }
+
   if (Triple.isOSLinux() || Triple.getOS() == llvm::Triple::CloudABI ||
   Triple.isOSHurd()) {
 switch (Triple.getArch()) {

Modified: cfe/trunk/test/Driver/frame-pointer-elim.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer-elim.c?rev=358245&r1=358244&r2=358245&view=diff
==
--- cfe/trunk/test/Driver/frame-pointer-elim.c (original)
+++ cfe/trunk/test/Driver/frame-pointer-elim.c Thu Apr 11 18:29:18 2019
@@ -26,6 +26,15 @@
 // RUN:   FileCheck --check-prefix=NETBSD %s
 // NETBSD-NOT: "-momit-leaf-frame-pointer"
 
+// OpenBSD follows the same rules as Linux.
+// RUN: %clang -### -target x86_64-unknown-openbsd -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OPENBSD-OPT %s
+// OPENBSD-OPT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -target x86_64-unknown-openbsd -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OPENBSD %s
+// OPENBSD-NOT: "-momit-leaf-frame-pointer"
+
 // Darwin disables omitting the leaf frame pointer even under optimization
 // unless the command lines are given.
 // RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \


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


[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D60573#1463611 , @rsmith wrote:

> > I have applied the fix to all language versions, even though I think that 
> > the DR only applies to C++14
>
> DRs don't have a specific version that they are intended to apply to; that's 
> up to us to determine, and generally we apply them retroactively as far back 
> as they make sense -- they are supposed to be bug fixes, after all. (From 
> ISO's perspective, C++11 was retracted and replaced by C++14 when the latter 
> was published, so it's simply not meaningful for a DR to officially target 
> anything older than that, and the only version that DRs can meaningfully list 
> is whatever version was most recently published when they were approved.)
>
> This looks good to me. Thanks!


Good to know, thanks for the explanation and review !


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573



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


[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D60573#1463569 , @rjmccall wrote:

> Hmm.  Does this never impact code that's just using a locally-defined type 
> within its scope?  I guess if ADL is involved, unqualified lookup must have 
> reached the scope of the innermost namespace, and so it would be searching 
> that namespace anyway.
>
> In that case, I think I'm mollified that the source-compatibility risk is low 
> and we should just unconditionally apply the new rule.  LGTM.


I am not sure about what you mean. It is certainly possible to construct a 
piece of C++11 code which breaks with this patch. A possible example is:

  constexpr int f(void *) { return 1; }
  
  static auto lambda = []() { struct S {} s; return s; };
  using S = decltype(lambda());
  
  template  void test() {
  constexpr T *p = nullptr;
  static_assert(f(p) == 1, "");
  }
  
  constexpr int f(S *) { return 2; }
  
  template void test();

Clang currently accept this because ADL does not currently find the second 
better matching `f`. After this patch it will be found and the `static_assert` 
will fail (which is the behavior of gcc, and as far as I can tell the specified 
behavior).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I got an lgtm from @pcc on IRC, so I'll commit this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358243: Variable auto-init: also auto-init alloca (authored 
by jfb, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60548?vs=194762&id=194787#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60548

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/PatternInit.cpp
  lib/CodeGen/PatternInit.h
  test/CodeGenCXX/trivial-auto-var-init.cpp

Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -19,6 +19,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CharUnits.h"
@@ -984,92 +985,13 @@
   return false;
 }
 
-static llvm::Constant *patternFor(CodeGenModule &CGM, llvm::Type *Ty) {
-  // The following value is a guaranteed unmappable pointer value and has a
-  // repeated byte-pattern which makes it easier to synthesize. We use it for
-  // pointers as well as integers so that aggregates are likely to be
-  // initialized with this repeated value.
-  constexpr uint64_t LargeValue = 0xull;
-  // For 32-bit platforms it's a bit trickier because, across systems, only the
-  // zero page can reasonably be expected to be unmapped, and even then we need
-  // a very low address. We use a smaller value, and that value sadly doesn't
-  // have a repeated byte-pattern. We don't use it for integers.
-  constexpr uint32_t SmallValue = 0x00AA;
-  // Floating-point values are initialized as NaNs because they propagate. Using
-  // a repeated byte pattern means that it will be easier to initialize
-  // all-floating-point aggregates and arrays with memset. Further, aggregates
-  // which mix integral and a few floats might also initialize with memset
-  // followed by a handful of stores for the floats. Using fairly unique NaNs
-  // also means they'll be easier to distinguish in a crash.
-  constexpr bool NegativeNaN = true;
-  constexpr uint64_t NaNPayload = 0xull;
-  if (Ty->isIntOrIntVectorTy()) {
-unsigned BitWidth = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
-->getBitWidth();
-if (BitWidth <= 64)
-  return llvm::ConstantInt::get(Ty, LargeValue);
-return llvm::ConstantInt::get(
-Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, LargeValue)));
-  }
-  if (Ty->isPtrOrPtrVectorTy()) {
-auto *PtrTy = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
-unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
-PtrTy->getAddressSpace());
-llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
-uint64_t IntValue;
-switch (PtrWidth) {
-default:
-  llvm_unreachable("pattern initialization of unsupported pointer width");
-case 64:
-  IntValue = LargeValue;
-  break;
-case 32:
-  IntValue = SmallValue;
-  break;
-}
-auto *Int = llvm::ConstantInt::get(IntTy, IntValue);
-return llvm::ConstantExpr::getIntToPtr(Int, PtrTy);
-  }
-  if (Ty->isFPOrFPVectorTy()) {
-unsigned BitWidth = llvm::APFloat::semanticsSizeInBits(
-(Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
-->getFltSemantics());
-llvm::APInt Payload(64, NaNPayload);
-if (BitWidth >= 64)
-  Payload = llvm::APInt::getSplat(BitWidth, Payload);
-return llvm::ConstantFP::getQNaN(Ty, NegativeNaN, &Payload);
-  }
-  if (Ty->isArrayTy()) {
-// Note: this doesn't touch tail padding (at the end of an object, before
-// the next array object). It is instead handled by replaceUndef.
-auto *ArrTy = cast(Ty);
-llvm::SmallVector Element(
-ArrTy->getNumElements(), patternFor(CGM, ArrTy->getElementType()));
-return llvm::ConstantArray::get(ArrTy, Element);
-  }
-
-  // Note: this doesn't touch struct padding. It will initialize as much union
-  // padding as is required for the largest type in the union. Padding is
-  // instead handled by replaceUndef. Stores to structs with volatile members
-  // don't have a volatile qualifier when initialized according to C++. This is
-  // fine because stack-based volatiles don't really have volatile semantics
-  // anyways, and the initialization shouldn't be observable.
-  auto *StructTy = cast(Ty);
-  llvm::SmallVector Struct(StructTy->getNumElements());
-  for (unsigned El = 0; El != Struct.size(); ++El)
-Struct[El] = patternFor(CGM, StructTy->getElementType(El));
-  return llvm::ConstantStruct::get(StructTy, Struct);
-}
-
 enum class IsPattern { No, Yes };
 
 /// Generate a constant filled with either a pattern or zeroes.
 static llvm::Constan

r358243 - Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via cfe-commits
Author: jfb
Date: Thu Apr 11 17:11:27 2019
New Revision: 358243

URL: http://llvm.org/viewvc/llvm-project?rev=358243&view=rev
Log:
Variable auto-init: also auto-init alloca

Summary:
alloca isn’t auto-init’d right now because it’s a different path in clang that
all the other stuff we support (it’s a builtin, not an expression).
Interestingly, alloca doesn’t have a type (as opposed to even VLA) so we can
really only initialize it with memset.



Subscribers: jkorous, dexonsmith, cfe-commits, rjmccall, glider, kees, kcc, pcc

Tags: #clang

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

Added:
cfe/trunk/lib/CodeGen/PatternInit.cpp
cfe/trunk/lib/CodeGen/PatternInit.h
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=358243&r1=358242&r2=358243&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Apr 11 17:11:27 2019
@@ -17,6 +17,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
@@ -44,6 +45,25 @@ int64_t clamp(int64_t Value, int64_t Low
   return std::min(High, std::max(Low, Value));
 }
 
+static void initializeAlloca(CodeGenFunction &CGF, AllocaInst *AI, Value 
*Size, unsigned AlignmentInBytes) {
+  ConstantInt *Byte;
+  switch (CGF.getLangOpts().getTrivialAutoVarInit()) {
+  case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+// Nothing to initialize.
+return;
+  case LangOptions::TrivialAutoVarInitKind::Zero:
+Byte = CGF.Builder.getInt8(0x00);
+break;
+  case LangOptions::TrivialAutoVarInitKind::Pattern: {
+llvm::Type *Int8 = llvm::IntegerType::getInt8Ty(CGF.CGM.getLLVMContext());
+Byte = llvm::dyn_cast(
+initializationPatternFor(CGF.CGM, Int8));
+break;
+  }
+  }
+  CGF.Builder.CreateMemSet(AI, Byte, Size, AlignmentInBytes);
+}
+
 /// getBuiltinLibFunction - Given a builtin id for a function like
 /// "__builtin_fabsf", return a Function* for "fabsf".
 llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
@@ -2259,6 +2279,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 .getQuantity();
 AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size);
 AI->setAlignment(SuitableAlignmentInBytes);
+initializeAlloca(*this, AI, Size, SuitableAlignmentInBytes);
 return RValue::get(AI);
   }
 
@@ -2271,6 +2292,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 CGM.getContext().toCharUnitsFromBits(AlignmentInBits).getQuantity();
 AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size);
 AI->setAlignment(AlignmentInBytes);
+initializeAlloca(*this, AI, Size, AlignmentInBytes);
 return RValue::get(AI);
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=358243&r1=358242&r2=358243&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Apr 11 17:11:27 2019
@@ -19,6 +19,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CharUnits.h"
@@ -984,92 +985,13 @@ static bool shouldSplitConstantStore(Cod
   return false;
 }
 
-static llvm::Constant *patternFor(CodeGenModule &CGM, llvm::Type *Ty) {
-  // The following value is a guaranteed unmappable pointer value and has a
-  // repeated byte-pattern which makes it easier to synthesize. We use it for
-  // pointers as well as integers so that aggregates are likely to be
-  // initialized with this repeated value.
-  constexpr uint64_t LargeValue = 0xull;
-  // For 32-bit platforms it's a bit trickier because, across systems, only the
-  // zero page can reasonably be expected to be unmapped, and even then we need
-  // a very low address. We use a smaller value, and that value sadly doesn't
-  // have a repeated byte-pattern. We don't use it for integers.
-  constexpr uint32_t SmallValue = 0x00AA;
-  // Floating-point values are initialized as NaNs because they propagate. 
Using
-  // a repeated byte pattern means that it will be easier to initialize
-  // all-floating-point aggregates and arrays with memset. Further, aggregates
-  // which mix integral and a few floats might also initialize with memset
-  // followed by a handful of stores for the floats. Using fairly unique NaNs
-  // also means they'll be easier to distinguish in a crash.

[libunwind] r358242 - Creating release candidate final from release_710 branch

2019-04-11 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Apr 11 16:41:27 2019
New Revision: 358242

URL: http://llvm.org/viewvc/llvm-project?rev=358242&view=rev
Log:
Creating release candidate final from release_710 branch

Added:
libunwind/tags/RELEASE_710/final/
  - copied from r358241, libunwind/branches/release_70/

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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 194782.
hintonda added a comment.

- Update isa_and_nonnull diagnostic message, and fix typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802

Files:
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.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-isa-or-dyn-cast-in-conditionals.rst
  
clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp

Index: clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s llvm-prefer-isa-or-dyn-cast-in-conditionals %t
+
+struct X;
+struct Y;
+struct Z {
+  int foo();
+  X *bar();
+  X *cast(Y*);
+  bool baz(Y*);
+};
+
+template 
+bool isa(Y *);
+template 
+X *cast(Y *);
+template 
+X *dyn_cast(Y *);
+template 
+X *dyn_cast_or_null(Y *);
+
+bool foo(Y *y, Z *z) {
+  if (auto x = cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: cast<> in conditional will assert rather than return a null pointer [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (auto x = dyn_cast(y))
+
+  while (auto x = cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: cast<> in conditional
+  // CHECK-FIXES: while (auto x = dyn_cast(y))
+
+  if (cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: cast<> in conditional
+  // CHECK-FIXES: if (isa(y))
+
+  while (cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: cast<> in conditional
+  // CHECK-FIXES: while (isa(y))
+
+  do {
+break;
+  } while (cast(y));
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: cast<> in conditional
+  // CHECK-FIXES: while (isa(y));
+
+  if (dyn_cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: return value from dyn_cast<> not used [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa(y))
+
+  while (dyn_cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: return value from dyn_cast<> not used
+  // CHECK-FIXES: while (isa(y))
+
+  do {
+break;
+  } while (dyn_cast(y));
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: return value from dyn_cast<> not used
+  // CHECK-FIXES: while (isa(y));
+
+  if (y && isa(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa_and_nonnull(y))
+
+  if (z->bar() && isa(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && cast(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && dyn_cast(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && dyn_cast_or_null(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  bool b = z->bar() && cast(z->bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: bool b = isa_and_nonnull(z->bar());
+
+  // These don't trigger a warning.
+  if (auto x = cast(y)->foo())
+return true;
+  if (auto x = z->cast(y))
+return true;
+  while (auto x = cast(y)->foo())
+break;
+  if (cast(y)->foo())
+return true;
+  if (z->cast(y))
+return true;
+  while (cast(y)->foo())
+break;
+  if (y && cast(z->bar()))
+return true;
+  if (z && cast(y)->foo())
+return true;
+  bool b2 = y && cast(z);
+  if(z->cast(y))
+return true;
+  if (z->baz(cast(z)))
+return true;
+
+#define CAST(T, Obj) cast(Obj)
+#define AUTO_VAR_CAST(X, Y, Z) auto X = cast(Z)
+#define ISA(T, Obj) isa(Obj)
+#define ISA_OR_NULL(T, Obj) Obj &&isa(Obj)
+
+  // Macros don't trigger warning.
+  if (auto x = CAST(X, y))
+return true;
+  if (AUTO_VAR_CAST(x, X, z))
+return true;
+  if (z->bar() && ISA(Y, z->bar()))
+return true;
+  if (ISA_OR_NULL(Y, z->bar()))
+return true;
+
+  return false;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-isa-or-dyn-cast-in-conditionals.rst
=

[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

> I have applied the fix to all language versions, even though I think that the 
> DR only applies to C++14

DRs don't have a specific version that they are intended to apply to; that's up 
to us to determine, and generally we apply them retroactively as far back as 
they make sense -- they are supposed to be bug fixes, after all. (From ISO's 
perspective, C++11 was retracted and replaced by C++14 when the latter was 
published, so it's simply not meaningful for a DR to officially target anything 
older than that, and the only version that DRs can meaningfully list is 
whatever version was most recently published when they were approved.)

This looks good to me. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h:37-39
+///  if (var && isa(var)) {}
+///  // is replaced by:
+///  if (dyn_cast_or_null(var.foo())) {}

aaron.ballman wrote:
> I think this comment is now out of date.
Thanks, I'll fix that.  

I'll give the RFC a few more days, but not sure it's been definitive.  A few no 
votes, but there are always some of those.  I sorta like `isa_nonnull` for 
brevity, so I'll mention that why I follow-up on that thread.  Btw, the 
`isa_and_nonnull` has been in for a week: r357761, and nothing on that 
thread leads me to believe I should revert it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 194781.
gtbercea added a comment.

- Handle OpenMP simd case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
@@ -2094,6 +2102,10 @@
   /// \param GD Global to scan.
   bool emitTargetGlobal(GlobalDecl GD) override;
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun() override;
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRu

[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In D60151#1463484 , @MyDeveloperDay 
wrote:

> >> I suppose we could keep the names and directory structure and just change 
> >> the namespace.  That would just be a special case in the scripts.  Haven't 
> >> looked into it yet, but will do so as soon as I can.
> > 
> > Isn't that matching done on strings? I.e. is there difference between 
> > `-llvm-*` and `-ll*` ?
>
> it would be if they only do it to -llm-* (which could possibly catch most 
> cases)
>
> but what if someone is doing
>
> -llvm-header-guard
>
> We wouldn't catch those..
>
> This is a snippet of a .clang-tidy file from a  project I work on, we turn 
> off specific checks by fully qualifying the checker
>
>   
>   llvm-*,
>   -llvm-header-guard,
>   -llvm-include-order,
>   misc-*,
>   modernize-*,
>   ...
>


You make a great point.  I'll look into just changing the namespace name.  I 
wasn't really comfortable with all the code churn it involved anyway, but once 
I got started, I figured I'd finish it.  The duplicate `llvm` namespace is the 
issue, not other names.  Thanks for the feedback...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb marked an inline comment as done.
jfb added inline comments.



Comment at: lib/CodeGen/PatternInit.h:22
+
+llvm::Constant *patternFor(CodeGenModule&, llvm::Type*);
+

rjmccall wrote:
> jfb wrote:
> > rjmccall wrote:
> > > Please choose names that mean something outside of the mental context you 
> > > were in when you wrote the patch. :)
> > I was just copy / pasting!
> Your own code. :)
Hey you can't pull that one on me! Pulling it on you is *my* hobby!
And like... it's communal code now! ;-)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Hmm.  Does this never impact code that's just using a locally-defined type 
within its scope?  I guess if ADL is involved, unqualified lookup must have 
reached the scope of the innermost namespace, and so it would be searching that 
namespace anyway.

In that case, I think I'm mollified that the source-compatibility risk is low 
and we should just unconditionally apply the new rule.  LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/CodeGen/PatternInit.h:22
+
+llvm::Constant *patternFor(CodeGenModule&, llvm::Type*);
+

jfb wrote:
> rjmccall wrote:
> > Please choose names that mean something outside of the mental context you 
> > were in when you wrote the patch. :)
> I was just copy / pasting!
Your own code. :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


Re: r358104 - Don't emit an unreachable return block.

2019-04-11 Thread Marco Castelluccio via cfe-commits
Thanks, your fix looks good to me.

- Marco.


Il 11/04/19 05:05, John McCall ha scritto:
>
>
> On 10 Apr 2019, at 21:50, wolfgang.p...@sony.com wrote:
>
>> Hi,
>> This commit seems to be causing a test failure on several buildbots
>> (e.g.
>> http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/26305).
>> instrprof-shared-gcov-flush.test is failing because of differences in
>> profile info. The test passes when I revert your change, so perhaps
>> it's just a case of updating the test.
>> Could you please take a look?
>
> Adjusted the test in r358149 as a hopeful fix.  CC'ing Marco since I
> believe this was originally his test.
>
> John.
>
>>
>> Thanks,
>> Wolfgang Pieb
>>
>> -Original Message-
>> From: cfe-commits  On Behalf Of
>> John McCall via cfe-commits
>> Sent: Wednesday, April 10, 2019 10:03 AM
>> To: cfe-commits@lists.llvm.org
>> Subject: r358104 - Don't emit an unreachable return block.
>>
>> Author: rjmccall
>> Date: Wed Apr 10 10:03:09 2019
>> New Revision: 358104
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=358104&view=rev
>> Log:
>> Don't emit an unreachable return block.
>>
>> Patch by Brad Moody.
>>
>> Added:
>>     cfe/trunk/test/CodeGen/unreachable-ret.c
>> Modified:
>>     cfe/trunk/lib/CodeGen/CGCall.cpp
>>     cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>     cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=358104&r1=358103&r2=358104&view=diff
>> ==
>>
>> --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Apr 10 10:03:09 2019
>> @@ -2873,15 +2873,6 @@ void CodeGenFunction::EmitFunctionEpilog
>>  RV = SI->getValueOperand();
>>  SI->eraseFromParent();
>>
>> -    // If that was the only use of the return value, nuke it as
>> well now.
>> -    auto returnValueInst = ReturnValue.getPointer();
>> -    if (returnValueInst->use_empty()) {
>> -  if (auto alloca =
>> dyn_cast(returnValueInst)) {
>> -    alloca->eraseFromParent();
>> -    ReturnValue = Address::invalid();
>> -  }
>> -    }
>> -
>>    // Otherwise, we have to do a simple load.
>>    } else {
>>  RV = Builder.CreateLoad(ReturnValue);
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=358104&r1=358103&r2=358104&view=diff
>> ==
>>
>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Apr 10 10:03:09 2019
>> @@ -255,6 +255,7 @@ llvm::DebugLoc CodeGenFunction::EmitRetu
>>  if (CurBB->empty() || ReturnBlock.getBlock()->use_empty()) {
>>    ReturnBlock.getBlock()->replaceAllUsesWith(CurBB);
>>    delete ReturnBlock.getBlock();
>> +  ReturnBlock = JumpDest();
>>  } else
>>    EmitBlock(ReturnBlock.getBlock());
>>  return llvm::DebugLoc();
>> @@ -274,6 +275,7 @@ llvm::DebugLoc CodeGenFunction::EmitRetu
>>    Builder.SetInsertPoint(BI->getParent());
>>    BI->eraseFromParent();
>>    delete ReturnBlock.getBlock();
>> +  ReturnBlock = JumpDest();
>>    return Loc;
>>  }
>>    }
>> @@ -448,6 +450,19 @@ void CodeGenFunction::FinishFunction(Sou
>>    // 5. Width of vector aguments and return types for functions
>> called by this
>>    //    function.
>>    CurFn->addFnAttr("min-legal-vector-width",
>> llvm::utostr(LargestVectorWidth));
>> +
>> +  // If we generated an unreachable return block, delete it now.
>> +  if (ReturnBlock.isValid() && ReturnBlock.getBlock()->use_empty()) {
>> +    Builder.ClearInsertionPoint();
>> +    ReturnBlock.getBlock()->eraseFromParent();
>> +  }
>> +  if (ReturnValue.isValid()) {
>> +    auto *RetAlloca =
>> dyn_cast(ReturnValue.getPointer());
>> +    if (RetAlloca && RetAlloca->use_empty()) {
>> +  RetAlloca->eraseFromParent();
>> +  ReturnValue = Address::invalid();
>> +    }
>> +  }
>>  }
>>
>>  /// ShouldInstrumentFunction - Return true if the current function
>> should be
>>
>> Added: cfe/trunk/test/CodeGen/unreachable-ret.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/unreachable-ret.c?rev=358104&view=auto
>> ==
>>
>> --- cfe/trunk/test/CodeGen/unreachable-ret.c (added)
>> +++ cfe/trunk/test/CodeGen/unreachable-ret.c Wed Apr 10 10:03:09 2019
>> @@ -0,0 +1,23 @@
>> +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
>> +
>> +extern void abort() __attribute__((noreturn));
>> +
>> +void f1() {
>> +  abort();
>> +}
>> +// CHECK-LABEL: define void @f1()
>> +// CHECK-NEXT: entry:
>> +// CHECK-NEXT:   call void @abort()
>> +// CHECK-NEXT:   unreachable
>> +// CHECK-NEXT:

[PATCH] D59459: [analyzer][NFC] Prefer binary searches in CheckerRegistry

2019-04-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp:70
+  Collection, Info,
+  FullNameLT{});
+}

baloghadamsoftware wrote:
> Please note that `llvm::lower_bound()` uses `std::lower_bound()` which 
> returns an iterator pointing to the first element that is not less than the 
> sought value, or last if no such element is found. So it is mandatory to 
> check the return value whether it is equal to sought value or greater. In 
> latter case you should return `Collection.end()` to keep up compatibility 
> with `find_if`.
Yup, nice catch!


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

https://reviews.llvm.org/D59459



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


[PATCH] D59459: [analyzer][NFC] Prefer binary searches in CheckerRegistry

2019-04-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 194768.
Szelethus added a comment.

Change asserts according to reviewer feedback.


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

https://reviews.llvm.org/D59459

Files:
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -48,6 +48,28 @@
 using CheckerNameLT = FullNameLT;
 } // end of anonymous namespace
 
+template 
+static
+typename std::conditional::value,
+  typename CheckerOrPackageInfoList::const_iterator,
+  typename CheckerOrPackageInfoList::iterator>::type
+binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
+
+  using CheckerOrPackage = typename CheckerOrPackageInfoList::value_type;
+  using CheckerOrPackageFullNameLT = FullNameLT;
+
+  assert(std::is_sorted(Collection.begin(), Collection.end(),
+CheckerOrPackageFullNameLT{}) &&
+ "In order to efficiently gather checkers/packages, this function "
+ "expects them to be already sorted!");
+
+  typename CheckerOrPackageInfoList::value_type Info(FullName);
+
+  return llvm::lower_bound(
+  Collection, Info,
+  FullNameLT{});
+}
+
 static constexpr char PackageSeparator = '.';
 
 static bool isInPackage(const CheckerRegistry::CheckerInfo &Checker,
@@ -69,16 +91,7 @@
 
 CheckerRegistry::CheckerInfoListRange
 CheckerRegistry::getMutableCheckersForCmdLineArg(StringRef CmdLineArg) {
-
-  assert(std::is_sorted(Checkers.begin(), Checkers.end(), CheckerNameLT{}) &&
- "In order to efficiently gather checkers, this function expects them "
- "to be already sorted!");
-
-  // Use a binary search to find the possible start of the package.
-  CheckerRegistry::CheckerInfo PackageInfo(nullptr, nullptr, CmdLineArg, "",
-   "");
-  auto It = std::lower_bound(Checkers.begin(), Checkers.end(), PackageInfo,
- CheckerNameLT{});
+  auto It = binaryFind(Checkers, CmdLineArg);
 
   if (!isInPackage(*It, CmdLineArg))
 return {Checkers.end(), Checkers.end()};
@@ -268,24 +281,17 @@
   }
 }
 
-void CheckerRegistry::addDependency(StringRef FullName, StringRef dependency) {
-  auto CheckerThatNeedsDeps = [&FullName](const CheckerInfo &Chk) {
-return Chk.FullName == FullName;
-  };
-  auto Dependency = [&dependency](const CheckerInfo &Chk) {
-return Chk.FullName == dependency;
-  };
-
-  auto CheckerIt = llvm::find_if(Checkers, CheckerThatNeedsDeps);
-  assert(CheckerIt != Checkers.end() &&
+void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
+  auto CheckerIt = binaryFind(Checkers, FullName);
+  assert(CheckerIt->FullName == FullName &&
  "Failed to find the checker while attempting to set up its "
  "dependencies!");
 
-  auto DependencyIt = llvm::find_if(Checkers, Dependency);
-  assert(DependencyIt != Checkers.end() &&
+  auto DependencyIt = binaryFind(Checkers, Dependency);
+  assert(DependencyIt->FullName == Dependency &&
  "Failed to find the dependency of a checker!");
 
-  CheckerIt->Dependencies.push_back(&*DependencyIt);
+  CheckerIt->Dependencies.emplace_back(&*DependencyIt);
 }
 
 void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const {
Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -108,8 +108,8 @@
   State_Enabled
 };
 
-InitializationFunction Initialize;
-ShouldRegisterFunction ShouldRegister;
+InitializationFunction Initialize = nullptr;
+ShouldRegisterFunction ShouldRegister = nullptr;
 StringRef FullName;
 StringRef Desc;
 StringRef DocumentationUri;
@@ -129,6 +129,9 @@
 StringRef Name, StringRef Desc, StringRef DocsUri)
 : Initialize(Fn), ShouldRegister(sfn), FullName(Name), Desc(Desc),
   DocumentationUri(DocsUri) {}
+
+// Used for lower_bound.
+explicit CheckerInfo(StringRef FullName) : FullName(FullName) {}
   };
 
   using StateFromCmdLine = CheckerInfo::StateFromCmdLine;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



>> I suppose we could keep the names and directory structure and just change 
>> the namespace.  That would just be a special case in the scripts.  Haven't 
>> looked into it yet, but will do so as soon as I can.
> 
> Isn't that matching done on strings? I.e. is there difference between 
> `-llvm-*` and `-ll*` ?

it would be if they only do it to -llm-* (which could possibly catch most cases)

but what if someone is doing

-llvm-header-guard

We wouldn't catch those..

This is a snippet of a .clang-tidy file from a  project I work on, we turn off 
specific checks by fully qualifying the checker

  
  llvm-*,
  -llvm-header-guard,
  -llvm-include-order,
  misc-*,
  modernize-*,
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 194765.
riccibruno added a comment.

Removed the call to `isTransparentContext()` in the loop in 
`CollectEnclosingNamespace`. It is not actually needed since we only care about 
finding the innermost enclosing namespace.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60573

Files:
  lib/Sema/SemaLookup.cpp
  
test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
  test/CXX/drs/dr16xx.cpp

Index: test/CXX/drs/dr16xx.cpp
===
--- test/CXX/drs/dr16xx.cpp
+++ test/CXX/drs/dr16xx.cpp
@@ -284,6 +284,54 @@
 #endif
 }
 
+namespace dr1690 { // dr1690: 9
+  // See also the various tests in "CXX/basic/basic.lookup/basic.lookup.argdep".
+#if __cplusplus >= 201103L
+  namespace N {
+static auto lambda = []() { struct S {} s; return s; };
+void f(decltype(lambda()));
+  }
+
+  void test() {
+auto s = N::lambda();
+f(s); // ok
+  }
+#endif
+}
+
+namespace dr1691 { // dr1691: 9
+#if __cplusplus >= 201103L
+  namespace N {
+namespace M {
+  enum E : int;
+  void f(E);
+}
+enum M::E : int {};
+void g(M::E); // expected-note {{declared here}}
+  }
+  void test() {
+N::M::E e;
+f(e); // ok
+g(e); // expected-error {{use of undeclared}}
+  }
+#endif
+}
+
+namespace dr1692 { // dr1692: 9
+  namespace N {
+struct A {
+  struct B {
+struct C {};
+  };
+};
+void f(A::B::C);
+  }
+  void test() {
+N::A::B::C c;
+f(c); // ok
+  }
+}
+
 namespace dr1696 { // dr1696: 7
   namespace std_examples {
 #if __cplusplus >= 201402L
Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
@@ -38,12 +38,11 @@
   return s;
 }
 using S = decltype(foo());
-void f(S); // expected-note {{'X2::f' declared here}}
+void f(S); // #1
   }
   void test2() {
-f(X2::S{}); // FIXME: This is well-formed; X2 is the innermost enclosing namespace
-// of the local struct S.
-// expected-error@-2 {{use of undeclared identifier 'f'}}
+f(X2::S{}); // This is well-formed; X2 is the innermost enclosing namespace
+// of the local struct S. Calls #1.
   }
 
   // associated class: the parent class
@@ -83,7 +82,7 @@
 
 void test5() {
   auto lambda = N::get_lambda();
-  f(lambda); // FIXME: This is well-formed. expected-error {{use of undeclared}}
+  f(lambda); // ok
 }
   }
 } // namespace adl_class_type
@@ -172,6 +171,12 @@
   enum F : int;
   friend void g(F);
 };
+auto foo() {
+  enum G {} g;
+  return g;
+}
+using G = decltype(foo());
+void h(G);
   }
 
   void test() {
@@ -179,6 +184,9 @@
 f(e); // ok
 N::S::F f;
 g(f); // ok
+N::G g;
+h(g); // ok
+
   }
 }
 
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -2458,30 +2458,38 @@
 static void
 addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T);
 
+// Given the declaration context \param Ctx of a class, class template or
+// enumeration, add the associated namespaces to \param Namespaces as described
+// in [basic.lookup.argdep]p2.
 static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces,
   DeclContext *Ctx) {
-  // Add the associated namespace for this class.
-
-  // We don't use DeclContext::getEnclosingNamespaceContext() as this may
-  // be a locally scoped record.
+  // The exact wording has been changed in C++14 as a result of
+  // CWG 1691 (see also CWG 1690 and CWG 1692). We apply it unconditionally
+  // to all language versions since it is possible to return a local type
+  // from a lambda in C++11.
+  //
+  // C++14 [basic.lookup.argdep]p2:
+  //   If T is a class type [...]. Its associated namespaces are the innermost
+  //   enclosing namespaces of its associated classes. [...]
+  //
+  //   If T is an enumeration type, its associated namespace is the innermost
+  //   enclosing namespace of its declaration. [...]
 
-  // We skip out of inline namespaces. The innermost non-inline namespace
+  // We additionally skip inline namespaces. The innermost non-inline namespace
   // contains all names of all its nested inline namespaces anyway, so we can
   // replace the entire inline namespace tree with its root.
-  while (Ctx->isRecord() || Ctx->isTransparentContext() ||
- Ctx->isInlineNamespace())
+  while (!Ctx->isFileContext() || Ctx->isInlineNamespace())
 Ctx = Ctx->getParent();
 
-  if (Ctx-

[PATCH] D60570: [Sema] Add more tests for the behavior of argument-dependent name lookup

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 194763.
riccibruno added a comment.
Herald added a subscriber: eraman.

Also test for inline namespaces.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60570

Files:
  
test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
  test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-inline-namespace.cpp
  test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
  test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp

Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -67,3 +67,96 @@
 foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
   }
 }
+
+
+// Check the rules described in p4:
+//  When considering an associated namespace, the lookup is the same as the lookup
+//  performed when the associated namespace is used as a qualifier (6.4.3.2) except that:
+
+//  - Any using-directives in the associated namespace are ignored.
+namespace test_using_directives {
+  namespace M { struct S; }
+  namespace N {
+void f(M::S); // expected-note {{declared here}}
+  }
+  namespace M {
+using namespace N;
+struct S {};
+  }
+  void test() {
+M::S s;
+f(s); // expected-error {{use of undeclared}}
+M::f(s); // ok
+  }
+}
+
+//  - Any namespace-scope friend functions or friend function templates declared in
+//associated classes are visible within their respective namespaces even if
+//they are not visible during an ordinary lookup
+// (Note: For the friend declaration to be visible, the corresponding class must be
+//  included in the set of associated classes. Merely including the namespace in
+//  the set of associated namespaces is not enough.)
+namespace test_friend1 {
+  namespace N {
+struct S;
+struct T {
+  friend void f(S); // #1
+};
+struct S { S(); S(T); };
+  }
+
+  void test() {
+N::S s;
+N::T t;
+f(s); // expected-error {{use of undeclared}}
+f(t); // ok, #1
+  }
+}
+
+// credit: Arthur O’Dwyer
+namespace test_friend2 {
+  struct A {
+struct B {
+struct C {};
+};
+friend void foo(...); // #1
+  };
+
+  struct D {
+friend void foo(...); // #2
+  };
+  template struct E {
+struct F {};
+  };
+
+  template struct G {};
+  template struct H {};
+  template struct I {};
+  struct J { friend void foo(...) {} }; // #3
+
+  void test() {
+A::B::C c;
+foo(c); // #1 is not visible since A is not an associated class
+// expected-error@-1 {{use of undeclared}}
+E::F f;
+foo(f); // #2 is not visible since D is not an associated class
+// expected-error@-1 {{use of undeclared}}
+G > > j;
+foo(j);  // ok, #3.
+  }
+}
+
+//  - All names except those of (possibly overloaded) functions and
+//function templates are ignored.
+namespace test_other_names {
+  namespace N {
+struct S {};
+struct Callable { void operator()(S); };
+static struct Callable Callable;
+  }
+
+  void test() {
+N::S s;
+Callable(s); // expected-error {{use of undeclared}}
+  }
+}
Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
@@ -18,3 +18,48 @@
 }
   };
 }
+
+// If X contains [...] then Y is empty.
+// - a declaration of a class member
+namespace test_adl_suppression_by_class_member {
+  namespace N {
+struct T {};
+void f(T); // expected-note {{declared here}}
+  }
+  struct S {
+void f();
+void test() {
+  N::T t;
+  f(t); // expected-error {{too many arguments}}
+}
+  };
+}
+
+// - a block-scope function declaration that is not a using-declaration
+namespace test_adl_suppression_by_block_scope {
+  namespace N {
+struct S {};
+void f(S);
+  }
+  namespace M { void f(int); } // expected-note {{candidate}}
+  void test() {
+N::S s;
+using M::f;
+f(s); // ok
+extern void f(char); // expected-note {{candidate}}
+f(s); // expected-error {{no matching function for call to 'f'}}
+  }
+}
+
+// - a declaration that is neither a function nor a function template
+namespace test_adl_suppression_by_non_function {
+  namespace N {
+struct S {};
+void f(S);
+  }
+  void test() {
+extern void (*f)();
+N::S s;
+f(s); // expected-error {{too many arguments}}
+  }
+}
Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-inline-namespace.cpp
===
--- /dev/null
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-inline-namespace.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+/

[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb marked 2 inline comments as done.
jfb added inline comments.



Comment at: lib/CodeGen/PatternInit.h:22
+
+llvm::Constant *patternFor(CodeGenModule&, llvm::Type*);
+

rjmccall wrote:
> Please choose names that mean something outside of the mental context you 
> were in when you wrote the patch. :)
I was just copy / pasting!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 194762.
jfb marked 2 inline comments as done.
jfb added a comment.

- Change name, qualify declaration.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/PatternInit.cpp
  lib/CodeGen/PatternInit.h
  test/CodeGenCXX/trivial-auto-var-init.cpp

Index: test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- test/CodeGenCXX/trivial-auto-var-init.cpp
+++ test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -173,6 +173,34 @@
   used(ptr);
 }
 
+// UNINIT-LABEL:  test_alloca(
+// ZERO-LABEL:test_alloca(
+// ZERO:  %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// ZERO-NEXT: %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align [[ALIGN:[0-9]+]]
+// ZERO-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %[[ALLOCA]], i8 0, i64 %[[SIZE]], i1 false)
+// PATTERN-LABEL: test_alloca(
+// PATTERN:   %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// PATTERN-NEXT:  %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align [[ALIGN:[0-9]+]]
+// PATTERN-NEXT:  call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %[[ALLOCA]], i8 -86, i64 %[[SIZE]], i1 false)
+void test_alloca(int size) {
+  void *ptr = __builtin_alloca(size);
+  used(ptr);
+}
+
+// UNINIT-LABEL:  test_alloca_with_align(
+// ZERO-LABEL:test_alloca_with_align(
+// ZERO:  %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// ZERO-NEXT: %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align 128
+// ZERO-NEXT: call void @llvm.memset{{.*}}(i8* align 128 %[[ALLOCA]], i8 0, i64 %[[SIZE]], i1 false)
+// PATTERN-LABEL: test_alloca_with_align(
+// PATTERN:   %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// PATTERN-NEXT:  %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align 128
+// PATTERN-NEXT:  call void @llvm.memset{{.*}}(i8* align 128 %[[ALLOCA]], i8 -86, i64 %[[SIZE]], i1 false)
+void test_alloca_with_align(int size) {
+  void *ptr = __builtin_alloca_with_align(size, 1024);
+  used(ptr);
+}
+
 // UNINIT-LABEL:  test_struct_vla(
 // ZERO-LABEL:test_struct_vla(
 // ZERO:  %[[SIZE:[0-9]+]] = mul nuw i64 %{{.*}}, 16
Index: lib/CodeGen/PatternInit.h
===
--- /dev/null
+++ lib/CodeGen/PatternInit.h
@@ -0,0 +1,27 @@
+//===- PatternInit - Pattern initialization -*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_PATTERNINIT_H
+#define LLVM_CLANG_LIB_CODEGEN_PATTERNINIT_H
+
+namespace llvm {
+class Constant;
+class Type;
+} // namespace llvm
+
+namespace clang {
+namespace CodeGen {
+
+class CodeGenModule;
+
+llvm::Constant *initializationPatternFor(CodeGenModule &, llvm::Type *);
+
+} // end namespace CodeGen
+} // end namespace clang
+
+#endif
Index: lib/CodeGen/PatternInit.cpp
===
--- /dev/null
+++ lib/CodeGen/PatternInit.cpp
@@ -0,0 +1,93 @@
+//===--- PatternInit.cpp - Pattern Initialization -===//
+//
+// 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 "PatternInit.h"
+#include "CodeGenModule.h"
+#include "llvm/IR/Constant.h"
+#include "llvm/IR/Type.h"
+
+llvm::Constant *clang::CodeGen::initializationPatternFor(CodeGenModule &CGM,
+ llvm::Type *Ty) {
+  // The following value is a guaranteed unmappable pointer value and has a
+  // repeated byte-pattern which makes it easier to synthesize. We use it for
+  // pointers as well as integers so that aggregates are likely to be
+  // initialized with this repeated value.
+  constexpr uint64_t LargeValue = 0xull;
+  // For 32-bit platforms it's a bit trickier because, across systems, only the
+  // zero page can reasonably be expected to be unmapped, and even then we need
+  // a very low address. We use a smaller value, and that value sadly doesn't
+  // have a repeated byte-pattern. We don't use it for integers.
+  constexpr uint32_t SmallValue = 0x00AA;
+  // Floating-point values are initialized as NaNs because they propagate. Using
+  // a repeated byte pattern means that it will be easier to initialize
+  // all-floating-point aggregates and arrays with memset. Further, aggregates
+  // which mix integral and a few floats might also init

RE: r357610 - Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-11 Thread Yu, Jennifer via cfe-commits
Thank you so much.  Jennifer

From: Nico Weber [mailto:tha...@chromium.org]
Sent: Thursday, April 11, 2019 2:25 PM
To: Yu, Jennifer 
Cc: cfe-commits 
Subject: Re: r357610 - Bug-40323: MS ABI adding template static member in the 
linker directive section to make sure init function can be called before main.

Done in 358232. Thanks!

On Thu, Apr 11, 2019 at 5:19 PM Yu, Jennifer 
mailto:jennifer...@intel.com>> wrote:
Hi Nico,

Iet’s revert it now.  I will try to re-submit latter.
Thanks.
Jennifer

From: Nico Weber [mailto:tha...@chromium.org]
Sent: Thursday, April 11, 2019 2:04 PM
To: Yu, Jennifer mailto:jennifer...@intel.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r357610 - Bug-40323: MS ABI adding template static member in the 
linker directive section to make sure init function can be called before main.

Hi Jennifer,

this caused https://bugs.llvm.org/show_bug.cgi?id=41471

Do you think this is easy to fix, or should we revert for now?

Thanks,
Nico

On Wed, Apr 3, 2019 at 1:20 PM Jennifer Yu via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: jyu2
Date: Wed Apr  3 10:21:40 2019
New Revision: 357610

URL: http://llvm.org/viewvc/llvm-project?rev=357610&view=rev
Log:
Bug-40323: MS ABI adding template static member in the linker directive section 
to make sure init function can be called before main.

Added:
cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=357610&r1=357609&r2=357610&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr  3 10:21:40 2019
@@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
+if (getTarget().getCXXABI().isMicrosoft()) {
+  // In The MS C++, MS add template static data member in the linker
+  // drective.
+  assert(COMDATKey);
+  addUsedGlobal(COMDATKey);
+}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the global, so the initializers get folded

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=357610&view=auto
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp Wed Apr  3 
10:21:40 2019
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions 
-emit-llvm -o - | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+template  struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template  S ExportedTemplate::s;
+void useExportedTemplate(ExportedTemplate x) {
+  (void)x.s;
+}
+int f();
+namespace selectany_init {
+// MS don't put selectany static var in the linker directive, init routine
+// f() is not getting called if x is not referenced.
+int __declspec(selectany) x = f();
+}
+
+namespace explicit_template_instantiation {
+template  struct A { static  int x; };
+template  int A::x = f();
+template struct A;
+}
+
+namespace implicit_template_instantiation {
+template  struct A { static  int x; };
+template   int A::x = f();
+int g() { return A::x; }
+}
+
+
+template 
+struct X_ {
+  static T ioo;
+  static T init();
+};
+template  T X_::ioo = X_::init();
+template struct X_;
+
+template 
+struct X {
+  static T ioo;
+  static T init();
+};
+// template specialized static data don't need in llvm.used,
+// the static init routine get call from _GLOBAL__sub_I_ routines.
+template <> int X::ioo = X::init();
+template struct X;
+// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", 
i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { 
i32 65535, void ()* 
@"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*) }, { i

Re: r357610 - Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-11 Thread Nico Weber via cfe-commits
Done in 358232. Thanks!

On Thu, Apr 11, 2019 at 5:19 PM Yu, Jennifer  wrote:

> Hi Nico,
>
>
>
> Iet’s revert it now.  I will try to re-submit latter.
>
> Thanks.
>
> Jennifer
>
>
>
> *From:* Nico Weber [mailto:tha...@chromium.org]
> *Sent:* Thursday, April 11, 2019 2:04 PM
> *To:* Yu, Jennifer 
> *Cc:* cfe-commits 
> *Subject:* Re: r357610 - Bug-40323: MS ABI adding template static member
> in the linker directive section to make sure init function can be called
> before main.
>
>
>
> Hi Jennifer,
>
>
>
> this caused https://bugs.llvm.org/show_bug.cgi?id=41471
>
>
> Do you think this is easy to fix, or should we revert for now?
>
>
>
> Thanks,
>
> Nico
>
>
>
> On Wed, Apr 3, 2019 at 1:20 PM Jennifer Yu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: jyu2
> Date: Wed Apr  3 10:21:40 2019
> New Revision: 357610
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357610&view=rev
> Log:
> Bug-40323: MS ABI adding template static member in the linker directive
> section to make sure init function can be called before main.
>
> Added:
> cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=357610&r1=357609&r2=357610&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr  3 10:21:40 2019
> @@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
>  // minor startup time optimization.  In the MS C++ ABI, there are no
> guard
>  // variables, so this COMDAT key is required for correctness.
>  AddGlobalCtor(Fn, 65535, COMDATKey);
> +if (getTarget().getCXXABI().isMicrosoft()) {
> +  // In The MS C++, MS add template static data member in the linker
> +  // drective.
> +  assert(COMDATKey);
> +  addUsedGlobal(COMDATKey);
> +}
>} else if (D->hasAttr()) {
>  // SelectAny globals will be comdat-folded. Put the initializer into a
>  // COMDAT group associated with the global, so the initializers get
> folded
>
> Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=357610&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> (added)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp Wed
> Apr  3 10:21:40 2019
> @@ -0,0 +1,57 @@
> +// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o
> - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm
> -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions
> -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions
> -emit-llvm -o - | FileCheck %s
> +
> +struct S {
> +  S();
> +  ~S();
> +};
> +
> +template  struct __declspec(dllexport) ExportedTemplate {
> +  static S s;
> +};
> +template  S ExportedTemplate::s;
> +void useExportedTemplate(ExportedTemplate x) {
> +  (void)x.s;
> +}
> +int f();
> +namespace selectany_init {
> +// MS don't put selectany static var in the linker directive, init routine
> +// f() is not getting called if x is not referenced.
> +int __declspec(selectany) x = f();
> +}
> +
> +namespace explicit_template_instantiation {
> +template  struct A { static  int x; };
> +template  int A::x = f();
> +template struct A;
> +}
> +
> +namespace implicit_template_instantiation {
> +template  struct A { static  int x; };
> +template   int A::x = f();
> +int g() { return A::x; }
> +}
> +
> +
> +template 
> +struct X_ {
> +  static T ioo;
> +  static T init();
> +};
> +template  T X_::ioo = X_::init();
> +template struct X_;
> +
> +template 
> +struct X {
> +  static T ioo;
> +  static T init();
> +};
> +// template specialized static data don't need in llvm.used,
> +// the static init routine get call from _GLOBAL__sub_I_ routines.
> +template <> int X::ioo = X::init();
> +template struct X;
> +// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8*
> }] [{ i32, void ()*, i8* } { i32 65535, void ()* 
> @"??__Ex@selectany_init@@YAXXZ",
> i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*,
> i8* } { i32 65535, void ()* @"??__E?x@?$A@H
> @explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* @"?x@
> ?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*,
> i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast
> (i32* @"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535,
> void ()* @"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8*
> getelementptr inbounds (%struct.S, %struct.

r358232 - Revert r357610, it caused PR41471

2019-04-11 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr 11 14:26:34 2019
New Revision: 358232

URL: http://llvm.org/viewvc/llvm-project?rev=358232&view=rev
Log:
Revert r357610, it caused PR41471

Removed:
cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=358232&r1=358231&r2=358232&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Apr 11 14:26:34 2019
@@ -481,12 +481,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
-if (getTarget().getCXXABI().isMicrosoft()) {
-  // In The MS C++, MS add template static data member in the linker
-  // drective.
-  assert(COMDATKey);
-  addUsedGlobal(COMDATKey);
-}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the global, so the initializers get folded

Removed: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=358231&view=auto
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (removed)
@@ -1,57 +0,0 @@
-// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
-// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions 
-emit-llvm -o - | FileCheck %s
-
-struct S {
-  S();
-  ~S();
-};
-
-template  struct __declspec(dllexport) ExportedTemplate {
-  static S s;
-};
-template  S ExportedTemplate::s;
-void useExportedTemplate(ExportedTemplate x) {
-  (void)x.s;
-}
-int f();
-namespace selectany_init {
-// MS don't put selectany static var in the linker directive, init routine
-// f() is not getting called if x is not referenced.
-int __declspec(selectany) x = f();
-}
-
-namespace explicit_template_instantiation {
-template  struct A { static  int x; };
-template  int A::x = f();
-template struct A;
-}
-
-namespace implicit_template_instantiation {
-template  struct A { static  int x; };
-template   int A::x = f();
-int g() { return A::x; }
-}
-
-
-template 
-struct X_ {
-  static T ioo;
-  static T init();
-};
-template  T X_::ioo = X_::init();
-template struct X_;
-
-template 
-struct X {
-  static T ioo;
-  static T init();
-};
-// template specialized static data don't need in llvm.used,
-// the static init routine get call from _GLOBAL__sub_I_ routines.
-template <> int X::ioo = X::init();
-template struct X;
-// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", 
i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { 
i32 65535, void ()* 
@"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8* getelementptr inbounds 
(%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) }, { 
i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }]
-// CHECK: @llvm.used = appending global [4 x i8*] [i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.S, %struct.S* 
@"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section 
"llvm.metadata"
-


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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 194760.
gtbercea added a comment.

- Split patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,30 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD   

Re: r357340 - Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.

2019-04-11 Thread Nico Weber via cfe-commits
I tried using this to see why X86ISelLowering.cpp takes so long to build on
my system. The output json produced by this flag is at
http://s000.tinyupload.com/?file_id=00019982161870973700

It looks like this produces lots of useful information for frontend time,
but in this case most time is spent in the backend, where this doesn't
produce very useful output. Are there any plans to improve output for
backend time?

On Sat, Mar 30, 2019 at 9:38 AM Anton Afanasyev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: anton-afanasyev
> Date: Sat Mar 30 01:42:48 2019
> New Revision: 357340
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357340&view=rev
> Log:
> Adds `-ftime-trace` option to clang that produces Chrome
> `chrome://tracing` compatible JSON profiling output dumps.
>
> This change adds hierarchical "time trace" profiling blocks that can be
> visualized in Chrome, in a "flame chart" style. Each profiling block can
> have a "detail" string that for example indicates the file being processed,
> template name being instantiated, function being optimized etc.
>
> This is taken from GitHub PR:
> https://github.com/aras-p/llvm-project-20170507/pull/2
>
> Patch by Aras Pranckevičius.
>
> Differential Revision: https://reviews.llvm.org/D58675
>
> Modified:
> cfe/trunk/include/clang/Basic/CodeGenOptions.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/FrontendOptions.h
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInstance.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Parse/ParseAST.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Parse/ParseTemplate.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
> cfe/trunk/tools/driver/cc1_main.cpp
>
> Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=357340&r1=357339&r2=357340&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Sat Mar 30 01:42:48
> 2019
> @@ -224,6 +224,7 @@ CODEGENOPT(FineGrainedBitfieldAccesses,
>  CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum
> definition.
>  CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict
> vtable pointers
>  CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report is
> enabled.
> +CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is
> enabled.
>  CODEGENOPT(UnrollLoops   , 1, 0) ///< Control whether loops are
> unrolled.
>  CODEGENOPT(RerollLoops   , 1, 0) ///< Control whether loops are
> rerolled.
>  CODEGENOPT(NoUseJumpTables   , 1, 0) ///< Set when -fno-jump-tables is
> enabled.
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=357340&r1=357339&r2=357340&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Sat Mar 30 01:42:48 2019
> @@ -1745,6 +1745,7 @@ def Wframe_larger_than_EQ : Joined<["-"]
>  def : Flag<["-"], "fterminated-vtables">, Alias;
>  def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">,
> Group;
>  def ftime_report : Flag<["-"], "ftime-report">, Group,
> Flags<[CC1Option]>;
> +def ftime_trace : Flag<["-"], "ftime-trace">, Group,
> Flags<[CC1Option]>;
>  def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group,
> Flags<[CC1Option]>;
>  def ftrapv : Flag<["-"], "ftrapv">, Group, Flags<[CC1Option]>,
>HelpText<"Trap on integer overflow">;
>
> Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=357340&r1=357339&r2=357340&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Sat Mar 30 01:42:48
> 2019
> @@ -256,6 +256,9 @@ public:
>/// Show timers for individual actions.
>unsigned ShowTimers : 1;
>
> +  /// Output time trace profile.
> +  unsigned TimeTrace : 1;
> +
>/// Show the -version text.
>unsigned ShowVersion : 1;
>
> @@ -437,13 +440,14 @@ public:
>  public:
>FrontendOptions()
>: DisableFree(false), RelocatablePCH(false), ShowHelp(false),
> -ShowStats(false), ShowTimers(false), ShowVersion(false),
> -FixWhatYouCan(false), F

RE: r357610 - Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-11 Thread Yu, Jennifer via cfe-commits
Hi Nico,

Iet’s revert it now.  I will try to re-submit latter.
Thanks.
Jennifer

From: Nico Weber [mailto:tha...@chromium.org]
Sent: Thursday, April 11, 2019 2:04 PM
To: Yu, Jennifer 
Cc: cfe-commits 
Subject: Re: r357610 - Bug-40323: MS ABI adding template static member in the 
linker directive section to make sure init function can be called before main.

Hi Jennifer,

this caused https://bugs.llvm.org/show_bug.cgi?id=41471

Do you think this is easy to fix, or should we revert for now?

Thanks,
Nico

On Wed, Apr 3, 2019 at 1:20 PM Jennifer Yu via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: jyu2
Date: Wed Apr  3 10:21:40 2019
New Revision: 357610

URL: http://llvm.org/viewvc/llvm-project?rev=357610&view=rev
Log:
Bug-40323: MS ABI adding template static member in the linker directive section 
to make sure init function can be called before main.

Added:
cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=357610&r1=357609&r2=357610&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr  3 10:21:40 2019
@@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
+if (getTarget().getCXXABI().isMicrosoft()) {
+  // In The MS C++, MS add template static data member in the linker
+  // drective.
+  assert(COMDATKey);
+  addUsedGlobal(COMDATKey);
+}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the global, so the initializers get folded

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=357610&view=auto
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp Wed Apr  3 
10:21:40 2019
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions 
-emit-llvm -o - | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+template  struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template  S ExportedTemplate::s;
+void useExportedTemplate(ExportedTemplate x) {
+  (void)x.s;
+}
+int f();
+namespace selectany_init {
+// MS don't put selectany static var in the linker directive, init routine
+// f() is not getting called if x is not referenced.
+int __declspec(selectany) x = f();
+}
+
+namespace explicit_template_instantiation {
+template  struct A { static  int x; };
+template  int A::x = f();
+template struct A;
+}
+
+namespace implicit_template_instantiation {
+template  struct A { static  int x; };
+template   int A::x = f();
+int g() { return A::x; }
+}
+
+
+template 
+struct X_ {
+  static T ioo;
+  static T init();
+};
+template  T X_::ioo = X_::init();
+template struct X_;
+
+template 
+struct X {
+  static T ioo;
+  static T init();
+};
+// template specialized static data don't need in llvm.used,
+// the static init routine get call from _GLOBAL__sub_I_ routines.
+template <> int X::ioo = X::init();
+template struct X;
+// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", 
i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { 
i32 65535, void ()* 
@"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8* getelementptr inbounds 
(%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) }, { 
i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }]
+// CHECK: @l

r358231 - [C++20] Implement context-sensitive header-name lexing and pp-import parsing in the preprocessor.

2019-04-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 11 14:18:23 2019
New Revision: 358231

URL: http://llvm.org/viewvc/llvm-project?rev=358231&view=rev
Log:
[C++20] Implement context-sensitive header-name lexing and pp-import parsing in 
the preprocessor.

Added:
cfe/trunk/test/CXX/cpp/cpp.module/
cfe/trunk/test/CXX/cpp/cpp.module/Inputs/
cfe/trunk/test/CXX/cpp/cpp.module/Inputs/attrs.h
cfe/trunk/test/CXX/cpp/cpp.module/Inputs/empty.h
cfe/trunk/test/CXX/cpp/cpp.module/p1.cpp
cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp
cfe/trunk/test/CXX/lex/lex.pptoken/Inputs/
cfe/trunk/test/CXX/lex/lex.pptoken/Inputs/foo  bar
cfe/trunk/test/CXX/lex/lex.pptoken/Inputs/foo bar
cfe/trunk/test/CXX/lex/lex.pptoken/p3-2a.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPCaching.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Lex/TokenConcatenation.cpp
cfe/trunk/test/Modules/framework-name.m
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=358231&r1=358230&r2=358231&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Apr 11 14:18:23 2019
@@ -418,7 +418,8 @@ def warn_pp_hdrstop_filename_ignored : W
   "/Fp can be used to specify precompiled header filename">,
   InGroup;
 def err_pp_file_not_found_angled_include_not_fatal : Error<
-  "'%0' file not found with  include; use \"quotes\" instead">;
+  "'%0' file not found with  %select{include|import}1; "
+  "use \"quotes\" instead">;
 def err_pp_file_not_found_typo_not_fatal
 : Error<"'%0' file not found, did you mean '%1'?">;
 def note_pp_framework_without_header : Note<
@@ -642,7 +643,8 @@ def err_pp_double_begin_of_arc_cf_code_a
 def err_pp_unmatched_end_of_arc_cf_code_audited : Error<
   "not currently inside '#pragma clang arc_cf_code_audited'">;
 def err_pp_include_in_arc_cf_code_audited : Error<
-  "cannot #include files inside '#pragma clang arc_cf_code_audited'">;
+  "cannot %select{#include files|import headers}0 "
+  "inside '#pragma clang arc_cf_code_audited'">;
 def err_pp_eof_in_arc_cf_code_audited : Error<
   "'#pragma clang arc_cf_code_audited' was not ended within this file">;
 
@@ -776,6 +778,14 @@ def warn_module_conflict : Warning<
   "module '%0' conflicts with already-imported module '%1': %2">,
   InGroup;
 
+// C++20 modules
+def err_header_import_semi_in_macro : Error<
+  "semicolon terminating header import declaration cannot be produced "
+  "by a macro">;
+def err_header_import_not_header_unit : Error<
+  "header file %0 (aka '%1') cannot be imported because "
+  "it is not known to be a header unit">;
+
 def warn_header_guard : Warning<
   "%0 is used as a header guard here, followed by #define of a different 
macro">,
   InGroup>;
@@ -797,7 +807,8 @@ def err_pp_double_begin_of_assume_nonnul
 def err_pp_unmatched_end_of_assume_nonnull : Error<
   "not currently inside '#pragma clang assume_nonnull'">;
 def err_pp_include_in_assume_nonnull : Error<
-  "cannot #include files inside '#pragma clang assume_nonnull'">;
+  "cannot %select{#include files|import headers}0 "
+  "inside '#pragma clang assume_nonnull'">;
 def err_pp_eof_in_assume_nonnull : Error<
   "'#pragma clang assume_nonnull' was not ended within this file">;
 

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=358231&r1=358230&r2=358231&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Apr 11 14:18:23 2019
@@ -148,8 +148,9 @@ LANGOPT(Blocks, 1, 0, "block
 BENIGN_LANGOPT(EmitAllDecls  , 1, 0, "emitting all declarations")
 LANGOPT(MathErrno , 1, 1, "errno in math functions")
 BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like 
and may be ripped out at any time")
-LANGOPT(Modules   , 1, 0, "modules extension to C")
-COMPATIBLE_LANGOPT(ModulesTS  , 1, 0, "C++ Modules TS")
+LANGOPT(Modules   , 1, 0, "modules semantics")
+COMPATIBLE_LANGOPT(ModulesTS  , 1, 0, "C++ Modules TS syntax")
+COMPATIBLE_LANGOPT(CPlusPlusModules, 1, 0, "C++ modules syntax")
 BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None

r358230 - Remove use of lookahead from _Pragma handling and from all other

2019-04-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 11 14:18:22 2019
New Revision: 358230

URL: http://llvm.org/viewvc/llvm-project?rev=358230&view=rev
Log:
Remove use of lookahead from _Pragma handling and from all other
internal lexing steps in the preprocessor.

It is not safe to use the preprocessor's token lookahead except when
operating on the final sequence of tokens that would be produced by
phase 4 of translation. Doing so corrupts the token lookahead cache used
by the parser. (See added testcase for an example.) Lookahead should
instead be viewed as a layer on top of the normal lexer.

Added assertions to catch any further incorrect uses of lookahead within
lexing actions.

Added:
cfe/trunk/test/Preprocessor/_Pragma-in-macro-arg.cpp
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPCaching.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=358230&r1=358229&r2=358230&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Apr 11 14:18:22 2019
@@ -323,6 +323,14 @@ class Preprocessor {
   /// to avoid hitting the same error over and over again.
   bool HasReachedMaxIncludeDepth = false;
 
+  /// The number of currently-active calls to Lex.
+  ///
+  /// Lex is reentrant, and asking for an (end-of-phase-4) token can often
+  /// require asking for multiple additional tokens. This counter makes it
+  /// possible for Lex to detect whether it's producing a token for the end
+  /// of phase 4 of translation or for some other situation.
+  unsigned LexLevel = 0;
+
 public:
   struct PreambleSkipInfo {
 SourceLocation HashTokenLoc;
@@ -1244,24 +1252,6 @@ public:
   /// Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
 
-  struct CachedTokensRange {
-CachedTokensTy::size_type Begin, End;
-  };
-
-private:
-  /// A range of cached tokens that should be erased after lexing
-  /// when backtracking requires the erasure of such cached tokens.
-  Optional CachedTokenRangeToErase;
-
-public:
-  /// Returns the range of cached tokens that were lexed since
-  /// EnableBacktrackAtThisPos() was previously called.
-  CachedTokensRange LastCachedTokenRange();
-
-  /// Erase the range of cached tokens that were lexed since
-  /// EnableBacktrackAtThisPos() was previously called.
-  void EraseCachedTokens(CachedTokensRange TokenRange);
-
   /// Make Preprocessor re-lex the tokens that were lexed since
   /// EnableBacktrackAtThisPos() was previously called.
   void Backtrack();
@@ -1353,6 +1343,7 @@ public:
   /// tokens after phase 5.  As such, it is equivalent to using
   /// 'Lex', not 'LexUnexpandedToken'.
   const Token &LookAhead(unsigned N) {
+assert(LexLevel == 0 && "cannot use lookahead while lexing");
 if (CachedLexPos + N < CachedTokens.size())
   return CachedTokens[CachedLexPos+N];
 else
@@ -1379,8 +1370,16 @@ public:
   /// If BackTrack() is called afterwards, the token will remain at the
   /// insertion point.
   void EnterToken(const Token &Tok) {
-EnterCachingLexMode();
-CachedTokens.insert(CachedTokens.begin()+CachedLexPos, Tok);
+if (LexLevel) {
+  // It's not correct in general to enter caching lex mode while in the
+  // middle of a nested lexing action.
+  auto TokCopy = llvm::make_unique(1);
+  TokCopy[0] = Tok;
+  EnterTokenStream(std::move(TokCopy), 1, true);
+} else {
+  EnterCachingLexMode();
+  CachedTokens.insert(CachedTokens.begin()+CachedLexPos, Tok);
+}
   }
 
   /// We notify the Preprocessor that if it is caching tokens (because
@@ -2062,6 +2061,7 @@ private:
   }
 
   void EnterCachingLexMode();
+  void EnterCachingLexModeUnchecked();
 
   void ExitCachingLexMode() {
 if (InCachingLexMode())

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=358230&r1=358229&r2=358230&view=diff
==
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Thu Apr 11 14:18:22 2019
@@ -23,6 +23,7 @@ using namespace clang;
 // be called multiple times and CommitBacktrackedTokens/Backtrack calls will
 // be combined with the EnableBacktrackAtThisPos calls in reverse order.
 void Preprocessor::EnableBacktrackAtThisPos() {
+  assert(LexLevel == 0 && "cannot use lookahead while lexing");
   BacktrackPositions.push_back(CachedLexPos);
   EnterCachingLexMode();
 }
@@ -34,29 +35,6 @@ void Preprocessor::CommitBacktrackedToke
   BacktrackPositions.pop_back();
 }
 
-Preprocessor::CachedTokensRange Preprocessor::LastCachedTokenRange() {
-  assert(isBacktrackEnabled());
-  auto PrevCach

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 194758.
gtbercea marked 2 inline comments as done.
gtbercea added a comment.

- Fix enum.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,10 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
+
+  /// Return true if unified addressing is supported by the architecture.
+  virtual bool hasUnifiedAddressingSupport() const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,30 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequ

Re: r357610 - Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-11 Thread Nico Weber via cfe-commits
Hi Jennifer,

this caused https://bugs.llvm.org/show_bug.cgi?id=41471

Do you think this is easy to fix, or should we revert for now?

Thanks,
Nico

On Wed, Apr 3, 2019 at 1:20 PM Jennifer Yu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jyu2
> Date: Wed Apr  3 10:21:40 2019
> New Revision: 357610
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357610&view=rev
> Log:
> Bug-40323: MS ABI adding template static member in the linker directive
> section to make sure init function can be called before main.
>
> Added:
> cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=357610&r1=357609&r2=357610&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr  3 10:21:40 2019
> @@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
>  // minor startup time optimization.  In the MS C++ ABI, there are no
> guard
>  // variables, so this COMDAT key is required for correctness.
>  AddGlobalCtor(Fn, 65535, COMDATKey);
> +if (getTarget().getCXXABI().isMicrosoft()) {
> +  // In The MS C++, MS add template static data member in the linker
> +  // drective.
> +  assert(COMDATKey);
> +  addUsedGlobal(COMDATKey);
> +}
>} else if (D->hasAttr()) {
>  // SelectAny globals will be comdat-folded. Put the initializer into a
>  // COMDAT group associated with the global, so the initializers get
> folded
>
> Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=357610&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
> (added)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp Wed
> Apr  3 10:21:40 2019
> @@ -0,0 +1,57 @@
> +// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o
> - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm
> -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions
> -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions
> -emit-llvm -o - | FileCheck %s
> +
> +struct S {
> +  S();
> +  ~S();
> +};
> +
> +template  struct __declspec(dllexport) ExportedTemplate {
> +  static S s;
> +};
> +template  S ExportedTemplate::s;
> +void useExportedTemplate(ExportedTemplate x) {
> +  (void)x.s;
> +}
> +int f();
> +namespace selectany_init {
> +// MS don't put selectany static var in the linker directive, init routine
> +// f() is not getting called if x is not referenced.
> +int __declspec(selectany) x = f();
> +}
> +
> +namespace explicit_template_instantiation {
> +template  struct A { static  int x; };
> +template  int A::x = f();
> +template struct A;
> +}
> +
> +namespace implicit_template_instantiation {
> +template  struct A { static  int x; };
> +template   int A::x = f();
> +int g() { return A::x; }
> +}
> +
> +
> +template 
> +struct X_ {
> +  static T ioo;
> +  static T init();
> +};
> +template  T X_::ioo = X_::init();
> +template struct X_;
> +
> +template 
> +struct X {
> +  static T ioo;
> +  static T init();
> +};
> +// template specialized static data don't need in llvm.used,
> +// the static init routine get call from _GLOBAL__sub_I_ routines.
> +template <> int X::ioo = X::init();
> +template struct X;
> +// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8*
> }] [{ i32, void ()*, i8* } { i32 65535, void ()* 
> @"??__Ex@selectany_init@@YAXXZ",
> i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*,
> i8* } { i32 65535, void ()* @"??__E?x@?$A@H
> @explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* @"?x@
> ?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*,
> i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast
> (i32* @"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535,
> void ()* @"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8*
> getelementptr inbounds (%struct.S, %struct.S* @"?s@?$ExportedTemplate@H
> @@2US@@A", i32 0, i32 0) }, { i32, void ()*, i8* } { i32 65535, void ()*
> @"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast
> (i32* @"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32,
> void ()*, i8* } { i32 65535, void ()*
> @_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }]
> +// CHECK: @llvm.used = appending global [4 x i8*] [i8* bitcast (i32* @"?x@
> ?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32*
> @"?ioo@

[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/PatternInit.cpp:17
+
+llvm::Constant *patternFor(CodeGenModule &CGM, llvm::Type *Ty) {
+  // The following value is a guaranteed unmappable pointer value and has a

Please use a qualified declaration here instead of defining it in the namespace.



Comment at: lib/CodeGen/PatternInit.h:22
+
+llvm::Constant *patternFor(CodeGenModule&, llvm::Type*);
+

Please choose names that mean something outside of the mental context you were 
in when you wrote the patch. :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D59221: [asan] Add gcc 8's driver option -fsanitize=pointer-compare and -fsanitize=pointer-substract.

2019-04-11 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Seems like harmless plumbing. Given that the LLVM side of this is accepted, 
this lgtm.




Comment at: test/Driver/fsanitize.c:837
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=pointer-compare 
-fno-sanitize=pointer-compare %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-POINTER-CMP
+// CHECK-POINTER-ALL: 
"-cc1{{.*}}-fsanitize={{.*}}pointer-compare,pointer-subtract{{.*}}" {{.*}} 
"-mllvm" "-asan-detect-invalid-pointer-cmp" "-mllvm" 
"-asan-detect-invalid-pointer-sub"
+// CHECK-POINTER-CMP-NEEDS-ADDRESS: error: invalid argument 
'-fsanitize=pointer-compare' only allowed with '-fsanitize=address'

Should some of these be {{[^"}*}} instead of {{.*}} so that the match isn't 
accidentally across different flags?


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

https://reviews.llvm.org/D59221



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 4 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3870
 llvm::Function *
+CGOpenMPRuntime::createRequiresDirectiveRegistration() {
+  // If we don't have entries or if we are emitting code for the device, we

ABataev wrote:
> Why do you need a new member function? Can you make a static local function?
Same as for register lib.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3887
+CGF.StartFunction(GlobalDecl(), C.VoidTy, RequiresRegFn, FI, {});
+int64_t Flags = OMP_REQ_NONE;
+//TODO: check for other requires clauses.

ABataev wrote:
> Use `OpenMPOffloadingRequiresDirFlags` instead of `int64_t`
Leads to error if I do that. This enum behaves like OpenMPLocationFlags.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7983
 MapFlagsArrayTy &Types) const {
+// If using unified memory, no need to do the mappings.
+if (CGF.CGM.HasRequiresUnifiedSharedMemory)

ABataev wrote:
> Seems to me, this must be in another patch, has nothing to do with this patch
I will split it.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9069
 
+llvm::Function *CGOpenMPRuntime::emitRequiresDirectiveRegFun() {
+  // Create and register the function that handles the requires directives.

ABataev wrote:
> Why do you need the second function?
Second function eliminated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 194743.
gtbercea marked 6 inline comments as done.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,10 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
+
+  /// Return true if unified addressing is supported by the architecture.
+  virtual bool hasUnifiedAddressingSupport() const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,26 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires dire

[PATCH] D59221: [asan] Add gcc 8's driver option -fsanitize=pointer-compare and -fsanitize=pointer-substract.

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno resigned from this revision.
riccibruno added a comment.

I am not the best person to review this, sorry!


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

https://reviews.llvm.org/D59221



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 194741.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,13 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
+  /// Creates and registers requires directives.
+  llvm::Function *createRequiresDirectiveRegistration();
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1436,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1608,10 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
+
+  /// Return true if unified addressing is supported by the architecture.
+  virtual bool hasUnifiedAddressingSupport() const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,26 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+/// Values for bit flags for marking which requires clauses have been used.
+enum O

[PATCH] D57660: [Sema] SequenceChecker: Handle references, members and structured bindings.

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Friendly ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57660



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


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-11 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358219: [DebugInfo] Combine Trivial and NonTrivial flags 
(authored by asmith, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59347?vs=194249&id=194737#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59347

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 
Index: cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialC",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialC {
   struct Trivial x;
 } TrivialC;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialD",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct NT {
   NT() {};
 };


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 
Index: cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG:

r358219 - [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-11 Thread Aaron Smith via cfe-commits
Author: asmith
Date: Thu Apr 11 13:24:54 2019
New Revision: 358219

URL: http://llvm.org/viewvc/llvm-project?rev=358219&view=rev
Log:
[DebugInfo] Combine Trivial and NonTrivial flags

Summary:
These flags are used when emitting debug info and needed to initialize 
subprogram and member function attributes (function options) for Codeview. 
These function options are used to create an accurate compiler type for UDT 
symbols (class/struct/union) from PDBs.

The Trivial flag was introduced in https://reviews.llvm.org/D45122

It's been pointed out that Trivial and NonTrivial may imply each other and that 
seems to be the case in the current tests. This change combines them into a 
single flag -- NonTrivial -- and updates the corresponding unit tests. There is 
an additional change to llvm to update the flags.

Reviewers: rnk, zturner, dblaikie, probinson, Hui

Reviewed By: dblaikie

Subscribers: aprantl, jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=358219&r1=358218&r2=358219&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Apr 11 13:24:54 2019
@@ -3034,10 +3034,8 @@ llvm::DICompositeType *CGDebugInfo::Crea
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp?rev=358219&r1=358218&r2=358219&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp Thu Apr 11 
13:24:54 2019
@@ -25,34 +25,40 @@ int GlobalVar = 0;
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialC",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialC {
   struct Trivial x;
 } TrivialC;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialD",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct NT {
   NT() {};
 };


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


[PATCH] D60561: [clang] fixing diagnostics of constexpr callstack

2019-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This seems liable to be moderately expensive, especially for large argument 
values, and it's a cost that is unnecessary in the common case where evaluation 
succeeds.

I wonder if we'd be better off speculatively trying the entire evaluation 
without storing any such values, and rerunning the evaluation to collect 
diagnostics only when we find that evaluation would fail (and we're in a 
context where the caller actually wants the diagnostics).


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

https://reviews.llvm.org/D60561



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb marked 2 inline comments as done.
jfb added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:57
+  case LangOptions::TrivialAutoVarInitKind::Pattern:
+Byte = CGF.Builder.getInt8(0xAA);
+break;

rjmccall wrote:
> Can this value be taken from some common source with the existing code?  I 
> mean, even if it's just a constant in some header, that'd be a start.
Done.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 194736.
jfb added a comment.
Herald added a subscriber: mgorny.

- Move patternFor to a shared file as requested by @rjmccall


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/PatternInit.cpp
  lib/CodeGen/PatternInit.h
  test/CodeGenCXX/trivial-auto-var-init.cpp

Index: test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- test/CodeGenCXX/trivial-auto-var-init.cpp
+++ test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -173,6 +173,34 @@
   used(ptr);
 }
 
+// UNINIT-LABEL:  test_alloca(
+// ZERO-LABEL:test_alloca(
+// ZERO:  %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// ZERO-NEXT: %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align [[ALIGN:[0-9]+]]
+// ZERO-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %[[ALLOCA]], i8 0, i64 %[[SIZE]], i1 false)
+// PATTERN-LABEL: test_alloca(
+// PATTERN:   %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// PATTERN-NEXT:  %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align [[ALIGN:[0-9]+]]
+// PATTERN-NEXT:  call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %[[ALLOCA]], i8 -86, i64 %[[SIZE]], i1 false)
+void test_alloca(int size) {
+  void *ptr = __builtin_alloca(size);
+  used(ptr);
+}
+
+// UNINIT-LABEL:  test_alloca_with_align(
+// ZERO-LABEL:test_alloca_with_align(
+// ZERO:  %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// ZERO-NEXT: %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align 128
+// ZERO-NEXT: call void @llvm.memset{{.*}}(i8* align 128 %[[ALLOCA]], i8 0, i64 %[[SIZE]], i1 false)
+// PATTERN-LABEL: test_alloca_with_align(
+// PATTERN:   %[[SIZE:[a-z0-9]+]] = sext i32 %{{.*}} to i64
+// PATTERN-NEXT:  %[[ALLOCA:[a-z0-9]+]] = alloca i8, i64 %[[SIZE]], align 128
+// PATTERN-NEXT:  call void @llvm.memset{{.*}}(i8* align 128 %[[ALLOCA]], i8 -86, i64 %[[SIZE]], i1 false)
+void test_alloca_with_align(int size) {
+  void *ptr = __builtin_alloca_with_align(size, 1024);
+  used(ptr);
+}
+
 // UNINIT-LABEL:  test_struct_vla(
 // ZERO-LABEL:test_struct_vla(
 // ZERO:  %[[SIZE:[0-9]+]] = mul nuw i64 %{{.*}}, 16
Index: lib/CodeGen/PatternInit.h
===
--- /dev/null
+++ lib/CodeGen/PatternInit.h
@@ -0,0 +1,27 @@
+//===- PatternInit - Pattern initialization -*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_PATTERNINIT_H
+#define LLVM_CLANG_LIB_CODEGEN_PATTERNINIT_H
+
+namespace llvm {
+class Constant;
+class Type;
+}
+
+namespace clang {
+namespace CodeGen {
+
+class CodeGenModule;
+
+llvm::Constant *patternFor(CodeGenModule&, llvm::Type*);
+
+}  // end namespace CodeGen
+}  // end namespace clang
+
+#endif
Index: lib/CodeGen/PatternInit.cpp
===
--- /dev/null
+++ lib/CodeGen/PatternInit.cpp
@@ -0,0 +1,97 @@
+//===--- CGDecl.cpp - Emit LLVM Code for declarations -===//
+//
+// 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 "CodeGenModule.h"
+#include "PatternInit.h"
+#include "llvm/IR/Constant.h"
+#include "llvm/IR/Type.h"
+
+namespace clang {
+namespace CodeGen {
+
+llvm::Constant *patternFor(CodeGenModule &CGM, llvm::Type *Ty) {
+  // The following value is a guaranteed unmappable pointer value and has a
+  // repeated byte-pattern which makes it easier to synthesize. We use it for
+  // pointers as well as integers so that aggregates are likely to be
+  // initialized with this repeated value.
+  constexpr uint64_t LargeValue = 0xull;
+  // For 32-bit platforms it's a bit trickier because, across systems, only the
+  // zero page can reasonably be expected to be unmapped, and even then we need
+  // a very low address. We use a smaller value, and that value sadly doesn't
+  // have a repeated byte-pattern. We don't use it for integers.
+  constexpr uint32_t SmallValue = 0x00AA;
+  // Floating-point values are initialized as NaNs because they propagate. Using
+  // a repeated byte pattern means that it will be easier to initialize
+  // all-floating-point aggregates and arrays with memset. Further, aggregates
+  // which mix integral and a few floats might also initialize with memset
+  // followed by a handful of stores

[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:57
+  case LangOptions::TrivialAutoVarInitKind::Pattern:
+Byte = CGF.Builder.getInt8(0xAA);
+break;

Can this value be taken from some common source with the existing code?  I 
mean, even if it's just a constant in some header, that'd be a start.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60507: [clang-tidy] new check: bugprone-unhandled-self-assignment

2019-04-11 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

I'll update the patch based on the comments.
Just a note about the false positive ratio. In LibreOffice we run other static 
analyzers too, that's why there were less positive catches there than false 
positives. For example, PVS studio also catches unprotected copy assignment 
operators. Some of these issues were already fixed before I run this new check 
on the code:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=e5e0cc68f70d35e1849aeaf21c0ce68afd6a1f59


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60507



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D60548#1462124 , @jfb wrote:

> One downside to alloca is that we can's use `__attribute__((uninitialized))` 
> because it's a builtin. Maybe we need a separate uninitialized alloca? What 
> do you all think?


Actually I'm wondering if we should just implement:

  #pragma clang attribute push (__attribute__((uninitialized)), apply_to = 
variable(unless(is_global)))

And lean on that for `alloca`, instead of having a new uninitialized `alloca` 
builtin. The pragma is useful for debugging regardless, so I think overall it's 
better.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D60548#1463181 , @jfb wrote:

> In D60548#1462124 , @jfb wrote:
>
> > One downside to alloca is that we can's use 
> > `__attribute__((uninitialized))` because it's a builtin. Maybe we need a 
> > separate uninitialized alloca? What do you all think?
>
>
> Actually I'm wondering if we should just implement:
>
>   #pragma clang attribute push (__attribute__((uninitialized)), apply_to = 
> variable(unless(is_global)))
>
>
> And lean on that for `alloca`, instead of having a new uninitialized `alloca` 
> builtin. The pragma is useful for debugging regardless, so I think overall 
> it's better.


Although the pragma syntax 

 doesn't seem to support builtins, only variables, so it's still; weird for 
alloca... I'd really want the pragma to apply to everything in its scope 
including alloca.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60572: creduce-clang-crash: Use `!` instead of `not`

2019-04-11 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

Looks good- if we remove `not` there are a few other things that should be 
removed




Comment at: clang/utils/creduce-clang-crash.py:138
 if "fatal error:" in msg_re:
   self.is_crash = False
 break

also wouldn't need `self.is_crash`



Comment at: clang/utils/creduce-clang-crash.py:178
 
 crash_flag = "--crash" if self.is_crash else ""
 

We should remove `crash_flag` as well


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

https://reviews.llvm.org/D60572



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

@klimek, this patch is now ready for review.  Thanks...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 194729.
hintonda added a comment.

Enhance Option::reset to reset the default value and remove the option
if it's a cl::DefaultOption.

Also, make sure removeOption only removes an option if both the name
and the Option matches, not just the name -- different Options with
the same name in different SubCommands have always been possible, but
are more common with DefaultOptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/test/Support/check-default-options.txt
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,67 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/test/Support/check-default-options.txt
===
--- /dev/null
+++ llvm/test/Support/check-default-options.txt
@@ -0,0 +1,18 @@
+# RUN: llvm-objdump -help-hidden %t | FileCheck --check-prefix=CHECK-OBJDUMP %s
+# RUN: llvm-readobj -help-hidden %t | FileCheck --check-prefix=CHECK-READOBJ %s
+# RUN: llvm-tblgen -help-hidden %t | FileCheck --check-prefix=CHECK-TBLGEN %s
+# RUN: llvm-opt-report -help-hidden %t | FileCheck --check-prefix=CHECK-OPT-RPT %s
+# RUN: llvm-dwarfdump -help-hidden %t | FileCheck --check-prefix=CHECK-D

[PATCH] D60573: [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: rjmccall, Quuxplusone.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
riccibruno added a parent revision: D60570: [Sema] Add more tests for the 
behavior of argument-dependent name lookup.

CWG 1691 changed the definition of the namespaces associated with a class type 
or enumeration type.

For a class type, the associated namespaces are the innermost enclosing 
namespaces of the associated classes.
For an enumeration type, the associated namespace is the innermost enclosing 
namespace of its declaration.

This also fixes CWG 1690 and CWG 1692.

I have applied the fix to all language versions, even though I think that the 
DR only applies to C++14. The reason for this is that it is possible to return 
a local type from a lambda in C++11, and I don't think that this will affect 
anyone (although  this can totally be a failure of my imagination...)


Repository:
  rC Clang

https://reviews.llvm.org/D60573

Files:
  lib/Sema/SemaLookup.cpp
  
test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
  test/CXX/drs/dr16xx.cpp

Index: test/CXX/drs/dr16xx.cpp
===
--- test/CXX/drs/dr16xx.cpp
+++ test/CXX/drs/dr16xx.cpp
@@ -284,6 +284,54 @@
 #endif
 }
 
+namespace dr1690 { // dr1690: 9
+  // See also the various tests in "CXX/basic/basic.lookup/basic.lookup.argdep".
+#if __cplusplus >= 201103L
+  namespace N {
+static auto lambda = []() { struct S {} s; return s; };
+void f(decltype(lambda()));
+  }
+
+  void test() {
+auto s = N::lambda();
+f(s); // ok
+  }
+#endif
+}
+
+namespace dr1691 { // dr1691: 9
+#if __cplusplus >= 201103L
+  namespace N {
+namespace M {
+  enum E : int;
+  void f(E);
+}
+enum M::E : int {};
+void g(M::E); // expected-note {{declared here}}
+  }
+  void test() {
+N::M::E e;
+f(e); // ok
+g(e); // expected-error {{use of undeclared}}
+  }
+#endif
+}
+
+namespace dr1692 { // dr1692: 9
+  namespace N {
+struct A {
+  struct B {
+struct C {};
+  };
+};
+void f(A::B::C);
+  }
+  void test() {
+N::A::B::C c;
+f(c); // ok
+  }
+}
+
 namespace dr1696 { // dr1696: 7
   namespace std_examples {
 #if __cplusplus >= 201402L
Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
@@ -38,12 +38,11 @@
   return s;
 }
 using S = decltype(foo());
-void f(S); // expected-note {{'X2::f' declared here}}
+void f(S); // #1
   }
   void test2() {
-f(X2::S{}); // FIXME: This is well-formed; X2 is the innermost enclosing namespace
-// of the local struct S.
-// expected-error@-2 {{use of undeclared identifier 'f'}}
+f(X2::S{}); // This is well-formed; X2 is the innermost enclosing namespace
+// of the local struct S. Calls #1.
   }
 
   // associated class: the parent class
@@ -83,7 +82,7 @@
 
 void test5() {
   auto lambda = N::get_lambda();
-  f(lambda); // FIXME: This is well-formed. expected-error {{use of undeclared}}
+  f(lambda); // ok
 }
   }
 } // namespace adl_class_type
@@ -172,6 +171,12 @@
   enum F : int;
   friend void g(F);
 };
+auto foo() {
+  enum G {} g;
+  return g;
+}
+using G = decltype(foo());
+void h(G);
   }
 
   void test() {
@@ -179,6 +184,9 @@
 f(e); // ok
 N::S::F f;
 g(f); // ok
+N::G g;
+h(g); // ok
+
   }
 }
 
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -2458,30 +2458,39 @@
 static void
 addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T);
 
+// Given the declaration context \param Ctx of a class, class template or
+// enumeration, add the associated namespaces to \param Namespaces as described
+// in [basic.lookup.argdep]p2.
 static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces,
   DeclContext *Ctx) {
-  // Add the associated namespace for this class.
-
-  // We don't use DeclContext::getEnclosingNamespaceContext() as this may
-  // be a locally scoped record.
+  // The exact wording has been changed in C++14 as a result of
+  // CWG 1691 (see also CWG 1690 and CWG 1692). We apply it unconditionally
+  // to all language versions since it is possible to return a local type
+  // from a lambda in C++11.
+  //
+  // C++14 [basic.lookup.argdep]p2:
+  //   If T is a class type [...]. Its associated namespaces are the innermost
+  //   enclosing namespaces of its associated classes. [...]
+  //
+  //   If 

[PATCH] D60572: creduce-clang-crash: Use `!` instead of `not`

2019-04-11 Thread Nico Weber via Phabricator via cfe-commits
thakis abandoned this revision.
thakis added a comment.

This seems to break the script, nevermind!


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

https://reviews.llvm.org/D60572



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


[PATCH] D60572: creduce-clang-crash: Use `!` instead of `not`

2019-04-11 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: akhuang.

The run script runs in bash, so no need to depend on llvm's `not` binary.


https://reviews.llvm.org/D60572

Files:
  clang/utils/creduce-clang-crash.py


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -23,7 +23,6 @@
 verbose = False
 creduce_cmd = None
 clang_cmd = None
-not_cmd = None
 
 def verbose_print(*args, **kwargs):
   if verbose:
@@ -178,8 +177,8 @@
 
 crash_flag = "--crash" if self.is_crash else ""
 
-output = "#!/bin/bash\n%s %s %s >& t.log || exit 1\n" % \
-(pipes.quote(not_cmd), crash_flag, quote_cmd(self.get_crash_cmd()))
+output = "#!/bin/bash\n! %s %s >& t.log || exit 1\n" % \
+(crash_flag, quote_cmd(self.get_crash_cmd()))
 
 for msg in self.expected_output:
   output += 'grep %s t.log || exit 1\n' % pipes.quote(msg)
@@ -360,7 +359,6 @@
   global verbose
   global creduce_cmd
   global clang_cmd
-  global not_cmd
 
   parser = ArgumentParser(description=__doc__,
   formatter_class=RawTextHelpFormatter)
@@ -370,9 +368,6 @@
   help="Name of the file to be reduced.")
   parser.add_argument('--llvm-bin', dest='llvm_bin', type=str,
   help="Path to the LLVM bin directory.")
-  parser.add_argument('--llvm-not', dest='llvm_not', type=str,
-  help="The path to the `not` executable. "
-  "By default uses the llvm-bin directory.")
   parser.add_argument('--clang', dest='clang', type=str,
   help="The path to the `clang` executable. "
   "By default uses the llvm-bin directory.")
@@ -386,7 +381,6 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
-  not_cmd = check_cmd('not', llvm_bin, args.llvm_not)
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -23,7 +23,6 @@
 verbose = False
 creduce_cmd = None
 clang_cmd = None
-not_cmd = None
 
 def verbose_print(*args, **kwargs):
   if verbose:
@@ -178,8 +177,8 @@
 
 crash_flag = "--crash" if self.is_crash else ""
 
-output = "#!/bin/bash\n%s %s %s >& t.log || exit 1\n" % \
-(pipes.quote(not_cmd), crash_flag, quote_cmd(self.get_crash_cmd()))
+output = "#!/bin/bash\n! %s %s >& t.log || exit 1\n" % \
+(crash_flag, quote_cmd(self.get_crash_cmd()))
 
 for msg in self.expected_output:
   output += 'grep %s t.log || exit 1\n' % pipes.quote(msg)
@@ -360,7 +359,6 @@
   global verbose
   global creduce_cmd
   global clang_cmd
-  global not_cmd
 
   parser = ArgumentParser(description=__doc__,
   formatter_class=RawTextHelpFormatter)
@@ -370,9 +368,6 @@
   help="Name of the file to be reduced.")
   parser.add_argument('--llvm-bin', dest='llvm_bin', type=str,
   help="Path to the LLVM bin directory.")
-  parser.add_argument('--llvm-not', dest='llvm_not', type=str,
-  help="The path to the `not` executable. "
-  "By default uses the llvm-bin directory.")
   parser.add_argument('--clang', dest='clang', type=str,
   help="The path to the `clang` executable. "
   "By default uses the llvm-bin directory.")
@@ -386,7 +381,6 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
-  not_cmd = check_cmd('not', llvm_bin, args.llvm_not)
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60570: [Sema] Add more tests for the behavior of argument-dependent name lookup

2019-04-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: rjmccall, Quuxplusone.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

The goal here is to exercise each rule in [basic.lookup.argdep] at least once. 
These new tests expose what I believe are 2 issues:

1. CWG 1691 needs to be implemented (`p2:  [...] Its associated namespaces are 
the innermost enclosing namespaces of its associated classes [...]`) The 
corresponding tests are `adl_class_type::X2` and `adl_class_type::X5`.

2. The end of paragraph 2 (`[...] Additionally, if the aforementioned set of 
overloaded functions is named with a template-id, its associated classes and 
namespaces also include those of its type template-arguments and its template 
template-arguments.`) is not implemented. Closely related, the restriction on 
non-dependent parameter types in this same paragraph needs to be removed. The 
corresponding tests are in `adl_overload_set`. (both issues are from CWG 997).


Repository:
  rC Clang

https://reviews.llvm.org/D60570

Files:
  
test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp
  test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
  test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp

Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -67,3 +67,96 @@
 foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
   }
 }
+
+
+// Check the rules described in p4:
+//  When considering an associated namespace, the lookup is the same as the lookup
+//  performed when the associated namespace is used as a qualifier (6.4.3.2) except that:
+
+//  - Any using-directives in the associated namespace are ignored.
+namespace test_using_directives {
+  namespace M { struct S; }
+  namespace N {
+void f(M::S); // expected-note {{declared here}}
+  }
+  namespace M {
+using namespace N;
+struct S {};
+  }
+  void test() {
+M::S s;
+f(s); // expected-error {{use of undeclared}}
+M::f(s); // ok
+  }
+}
+
+//  - Any namespace-scope friend functions or friend function templates declared in
+//associated classes are visible within their respective namespaces even if
+//they are not visible during an ordinary lookup
+// (Note: For the friend declaration to be visible, the corresponding class must be
+//  included in the set of associated classes. Merely including the namespace in
+//  the set of associated namespaces is not enough.)
+namespace test_friend1 {
+  namespace N {
+struct S;
+struct T {
+  friend void f(S); // #1
+};
+struct S { S(); S(T); };
+  }
+
+  void test() {
+N::S s;
+N::T t;
+f(s); // expected-error {{use of undeclared}}
+f(t); // ok, #1
+  }
+}
+
+// credit: Arthur O’Dwyer
+namespace test_friend2 {
+  struct A {
+struct B {
+struct C {};
+};
+friend void foo(...); // #1
+  };
+
+  struct D {
+friend void foo(...); // #2
+  };
+  template struct E {
+struct F {};
+  };
+
+  template struct G {};
+  template struct H {};
+  template struct I {};
+  struct J { friend void foo(...) {} }; // #3
+
+  void test() {
+A::B::C c;
+foo(c); // #1 is not visible since A is not an associated class
+// expected-error@-1 {{use of undeclared}}
+E::F f;
+foo(f); // #2 is not visible since D is not an associated class
+// expected-error@-1 {{use of undeclared}}
+G > > j;
+foo(j);  // ok, #3.
+  }
+}
+
+//  - All names except those of (possibly overloaded) functions and
+//function templates are ignored.
+namespace test_other_names {
+  namespace N {
+struct S {};
+struct Callable { void operator()(S); };
+static struct Callable Callable;
+  }
+
+  void test() {
+N::S s;
+Callable(s); // expected-error {{use of undeclared}}
+  }
+}
Index: test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
===
--- test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
@@ -18,3 +18,48 @@
 }
   };
 }
+
+// If X contains [...] then Y is empty.
+// - a declaration of a class member
+namespace test_adl_suppression_by_class_member {
+  namespace N {
+struct T {};
+void f(T); // expected-note {{declared here}}
+  }
+  struct S {
+void f();
+void test() {
+  N::T t;
+  f(t); // expected-error {{too many arguments}}
+}
+  };
+}
+
+// - a block-scope function declaration that is not a using-declaration
+namespace test_adl_suppression_by_block_scope {
+  namespace N {
+struct S {};
+void f(S);
+  }
+  namespace M { void f(int); } // expected-note {{candidate}}
+  void test() {
+N::S s;
+using M::f;
+f(s); // ok
+extern void f(char); // expected

Re: [PATCH] D59605: [clangd] Introduce background-indexer

2019-04-11 Thread Sam McCall via cfe-commits
Thanks - I think there's quite a lot of background missing here: what/who
is this for, why a separate binary from clangd-indexer (or and how do they
relate, how much of the BackgroundIndex code structure makes sense with
multiple users.

I assume there's been some offline discussion about this, but i missed it
:-)

On Thu, Apr 11, 2019, 18:16 Ilya Biryukov via Phabricator <
revi...@reviews.llvm.org> wrote:

> ilya-biryukov added a comment.
>
> To make it clear, I think the question is not just "which part of
> functionality is missing in BackgroundIndex", it's rather "which part of
> BackgroundIndex we **don't** need".
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59605/new/
>
> https://reviews.llvm.org/D59605
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60544: Support objc_nonlazy_class attribute on Objective-C implementations

2019-04-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358201: Support objc_nonlazy_class attribute on Objective-C 
implementations (authored by epilk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60544?vs=194596&id=194717#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60544

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
  cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m

Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp
@@ -6262,7 +6262,8 @@
 bool CGObjCNonFragileABIMac::ImplementationIsNonLazy(
 const ObjCImplDecl *OD) const {
   return OD->getClassMethod(GetNullarySelector("load")) != nullptr ||
- OD->getClassInterface()->hasAttr();
+ OD->getClassInterface()->hasAttr() ||
+ OD->hasAttr();
 }
 
 void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID,
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3711,14 +3711,14 @@
 def ObjCNonLazyClassDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
-This attribute can be added to an Objective-C ``@interface`` declaration to
-add the class to the list of non-lazily initialized classes. A non-lazy class
-will be initialized eagerly when the Objective-C runtime is loaded.  This is
-required for certain system classes which have instances allocated in
-non-standard ways, such as the classes for blocks and constant strings.  Adding
-this attribute is essentially equivalent to providing a trivial `+load` method 
-but avoids the (fairly small) load-time overheads associated with defining and
-calling such a method.
+This attribute can be added to an Objective-C ``@interface`` or
+``@implementation`` declaration to add the class to the list of non-lazily
+initialized classes. A non-lazy class will be initialized eagerly when the
+Objective-C runtime is loaded. This is required for certain system classes which
+have instances allocated in non-standard ways, such as the classes for blocks
+and constant strings. Adding this attribute is essentially equivalent to
+providing a trivial `+load` method but avoids the (fairly small) load-time
+overheads associated with defining and calling such a method.
   }];
 }
 
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1767,7 +1767,7 @@
 
 def ObjCNonLazyClass : Attr {
   let Spellings = [Clang<"objc_nonlazy_class">];
-  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
   let LangOpts = [ObjC];
   let Documentation = [ObjCNonLazyClassDocs];
 }
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -102,7 +102,7 @@
 // CHECK-NEXT: ObjCExplicitProtocolImpl (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
-// CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface)
+// CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface, SubjectMatchRule_objc_implementation)
 // CHECK-NEXT: ObjCPreciseLifetime (SubjectMatchRule_variable)
 // CHECK-NEXT: ObjCRequiresPropertyDefs (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCRequiresSuper (SubjectMatchRule_objc_method)
Index: cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
===
--- cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
+++ cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
@@ -29,7 +29,11 @@
 
 @interface E
 @end
-// expected-error@+1 {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}}
+
 __attribute__((objc_nonlazy_class))
 @implementation E
 @end
+
+__attribute__((objc_nonlazy_class))
+@implementation E (MyCat)
+@end
Index: cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
===
--- cfe/trunk/test/CodeGenObjC/no

[PATCH] D60542: Add support for attributes on @implementations in Objective-C

2019-04-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358200: Add support for attributes on @implementations in 
Objective-C (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60542?vs=194594&id=194716#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60542

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseObjc.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclObjC.cpp
  test/FixIt/fixit-pragma-attribute.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Parser/attributes.mm
  test/Parser/objc-implementation-attrs.m
  test/Parser/placeholder-recovery.m
  test/Sema/pragma-attribute-strict-subjects.c
  test/SemaObjC/attr-objc-non-lazy.m
  test/SemaObjC/objc-asm-attribute-neg-test.m

Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -1892,7 +1892,8 @@
 Decl *Sema::ActOnStartCategoryImplementation(
   SourceLocation AtCatImplLoc,
   IdentifierInfo *ClassName, SourceLocation ClassLoc,
-  IdentifierInfo *CatName, SourceLocation CatLoc) {
+  IdentifierInfo *CatName, SourceLocation CatLoc,
+  const ParsedAttributesView &Attrs) {
   ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
   ObjCCategoryDecl *CatIDecl = nullptr;
   if (IDecl && IDecl->hasDefinition()) {
@@ -1920,6 +1921,9 @@
 CDecl->setInvalidDecl();
   }
 
+  ProcessDeclAttributeList(TUScope, CDecl, Attrs);
+  AddPragmaAttributes(TUScope, CDecl);
+
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(CDecl);
 
@@ -1955,7 +1959,8 @@
   SourceLocation AtClassImplLoc,
   IdentifierInfo *ClassName, SourceLocation ClassLoc,
   IdentifierInfo *SuperClassname,
-  SourceLocation SuperClassLoc) {
+  SourceLocation SuperClassLoc,
+  const ParsedAttributesView &Attrs) {
   ObjCInterfaceDecl *IDecl = nullptr;
   // Check for another declaration kind with the same name.
   NamedDecl *PrevDecl
@@ -2049,6 +2054,9 @@
 ObjCImplementationDecl::Create(Context, CurContext, IDecl, SDecl,
ClassLoc, AtClassImplLoc, SuperClassLoc);
 
+  ProcessDeclAttributeList(TUScope, IMPDecl, Attrs);
+  AddPragmaAttributes(TUScope, IMPDecl);
+
   if (CheckObjCDeclScope(IMPDecl))
 return ActOnObjCContainerStartDefinition(IMPDecl);
 
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -64,7 +64,7 @@
   case tok::objc_protocol:
 return ParseObjCAtProtocolDeclaration(AtLoc, Attrs);
   case tok::objc_implementation:
-return ParseObjCAtImplementationDeclaration(AtLoc);
+return ParseObjCAtImplementationDeclaration(AtLoc, Attrs);
   case tok::objc_end:
 return ParseObjCAtEndDeclaration(AtLoc);
   case tok::objc_compatibility_alias:
@@ -2097,7 +2097,8 @@
 ///   objc-category-implementation-prologue:
 /// @implementation identifier ( identifier )
 Parser::DeclGroupPtrTy
-Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
+Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
+ ParsedAttributes &Attrs) {
   assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
  "ParseObjCAtImplementationDeclaration(): Expected @implementation");
   CheckNestedObjCContexts(AtLoc);
@@ -2174,8 +2175,7 @@
 /*consumeLastToken=*/true);
 }
 ObjCImpDecl = Actions.ActOnStartCategoryImplementation(
-AtLoc, nameId, nameLoc, categoryId,
-categoryLoc);
+AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
 
   } else {
 // We have a class implementation
@@ -2189,8 +2189,7 @@
   superClassLoc = ConsumeToken(); // Consume super class name
 }
 ObjCImpDecl = Actions.ActOnStartClassImplementation(
-AtLoc, nameId, nameLoc,
-superClassId, superClassLoc);
+AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
 
 if (Tok.is(tok::l_brace)) // we have ivars
   ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -980,9 +980,10 @@
   if (getLangOpts().ObjC && Tok.is(tok::at)) {
 SourceLocation AtLoc = ConsumeToken(); // the "@"
 if (!Tok.isObjCAtKeyword

r358200 - Add support for attributes on @implementations in Objective-C

2019-04-11 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Apr 11 10:55:30 2019
New Revision: 358200

URL: http://llvm.org/viewvc/llvm-project?rev=358200&view=rev
Log:
Add support for attributes on @implementations in Objective-C

We want to make objc_nonlazy_class apply to implementations, but ran into this.
There doesn't seem to be any reason that this isn't supported.

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

Added:
cfe/trunk/test/Parser/objc-implementation-attrs.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/FixIt/fixit-pragma-attribute.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/test/Parser/attributes.mm
cfe/trunk/test/Parser/placeholder-recovery.m
cfe/trunk/test/Sema/pragma-attribute-strict-subjects.c
cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
cfe/trunk/test/SemaObjC/objc-asm-attribute-neg-test.m

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=358200&r1=358199&r2=358200&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Apr 11 10:55:30 2019
@@ -419,6 +419,10 @@ def SubjectMatcherForObjCCategory : Attr
[ObjCCategory]> {
   let LangOpts = [ObjC];
 }
+def SubjectMatcherForObjCImplementation :
+AttrSubjectMatcherRule<"objc_implementation", [ObjCImpl]> {
+  let LangOpts = [ObjC];
+}
 def SubjectMatcherForObjCMethod : AttrSubjectMatcherRule<"objc_method",
  [ObjCMethod], [
   AttrSubjectMatcherSubRule<"is_instance", [ObjCInstanceMethod]>

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=358200&r1=358199&r2=358200&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Apr 11 10:55:30 
2019
@@ -433,7 +433,7 @@ def err_objc_expected_property_attr : Er
 def err_objc_properties_require_objc2 : Error<
   "properties are an Objective-C 2 feature">;
 def err_objc_unexpected_attr : Error<
-  "prefix attribute must be followed by an interface or protocol">;
+  "prefix attribute must be followed by an interface, protocol, or 
implementation">;
 def err_objc_postfix_attribute : Error <
   "postfix attributes are not allowed on Objective-C directives">;
 def err_objc_postfix_attribute_hint : Error <

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=358200&r1=358199&r2=358200&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Apr 11 10:55:30 2019
@@ -1573,7 +1573,8 @@ private:
   ObjCImplParsingDataRAII *CurParsedObjCImpl;
   void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
 
-  DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc);
+  DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
+  ParsedAttributes &Attrs);
   DeclGroupPtrTy ParseObjCAtEndDeclaration(SourceRange atEnd);
   Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
   Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=358200&r1=358199&r2=358200&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 11 10:55:30 2019
@@ -8105,17 +8105,19 @@ public:
   const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
   const ParsedAttributesView &AttrList);
 
-  Decl *ActOnStartClassImplementation(
-SourceLocation AtClassImplLoc,
-IdentifierInfo *ClassName, SourceLocation ClassLoc,
-IdentifierInfo *SuperClassname,
-SourceLocation SuperClassLoc);
+  Decl *ActOnStartClassImplementation(SourceLocation AtClassImplLoc,
+  IdentifierInfo *ClassName,
+  SourceLocation ClassLoc,
+  IdentifierInfo *SuperClassname,
+  SourceL

r358201 - Support objc_nonlazy_class attribute on Objective-C implementations

2019-04-11 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Apr 11 10:55:34 2019
New Revision: 358201

URL: http://llvm.org/viewvc/llvm-project?rev=358201&view=rev
Log:
Support objc_nonlazy_class attribute on Objective-C implementations

Fixes rdar://49523079

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=358201&r1=358200&r2=358201&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Apr 11 10:55:34 2019
@@ -1767,7 +1767,7 @@ def ObjCRootClass : InheritableAttr {
 
 def ObjCNonLazyClass : Attr {
   let Spellings = [Clang<"objc_nonlazy_class">];
-  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Subjects = SubjectList<[ObjCInterface, ObjCImpl], ErrorDiag>;
   let LangOpts = [ObjC];
   let Documentation = [ObjCNonLazyClassDocs];
 }

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=358201&r1=358200&r2=358201&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Apr 11 10:55:34 2019
@@ -3711,14 +3711,14 @@ ensure that this class cannot be subclas
 def ObjCNonLazyClassDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
-This attribute can be added to an Objective-C ``@interface`` declaration to
-add the class to the list of non-lazily initialized classes. A non-lazy class
-will be initialized eagerly when the Objective-C runtime is loaded.  This is
-required for certain system classes which have instances allocated in
-non-standard ways, such as the classes for blocks and constant strings.  Adding
-this attribute is essentially equivalent to providing a trivial `+load` method 
-but avoids the (fairly small) load-time overheads associated with defining and
-calling such a method.
+This attribute can be added to an Objective-C ``@interface`` or
+``@implementation`` declaration to add the class to the list of non-lazily
+initialized classes. A non-lazy class will be initialized eagerly when the
+Objective-C runtime is loaded. This is required for certain system classes 
which
+have instances allocated in non-standard ways, such as the classes for blocks
+and constant strings. Adding this attribute is essentially equivalent to
+providing a trivial `+load` method but avoids the (fairly small) load-time
+overheads associated with defining and calling such a method.
   }];
 }
 

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=358201&r1=358200&r2=358201&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Apr 11 10:55:34 2019
@@ -6262,7 +6262,8 @@ CGObjCNonFragileABIMac::BuildClassObject
 bool CGObjCNonFragileABIMac::ImplementationIsNonLazy(
 const ObjCImplDecl *OD) const {
   return OD->getClassMethod(GetNullarySelector("load")) != nullptr ||
- OD->getClassInterface()->hasAttr();
+ OD->getClassInterface()->hasAttr() ||
+ OD->hasAttr();
 }
 
 void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl 
*OID,

Modified: cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/non-lazy-classes.m?rev=358201&r1=358200&r2=358201&view=diff
==
--- cfe/trunk/test/CodeGenObjC/non-lazy-classes.m (original)
+++ cfe/trunk/test/CodeGenObjC/non-lazy-classes.m Thu Apr 11 10:55:34 2019
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class 
-emit-llvm -o - %s | \
-// RUN: FileCheck %s
-// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [2 x 
{{.*}}]{{.*}}@"OBJC_CLASS_$_A"{{.*}},{{.*}}@"OBJC_CLASS_$_D"{{.*}} section 
"__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
-// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [1 x {{.*}}] 
{{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}}, section 
"__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class 
-emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [3 x 
{{.*}}]{{.*}}@"OBJC_CLASS_$_A"{{.*}},{{.*}}@"OBJC_CLASS_$_D"{{.*}},{{.*}}"OBJC_CLASS_$_E"{{

[PATCH] D60544: Support objc_nonlazy_class attribute on Objective-C implementations

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Great, SGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60544



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


[PATCH] D60548: Variable auto-init: also auto-init alloca

2019-04-11 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

I probably wouldn't do anything about suppressing init on alloca for now, but 
if we did do something I think I'd be in favour of the separate builtin for 
uninitialized alloca. I also considered the alternative of allowing 
`__attribute__((uninitialized))` to appear on a function or block statement, 
but it seemed clearer for the uninitialized-ness to be as close to the alloca 
as possible.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60548



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


[PATCH] D60542: Add support for attributes on @implementations in Objective-C

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/FixIt/fixit-pragma-attribute.cpp:19-20
 #pragma clang attribute push 
(__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, 
variable(is_parameter), function(is_member), variable(is_global)))
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:108-[[@LINE-1]]:132}:""
-// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:153-[[@LINE-2]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:153-[[@LINE-1]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:108-[[@LINE-2]]:132}:""
 

erik.pilkington wrote:
> aaron.ballman wrote:
> > Any idea why this swapped?
> Its because I added a new subject match rule in Attr.td, and the match rules 
> enumerators are being stored in a DenseMap in 
> Sema::ActOnPragmaAttributeAttribute. I think we should make that a std::map 
> or something so this test is less fragile.
Ah, that makes sense, thank you. Yeah, using an ordered container may be a 
better approach to reduce fragility.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60542



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


[PATCH] D60544: Support objc_nonlazy_class attribute on Objective-C implementations

2019-04-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In D60544#1462869 , @rjmccall wrote:

> Should we have a special `has_feature` test to check that this attribute is 
> allowed on implementations?  We've done that in the past when expanding the 
> set of subjects for an attribute.  But that's not necessary if we haven't 
> made this attribute part of a public Xcode release yet, because then the 
> attribute is just understood to always apply to implementations; I can't 
> remember when exactly this was added and what releases it's made it into.


I think we can sneak by without a `__has_feature` for this, D56555 
 isn't in LLVM 8 nor Xcode 10.2.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60544



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


[PATCH] D55411: [clang-tidy] check for flagging using declarations not in the inner most namespace

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/abseil/SafelyScopedCheck.cpp:37
+  diag(MatchedDecl->getLocation(),
+   "using declaration %0 not declared in the innermost namespace.")
+  << MatchedDecl;

You should remove the full stop at the end of the diagnostic.



Comment at: test/clang-tidy/abseil-safely-scoped.cpp:15-16
+} // namespace foo1
+// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: using declaration 'A' not
+// declared in the innermost namespace. [abseil-safely-scoped]
+

This should be moved closer to where the actual warning will show up.

However, the diagnostic doesn't help me to understand what is wrong with the 
code or how to fix it. I think it might be telling me that the using 
declaration is supposed to be inside of the anonymous namespace, but moving the 
using declaration there will break the declaration of `f()`.


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

https://reviews.llvm.org/D55411



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


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D60151#1462976 , @hintonda wrote:

> In D60151#1462850 , @MyDeveloperDay 
> wrote:
>
> > are we supporting "-llvm-*" in existing .clang-tidy files?
> >
> > If people selectively turn checkers off, won't all of a sudden everyone 
> > start getting llvm-project checks and fixes turned back on?
> >
> > https://github.com/search?q=-llvm-%2A&type=Code
> >
> > maybe we need to add something like:
> >
> >   llvm-header-guard (redirects to llvm-project-header-guard) 
> > 
> >   llvm-header-include-order (redirects to llvm-project-include-order) 
> > 
> >   llvm-header-namespace-comment(redirects to 
> > llvm-project-namespace-comment) 
> >   llvm-header-twine-local(redirects to llvm-project-twine-local) 
> > 
> >  
> >
>
>
> I suppose we could keep the names and directory structure and just change the 
> namespace.  That would just be a special case in the scripts.  Haven't looked 
> into it yet, but will do so as soon as I can.


Isn't that matching done on strings? I.e. is there difference between `-llvm-*` 
and `-ll*` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60542: Add support for attributes on @implementations in Objective-C

2019-04-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington marked an inline comment as done.
erik.pilkington added inline comments.



Comment at: clang/test/FixIt/fixit-pragma-attribute.cpp:19-20
 #pragma clang attribute push 
(__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, 
variable(is_parameter), function(is_member), variable(is_global)))
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:108-[[@LINE-1]]:132}:""
-// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:153-[[@LINE-2]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:153-[[@LINE-1]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:108-[[@LINE-2]]:132}:""
 

aaron.ballman wrote:
> Any idea why this swapped?
Its because I added a new subject match rule in Attr.td, and the match rules 
enumerators are being stored in a DenseMap in 
Sema::ActOnPragmaAttributeAttribute. I think we should make that a std::map or 
something so this test is less fragile.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60542



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


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In D60151#1462850 , @MyDeveloperDay 
wrote:

> are we supporting "-llvm-*" in existing .clang-tidy files?
>
> If people selectively turn checkers off, won't all of a sudden everyone start 
> getting llvm-project checks and fixes turned back on?
>
> https://github.com/search?q=-llvm-%2A&type=Code
>
> maybe we need to add something like:
>
>   llvm-header-guard (redirects to llvm-project-header-guard) 
> 
>   llvm-header-include-order (redirects to llvm-project-include-order) 
> 
>   llvm-header-namespace-comment(redirects to llvm-project-namespace-comment) 
> 
>   llvm-header-twine-local(redirects to llvm-project-twine-local) 
> 
>  
>


I suppose we could keep the names and directory structure and just change the 
namespace.  That would just be a special case in the scripts.  Haven't looked 
into it yet, but will do so as soon as I can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60507: [clang-tidy] new check: bugprone-unhandled-self-assignment

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst:10
+
+This check corresponds to the CERT C++ Coding Standard rule
+`OOP54-CPP. Gracefully handle self-copy assignment

Eugene.Zelenko wrote:
> alexfh wrote:
> > JonasToth wrote:
> > > It is worth an alias into the cert module. Please add this with this 
> > > revision already.
> > Please add a corresponding alias into the cert module.
> See also other aliased checks for documentation examples.
I kind of wonder whether we want it as an alias in the CERT module or just move 
it into the CERT module directly (and maybe provide an alias to bugprone, if we 
think the fp rate is reasonable enough).


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60507



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


[PATCH] D55409: [clang-tidy] check for using declarations not in an anonymous namespace when there exists one

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp:41
+// to the vector containing all candidate using declarations.
+if (AnonymousNamespaceDecl) {
+   diag(MatchedUsingDecl->getLocation(),

Naysh wrote:
> aaron.ballman wrote:
> > I don't think this logic works in practice because there's no way to 
> > determine that the anonymous namespace is even a candidate for putting the 
> > using declaration into it. Consider a common scenario where there's an 
> > anonymous namespace declared in a header file (like an STL header outside 
> > of the user's control), and a using declaration inside of an implementation 
> > file. Just because the STL declared an anonymous namespace doesn't mean 
> > that the user could have put their using declaration in it.
> If we altered the check to only apply to anonymous namespaces and using 
> declarations at namespace scope (that is, we only suggest aliases be moved to 
> anonymous namespaces when the unnamed namespace and alias are themselves 
> inside some other namespace), would this issue be resolved? 
If they're inside the same namespace, then I think that could work, but if the 
namespaces are different I don't know that you can be sure the alias can be 
moved into the anonymous namespace.


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

https://reviews.llvm.org/D55409



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


[PATCH] D60543: [clang] Add matcher for subclasses of Objective-C interfaces 🔍

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:1479
+/// \endcode
+AST_MATCHER_P(ObjCInterfaceDecl, isSubclassOfInterface,
+  internal::Matcher,

stephanemoore wrote:
> I am still uncertain about the naming.
> 
> `isSubclassOf` seemed too generic as that could apply to C++ classes.
> `objcIsSubclassOf` seemed unconventional as a matcher name.
> `isSubclassOfObjCInterface` and `isSubclassOfObjCClass` seemed awkwardly 
> lengthy.
> Creating a new namespace `clang::ast_matchers::objc` seemed unprecedented.
> 
> I am happy to change the name if you think another name would be more 
> appropriate.
Does ObjC use the term "derived" by any chance? We already have 
`isDerivedFrom`, so I'm wondering if we can use that to also match on an 
`ObjCInterfaceDecl`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


[libunwind] r358191 - [NFC] Correct outdated links to the Itanium C++ ABI documentation

2019-04-11 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Thu Apr 11 09:37:07 2019
New Revision: 358191

URL: http://llvm.org/viewvc/llvm-project?rev=358191&view=rev
Log:
[NFC] Correct outdated links to the Itanium C++ ABI documentation

Those are now hosted on GitHub.

rdar://problem/36557462

Modified:
libunwind/trunk/include/unwind.h
libunwind/trunk/src/UnwindLevel1.c

Modified: libunwind/trunk/include/unwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/unwind.h?rev=358191&r1=358190&r2=358191&view=diff
==
--- libunwind/trunk/include/unwind.h (original)
+++ libunwind/trunk/include/unwind.h Thu Apr 11 09:37:07 2019
@@ -6,7 +6,7 @@
 //
 //
 // C++ ABI Level 1 ABI documented at:
-//   http://mentorembedded.github.io/cxx-abi/abi-eh.html
+//   https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
 //
 
//===--===//
 

Modified: libunwind/trunk/src/UnwindLevel1.c
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindLevel1.c?rev=358191&r1=358190&r2=358191&view=diff
==
--- libunwind/trunk/src/UnwindLevel1.c (original)
+++ libunwind/trunk/src/UnwindLevel1.c Thu Apr 11 09:37:07 2019
@@ -6,7 +6,7 @@
 //
 //
 // Implements C++ ABI Exception Handling Level 1 as documented at:
-//  http://mentorembedded.github.io/cxx-abi/abi-eh.html
+//  https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
 // using libunwind
 //
 
//===--===//


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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1000
+def SYCLDevice : InheritableAttr {
+  let Spellings = [GNU<"sycl_device">];
+  let Subjects = SubjectList<[Function, Var]>;

keryell wrote:
> Fznamznon wrote:
> > aaron.ballman wrote:
> > > Is there a reason to not also introduce a C++11 and C2x style spelling in 
> > > the `clang` namespace? e.g., `[[clang::sycl_device]]`
> > I don't think that it makes sense because these attributes not for public 
> > consumption. These attributes is needed to separate code which is supposed 
> > to be offloaded from regular host code. I think SYCLDevice attribute 
> > actually doesn't need a spelling because it will be added only implicitly 
> > by compiler.
> 
> If we go towards this direction, `[[clang::sycl::device]]` or 
> `[[clang::sycl::kernel]]` look more compatible with the concept of name space.
> While not a public interface, if we have a kind of "standard" outlining in 
> Clang/LLVM, some people might want to use it in some other contexts too.
If these are only being added implicitly by the compiler, then they should not 
be given any `Spelling`. See `AlignMac68k` for an example.



Comment at: clang/include/clang/Basic/Attr.td:1003
+  let LangOpts = [SYCL];
+  let Documentation = [Undocumented];
+}

keryell wrote:
> Fznamznon wrote:
> > aaron.ballman wrote:
> > > No new, undocumented attributes, please.
> > As I said, these attributes are not for public consumption. Should I add 
> > documentation in this case too?
> Yes, documentation and comments are always appreciated.
If the attribute is only ever added implicitly and the user cannot spell it in 
any way, then I think it's reasonable to elide the documentation. It's an 
implementation detail at that point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp:125
+diag(MatchedDecl->getBeginLoc(),
+ "isa_and_nonnull<> is cleaner and more efficient")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

How about `'isa_and_nonnull<>' is preferred over an explicit test for null 
followed by calling 'isa<>'`?



Comment at: 
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h:37-39
+///  if (var && isa(var)) {}
+///  // is replaced by:
+///  if (dyn_cast_or_null(var.foo())) {}

I think this comment is now out of date.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-04-11 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D54881#1462893 , @MyDeveloperDay 
wrote:

> > I agree and would be happy with the change if it would only change the 
> > line-filtered workflow, but this afaict (unless I'm missing something :) 
> > will also affect the workflow where the provided range is 0-length range, 
> > which has an implicit "format stuff around this" request from the user 
> > inside it. I'd be happy with a patch that differentiates these two sides.
>
> This use case needs capturing in a unit test..it isn't obvious


Agreed!


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

https://reviews.llvm.org/D54881



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2576
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {
-  getOpenMPRuntime().checkArchForUnifiedAddressing(D);
 }

You don't need to pass the reference to CodeGenModule to CGOpenMPRuntime class, 
it handles a reference to the CodeGenMode already.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:726
 
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.

You must use `LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();` and 
`LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */)` from 
`clang/Basic/BitmaskEnum.h` to enable bit operations on your new bit-arithmetic 
based enumeric.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:726
 
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.

ABataev wrote:
> You must use `LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();` and 
> `LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */)` from 
> `clang/Basic/BitmaskEnum.h` to enable bit operations on your new 
> bit-arithmetic based enumeric.
Add a comment for the whole new type



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:728
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.

You should not handle all the possible flags for the requires directives, since 
you try to support only target-specific flags.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2322
+auto *FnTy =
+llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg*/ false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_register_requires");

Function return type must be `void`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3870
 llvm::Function *
+CGOpenMPRuntime::createRequiresDirectiveRegistration() {
+  // If we don't have entries or if we are emitting code for the device, we

Why do you need a new member function? Can you make a static local function?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3882
+const auto &FI =
+CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, {});
+llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FI);

Use `getTypes().arrangeNullaryFunction()`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3887
+CGF.StartFunction(GlobalDecl(), C.VoidTy, RequiresRegFn, FI, {});
+int64_t Flags = OMP_REQ_NONE;
+//TODO: check for other requires clauses.

Use `OpenMPOffloadingRequiresDirFlags` instead of `int64_t`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7983
 MapFlagsArrayTy &Types) const {
+// If using unified memory, no need to do the mappings.
+if (CGF.CGM.HasRequiresUnifiedSharedMemory)

Seems to me, this must be in another patch, has nothing to do with this patch



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9069
 
+llvm::Function *CGOpenMPRuntime::emitRequiresDirectiveRegFun() {
+  // Create and register the function that handles the requires directives.

Why do you need the second function?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:4946
+CodeGenModule &CGM, const OMPRequiresDecl *D) const {
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(CGM, D);
   for (const OMPClause *Clause : D->clauselists()) {

Call this function after the target-specific processing.



Comment at: lib/CodeGen/CodeGenModule.h:294
 
+  bool HasRequiresUnifiedSharedMemory = false;
+

Why public? Must be private. Also, add comments for this new data member.
Also, I don't think this must be in CGM. It must be a member of CGOpenMPRuntime 
class.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D59605: [clangd] Introduce background-indexer

2019-04-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

To make it clear, I think the question is not just "which part of functionality 
is missing in BackgroundIndex", it's rather "which part of BackgroundIndex we 
**don't** need".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59605



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-11 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 194708.
hintonda added a comment.

- Add unittest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/test/Support/check-default-options.txt
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,74 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  Bar = "";
+  Foo = false;
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  Bar = "";
+  Foo = false;
+  SC1_B = false;
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), &llvm::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/test/Support/check-default-options.txt
===
--- /dev/null
+++ llvm/test/Support/check-default-options.txt
@@ -0,0 +1,18 @@
+# RUN: llvm-objdump -help-hidden %t | FileCheck --check-prefix=CHECK-OBJDUMP %s
+# RUN: llvm-readobj -help-hidden %t | FileCheck --check-prefix=CHECK-READOBJ %s
+# RUN: llvm-tblgen -help-hidden %t | FileCheck --check-prefix=CHECK-TBLGEN %s
+# RUN: llvm-opt-report -help-hidden %t | FileCheck --check-prefix=CHECK-OPT-RPT %s
+# RUN: llvm-dwarfdump -help-hidden %t | FileCheck --check-prefix=CHECK-DWARF %s
+# RUN: llvm-dwarfdump -h %t | FileCheck --check-prefix=CHECK-DWARF-H %s
+
+
+# CHECK-OBJDUMP: -h  - Alias for --section-headers
+# CHECK-READOBJ: -h  - Alias for --file-headers
+# CHECK-TBLGEN:  -h  - Alias for -help
+# CHECK-OPT-RPT: -h  -

[PATCH] D59605: [clangd] Introduce background-indexer

2019-04-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a subscriber: sammccall.
ilya-biryukov added a comment.

To reiterate the offline discussion: the tool seems useful to me, but it would 
be best to keep the client code simpler, it's currently fighting with 
`BackgroundIndex` because it's trying to hijack some of its functionality.
More specifically, I propose to add a function to `BackgroundIndex.h` that 
would be a one-shot update of the index, the client code would become 
significantly simpler and we would have more flexibility in how we move code 
around in `BackgroundIndex.cpp` to actually make this happen.

Adding @sammccall, who might also be interested in this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59605



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


[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-04-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> I agree and would be happy with the change if it would only change the 
> line-filtered workflow, but this afaict (unless I'm missing something :) will 
> also affect the workflow where the provided range is 0-length range, which 
> has an implicit "format stuff around this" request from the user inside it. 
> I'd be happy with a patch that differentiates these two sides.

This use case needs capturing in a unit test..it isn't obvious


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

https://reviews.llvm.org/D54881



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


[PATCH] D60544: Support objc_nonlazy_class attribute on Objective-C implementations

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

LGTM, modulo the `__has_feature` question.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60544



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


[PATCH] D60542: Add support for attributes on @implementations in Objective-C

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from a question.




Comment at: clang/test/FixIt/fixit-pragma-attribute.cpp:19-20
 #pragma clang attribute push 
(__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, 
variable(is_parameter), function(is_member), variable(is_global)))
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:108-[[@LINE-1]]:132}:""
-// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:153-[[@LINE-2]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:153-[[@LINE-1]]:172}:""
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:108-[[@LINE-2]]:132}:""
 

Any idea why this swapped?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60542



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


[PATCH] D60544: Support objc_nonlazy_class attribute on Objective-C implementations

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Should we have a special `has_feature` test to check that this attribute is 
allowed on implementations?  We've done that in the past when expanding the set 
of subjects for an attribute.  But that's not necessary if we haven't made this 
attribute part of a public Xcode release yet, because then the attribute is 
just understood to always apply to implementations; I can't remember when 
exactly this was added and what releases it's made it into.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60544



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


[PATCH] D59605: [clangd] Introduce background-indexer

2019-04-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added a comment.

Looking at the current state of `BackgroundIndex`, it has the following 
implementation details:

- Loading of shards from storage
- Storing of shards to storage
- Collecting symbols from a TU
- Sharding of symbol information collected from one translation unit
- Performing all these tasks in a thread pool that can change scheduling 
priority of the thread depending on the task running.

Our requirements from the tool that currently is not possible through 
`BackgroundIndex`:

- Running tasks without lowering scheduling priority
- Blocking until all of the indexing actions finishes

I believe we can achive the first one by adding some options. The second one is 
already possible but it is using a test method we implemented for tests, as you 
mentioned we can just change the name.
Of course the above mentioned solutions would imply exposing that functionality 
to every user of `BackgroundIndex`.

I feel like it is better than exposing rest of the implementation details I 
mentioned in the first section(and also would be a lot faster to implement). 
WDYT?




Comment at: clang-tools-extra/clangd/background-indexer/BackgroundIndexer.cpp:65
+  llvm::sys::path::append(DummyFile, "dummy.cpp");
+  CDB.getCompileCommand(DummyFile);
+

ilya-biryukov wrote:
> We seem to be fighting with the interface we defined here.
> If we need to support an operation of re-building the index for the 
> underlying CDB, let's add it explicitly.
I should've rather performed this through `enqueue`, will change to use that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59605



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


[PATCH] D60139: [clang-tidy] Add bugprone-placement-new-target-type-mismatch check

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D60139#1461269 , @DennisL wrote:

> In D60139#1460233 , @JonasToth wrote:
>
> > Hey Dennis,
> >
> > my 2cents on the check. I think it is very good to have! Did you check 
> > coding guidelines if they say something to this issue? (e.g. 
> > cppcoreguidelines, hicpp, cert) As we have modules for them it would be 
> > great to make aliases to this check if they demand this to be checked.
>
>
> Thanks for the great suggestions. Updated the diff according to the feedback. 
> Also checked with cppcoreguidelines, hicpp as well as cert. Only cert has a 
> related, yet different rule 
> 
>  stating that calls to placement new shall be provided with properly aligned 
> pointers. I'd say this should be a distinct check. Happy to work on it after 
> this one.


What is the rationale for separating those checks? It sort of feels like there 
is some overlap between alignment, size, and buffer type.

I'm not certain I agree with the way this check operates -- what problem is it 
trying to solve? For instance, this code would trigger on this check, but is 
perfectly valid code:

  static_assert(sizeof(int) == sizeof(float));
  static_assert(alignof(int) == alignof(float));
  int buffer;
  float *fp = new (&buffer) float;

The situations I can think of where the type mismatch is an issue would be for 
types with nontrivial special members, so there are times when this check makes 
sense, but perhaps it's too restrictive currently, but you may have a different 
problem in mind?




Comment at: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.cpp:20
+namespace {
+AST_MATCHER(Expr, isPlacementNewExpr) {
+  const auto *NewExpr = dyn_cast(&Node);

This should match on `CXXNewExpr` instead of `Expr`, then you won't need the 
`dyn_cast` below.



Comment at: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.cpp:29
+  Finder->addMatcher(
+  expr(isPlacementNewExpr(), unless(hasDescendant(unresolvedLookupExpr(
+  .bind("NewExpr"),

This should probably use `cxxNewExpr()` instead of `expr()` so you match on 
something more specific.



Comment at: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.cpp:38
+  assert(NewExpr && "Matched node bound by 'NewExpr' shoud be a 'CXXNewExpr'");
+  assert(NewExpr->getNumPlacementArgs() != 0 && "");
+

This assert message looks a bit incomplete. ;-)



Comment at: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.cpp:43
+  assert(PlacementExpr != nullptr && "PlacementExpr should not be null");
+  const CastExpr *Cast = dyn_cast(PlacementExpr);
+  if (Cast == nullptr)

You can use `const auto *` here.



Comment at: test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp:56
+  new (ptr) float[13];
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new parameter and 
allocated type mismatch [bugprone-placement-new-target-type-mismatch]
+}

While this code definitely has a bug from the buffer overflow, I don't think 
the diagnostic is valuable here. This is a very common pattern and I suspect 
this will yield a lot of false positives, unless the check starts taking 
alignment and buffer size into consideration.


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

https://reviews.llvm.org/D60139



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


[PATCH] D60542: Add support for attributes on @implementations in Objective-C

2019-04-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60542



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


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

are we supporting "-llvm-*" in existing .clang-tidy files?

If people selectively turn checkers off, won't all of a sudden everyone start 
getting llvm-project checks and fixes turned back on?

https://github.com/search?q=-llvm-%2A&type=Code

maybe we need to add something like:

  llvm-header-guard (redirects to llvm-project-header-guard) 
  llvm-header-include-order (redirects to llvm-project-include-order) 

  llvm-header-namespace-comment(redirects to llvm-project-namespace-comment) 

  llvm-header-twine-local(redirects to llvm-project-twine-local) 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, AlexEichenberger, caomhin.
Herald added subscribers: cfe-commits, jdoerfert, jfb, guansong, jholewinski.
Herald added a project: clang.

This patch adds support for the registration of the requires directives with 
the runtime.

Each requires directive clause will enable a particular flag to be set.

The set of flags is passed to the runtime to be checked for compatibility with 
other such flags coming from other object files.

The registration function is called whenever OpenMP is present even if a 
requires directive is not present. This helps detect cases in which requires 
directives are used inconsistently.


Repository:
  rC Clang

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call i32 @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare i32 @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -291,6 +291,8 @@
 
   typedef std::vector CtorList;
 
+  bool HasRequiresUnifiedSharedMemory = false;
+
 private:
   ASTContext &Context;
   const LangOptions &LangOpts;
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0, nullptr);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -383,7 +383,8 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const override;
+  void checkArchForUnifiedAddressing(CodeGenModule &CGM,
+ const OMPRequiresDecl *D) const override;
 
   /// Returns default address space for the constant firstprivates, __constant__
   /// address space by default.
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4942,7 +4942,8 @@
 /// Check to see if target architecture supports unified addressing which is
 /// a restriction for OpenMP requires clause "unified_shared_memory".
 void CGOpenMPRuntimeNVPTX::checkArchForUnifiedAddressing(
-const OMPRequiresDecl *D) const {
+CodeGenModule &CGM, const OMPRequiresDecl *D) const {
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(CGM, D);
   for (const OMPClause *Clause : D->clauselists()) {
 if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
   switch (getCudaArch(CGM)) {
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpen

[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-04-11 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D54881#1462804 , @russellmcc wrote:

> Thanks for the explanation!  I do understand your philosophy on this, and 
> agree with the desired behavior case you brought up where you have put in new 
> braces.
>
> After thinking about this more, the thing I really care about is that 
> clang-format is idempotent with a line filter - i.e., running it twice should 
> always have the same effect as running it once.
>
> So, either this fix, or your proposed fix of fixing all lines until the next 
> correct indentation would meet that idempotence criteria.
>
> However, I think in this particular case I still prefer my fix - to me, line 
> filter is meant to limit the effect of clang-format to just fix a particular 
> change and the fallout from that.  However, if the lines _after_ a change 
> were wrong before, this feels very unrelated to the change that was made - 
> why is now the time to fix these unrelated lines?


I agree and would be happy with the change if it would only change the 
line-filtered workflow, but this afaict (unless I'm missing something :) will 
also affect the workflow where the provided range is 0-length range, which has 
an implicit "format stuff around this" request from the user inside it. I'd be 
happy with a patch that differentiates these two sides.


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

https://reviews.llvm.org/D54881



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


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D60151#1454802 , @hintonda wrote:

> In D60151#1454741 , @alexfh wrote:
>
> > In D60151#1454105 , @hintonda 
> > wrote:
> >
> > > - Rename llvm directory to llvm_project.
> > > - Change llvm- to llvm-project-.
> > > - Rename files.
> >
> >
> > Awesome! Thanks for doing this. Could you ensure that the add_new_check.py 
> > script still works?
>
>
> Thanks for mentioning this.  Found a missing rename discovered by 
> add_new_check.py which I'll checkin shortly.  However, I'm not sure how best 
> to solve a rename issue.
>
> In rename_check.py, module names can't be hyphenated, e.g.:
>
>   190:  old_module = args.old_check_name.split('-')[0]
>   191:  new_module = args.new_check_name.split('-')[0]
>   
>
> If we keep this pattern, then "llvm-project" won't work.  It would need to be 
> something like "llvmproject" or something else.  Please let me know your 
> preference.


Hmm, that's unfortunate behavior. I guess my preference would be to go with 
`llvm_project`, but it's not a strong preference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-04-11 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Thanks for the explanation!  I do understand your philosophy on this, and agree 
with the desired behavior case you brought up where you have put in new braces.

After thinking about this more, the thing I really care about is that 
clang-format is idempotent with a line filter - i.e., running it twice should 
always have the same effect as running it once.

So, either this fix, or your proposed fix of fixing all lines until the next 
correct indentation would meet that idempotence criteria.

However, I think in this particular case I still prefer my fix - to me, line 
filter is meant to limit the effect of clang-format to just fix a particular 
change and the fallout from that.  However, if the lines _after_ a change were 
wrong before, this feels very unrelated to the change that was made - why is 
now the time to fix these unrelated lines?


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

https://reviews.llvm.org/D54881



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


[PATCH] D59639: [clangd] Print template arguments helper

2019-04-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:139
+  // location information.
+  printTemplateArgumentList(OS, Cls->getTemplateArgs().asArray(), Policy);
+}

ioeric wrote:
> Could you also add a test case for this with the current behavior and a FIXME?
Adding the test case, but the problem is there wouldn't be a change in 
behavior(at least not in the cases that I can think of) since a full 
specialization doesn't have any dependent types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59639



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


[PATCH] D59639: [clangd] Print template arguments helper

2019-04-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 194686.
kadircet marked 6 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59639

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/FindSymbolsTests.cpp
  clang-tools-extra/unittests/clangd/PrintASTTests.cpp
  clang/lib/AST/TypePrinter.cpp

Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1632,6 +1632,19 @@
   return A.getArgument();
 }
 
+static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP,
+  llvm::raw_ostream &OS) {
+  A.print(PP, OS);
+}
+
+static void printArgument(const TemplateArgumentLoc &A,
+  const PrintingPolicy &PP, llvm::raw_ostream &OS) {
+  const TemplateArgument::ArgKind &Kind = A.getArgument().getKind();
+  if (Kind == TemplateArgument::ArgKind::Type)
+return A.getTypeSourceInfo()->getType().print(OS, PP);
+  return A.getArgument().print(PP, OS);
+}
+
 template
 static void printTo(raw_ostream &OS, ArrayRef Args,
 const PrintingPolicy &Policy, bool SkipBrackets) {
@@ -1653,7 +1666,8 @@
 } else {
   if (!FirstArg)
 OS << Comma;
-  Argument.print(Policy, ArgOS);
+  // Tries to print the argument with location info if exists.
+  printArgument(Arg, Policy, ArgOS);
 }
 StringRef ArgString = ArgOS.str();
 
Index: clang-tools-extra/unittests/clangd/PrintASTTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/PrintASTTests.cpp
@@ -0,0 +1,100 @@
+//===--- PrintASTTests.cpp - 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
+//
+//===--===//
+
+#include "AST.h"
+#include "Annotations.h"
+#include "Protocol.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest-param-test.h"
+#include "gtest/gtest.h"
+#include "gtest/internal/gtest-param-util-generated.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::ElementsAreArray;
+
+struct Case {
+  const char *AnnotatedCode;
+  std::vector Expected;
+};
+class ASTUtils : public testing::Test,
+ public ::testing::WithParamInterface {};
+
+TEST_P(ASTUtils, PrintTemplateArgs) {
+  auto Pair = GetParam();
+  Annotations Test(Pair.AnnotatedCode);
+  auto AST = TestTU::withCode(Test.code()).build();
+  struct Visitor : RecursiveASTVisitor {
+Visitor(std::vector Points) : Points(std::move(Points)) {}
+bool VisitNamedDecl(const NamedDecl *ND) {
+  auto Pos = sourceLocToPosition(ND->getASTContext().getSourceManager(),
+ ND->getLocation());
+  if (Pos != Points[TemplateArgsAtPoints.size()])
+return true;
+  TemplateArgsAtPoints.push_back(printTemplateSpecializationArgs(*ND));
+  return true;
+}
+std::vector TemplateArgsAtPoints;
+const std::vector Points;
+  };
+  Visitor V(Test.points());
+  V.TraverseDecl(AST.getASTContext().getTranslationUnitDecl());
+  EXPECT_THAT(V.TemplateArgsAtPoints, ElementsAreArray(Pair.Expected));
+}
+
+INSTANTIATE_TEST_CASE_P(ASTUtilsTests, ASTUtils,
+testing::ValuesIn(std::vector({
+{
+R"cpp(
+  template  class Bar {};
+  template <> class ^Bar {};)cpp",
+{""}},
+{
+R"cpp(
+  template  class Bar {};
+  template  class Z, int Q>
+  struct Foo {};
+  template struct ^Foo;
+  template 
+  struct ^Foo {};)cpp",
+{"", ""}},
+{
+R"cpp(
+  template  void Foz() {};
+  template <> void ^Foz<3, 5, 8>() {};)cpp",
+{"<3, 5, 8>"}},
+{
+R"cpp(
+  template  class Bar {};
+  template  class ...>
+ 

[PATCH] D60561: [clang] fixing diagnostics of constexpr callstack

2019-04-11 Thread Gauthier via Phabricator via cfe-commits
Tyker updated this revision to Diff 194684.
Tyker added a comment.

@Quuxplusone  edited based of feedback

i simplified the test but didn't put the original because this one test 
arguments for variable and literal and there may be corner case differences


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

https://reviews.llvm.org/D60561

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp

Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1159,3 +1159,18 @@
 enum class InEnum3 {
   THREE = indirect_builtin_constant_p("abc")
 };
+
+constexpr int f1(int i) {
+  i -= 1;
+  return 1 << i; // expected-note {{negative shift count -2}}
+}
+
+constexpr int f2(int i) {
+  i -= 1;
+  // expected-note@+1 {{'f1(-1)}}
+  return f1(i);
+}
+
+// expected-error@+2 {{constant expression}}
+// expected-note@+1 {{'f2(0)}}
+constexpr int a = f2(0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -476,9 +476,14 @@
 const LValue *This;
 
 /// Arguments - Parameter bindings for this function call, indexed by
-/// parameters' function scope indices.
+/// parameters' function scope indices. may be modified by called function
 APValue *Arguments;
 
+/// ConstantArgs - Parameter bindings for this function call, indexed by
+/// parameters' function scope indices. can't be modified. used for
+/// diagnostics
+const APValue *ConstantArgs;
+
 // Note that we intentionally use std::map here so that references to
 // values are stable.
 typedef std::pair MapKeyTy;
@@ -519,7 +524,7 @@
 
 CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
-   APValue *Arguments);
+   APValue *Arguments, const APValue *ConstantArgs);
 ~CallStackFrame();
 
 // Return the temporary for Key whose version number is Version.
@@ -789,14 +794,15 @@
 bool checkingForOverflow() { return EvalMode == EM_EvaluateForOverflow; }
 
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
-  : Ctx(const_cast(C)), EvalStatus(S), CurrentCall(nullptr),
-CallStackDepth(0), NextCallIndex(1),
-StepsLeft(getLangOpts().ConstexprStepLimit),
-BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
-EvaluatingDecl((const ValueDecl *)nullptr),
-EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-HasFoldFailureDiagnostic(false), IsSpeculativelyEvaluating(false),
-InConstantContext(false), EvalMode(Mode) {}
+: Ctx(const_cast(C)), EvalStatus(S), CurrentCall(nullptr),
+  CallStackDepth(0), NextCallIndex(1),
+  StepsLeft(getLangOpts().ConstexprStepLimit),
+  BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr,
+  nullptr),
+  EvaluatingDecl((const ValueDecl *)nullptr),
+  EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
+  HasFoldFailureDiagnostic(false), IsSpeculativelyEvaluating(false),
+  InConstantContext(false), EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value) {
   EvaluatingDecl = Base;
@@ -1235,9 +1241,10 @@
 
 CallStackFrame::CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
-   APValue *Arguments)
+   APValue *Arguments, const APValue *CArgs)
 : Info(Info), Caller(Info.CurrentCall), Callee(Callee), This(This),
-  Arguments(Arguments), CallLoc(CallLoc), Index(Info.NextCallIndex++) {
+  Arguments(Arguments), ConstantArgs(CArgs), CallLoc(CallLoc),
+  Index(Info.NextCallIndex++) {
   Info.CurrentCall = this;
   ++Info.CallStackDepth;
 }
@@ -1679,7 +1686,7 @@
   Out << ", ";
 
 const ParmVarDecl *Param = *I;
-const APValue &Arg = Frame->Arguments[ArgIndex];
+const APValue &Arg = Frame->ConstantArgs[ArgIndex];
 Arg.printPretty(Out, Frame->Info.Ctx, Param->getType());
 
 if (ArgIndex == 0 && IsMemberCall)
@@ -4455,7 +4462,11 @@
   if (!Info.CheckCallLimit(CallLoc))
 return false;
 
-  CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data());
+  // ArgValues - may be modified by the called function.
+  // ConstantArgs - can't be modified by the called function
+  const ArgVector ConstantArgs(ArgValues.begin(), ArgValues.end());
+  CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data(),
+   ConstantArgs.data());
 
   // For a trivial copy or move assignment, perform an APValue copy. This is
   // 

  1   2   >