[PATCH] D44191: Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

2018-03-07 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi created this revision.
yamaguchi added reviewers: teemperor, v.g.vassilev.

--autocomplete flag now handles all the flags passed to shell, and this
implementation breaks backward compatibily before Clang 6.0.


https://reviews.llvm.org/D44191

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -71,6 +71,16 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 6.0, we passed "#" to --autocomplete flag to indicate to enable 
cc1
+  flags. For example, when -cc1 or -Xclang was passed to shell, shell executed 
clang
+  --autocomplete=#-. Clang 7.0 now passes all 
flags that
+  shell has, so that Clang can handle them internally which breaks backward 
compatibility
+  before Clang 6.0.
+
+
 New Pragmas in Clang
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -71,6 +71,16 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 6.0, we passed "#" to --autocomplete flag to indicate to enable cc1
+  flags. For example, when -cc1 or -Xclang was passed to shell, shell executed clang
+  --autocomplete=#-. Clang 7.0 now passes all flags that
+  shell has, so that Clang can handle them internally which breaks backward compatibility
+  before Clang 6.0.
+
+
 New Pragmas in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41517: mmintrin.h documentation fixes and updates

2018-03-07 Thread Douglas Yung via Phabricator via cfe-commits
dyung updated this revision to Diff 137333.
dyung marked an inline comment as done.
dyung added a comment.

Update based on feedback from Simon.


https://reviews.llvm.org/D41517

Files:
  lib/Headers/mmintrin.h


Index: lib/Headers/mmintrin.h
===
--- lib/Headers/mmintrin.h
+++ lib/Headers/mmintrin.h
@@ -52,7 +52,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value.
@@ -69,7 +69,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -85,7 +85,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVQ  instruction.
 ///
 /// \param __i
 ///A 64-bit signed integer.
@@ -101,7 +101,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVQ  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -1289,7 +1289,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  PXOR  instruction.
 ///
 /// \returns An initialized 64-bit integer vector with all elements set to 
zero.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
@@ -1381,7 +1381,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFD / PSHUFD  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __i
 ///A 32-bit integer value used to initialize each vector element of the
@@ -1399,7 +1400,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFLW / PSHUFLW  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __w
 ///A 16-bit integer value used to initialize each vector element of the
@@ -1416,8 +1418,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPUNPCKLBW + VPSHUFLW / PUNPCKLBW +
-///PSHUFLW  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __b
 ///An 8-bit integer value used to initialize each vector element of the


Index: lib/Headers/mmintrin.h
===
--- lib/Headers/mmintrin.h
+++ lib/Headers/mmintrin.h
@@ -52,7 +52,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value.
@@ -69,7 +69,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -85,7 +85,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVQ  instruction.
 ///
 /// \param __i
 ///A 64-bit signed integer.
@@ -101,7 +101,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVQ  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -1289,7 +1289,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  PXOR  instruction.
 ///
 /// \returns An initialized 64-bit integer vector with all elements set to zero.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
@@ -1381,7 +1381,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFD / PSHUFD  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __i
 ///A 32-bit integer value used to initialize each vector element of the
@@ -1399,7 +1400,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFLW / PSHUFLW  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __w
 ///A 16-bit integer value used to initialize each vector element of the
@@ -1416,8 +1418,8 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPUNPCKLBW + VPSHUFLW / PUNPCKLBW +
-///PSHUFLW  instruction.
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
 ///
 /// \param __b
 ///An 8-bit integer value used to initialize each vector element of the
___
cfe-comm

[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD

2018-03-07 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

While there can we add the remaining sanitizers here, like lsan, msan, tsan, 
esan etc?


https://reviews.llvm.org/D44069



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


[PATCH] D43805: Optionally use nameless IR types

2018-03-07 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 137336.
sepavloff added a comment.

Use more consistent option names


Repository:
  rC Clang

https://reviews.llvm.org/D43805

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/pr29160.cpp
  test/CodeGenCXX/type-names.cpp

Index: test/CodeGenCXX/type-names.cpp
===
--- /dev/null
+++ test/CodeGenCXX/type-names.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -fir-type-names=always -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -fir-type-names=never -o - %s | FileCheck %s --check-prefix=UNNAMED
+
+struct C1 {
+  int a;
+  int *b;
+};
+
+C1 var_C1_a;
+C1 var_C1_b[10];
+C1 *var_C1_c;
+int (*var_C1_d)(const C1 &);
+
+struct C1A {
+  int a;
+  int *b;
+};
+
+C1A var_C1A_a;
+
+template struct C2 {
+  C1 a;
+  T b;
+  struct Inner {
+  };
+};
+
+C2 var_C2_a;
+C2 var_C2_b;
+C2::Inner var_C2_c;
+
+struct C3 {
+  double a;
+  struct C4 {
+int a;
+float b;
+  };
+};
+
+C3::C4 var_c4;
+
+namespace {
+struct C5 {
+  int *a;
+};
+}
+
+C5 var_C5_a;
+void *var_C5_b = &var_C5_a;
+
+// CHECK: %struct.C1 = type { i32, i32* }
+// CHECK: %struct.C1A = type { i32, i32* }
+// CHECK: %struct.C2 = type { %struct.C1, i16 }
+// CHECK: %struct.C2.0 = type { %struct.C1, i64 }
+// CHECK: %"struct.C2::Inner" = type { i8 }
+// CHECK: %"struct.C3::C4" = type { i32, float }
+// CHECK: %"struct.(anonymous namespace)::C5" = type { i32* }
+
+// UNNAMED: %0 = type { i32, i32* }
+// UNNAMED: %1 = type { i32, i32* }
+// UNNAMED: %2 = type { %0, i16 }
+// UNNAMED: %3 = type { %0, i64 }
+// UNNAMED: %4 = type { i8 }
+// UNNAMED: %5 = type { i32, float }
+// UNNAMED: %6 = type { i32* }
Index: test/CodeGenCXX/pr29160.cpp
===
--- test/CodeGenCXX/pr29160.cpp
+++ test/CodeGenCXX/pr29160.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -triple i686-linux-gnu %s -o /dev/null -S -emit-llvm
+// RUN: %clang_cc1 -std=c++11 -triple i686-linux-gnu -DNAMELESS -fir-type-names=never %s -o /dev/null -S -emit-llvm
 //
 // This test's failure mode is running ~forever. (For some value of "forever"
 // that's greater than 25 minutes on my machine)
@@ -8,6 +9,7 @@
   template 
   static void ignore() {}
   Foo() { ignore(); }
+  struct ABC {};
 };
 
 struct Base {
@@ -39,3 +41,9 @@
 STAMP(Q, P);
 
 int main() { Q q; }
+
+#ifdef NAMELESS
+// Without '-fir-type-names=none' compiler tries to create name for Q::ABC,
+// which is really huge, so compilation never ends.
+Q::ABC var;
+#endif
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -804,6 +804,20 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(OPT_fir_type_names_EQ)) {
+StringRef Name = A->getValue();
+auto Info = llvm::StringSwitch(Name)
+.Case("auto", CodeGenOptions::IRNames_Auto)
+.Case("never", CodeGenOptions::IRNames_Never)
+.Case("always", CodeGenOptions::IRNames_Always)
+.Default(-1);
+if (Info == -1) {
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
+  Success = false;
+} else
+  Opts.setIRTypeNames(static_cast(Info));
+  }
+
   Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.InstrumentFunctionsAfterInlining =
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3279,6 +3279,8 @@
   if (C.getDriver().embedBitcodeMarkerOnly() && !C.getDriver().isUsingLTO())
 CmdArgs.push_back("-fembed-bitcode=marker");
 
+  Args.AddLastArg(CmdArgs, options::OPT_fir_type_names_EQ);
+
   // We normally speed up the clang process a bit by skipping destructors at
   // exit, but when we're generating diagnostics we can rely on some of the
   // cleanup.
Index: lib/CodeGen/CodeGenTypes.cpp
===
--- lib/CodeGen/CodeGenTypes.cpp
+++ lib/CodeGen/CodeGenTypes.cpp
@@ -51,10 +51,13 @@
 void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
  llvm::StructType *Ty,
  StringRef suffix) {
+  if (getCodeGenOpts().getIRTypeNames() == CodeGenOptions::IRNames_Never)
+return;
+
   SmallString<256> TypeName;
   llvm::raw_svector_ostream OS(TypeName);
   OS << RD->getKindName() << '.';
-  
+
   // Name the codegen type after the typedef name
   // if there is no tag type name available
   if 

[PATCH] D43902: [clang-format] Don't detect C++11 attribute specifiers as ObjC

2018-03-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/Format/FormatTest.cpp:6068-6069
+  verifyFormat("void f() [[deprecated(\"so sorry\")]];");
+  verifyFormat("aa\n"
+   "[[unused]] aaa(int i);");
+}

benhamilton wrote:
> I couldn't figure out why this breaks before the `[` in `[[unused]]`, when 
> the identical test using `__attribute__((unused))` above does *not* break 
> before the `__attribute__`.
> 
> I ran with `-debug` and the two seem fairly similar. Can anyone help shed 
> light on this?
> 
> ## With `__attribute__((unused))`
> 
> P8067
> 
> ## With `[[unused]]`
> 
> P8068
The block of `a`-s appears to be longer here than in the `__attribute__` 
example. That might be a reason.


Repository:
  rC Clang

https://reviews.llvm.org/D43902



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-07 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

In https://reviews.llvm.org/D41102#1028760, @juliehockett wrote:

> If you take a look at the follow-on patch to this (D43341 
> ), you'll see that that is where the pointer 
> is added in (since it is irrelevant to the mapper portion, as it cannot be 
> filled out until the information has been reduced). The back references to 
> children and whatnot are also added there.


Oops! I'll have a look!

In https://reviews.llvm.org/D41102#1028760, @juliehockett wrote:

> The USRs are kept for serialization purposes -- given the modular nature of 
> the design, the goal is to be able to write out the bitstream and have it be 
> consumable with all necessary information. Since we can't write out pointers 
> (and it would be useless if we did, since they would change as soon as the 
> file was read in), we maintain the USRs to have a means of re-finding the 
> referenced declaration.


What I was referring to was the storing of a USR per reference. Of course, 
serializing pointers wouldn't work, but what I mean is that what we used as a 
USR was stored in what was pointed to, not in the reference that tells what we 
are pointing to. To be a little more concise, a RecordInfo has pointers to the 
FuntionInfo for its member functions. Upon serialization, the RecordInfo 
queries the USR of those functions. A function being referenced multiple times 
remains to only have the USR stored. If I understand correctly, you currently 
save the USR for time an InfoType references another InfoType.

Anyhow, don't pay too much attention to that comment, it's all meant as a minor 
thing. It sure is looking good so far!


https://reviews.llvm.org/D41102



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


[PATCH] D44191: Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

2018-03-07 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 137352.
yamaguchi added a comment.

Fixed typos


https://reviews.llvm.org/D44191

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -71,6 +71,15 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 7.0, we prepended the "#" character to the --autocomplete 
argument to
+enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang 
invocation,
+the shell executed clang --autocomplete=#-. Clang 7.0 now
+requires the whole invocation including all flags to be passed to the 
--autocomplete
+like this: clang --autocomplete=-cc1,-xc++,-fsyn.
+
 New Pragmas in Clang
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -71,6 +71,15 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 7.0, we prepended the "#" character to the --autocomplete argument to
+enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang invocation,
+the shell executed clang --autocomplete=#-. Clang 7.0 now
+requires the whole invocation including all flags to be passed to the --autocomplete
+like this: clang --autocomplete=-cc1,-xc++,-fsyn.
+
 New Pragmas in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44191: Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

2018-03-07 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D44191



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


r326889 - Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

2018-03-07 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Wed Mar  7 03:34:02 2018
New Revision: 326889

URL: http://llvm.org/viewvc/llvm-project?rev=326889&view=rev
Log:
Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

Summary:
--autocomplete flag now handles all the flags passed to shell, and this
implementation breaks backward compatibily before Clang 6.0.

Reviewers: teemperor, v.g.vassilev

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=326889&r1=326888&r2=326889&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Mar  7 03:34:02 2018
@@ -71,6 +71,15 @@ future versions of Clang.
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 7.0, we prepended the "#" character to the --autocomplete 
argument to
+enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang 
invocation,
+the shell executed clang --autocomplete=#-. Clang 7.0 now
+requires the whole invocation including all flags to be passed to the 
--autocomplete
+like this: clang --autocomplete=-cc1,-xc++,-fsyn.
+
 New Pragmas in Clang
 ---
 


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


[PATCH] D44191: Add Clang ReleaseNotes that --autocomplete breaks backward compatibily

2018-03-07 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326889: Add Clang ReleaseNotes that --autocomplete breaks 
backward compatibily (authored by yamaguchi, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44191?vs=137352&id=137356#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44191

Files:
  cfe/trunk/docs/ReleaseNotes.rst


Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -71,6 +71,15 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 7.0, we prepended the "#" character to the --autocomplete 
argument to
+enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang 
invocation,
+the shell executed clang --autocomplete=#-. Clang 7.0 now
+requires the whole invocation including all flags to be passed to the 
--autocomplete
+like this: clang --autocomplete=-cc1,-xc++,-fsyn.
+
 New Pragmas in Clang
 ---
 


Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -71,6 +71,15 @@
 
 - ...
 
+Modified Compiler Flags
+---
+
+- Before Clang 7.0, we prepended the "#" character to the --autocomplete argument to
+enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang invocation,
+the shell executed clang --autocomplete=#-. Clang 7.0 now
+requires the whole invocation including all flags to be passed to the --autocomplete
+like this: clang --autocomplete=-cc1,-xc++,-fsyn.
+
 New Pragmas in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43906: [clang-format] Improve detection of Objective-C block types

2018-03-07 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:152
+  const FormatToken *Next = CurrentToken->getNextNonComment();
+  int ParenDepth = 1;
+  // Handle nested parens in case we have an array of blocks with

No. Don't implement yet another parenthesis counting. This function already 
iterates over all tokens until the closing paren. Just store a pointer to the 
caret here and mark it (or unmark it) when encountering the closing brace (line 
271). There is already very similar logic there to set TT_FunctionTypeLParen 
(which is actually doing the exact same parsing now that I think of it).


Repository:
  rC Clang

https://reviews.llvm.org/D43906



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


[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-03-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: sammccall.
Herald added subscribers: cfe-commits, klimek.

This patch improves detection of incomplete code for protos and text protos.
This is especially important for text protos in raw string literals, since they
might be partial strings concatenated, and we'd like to disable formatting in
these cases.


Repository:
  rC Clang

https://reviews.llvm.org/D44203

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -19,12 +19,22 @@
 
 class FormatTestTextProto : public ::testing::Test {
 protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -44,6 +54,12 @@
 Style.ColumnLimit = 60; // To make writing tests easier.
 verifyFormat(Code, Style);
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0, Code.size(), Style, SC_ExpectIncomplete));
+  }
 };
 
 TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
@@ -452,5 +468,43 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, IncompleteFormat) {
+  verifyIncompleteFormat("data {");
+  verifyIncompleteFormat("data <");
+  verifyIncompleteFormat("data [");
+  verifyIncompleteFormat("data: {");
+  verifyIncompleteFormat("data: <");
+  verifyIncompleteFormat("data: [");
+  verifyIncompleteFormat("key:");
+  verifyIncompleteFormat("key:}");
+  verifyIncompleteFormat("key: ]");
+  verifyIncompleteFormat("key: >");
+  verifyIncompleteFormat("data { key: }");
+  verifyIncompleteFormat("data < key: >");
+  verifyIncompleteFormat("data\n"
+ "[key: ]");
+  verifyIncompleteFormat(": value");
+  verifyIncompleteFormat(": {}");
+  verifyIncompleteFormat(": <>");
+  verifyIncompleteFormat(": []");
+  verifyIncompleteFormat("}\n"
+ "key: value");
+  verifyIncompleteFormat("]\n"
+ "key: value");
+  verifyIncompleteFormat("> key: value");
+  verifyIncompleteFormat("data { key: {");
+  verifyIncompleteFormat("data < key: [");
+  verifyIncompleteFormat("data [ key: {");
+  verifyIncompleteFormat("> key: value {");
+  verifyIncompleteFormat("> key: [");
+  verifyIncompleteFormat("}\n"
+ "key: {");
+  verifyIncompleteFormat("data { key: 1 id:");
+  verifyIncompleteFormat("}\n"
+ "key {");
+  verifyIncompleteFormat("> <");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -18,13 +18,23 @@
 namespace format {
 
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
 protected:
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.F

[PATCH] D44204: [clang-format] Break consecutive string literals in text protos

2018-03-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

This patch fixes a bug where consecutive string literals in text protos were
put on the same line.


Repository:
  rC Clang

https://reviews.llvm.org/D44204

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+   " \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@
   return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
- Style.Language == FormatStyle::LK_Proto) {
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
   }


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+   " \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@
   return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
- Style.Language == FormatStyle::LK_Proto) {
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-03-07 Thread Paul Semel via Phabricator via cfe-commits
paulsemel marked 2 inline comments as done.
paulsemel added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:1206
+QualType Arg0Type = Arg0->getType()->getPointeeType();
+const RecordType *RT = Arg0Type->getAs();
+

aaron.ballman wrote:
> You can use `const auto *` here because the type is spelled out in the 
> initializer.
After thinking about it, I find it clearer to spell the full type when possible 
(that's also probably because I'm used to code in C :) )



Comment at: lib/CodeGen/CGBuiltin.cpp:1231
+  Types[getContext().VoidPtrTy] = "%p";
+  Types[getContext().FloatTy] = "%f";
+  Types[getContext().DoubleTy] = "%f";

aaron.ballman wrote:
> It's unfortunate that you cannot distinguish between `float` and `double`. Do 
> you need to use the format specifiers exactly?
> 
> What about other type information, like qualifiers or array extents? How 
> should this handle types that do not exist in this mapping, like structure or 
> enum types?
So, I've think about it. What I am going to do is  that if I do not know the 
type of the field, I am just going to print it as a pointer. I know that it is 
not the best solution, but I think it's a okay-ish solution until I implement 
the other types.
For the qualifiers, at it is printed the same way with and without those, I can 
just add the entries in the DenseMap.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-03-07 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 137369.
paulsemel added a comment.

Applied Aaron suggestion changes.
Added parameters checking in Sema.


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1110,6 +1110,53 @@
 // so ensure that they are declared.
 DeclareGlobalNewDelete();
 break;
+  case Builtin::BI__builtin_dump_struct: {
+// We check for argument number
+if (checkArgCount(*this, TheCall, 2))
+  return ExprError();
+// Ensure that the first argument is of type 'struct XX *'
+const Expr *Arg0 = TheCall->getArg(0)->IgnoreImpCasts();
+if (!Arg0->getType()->isPointerType()) {
+  this->Diag(Arg0->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg0->getType() << "structure pointer type";
+  return ExprError();
+}
+QualType Arg0Type = Arg0->getType()->getPointeeType();
+const RecordType *RT = Arg0Type->getAs();
+if (!RT) {
+  this->Diag(Arg0->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg0->getType() << "structure pointer type";
+  return ExprError();
+}
+// Ensure that the second argument is of type 'FunctionType'
+const Expr *Arg1 = TheCall->getArg(1)->IgnoreImpCasts();
+if (!Arg1->getType()->isPointerType()) {
+  this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg1->getType() << "printf like function pointer type";
+  return ExprError();
+}
+
+const FunctionType *FuncType = Arg1->getType()->getPointeeType()->getAs();
+
+if (!FuncType) {
+  this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg1->getType() << "printf like function pointer type";
+  return ExprError();
+}
+
+const FunctionProtoType *FT = dyn_cast(FuncType);
+if (FT) {
+  if (!FT->isVariadic()) {
+this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+  << Arg1->getType() << "printf like function pointer type";
+return ExprError();
+  }
+}
+
+
+TheCall->setType(Context.IntTy);
+break;
+  }
 
   // check secure string manipulation functions where overflows
   // are detectable at compile time
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -1196,6 +1197,103 @@
 return RValue::get(ComplexVal.first);
   }
 
+  case Builtin::BI__builtin_dump_struct: {
+Value *Func = EmitScalarExpr(E->getArg(1)->IgnoreImpCasts());
+CharUnits Arg0Align = EmitPointerWithAlignment(E->getArg(0)).getAlignment();
+
+const Expr *Arg0 = E->getArg(0)->IgnoreImpCasts();
+QualType Arg0Type = Arg0->getType()->getPointeeType();
+const RecordType *RT = Arg0Type->getAs();
+
+RecordDecl *RD = RT->getDecl()->getDefinition();
+ASTContext &Ctx = RD->getASTContext();
+const ASTRecordLayout &RL = Ctx.getASTRecordLayout(RD);
+
+Value *GString = Builder.CreateGlobalStringPtr(Arg0Type.getAsString()
+   + " {\n");
+Value *Res = Builder.CreateCall(Func, {GString});
+
+#define GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(type, format) \
+Types[getContext().getConstType(type)] = format; \
+Types[getContext().getVolatileType(type)] = format; \
+Types[getContext().getConstType(getContext().getVolatileType(type))] = format;
+
+static llvm::DenseMap Types;
+if (Types.empty()) {
+  Types[getContext().CharTy] = "%c";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().CharTy, "%c")
+  Types[getContext().BoolTy] = "%d";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().BoolTy, "%d")
+  Types[getContext().IntTy] = "%d";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().IntTy, "%d")
+  Types[getContext().UnsignedIntTy] = "%u";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedIntTy, "%u")
+  Types[getContext().LongTy] = "%ld";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().LongTy, "%ld")
+  Types[getContext().UnsignedLongTy] = "%lu";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedLongTy, "%lu")
+  Types[getContext().LongLongTy] = "%lld";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().LongLongTy, "%lld")
+  Types[getContext().UnsignedLongLongTy] = "%llu";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedLongLongTy, "%llu")

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please always upload patches with full context (-U99)


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-03-07 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 137371.
paulsemel added a comment.

Updated with more context.


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1110,6 +1110,53 @@
 // so ensure that they are declared.
 DeclareGlobalNewDelete();
 break;
+  case Builtin::BI__builtin_dump_struct: {
+// We check for argument number
+if (checkArgCount(*this, TheCall, 2))
+  return ExprError();
+// Ensure that the first argument is of type 'struct XX *'
+const Expr *Arg0 = TheCall->getArg(0)->IgnoreImpCasts();
+if (!Arg0->getType()->isPointerType()) {
+  this->Diag(Arg0->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg0->getType() << "structure pointer type";
+  return ExprError();
+}
+QualType Arg0Type = Arg0->getType()->getPointeeType();
+const RecordType *RT = Arg0Type->getAs();
+if (!RT) {
+  this->Diag(Arg0->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg0->getType() << "structure pointer type";
+  return ExprError();
+}
+// Ensure that the second argument is of type 'FunctionType'
+const Expr *Arg1 = TheCall->getArg(1)->IgnoreImpCasts();
+if (!Arg1->getType()->isPointerType()) {
+  this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg1->getType() << "printf like function pointer type";
+  return ExprError();
+}
+
+const FunctionType *FuncType = Arg1->getType()->getPointeeType()->getAs();
+
+if (!FuncType) {
+  this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+<< Arg1->getType() << "printf like function pointer type";
+  return ExprError();
+}
+
+const FunctionProtoType *FT = dyn_cast(FuncType);
+if (FT) {
+  if (!FT->isVariadic()) {
+this->Diag(Arg1->getLocStart(), diag::err_dump_struct_invalid_argument_type)
+  << Arg1->getType() << "printf like function pointer type";
+return ExprError();
+  }
+}
+
+
+TheCall->setType(Context.IntTy);
+break;
+  }
 
   // check secure string manipulation functions where overflows
   // are detectable at compile time
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -1196,6 +1197,103 @@
 return RValue::get(ComplexVal.first);
   }
 
+  case Builtin::BI__builtin_dump_struct: {
+Value *Func = EmitScalarExpr(E->getArg(1)->IgnoreImpCasts());
+CharUnits Arg0Align = EmitPointerWithAlignment(E->getArg(0)).getAlignment();
+
+const Expr *Arg0 = E->getArg(0)->IgnoreImpCasts();
+QualType Arg0Type = Arg0->getType()->getPointeeType();
+const RecordType *RT = Arg0Type->getAs();
+
+RecordDecl *RD = RT->getDecl()->getDefinition();
+ASTContext &Ctx = RD->getASTContext();
+const ASTRecordLayout &RL = Ctx.getASTRecordLayout(RD);
+
+Value *GString = Builder.CreateGlobalStringPtr(Arg0Type.getAsString()
+   + " {\n");
+Value *Res = Builder.CreateCall(Func, {GString});
+
+#define GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(type, format) \
+Types[getContext().getConstType(type)] = format; \
+Types[getContext().getVolatileType(type)] = format; \
+Types[getContext().getConstType(getContext().getVolatileType(type))] = format;
+
+static llvm::DenseMap Types;
+if (Types.empty()) {
+  Types[getContext().CharTy] = "%c";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().CharTy, "%c")
+  Types[getContext().BoolTy] = "%d";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().BoolTy, "%d")
+  Types[getContext().IntTy] = "%d";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().IntTy, "%d")
+  Types[getContext().UnsignedIntTy] = "%u";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedIntTy, "%u")
+  Types[getContext().LongTy] = "%ld";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().LongTy, "%ld")
+  Types[getContext().UnsignedLongTy] = "%lu";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedLongTy, "%lu")
+  Types[getContext().LongLongTy] = "%lld";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().LongLongTy, "%lld")
+  Types[getContext().UnsignedLongLongTy] = "%llu";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().UnsignedLongLongTy, "%llu")
+  Types[getContext().ShortTy] = "%hd"

[PATCH] D16632: clang-cl: Take dllexport from original function decl into account

2018-03-07 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 137374.
sberg added a comment.

Turns out DLLAttr-inherited-from-class is only added to members during 
Sema::CheckCompletedClass -> Sema::checkClassLevelDLLAttribute, when friend 
re-decls of those members may already have been created.


https://reviews.llvm.org/D16632

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport.cpp


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -290,6 +290,16 @@
 __declspec(dllexport) void friend1() {}
   void friend2() {}
 
+// MSC-DAG: define dso_local dllexport void @"\01?func@Befriended@@SAXXZ"()
+// GNU-DAG: define dso_local dllexport void @_ZN10Befriended4funcEv()
+struct __declspec(dllexport) Befriended {
+  static void func();
+  struct Befriending {
+friend void Befriended::func();
+  };
+};
+void Befriended::func() {}
+
 // Implicit declarations can be redeclared with dllexport.
 // MSC-DAG: define dso_local dllexport noalias i8* 
@"\01??2@{{YAPAXI|YAPEAX_K}}@Z"(
 // GNU-DAG: define dso_local dllexport noalias i8* @_Znw{{[yj]}}(
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -5688,6 +5688,21 @@
   cast(ClassAttr->clone(getASTContext()));
   NewAttr->setInherited(true);
   Member->addAttr(NewAttr);
+
+  if (MD) {
+// Propagate DLLAttr to friend re-declarations of MD that have already
+// been constructed.
+for (FunctionDecl *FD = MD->getMostRecentDecl(); FD;
+ FD = FD->getPreviousDecl()) {
+  if (FD->getFriendObjectKind() == Decl::FOK_None)
+continue;
+  assert(!getDLLAttr(FD) &&
+ "friend re-decl should not already have a DLLAttr");
+  NewAttr = cast(ClassAttr->clone(getASTContext()));
+  NewAttr->setInherited(true);
+  FD->addAttr(NewAttr);
+}
+  }
 }
   }
 


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -290,6 +290,16 @@
 __declspec(dllexport) void friend1() {}
   void friend2() {}
 
+// MSC-DAG: define dso_local dllexport void @"\01?func@Befriended@@SAXXZ"()
+// GNU-DAG: define dso_local dllexport void @_ZN10Befriended4funcEv()
+struct __declspec(dllexport) Befriended {
+  static void func();
+  struct Befriending {
+friend void Befriended::func();
+  };
+};
+void Befriended::func() {}
+
 // Implicit declarations can be redeclared with dllexport.
 // MSC-DAG: define dso_local dllexport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"(
 // GNU-DAG: define dso_local dllexport noalias i8* @_Znw{{[yj]}}(
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -5688,6 +5688,21 @@
   cast(ClassAttr->clone(getASTContext()));
   NewAttr->setInherited(true);
   Member->addAttr(NewAttr);
+
+  if (MD) {
+// Propagate DLLAttr to friend re-declarations of MD that have already
+// been constructed.
+for (FunctionDecl *FD = MD->getMostRecentDecl(); FD;
+ FD = FD->getPreviousDecl()) {
+  if (FD->getFriendObjectKind() == Decl::FOK_None)
+continue;
+  assert(!getDLLAttr(FD) &&
+ "friend re-decl should not already have a DLLAttr");
+  NewAttr = cast(ClassAttr->clone(getASTContext()));
+  NewAttr->setInherited(true);
+  FD->addAttr(NewAttr);
+}
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D43902: [clang-format] Don't detect C++11 attribute specifiers as ObjC

2018-03-07 Thread Ben Hamilton via cfe-commits
I made it longer so the two lines (__attribute__((foo)) vs. [[foo]]) had
the same length.

If I shorten it much more, everything goes on one line.

On Wed, Mar 7, 2018, 03:42 Krasimir Georgiev via Phabricator <
revi...@reviews.llvm.org> wrote:

> krasimir added inline comments.
>
>
> 
> Comment at: unittests/Format/FormatTest.cpp:6068-6069
> +  verifyFormat("void f() [[deprecated(\"so sorry\")]];");
> +  verifyFormat("aa\n"
> +   "[[unused]] aaa(int i);");
> +}
> 
> benhamilton wrote:
> > I couldn't figure out why this breaks before the `[` in `[[unused]]`,
> when the identical test using `__attribute__((unused))` above does *not*
> break before the `__attribute__`.
> >
> > I ran with `-debug` and the two seem fairly similar. Can anyone help
> shed light on this?
> >
> > ## With `__attribute__((unused))`
> >
> > P8067
> >
> > ## With `[[unused]]`
> >
> > P8068
> The block of `a`-s appears to be longer here than in the `__attribute__`
> example. That might be a reason.
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D43902
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44204: [clang-format] Break consecutive string literals in text protos

2018-03-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D44204



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


[PATCH] D44173: [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics

2018-03-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thank you!
LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44173



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


[PATCH] D43906: [clang-format] Improve detection of Objective-C block types

2018-03-07 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 137394.
benhamilton added a comment.

- Greatly clean up ObjC block type logic by re-using `TT_FunctionTypeLParen` 
type logic.


Repository:
  rC Clang

https://reviews.llvm.org/D43906

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -845,6 +845,15 @@
   verifyFormat("@ /*foo*/ interface");
 }
 
+TEST_F(FormatTestObjC, ObjCBlockTypesAndVariables) {
+  verifyFormat("void DoStuffWithBlockType(int (^)(char));");
+  verifyFormat("int (^foo)(char, float);");
+  verifyFormat("int (^foo[10])(char, float);");
+  verifyFormat("int (^foo[kNumEntries])(char, float);");
+  verifyFormat("int (^foo[kNumEntries + 10])(char, float);");
+  verifyFormat("int (^foo[(kNumEntries + 10)])(char, float);");
+}
+
 TEST_F(FormatTestObjC, ObjCSnippets) {
   verifyFormat("@autoreleasepool {\n"
"  foo();\n"
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12128,6 +12128,22 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithCaret) {
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "FOO(^);"));
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "FOO(^, Bar);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo[10])(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo[kNumEntries])(char, float);"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -141,10 +141,7 @@
 Contexts.size() == 2 && Contexts[0].ColonIsForRangeExpr;
 
 bool StartsObjCMethodExpr = false;
-if (CurrentToken->is(tok::caret)) {
-  // (^ can start a block type.
-  Left->Type = TT_ObjCBlockLParen;
-} else if (FormatToken *MaybeSel = Left->Previous) {
+if (FormatToken *MaybeSel = Left->Previous) {
   // @selector( starts a selector.
   if (MaybeSel->isObjCAtKeyword(tok::objc_selector) && MaybeSel->Previous 
&&
   MaybeSel->Previous->is(tok::at)) {
@@ -210,8 +207,10 @@
   Left->Type = TT_ObjCMethodExpr;
 }
 
-bool MightBeFunctionType = !Contexts[Contexts.size() - 2].IsExpression;
-bool ProbablyFunctionType = CurrentToken->isOneOf(tok::star, tok::amp);
+bool MightBeFunctionOrObjCBlockType =
+!Contexts[Contexts.size() - 2].IsExpression;
+bool ProbablyFunctionOrObjCBlockType =
+CurrentToken->isOneOf(tok::star, tok::amp, tok::caret);
 bool HasMultipleLines = false;
 bool HasMultipleParametersOnALine = false;
 bool MightBeObjCForRangeLoop =
@@ -239,16 +238,18 @@
   if (CurrentToken->Previous->is(TT_PointerOrReference) &&
   CurrentToken->Previous->Previous->isOneOf(tok::l_paren,
 tok::coloncolon))
-ProbablyFunctionType = true;
+ProbablyFunctionOrObjCBlockType = true;
   if (CurrentToken->is(tok::comma))
-MightBeFunctionType = false;
+MightBeFunctionOrObjCBlockType = false;
   if (CurrentToken->Previous->is(TT_BinaryOperator))
 Contexts.back().IsExpression = true;
   if (CurrentToken->is(tok::r_paren)) {
-if (MightBeFunctionType && ProbablyFunctionType && CurrentToken->Next 
&&
+if (MightBeFunctionOrObjCBlockType && ProbablyFunctionOrObjCBlockType 
&&
+CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||
  (CurrentToken->Next->is(tok::l_square) && 
Line.MustBeDeclaration)))
-  Left->Type = TT_FunctionTypeLParen;
+  Left->Type = Left->Next->is(tok::caret) ? TT_ObjCBlockLParen
+  : TT_FunctionTypeLParen;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
 


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -845,6 +845,15 @@
   verifyFormat("@ /*foo*/ interface");
 }
 
+TEST_F(FormatTestObjC, ObjCBlockTypesAndVariables) {
+  verifyFormat("void Do

[PATCH] D43906: [clang-format] Improve detection of Objective-C block types

2018-03-07 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:152
+  const FormatToken *Next = CurrentToken->getNextNonComment();
+  int ParenDepth = 1;
+  // Handle nested parens in case we have an array of blocks with

djasper wrote:
> No. Don't implement yet another parenthesis counting. This function already 
> iterates over all tokens until the closing paren. Just store a pointer to the 
> caret here and mark it (or unmark it) when encountering the closing brace 
> (line 271). There is already very similar logic there to set 
> TT_FunctionTypeLParen (which is actually doing the exact same parsing now 
> that I think of it).
Oh! Yes, re-using the logic for `TT_FunctionTypeLParen` is clearly the right 
thing to do, since it has exactly the same syntax (just `*` or `&` instead of 
`^`).

Done, code is much cleaner now.


Repository:
  rC Clang

https://reviews.llvm.org/D43906



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


[PATCH] D42730: [clang-tidy]] Add check for use of types/classes/functions from header which are deprecated and removed in C++17

2018-03-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/modernize/DeprecatedFunctionalCheck.cpp:48-54
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("ptr_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::ptr_fun'";
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("mem_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::mem_fun'";
+  }

aaron.ballman wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > alexfh wrote:
> > > > > aaron.ballman wrote:
> > > > > > massberg wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > I think that this code should be generalized (same with the 
> > > > > > > > matchers) so that you match on `hasAnyName()` for the function 
> > > > > > > > calls and use `CallExpr::getCalleeDecl()` to get the 
> > > > > > > > declaration. e.g.,
> > > > > > > > ```
> > > > > > > > if (const auto *Call = 
> > > > > > > > Result.Nodes.getNodeAs("blech")) {
> > > > > > > >   if (const Decl *Callee = Call->getCalleeDecl())
> > > > > > > > diag(Call->getLocStart(), Message) << Calleee;
> > > > > > > > }
> > > > > > > > ```
> > > > > > > > This way you can add more named without having to add extra 
> > > > > > > > logic for the diagnostics.
> > > > > > > I generalized the code and the matcher.
> > > > > > > When we use
> > > > > > > ```
> > > > > > > << cast(Callee);
> > > > > > > ```
> > > > > > > we get the template arguments in the name , e.g. `ptr_fun > > > > > > int>`, so I chose to use `getQualifiedNameAsString`.
> > > > > > > If there is there a better way to get the function name without 
> > > > > > > template arguments I appreciate any suggestions.
> > > > > > > 
> > > > > > > 
> > > > > > Nope, in that case, your code is correct. However, we generally 
> > > > > > provide the template arguments in diagnostics. I see @alexfh was 
> > > > > > asking for them to be removed as not being useful, but I'm not 
> > > > > > certain I agree with his rationale. Yes, all instances are 
> > > > > > deprecated and thus the template arguments don't discern between 
> > > > > > good and bad cases, but showing the template arguments is also 
> > > > > > consistent with the other diagnostics we emit. For instance, other 
> > > > > > "deprecated" diagnostics also emit the template arguments. I'm not 
> > > > > > certain we should be inconsistent with the way we produce 
> > > > > > diagnostics, but I'll defer to Alex if he still feels strongly 
> > > > > > about leaving them off here.
> > > > > Indeed, -Wdeprecated-declarations warnings print template arguments. 
> > > > > Moreover, they seem to be issued only on instantiations, see 
> > > > > https://godbolt.org/g/W563gw.
> > > > > 
> > > > > But I have a number of concerns with template arguments in the 
> > > > > deprecation warnings:
> > > > > 
> > > > > 1. The note attached to the warning lies. Consider a warning from the 
> > > > > test above:
> > > > >   ...
> > > > >   :11:1: warning: 'B' is deprecated: bbb 
> > > > > [-Wdeprecated-declarations]
> > > > >   B e;
> > > > >   ^
> > > > >   :7:10: note: 'B' has been explicitly marked deprecated 
> > > > > here
> > > > >   struct [[deprecated("bbb")]] B {};
> > > > > 
> > > > >  But `B` hasn't been explicitly marked deprecated, only the 
> > > > > template definition of `B` has been. Template arguments are important 
> > > > > in the case of the explicit template specialization `A` in the 
> > > > > same example, but not in cases where the template definition was 
> > > > > marked deprecated, since template arguments only add noise and no 
> > > > > useful information there.
> > > > > 2. Warnings can easily become unreadable: https://godbolt.org/g/AFdznH
> > > > > 3. Certain coding patterns can result in numerous deprecation 
> > > > > warnings differing only in template arguments: 
> > > > > https://godbolt.org/g/U2JCbG. Clang-tidy can deduplicate warnings, if 
> > > > > they have identical text and location, but adding template arguments 
> > > > > to the message will prevent deduplication. I've seen a case where 
> > > > > thousands of deprecation warnings were generated for a single line in 
> > > > > a widely used header.
> > > > > 
> > > > > So yes, I feel strongly about leaving off template arguments in case 
> > > > > the whole template was marked deprecated. I think it would be the 
> > > > > right thing to do for the -Wdeprecated-declarations diagnostic as 
> > > > > well.
> > > > s/leaving off/leaving out/
> > > > The note attached to the warning lies.
> > > 
> > > No it doesn't? The attribute is inherited from the primary template 
> > > unless your explicit specialization *removes* the attribute. 
> > > https://godbolt.org/g/ZuXZds
> > > 
> > > > Warnings can easily become unreadable
> > > 
> > > This is true of all template diagnostics and isn't specific to 
> > > clang-tidy's treatment of them.
> > > 
> > > > I've seen a case where tho

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-03-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5022-5023
 
+def err_dump_struct_invalid_argument_type : Error<
+  "invalid argument of type %0; expected %1">;
+

Can you look to see if we have an existing diagnostic that can cover this 
instead?



Comment at: lib/CodeGen/CGBuiltin.cpp:1231
+  Types[getContext().VoidPtrTy] = "%p";
+  Types[getContext().FloatTy] = "%f";
+  Types[getContext().DoubleTy] = "%f";

paulsemel wrote:
> aaron.ballman wrote:
> > It's unfortunate that you cannot distinguish between `float` and `double`. 
> > Do you need to use the format specifiers exactly?
> > 
> > What about other type information, like qualifiers or array extents? How 
> > should this handle types that do not exist in this mapping, like structure 
> > or enum types?
> So, I've think about it. What I am going to do is  that if I do not know the 
> type of the field, I am just going to print it as a pointer. I know that it 
> is not the best solution, but I think it's a okay-ish solution until I 
> implement the other types.
> For the qualifiers, at it is printed the same way with and without those, I 
> can just add the entries in the DenseMap.
> So, I've think about it. What I am going to do is that if I do not know the 
> type of the field, I am just going to print it as a pointer. I know that it 
> is not the best solution, but I think it's a okay-ish solution until I 
> implement the other types.

Eek. That seems unfortunate. I'm thinking about very common use cases, like:
```
struct S {
  int i, j;
  float x, y;
};

struct T {
  struct S s;
  int k;
};
```
Printing out `s` as a pointer seems... not particularly useful.



Comment at: lib/CodeGen/CGBuiltin.cpp:1218
+Types[getContext().getConstType(type)] = format; \
+Types[getContext().getVolatileType(type)] = format; \
+Types[getContext().getConstType(getContext().getVolatileType(type))] = 
format;

This seems insufficient, as there are other qualifiers (restrict, ObjC GC 
qualifiers, etc). I think a better way to do this is to call 
`QualType::getUnqualifiedType()` on the type accessing the map.



Comment at: lib/CodeGen/CGBuiltin.cpp:1252
+  Types[getContext().getPointerType(getContext().CharTy)] = "%s";
+  GENERATE_TYPE_QUALIFIERS_NO_RESTRICT(getContext().CharTy, "%s")
+}

What about other types that have format specifiers (ptrdiff_t, size_t, 
intptr_t, char16_t, etc)?



Comment at: lib/CodeGen/CGBuiltin.cpp:1255
+
+/* field : RecordDecl::field_iterator */
+for (const auto *FD : RD->fields()) {

I don't think this comment adds a lot of value.



Comment at: lib/CodeGen/CGBuiltin.cpp:1269-1270
+
+  /* If the type is not handled yet, let's just print the data as a pointer
+   */
+  if (Types.find(FD->getType()) == Types.end())

We generally prefer `//` style comments unless there's good reason to use `/* 
*/`.



Comment at: lib/Sema/SemaChecking.cpp:1114
+  case Builtin::BI__builtin_dump_struct: {
+// We check for argument number
+if (checkArgCount(*this, TheCall, 2))

Comments should be grammatically correct, including punctuation (here and 
elsewhere).



Comment at: lib/Sema/SemaChecking.cpp:1118
+// Ensure that the first argument is of type 'struct XX *'
+const Expr *Arg0 = TheCall->getArg(0)->IgnoreImpCasts();
+if (!Arg0->getType()->isPointerType()) {

You probably want to use `IgnoreParenImpCasts()`.



Comment at: lib/Sema/SemaChecking.cpp:1119
+const Expr *Arg0 = TheCall->getArg(0)->IgnoreImpCasts();
+if (!Arg0->getType()->isPointerType()) {
+  this->Diag(Arg0->getLocStart(), 
diag::err_dump_struct_invalid_argument_type)

Rather than calling `is` followed by `get`, you should just call `get` once and 
check the results here.



Comment at: lib/Sema/SemaChecking.cpp:1121
+  this->Diag(Arg0->getLocStart(), 
diag::err_dump_struct_invalid_argument_type)
+<< Arg0->getType() << "structure pointer type";
+  return ExprError();

The string literals should be part of a `%select` in the diagnostic itself 
rather than printed this way.



Comment at: lib/Sema/SemaChecking.cpp:1132-1133
+// Ensure that the second argument is of type 'FunctionType'
+const Expr *Arg1 = TheCall->getArg(1)->IgnoreImpCasts();
+if (!Arg1->getType()->isPointerType()) {
+  this->Diag(Arg1->getLocStart(), 
diag::err_dump_struct_invalid_argument_type)

Same suggestions here.

Also, `Arg1` and `Arg0` aren't particularly descriptive names. Can you pick 
names based on the semantics of the arguments rather than their position?



Comment at: lib/Sema/SemaChecking.

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 20 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCall.h:248
+  return HasLV ? LV.getAddress() : RV.getAggregateAddress();
+}
+

rjmccall wrote:
> Part of my thinking in suggesting this representation change was that the 
> current representation was prone to a certain kind of bug where clients 
> blindly use the RValue without realizing that it's actually something they 
> need to copy from instead of using directly. That is generally a bug because 
> indirect arguments are expected to be independent slots and are not permitted 
> to alias. The new representation implicitly fixes these bugs by pushing users 
> towards using one of these approaches.
> 
> All of this is to say that I'm not thrilled about having a 
> getAggregateAddress here.
I see. I will remove getAggregateAddress.


https://reviews.llvm.org/D34367



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


[PATCH] D42730: [clang-tidy]] Add check for use of types/classes/functions from header which are deprecated and removed in C++17

2018-03-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/DeprecatedFunctionalCheck.cpp:48-54
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("ptr_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::ptr_fun'";
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("mem_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::mem_fun'";
+  }

alexfh wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > aaron.ballman wrote:
> > > > alexfh wrote:
> > > > > alexfh wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > massberg wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > I think that this code should be generalized (same with the 
> > > > > > > > > matchers) so that you match on `hasAnyName()` for the 
> > > > > > > > > function calls and use `CallExpr::getCalleeDecl()` to get the 
> > > > > > > > > declaration. e.g.,
> > > > > > > > > ```
> > > > > > > > > if (const auto *Call = 
> > > > > > > > > Result.Nodes.getNodeAs("blech")) {
> > > > > > > > >   if (const Decl *Callee = Call->getCalleeDecl())
> > > > > > > > > diag(Call->getLocStart(), Message) << Calleee;
> > > > > > > > > }
> > > > > > > > > ```
> > > > > > > > > This way you can add more named without having to add extra 
> > > > > > > > > logic for the diagnostics.
> > > > > > > > I generalized the code and the matcher.
> > > > > > > > When we use
> > > > > > > > ```
> > > > > > > > << cast(Callee);
> > > > > > > > ```
> > > > > > > > we get the template arguments in the name , e.g. `ptr_fun > > > > > > > int>`, so I chose to use `getQualifiedNameAsString`.
> > > > > > > > If there is there a better way to get the function name without 
> > > > > > > > template arguments I appreciate any suggestions.
> > > > > > > > 
> > > > > > > > 
> > > > > > > Nope, in that case, your code is correct. However, we generally 
> > > > > > > provide the template arguments in diagnostics. I see @alexfh was 
> > > > > > > asking for them to be removed as not being useful, but I'm not 
> > > > > > > certain I agree with his rationale. Yes, all instances are 
> > > > > > > deprecated and thus the template arguments don't discern between 
> > > > > > > good and bad cases, but showing the template arguments is also 
> > > > > > > consistent with the other diagnostics we emit. For instance, 
> > > > > > > other "deprecated" diagnostics also emit the template arguments. 
> > > > > > > I'm not certain we should be inconsistent with the way we produce 
> > > > > > > diagnostics, but I'll defer to Alex if he still feels strongly 
> > > > > > > about leaving them off here.
> > > > > > Indeed, -Wdeprecated-declarations warnings print template 
> > > > > > arguments. Moreover, they seem to be issued only on instantiations, 
> > > > > > see https://godbolt.org/g/W563gw.
> > > > > > 
> > > > > > But I have a number of concerns with template arguments in the 
> > > > > > deprecation warnings:
> > > > > > 
> > > > > > 1. The note attached to the warning lies. Consider a warning from 
> > > > > > the test above:
> > > > > >   ...
> > > > > >   :11:1: warning: 'B' is deprecated: bbb 
> > > > > > [-Wdeprecated-declarations]
> > > > > >   B e;
> > > > > >   ^
> > > > > >   :7:10: note: 'B' has been explicitly marked 
> > > > > > deprecated here
> > > > > >   struct [[deprecated("bbb")]] B {};
> > > > > > 
> > > > > >  But `B` hasn't been explicitly marked deprecated, only the 
> > > > > > template definition of `B` has been. Template arguments are 
> > > > > > important in the case of the explicit template specialization 
> > > > > > `A` in the same example, but not in cases where the template 
> > > > > > definition was marked deprecated, since template arguments only add 
> > > > > > noise and no useful information there.
> > > > > > 2. Warnings can easily become unreadable: 
> > > > > > https://godbolt.org/g/AFdznH
> > > > > > 3. Certain coding patterns can result in numerous deprecation 
> > > > > > warnings differing only in template arguments: 
> > > > > > https://godbolt.org/g/U2JCbG. Clang-tidy can deduplicate warnings, 
> > > > > > if they have identical text and location, but adding template 
> > > > > > arguments to the message will prevent deduplication. I've seen a 
> > > > > > case where thousands of deprecation warnings were generated for a 
> > > > > > single line in a widely used header.
> > > > > > 
> > > > > > So yes, I feel strongly about leaving off template arguments in 
> > > > > > case the whole template was marked deprecated. I think it would be 
> > > > > > the right thing to do for the -Wdeprecated-declarations diagnostic 
> > > > > > as well.
> > > > > s/leaving off/leaving out/
> > > > > The note attached to the warning lies.
> > > > 
> > > > No it doesn't? The attribute is inherited from the primary template 
> > > > unless your explicit specialization *removes* the attribute. 
> > > > https://godbolt.org/g/ZuXZds
> >

[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-03-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: unittests/clang-tidy/ClangTidyTest.h:145
+
+  if (Options.FormatStyle) {
+llvm::Expected Style = format::getStyle(

jdemeule wrote:
> alexfh wrote:
> > I wonder whether it's better to use lit for the tests that require 
> > formatting than to expand clang-tidy unit test utilities with 
> > runCheckAndFormatOnCode? What was the reason to use unit tests in this 
> > patch as opposed to lit tests?
> Indeed, that a good question.
> Personally, I found unit test easier to launch and debug than lit test and I 
> notice that it is not possible to made a unit test which react the same way 
> as clang-tidy.
> When I wrote this test, I want it to react as in clang-tidy and for this I 
> try to call `cleanupAroundReplacements` in the test.
> Adding formatting was more a side effect to have some sustainable and 
> comprehensive way to write test.
> 
With more features clang-tidy gets the discrepancies between how unit tests 
work and how clang-tidy works become larger. I wouldn't like to mirror every 
clang-tidy feature in the code that supports unit tests. We should either 
expose more high-level APIs or use clang-tidy itself and lit tests. (I 
personally like the latter more, since lit tests tend to be closer to the real 
use cases and are easier to write and iterate on.)


https://reviews.llvm.org/D43500



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


[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring

2018-03-07 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43509



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


[PATCH] D44173: [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics

2018-03-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 137406.
MaskRay added a comment.

ReleaseNotes.rst


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44173

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp
  clang-tidy/portability/CMakeLists.txt
  clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tidy/portability/SIMDIntrinsicsCheck.cpp
  clang-tidy/portability/SIMDIntrinsicsCheck.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/portability-simd-intrinsics.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/portability-simd-intrinsics-ppc.cpp
  test/clang-tidy/portability-simd-intrinsics-x86.cpp
  test/clang-tidy/readability-simd-intrinsics-ppc.cpp
  test/clang-tidy/readability-simd-intrinsics-x86.cpp

Index: test/clang-tidy/portability-simd-intrinsics-x86.cpp
===
--- test/clang-tidy/portability-simd-intrinsics-x86.cpp
+++ test/clang-tidy/portability-simd-intrinsics-x86.cpp
@@ -1,6 +1,6 @@
-// RUN: %check_clang_tidy %s readability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy %s portability-simd-intrinsics %t -- \
 // RUN:  -config='{CheckOptions: [ \
-// RUN:{key: readability-simd-intrinsics.Suggest, value: 1} \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: 1} \
 // RUN:  ]}' -- -target x86_64 -std=c++11
 
 typedef long long __m128i __attribute__((vector_size(16)));
@@ -17,7 +17,7 @@
   __m256 d0;
 
   _mm_add_epi32(i0, i1);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
   d0 = _mm256_load_pd(0);
   _mm256_store_pd(0, d0);
 
Index: test/clang-tidy/portability-simd-intrinsics-ppc.cpp
===
--- test/clang-tidy/portability-simd-intrinsics-ppc.cpp
+++ test/clang-tidy/portability-simd-intrinsics-ppc.cpp
@@ -1,13 +1,13 @@
-// RUN: %check_clang_tidy %s readability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy %s portability-simd-intrinsics %t -- \
 // RUN:  -config='{CheckOptions: [ \
-// RUN:{key: readability-simd-intrinsics.Suggest, value: 1} \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: 1} \
 // RUN:  ]}' -- -target ppc64le -maltivec -std=c++11
 
 vector int vec_add(vector int, vector int);
 
 void PPC() {
   vector int i0, i1;
 
   vec_add(i0, i1);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
 }
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -71,6 +71,8 @@
 ``mpi-``   Checks related to MPI (Message Passing Interface).
 ``objc-``  Checks related to Objective-C coding conventions.
 ``performance-``   Checks that target performance-related issues.
+``portability-``   Checks that target portability-related issues that don't
+   relate to any particular coding style.
 ``readability-``   Checks that target readability-related issues that don't
relate to any particular coding style.
 == =
Index: docs/clang-tidy/checks/portability-simd-intrinsics.rst
===
--- docs/clang-tidy/checks/portability-simd-intrinsics.rst
+++ docs/clang-tidy/checks/portability-simd-intrinsics.rst
@@ -1,6 +1,6 @@
-.. title:: clang-tidy - readability-simd-intrinsics
+.. title:: clang-tidy - portability-simd-intrinsics
 
-readability-simd-intrinsics
+portability-simd-intrinsics
 ===
 
 Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_)
@@ -41,4 +41,9 @@
`P0214`_ alternatives, otherwise it only points out the intrinsic function is
non-portable.
 
+.. option:: Std
+
+   The namespace used to suggest `P0214`_ alternatives. If not specified, `std::`
+   for `-std=c++2a` and `std::experimental::` for `-std=c++11`.
+
 .. _P0214: http://wg21.link/p0214
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ 

[PATCH] D44173: [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics

2018-03-07 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326909: [clang-tidy] Add "portability" module and 
rename readability-simd-intrinsics to… (authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44173?vs=137406&id=137407#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44173

Files:
  clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
  clang-tools-extra/trunk/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/portability/SIMDIntrinsicsCheck.h
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.h
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/portability-simd-intrinsics.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simd-intrinsics.rst
  clang-tools-extra/trunk/docs/clang-tidy/index.rst
  clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-ppc.cpp
  clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-x86.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-ppc.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-x86.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-x86.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-x86.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-x86.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s portability-simd-intrinsics %t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: 1} \
+// RUN:  ]}' -- -target x86_64 -std=c++11
+
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+}
Index: clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-ppc.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-ppc.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-ppc.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s portability-simd-intrinsics %t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: 1} \
+// RUN:  ]}' -- -target ppc64le -maltivec -std=c++11
+
+vector int vec_add(vector int, vector int);
+
+void PPC() {
+  vector int i0, i1;
+
+  vec_add(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+}
Index: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -118,6 +118,11 @@
 static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
 PerformanceModuleAnchorSource;
 
+// This anchor is used to force the linker to link the PortabilityModule.
+extern volatile int PortabilityModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination =
+PortabilityModuleAnchorSource;
+
 // This anchor is used to force the linker to link the ReadabilityModule.
 extern volatile int ReadabilityModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
Index: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
@@ -19,6 +19,7 @@
   clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
+  clangTidyPortabilityModule
  

[PATCH] D44213: [clangd] Remove unused field in HandlerRegisterer

2018-03-07 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 137410.
simark added a comment.

Fix formatting


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44213

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h


Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,7 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
   ProtocolCallbacks &Callbacks);
 
 } // namespace clangd
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);


Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,7 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
   ProtocolCallbacks &Callbacks);
 
 } // namespace clangd
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44213: [clangd] Remove unused field in HandlerRegisterer

2018-03-07 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, ilya-biryukov, 
klimek.

Tested by rebuilding.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44213

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h


Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,8 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
-  ProtocolCallbacks &Callbacks);
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, ProtocolCallbacks 
&Callbacks);
 
 } // namespace clangd
 } // namespace clang
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);


Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,8 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
-  ProtocolCallbacks &Callbacks);
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, ProtocolCallbacks &Callbacks);
 
 } // namespace clangd
 } // namespace clang
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r326909 - [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics

2018-03-07 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed Mar  7 08:57:42 2018
New Revision: 326909

URL: http://llvm.org/viewvc/llvm-project?rev=326909&view=rev
Log:
[clang-tidy] Add "portability" module and rename readability-simd-intrinsics to 
portability-simd-intrinsics

Reviewers: alexfh

Subscribers: klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/portability/
clang-tools-extra/trunk/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/portability/PortabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
  - copied, changed from r326809, 
clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.cpp
clang-tools-extra/trunk/clang-tidy/portability/SIMDIntrinsicsCheck.h
  - copied, changed from r326809, 
clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/portability-simd-intrinsics.rst
  - copied, changed from r326809, 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simd-intrinsics.rst
clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-ppc.cpp
  - copied, changed from r326809, 
clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-ppc.cpp
clang-tools-extra/trunk/test/clang-tidy/portability-simd-intrinsics-x86.cpp
  - copied, changed from r326809, 
clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-x86.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/SIMDIntrinsicsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simd-intrinsics.rst
clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-ppc.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-simd-intrinsics-x86.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=326909&r1=326908&r2=326909&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Wed Mar  7 08:57:42 2018
@@ -41,6 +41,7 @@ add_subdirectory(mpi)
 add_subdirectory(objc)
 add_subdirectory(performance)
 add_subdirectory(plugin)
+add_subdirectory(portability)
 add_subdirectory(readability)
 add_subdirectory(tool)
 add_subdirectory(utils)

Modified: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt?rev=326909&r1=326908&r2=326909&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt Wed Mar  7 
08:57:42 2018
@@ -19,6 +19,7 @@ add_clang_library(clangTidyPlugin
   clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
+  clangTidyPortabilityModule
   clangTidyReadabilityModule
   clangTooling
   )

Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp?rev=326909&r1=326908&r2=326909&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp Wed Mar  7 
08:57:42 2018
@@ -118,6 +118,11 @@ extern volatile int PerformanceModuleAnc
 static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
 PerformanceModuleAnchorSource;
 
+// This anchor is used to force the linker to link the PortabilityModule.
+extern volatile int PortabilityModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination =
+PortabilityModuleAnchorSource;
+
 // This anchor is used to force the linker to link the ReadabilityModule.
 extern volatile int ReadabilityModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =

Added: clang-tools-extra/trunk/clang-tidy/portability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/c

[PATCH] D43980: Push a function scope when parsing function bodies without a declaration

2018-03-07 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.

Fix LGTM, one optional comment below.




Comment at: clang/lib/Sema/SemaDecl.cpp:12412
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;

Feels a bit long-term risky since ActOnStartOfFunctionDef() and 
ActOnFinishFunctionBody() both need to know about this special-case invariant. 
Maybe it's worth to add a FakeFunctionScopeCount member to sema in +assert 
builds, and to increment that here, assert it's > 0 in the other place and 
decrement it there, and then assert it's 0 at end of TU?



Comment at: clang/test/SemaCXX/pr36536.cpp:19
+  // this when they forget to close a namespace, and we'd generate far fewer
+  // errors if names in Foo were in scope.
+  // expected-error@+1 {{unknown type name 'NameInClass'}}

Not 100% clear to me what the FIXME is here. Maybe "FIXME: We should improve 
our recovery to redeclare" if that's what's meant.


https://reviews.llvm.org/D43980



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


[PATCH] D43990: set dso_local on tls init functions

2018-03-07 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola added a comment.

Richard, you added the setVisibility line, are you OK with the change?


https://reviews.llvm.org/D43990



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


[PATCH] D44039: [Sema] Make getCurFunction() return null outside function parsing

2018-03-07 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.

Good luck!

I think the forward-looking statement in https://reviews.llvm.org/D43980 about 
this change here is a bit off, see below.

The hasLocalStorage() comment below is probably the only interesting comment.




Comment at: clang/include/clang/Sema/Sema.h:1320
   sema::FunctionScopeInfo *getCurFunction() const {
-return FunctionScopes.back();
+return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
   }

The other patch description said "This means the FunctionScopes stack will 
often be empty, which will make getCurFunction() assert" -- did you change your 
mind, or did you mean "which will make the caller of getCurFunction() crash 
when it uses the null pointer"?



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:635
 
-/// CheckFallThroughForFunctionDef - Check that we don't fall off the end of a
+/// CheckFallThroughForBody - Check that we don't fall off the end of a
 /// function that should return a value.  Check that we don't fall off the end

nit: Just remove everything up to and including the `-` – we no longer repeat 
function names in comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:11328
 
-  if (var->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+  if (var->hasLocalStorage() &&
+  var->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)

the hasLocalStorage() check addition here seems unrelated?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:1117
 
-  const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt ?
-*FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
+  const int MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
+ ? *FunctionScopeIndexToStopAt

Maybe add "// can be -1 if there's no current function scope and 
FunctionScopeIndexToStopAt is not set" since that seems pretty subtle.


https://reviews.llvm.org/D44039



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


[PATCH] D44039: [Sema] Make getCurFunction() return null outside function parsing

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks!




Comment at: clang/include/clang/Sema/Sema.h:1320
   sema::FunctionScopeInfo *getCurFunction() const {
-return FunctionScopes.back();
+return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
   }

thakis wrote:
> The other patch description said "This means the FunctionScopes stack will 
> often be empty, which will make getCurFunction() assert" -- did you change 
> your mind, or did you mean "which will make the caller of getCurFunction() 
> crash when it uses the null pointer"?
I changed my mind after fixing the fallout caused by the assert in `.back()`. 
There are a lot of places that want to say "if we're in a function scope and we 
had a VLA or object with a destructor, then mark this as a branch protected 
scope". If the variable is in global or class scope, we don't need to mark the 
scope as branch protected, and a null check seems like the right way to express 
that.



Comment at: clang/lib/Sema/SemaDecl.cpp:11328
 
-  if (var->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+  if (var->hasLocalStorage() &&
+  var->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)

thakis wrote:
> the hasLocalStorage() check addition here seems unrelated?
This is a different way of checking if the variable is in function scope. I 
think I made this change before making getCurFunction() return nullptr.


https://reviews.llvm.org/D44039



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


[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 137418.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Don't set the IsUnique bit of an OpaqueValueExpr that is used as the result 
expression.


https://reviews.llvm.org/D39562

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaPseudoObject.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/ms-property.cpp
  test/CodeGenObjC/objc-container-subscripting-1.m
  test/CodeGenObjCXX/property-dot-copy-elision.mm
  test/CodeGenObjCXX/property-objects.mm

Index: test/CodeGenObjCXX/property-objects.mm
===
--- test/CodeGenObjCXX/property-objects.mm
+++ test/CodeGenObjCXX/property-objects.mm
@@ -119,11 +119,11 @@
 // CHECK:define void @_Z6testB0P1B([[B:%.*]]*
 // CHECK:  [[BVAR:%.*]] = alloca [[B]]*, align 8
 // CHECK:  [[TEMP:%.*]] = alloca [[B0:%.*]], align 8
-// CHECK:  load [[B]]*, [[B]]** [[BVAR]]
-// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [[B0]], [[B0]]* [[TEMP]], i32 0, i32 0
+// CHECK:  [[X:%.*]] = getelementptr inbounds [[B0]], [[B0]]* [[TEMP]], i32 0, i32 0
 // CHECK-NEXT: [[T0:%.*]] = call i32 @_Z9b_makeIntv()
 // CHECK-NEXT: [[T1:%.*]] = sext i32 [[T0]] to i64
 // CHECK-NEXT: store i64 [[T1]], i64* [[X]], align 8
+// CHECK:  load [[B]]*, [[B]]** [[BVAR]]
 // CHECK-NOT:  call
 // CHECK:  call void @llvm.memcpy
 // CHECK-NOT:  call
@@ -161,12 +161,12 @@
 
 // CHECK:define void @_Z6testB2P1B([[B]]*
 // CHECK:  [[BVAR:%.*]] = alloca [[B]]*, align 8
-// CHECK:  load [[B]]*, [[B]]** [[BVAR]]
-// CHECK-NOT:  call
+// CHECK:  call void @llvm.dbg.declare(
 // CHECK:  call void @_ZN2B3C1Ev(
 // CHECK-NEXT: [[T0:%.*]] = call i64 @_ZN2B3cv2B1Ev(
 // CHECK-NOT:  call
 // CHECK:  store i64 [[T0]],
+// CHECK:  load [[B]]*, [[B]]** [[BVAR]]
 // CHECK-NOT:  call
 // CHECK:  call void @llvm.memcpy
 // CHECK-NOT:  call
Index: test/CodeGenObjCXX/property-dot-copy-elision.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/property-dot-copy-elision.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++1z -fobjc-arc -o - %s | FileCheck %s
+
+struct S0 {
+  id f;
+};
+
+struct S1 {
+  S1();
+  S1(S0);
+  id f;
+};
+
+@interface C
+@property S1 f;
+@end
+@implementation C
+@end
+
+// CHECK-LABEL: define void @_Z5test0P1C(
+// CHECK: %{{.*}} = alloca %
+// CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_S1:.*]], align
+// CHECK: %[[AGG_TMP_1:.*]] = alloca %[[STRUCT_S0:.*]], align
+// CHECK: call void @_ZN2S0C1Ev(%[[STRUCT_S0]]* %[[AGG_TMP_1]])
+// CHECK: call void @_ZN2S1C1E2S0(%[[STRUCT_S1]]* %[[AGG_TMP]], %[[STRUCT_S0]]* %[[AGG_TMP_1]])
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %[[STRUCT_S1]]*)*)(i8* %{{.*}}, i8* %{{.*}}, %[[STRUCT_S1]]* %[[AGG_TMP]])
+
+void test0(C *c) {
+  c.f = S0();
+}
+
+// CHECK: define void @_Z5test1P1C(
+// CHECK: %{{.*}} = alloca %
+// CHECK: %[[TEMP_LVALUE:.*]] = alloca %[[STRUCT_S1:.*]], align
+// CHECK: call void @_ZN2S1C1Ev(%[[STRUCT_S1]]* %[[TEMP_LVALUE]])
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %[[STRUCT_S1]]*)*)(i8* %{{.*}}, i8* %{{.*}}, %[[STRUCT_S1]]* %[[TEMP_LVALUE]])
+
+void test1(C *c) {
+  c.f = S1();
+}
Index: test/CodeGenObjC/objc-container-subscripting-1.m
===
--- test/CodeGenObjC/objc-container-subscripting-1.m
+++ test/CodeGenObjC/objc-container-subscripting-1.m
@@ -25,8 +25,8 @@
 // CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8
 
   val = (array[10] = oldObject);
-// CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
-// CHECK-NEXT: [[FOUR:%.*]] = load i8*, i8** [[oldObject:%.*]], align 8
+// CHECK:  [[FOUR:%.*]] = load i8*, i8** [[oldObject:%.*]], align 8
+// CHECK-NEXT: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
 // CHECK-NEXT: [[FIVE:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.2
 // CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8*
 // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10)
@@ -45,9 +45,9 @@
 
 
   val = (dictionary[key] = newObject);
-// CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
+// CHECK:   [[FOURTEEN:%.*]] = load i8*, i8** [[NEWOBJECT:%.*]], align 8
+// CHECK-NEXT:  [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
 // CHECK-NEXT:  [[THIRTEEN:%.*]] = load i8*, i8** [[KEY]], align 8
-// CHECK-NEXT:  [[FOURTEEN:%.*]] = load i8*, i8** [[NEWOBJECT:%.*]], align 8
 // CHECK-NEXT:  [[SIXTEEN:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.6
 // CHECK-NEXT:  [[SEV

[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:4815
+}
+  }
+

rjmccall wrote:
> Oh!  So it's an interesting point that the RHS might be used as the result 
> expression, which means its use might not really be unique anymore.  It 
> happens to work in some sense for non-trivial C++ class types (when they're 
> passed indirectly, as under the Itanium ABI) because the temporary outlives 
> the call; on the other hand, the call is allowed to mutate its argument, and 
> it's not clear that it's okay to have those mutations be reflected in code 
> that's using the result of the assignment.  Similarly, managed types (like 
> non-trivial C structs, or ARC pointers) might be consumed by the call; if 
> we're going to pass them, perhaps we need to copy the value before doing so.
> 
> What do you think?
> 
> I think the technical implication is that what you're doing here shouldn't be 
> necessary; the OVE arguably should not be unique if its value is used in 
> multiple places, and that includes being used as a result.
I made changes so that OVEs used as the result expression are not marked as 
unique. I wasn't sure whether treating such OVEs as unique would actually cause 
problems, but it's probably better to be on the safe side.


https://reviews.llvm.org/D39562



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


[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I also add a call to setIsUnique(false) in OpaqueValueExpr's constructor, which 
fixed the failing tests I was seeing.


https://reviews.llvm.org/D39562



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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 137421.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by John's comments. Removed CallArg::getAggregateAddress().


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMDGCN20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMDGCN-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMDGCN-LABEL: define void @test_indirect_arg_private()
+// AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN-NOT: @llvm.memcpy
+// AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMDGCN-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMDGCN-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-func-arg.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+class A {
+public:
+  int x;

r326922 - [OPENMP] Fix lifetime of the loop counters.

2018-03-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Mar  7 10:17:06 2018
New Revision: 326922

URL: http://llvm.org/viewvc/llvm-project?rev=326922&view=rev
Log:
[OPENMP] Fix lifetime of the loop counters.

We may emit incorrect lifetime info during codegen for loop counters in
OpenMP constructs because of automatic scope cleanup when we needed
temporarily locations for private loop counters.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=326922&r1=326921&r2=326922&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Mar  7 10:17:06 2018
@@ -120,18 +120,18 @@ public:
 /// of used expression from loop statement.
 class OMPLoopScope : public CodeGenFunction::RunCleanupsScope {
   void emitPreInitStmt(CodeGenFunction &CGF, const OMPLoopDirective &S) {
-CodeGenFunction::OMPPrivateScope PreCondScope(CGF);
+CodeGenFunction::OMPMapVars PreCondVars;
 for (auto *E : S.counters()) {
   const auto *VD = cast(cast(E)->getDecl());
-  (void)PreCondScope.addPrivate(VD, [&CGF, VD]() {
-return CGF.CreateMemTemp(VD->getType().getNonReferenceType());
-  });
+  (void)PreCondVars.setVarAddr(
+  CGF, VD, CGF.CreateMemTemp(VD->getType().getNonReferenceType()));
 }
-(void)PreCondScope.Privatize();
+(void)PreCondVars.apply(CGF);
 if (auto *PreInits = cast_or_null(S.getPreInits())) {
   for (const auto *I : PreInits->decls())
 CGF.EmitVarDecl(cast(*I));
 }
+PreCondVars.restore(CGF);
   }
 
 public:
@@ -1475,25 +1475,25 @@ void CodeGenFunction::EmitOMPPrivateLoop
   for (auto *E : S.counters()) {
 auto *VD = cast(cast(E)->getDecl());
 auto *PrivateVD = cast(cast(*I)->getDecl());
-(void)LoopScope.addPrivate(VD, [&]() -> Address {
-  // Emit var without initialization.
-  if (!LocalDeclMap.count(PrivateVD)) {
-auto VarEmission = EmitAutoVarAlloca(*PrivateVD);
-EmitAutoVarCleanups(VarEmission);
-  }
-  DeclRefExpr DRE(const_cast(PrivateVD),
-  /*RefersToEnclosingVariableOrCapture=*/false,
-  (*I)->getType(), VK_LValue, (*I)->getExprLoc());
-  return EmitLValue(&DRE).getAddress();
+// Emit var without initialization.
+auto VarEmission = EmitAutoVarAlloca(*PrivateVD);
+EmitAutoVarCleanups(VarEmission);
+LocalDeclMap.erase(PrivateVD);
+(void)LoopScope.addPrivate(VD, [&VarEmission]() {
+  return VarEmission.getAllocatedAddress();
 });
 if (LocalDeclMap.count(VD) || CapturedStmtInfo->lookup(VD) ||
 VD->hasGlobalStorage()) {
-  (void)LoopScope.addPrivate(PrivateVD, [&]() -> Address {
+  (void)LoopScope.addPrivate(PrivateVD, [this, VD, E]() {
 DeclRefExpr DRE(const_cast(VD),
 LocalDeclMap.count(VD) || CapturedStmtInfo->lookup(VD),
 E->getType(), VK_LValue, E->getExprLoc());
 return EmitLValue(&DRE).getAddress();
   });
+} else {
+  (void)LoopScope.addPrivate(PrivateVD, [&VarEmission]() {
+return VarEmission.getAllocatedAddress();
+  });
 }
 ++I;
   }
@@ -1611,9 +1611,9 @@ void CodeGenFunction::EmitOMPSimdFinal(
 }
   }
   Address OrigAddr = Address::invalid();
-  if (CED)
+  if (CED) {
 OrigAddr = EmitLValue(CED->getInit()->IgnoreImpCasts()).getAddress();
-  else {
+  } else {
 DeclRefExpr DRE(const_cast(PrivateVD),
 /*RefersToEnclosingVariableOrCapture=*/false,
 (*IPC)->getType(), VK_LValue, (*IPC)->getExprLoc());

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=326922&r1=326921&r2=326922&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Mar  7 10:17:06 2018
@@ -693,57 +693,107 @@ public:
 
   typedef llvm::DenseMap DeclMapTy;
 
-  /// \brief The scope used to remap some variables as private in the OpenMP
-  /// loop body (or other captured region emitted without outlining), and to
-  /// restore old vars back on exit.
-  class OMPPrivateScope : public RunCleanupsScope {
+  /// The class used to assign some variables some temporarily addresses.
+  class OMPMapVars {
 DeclMapTy SavedLocals;
-DeclMapTy SavedPrivates;
-
-  private:
-OMPPrivateScope(const OMPPrivateScope &) = delete;
-void operator=(const OMPPrivateScope &) = delete;
+DeclMapTy SavedTempAddresses;
+OMPMapVars(const OMPMapVars &) = delete;
+void operator=(const OMPMapVars &) = delete;
 
   publi

[PATCH] D43990: set dso_local on tls init functions

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

I think Richard has been really busy preparing for some C++ committee function. 
I think we should go forward with this.


https://reviews.llvm.org/D43990



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


[PATCH] D44217: [clang-tidy] Enable Python 3 support for add_new_check.py

2018-03-07 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: alexfh.
Herald added a subscriber: xazax.hun.

In Python 3, filters are lazily evaluated and strings are not bytes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44217

Files:
  clang-tools-extra/clang-tidy/add_new_check.py

Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -9,18 +9,19 @@
 #
 #======#
 
+from __future__ import print_function
+
 import argparse
 import os
 import re
 import sys
 
-
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new entry
 # and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
   with open(filename, 'r') as f:
-lines = f.readlines()
+lines = [x for x in f.readlines()]
 
   cpp_file = check_name_camel + '.cpp'
 
@@ -30,7 +31,7 @@
   return False
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 cpp_found = False
 file_added = False
 for line in lines:
@@ -50,7 +51,7 @@
   check_name_dashes = module + '-' + check_name
   filename = os.path.join(module_path, check_name_camel) + '.h'
   print('Creating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
 + check_name_camel.upper() + '_H')
 f.write('//===--- ')
@@ -103,7 +104,7 @@
 def write_implementation(module_path, module, check_name_camel):
   filename = os.path.join(module_path, check_name_camel) + '.cpp'
   print('Creating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 f.write('//===--- ')
 f.write(os.path.basename(filename))
 f.write(' - clang-tidy')
@@ -152,14 +153,15 @@
 
 # Modifies the module to include the new check.
 def adapt_module(module_path, module, check_name, check_name_camel):
-  modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
- os.listdir(module_path))[0]
+  modulecpp = list(filter(
+  lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
+  os.listdir(module_path)))[0]
   filename = os.path.join(module_path, modulecpp)
   with open(filename, 'r') as f:
 lines = f.readlines()
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 header_added = False
 header_found = False
 check_added = False
@@ -199,7 +201,7 @@
 lines = f.readlines()
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 note_added = False
 header_found = False
 
@@ -227,7 +229,7 @@
   filename = os.path.normpath(os.path.join(module_path, '../../test/clang-tidy',
check_name_dashes + '.' + test_extension))
   print('Creating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
@@ -251,8 +253,8 @@
   filename = os.path.normpath(os.path.join(docs_dir, 'list.rst'))
   with open(filename, 'r') as f:
 lines = f.readlines()
-  doc_files = filter(lambda s: s.endswith('.rst') and s != 'list.rst',
- os.listdir(docs_dir))
+  doc_files = list(filter(lambda s: s.endswith('.rst') and s != 'list.rst',
+ os.listdir(docs_dir)))
   doc_files.sort()
 
   def format_link(doc_file):
@@ -275,7 +277,7 @@
   checks = map(format_link, doc_files)
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 for line in lines:
   f.write(line)
   if line.startswith('.. toctree::'):
@@ -289,7 +291,7 @@
   filename = os.path.normpath(os.path.join(
   module_path, '../../docs/clang-tidy/checks/', check_name_dashes + '.rst'))
   print('Creating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with open(filename, 'w') as f:
 f.write(""".. title:: clang-tidy - %(check_name_dashes)s
 
 %(check_name_dashes)s
@@ -333,16 +335,16 @@
 return
 
   if not args.module or not args.check:
-print 'Module and check must be specified.'
+print('Module and check must be specified.')
 parser.print_usage()
 return
 
   module = args.module
   check_name = args.check
 
   if check_name.startswith(module):
-print 'Check name "%s" must not start with the module "%s". Exiting.' % (
-check_name, module)
+print('Check name "%s" must not start with the module "%s". Exiting.' % (
+check_name, module))
 return
   check_name_came

r326926 - Push a function scope when parsing function bodies without a declaration

2018-03-07 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Mar  7 10:55:10 2018
New Revision: 326926

URL: http://llvm.org/viewvc/llvm-project?rev=326926&view=rev
Log:
Push a function scope when parsing function bodies without a declaration

Summary:
This is PR36536.

There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null
Decl. Currently, the parser continues on to attempt to parse the
statements in the function body without pushing a function scope or
declaration context. However, lots of statement parsing logic relies on
getCurFunction() returning something reasonable. It turns out that
getCurFunction() will never return null today because of an optimization
where Sema pre-allocates one FunctionScopeInfo and reuses it when
possible. This goes wrong when something inside the function body causes
us to push another function scope, such as requiring an implicit
definition of a special member function. Reusing the state clears it
out, which will lead to bugs. In PR36536, we found that the SwitchStack
gets unbalanced, because we push a switch, clear out the stack, and then
try to pop a switch that isn't there.

As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out
of the FunctionScopes stack. This means the FunctionScopes stack will
often be empty, and callers of getCurFunction() will need to check for
null.

Reviewers: thakis

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/pr36536.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=326926&r1=326925&r2=326926&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar  7 10:55:10 2018
@@ -12406,8 +12406,13 @@ static void RebuildLambdaScopeInfo(CXXMe
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake 
scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
   getCurFunction()->ObjCWarnForNoInitDelegation = false;
 }
   } else {
+// Parsing the function declaration failed in some way. Pop the fake scope
+// we pushed on.
+PopFunctionScopeInfo(ActivePolicy, dcl);
 return nullptr;
   }
 

Added: cfe/trunk/test/SemaCXX/pr36536.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr36536.cpp?rev=326926&view=auto
==
--- cfe/trunk/test/SemaCXX/pr36536.cpp (added)
+++ cfe/trunk/test/SemaCXX/pr36536.cpp Wed Mar  7 10:55:10 2018
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
+// even though this is in the wrong namespace. That will allow name lookup to
+// find NameInClass below. Users are likely to hit this when they forget to
+// close namespaces.
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}


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


[PATCH] D43980: Push a function scope when parsing function bodies without a declaration

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326926: Push a function scope when parsing function bodies 
without a declaration (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43980?vs=136635&id=137437#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43980

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/pr36536.cpp


Index: test/SemaCXX/pr36536.cpp
===
--- test/SemaCXX/pr36536.cpp
+++ test/SemaCXX/pr36536.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
+// even though this is in the wrong namespace. That will allow name lookup to
+// find NameInClass below. Users are likely to hit this when they forget to
+// close namespaces.
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12406,8 +12406,13 @@
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake 
scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@
   getCurFunction()->ObjCWarnForNoInitDelegation = false;
 }
   } else {
+// Parsing the function declaration failed in some way. Pop the fake scope
+// we pushed on.
+PopFunctionScopeInfo(ActivePolicy, dcl);
 return nullptr;
   }
 


Index: test/SemaCXX/pr36536.cpp
===
--- test/SemaCXX/pr36536.cpp
+++ test/SemaCXX/pr36536.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
+// even though this is in the wrong namespace. That will allow name lookup to
+// find NameInClass below. Users are likely to hit this when they forget to
+// close namespaces.
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12406,8 +12406,13 @@
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@
   getCurFunction()->ObjCWarnForNoInitDelegation = false;
 }
   } else {
+// Parsing the function declaration failed in some way. Pop the fake scope
+// we pushed on.
+  

[PATCH] D43980: Push a function scope when parsing function bodies without a declaration

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326926: Push a function scope when parsing function bodies 
without a declaration (authored by rnk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43980?vs=136635&id=137436#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43980

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/pr36536.cpp


Index: cfe/trunk/test/SemaCXX/pr36536.cpp
===
--- cfe/trunk/test/SemaCXX/pr36536.cpp
+++ cfe/trunk/test/SemaCXX/pr36536.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
+// even though this is in the wrong namespace. That will allow name lookup to
+// find NameInClass below. Users are likely to hit this when they forget to
+// close namespaces.
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12406,8 +12406,13 @@
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake 
scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@
   getCurFunction()->ObjCWarnForNoInitDelegation = false;
 }
   } else {
+// Parsing the function declaration failed in some way. Pop the fake scope
+// we pushed on.
+PopFunctionScopeInfo(ActivePolicy, dcl);
 return nullptr;
   }
 


Index: cfe/trunk/test/SemaCXX/pr36536.cpp
===
--- cfe/trunk/test/SemaCXX/pr36536.cpp
+++ cfe/trunk/test/SemaCXX/pr36536.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
+// even though this is in the wrong namespace. That will allow name lookup to
+// find NameInClass below. Users are likely to hit this when they forget to
+// close namespaces.
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12406,8 +12406,13 @@
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@
  

[PATCH] D44218: Correct the alignment for the PS4 target

2018-03-07 Thread Matthew Voss via Phabricator via cfe-commits
ormris created this revision.
ormris added reviewers: rsmith, craig.topper, echristo, erichkeane.

See above.


Repository:
  rC Clang

https://reviews.llvm.org/D44218

Files:
  lib/Basic/Targets/OSTargets.h
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8965,6 +8965,9 @@
 // PS4:#define __x86_64__ 1
 // PS4:#define unix 1
 //
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < 
/dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s
+// PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
+//
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC %s
 // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
 // X86-64-DECLSPEC: #define __declspec{{.*}}
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -485,6 +485,7 @@
 default:
 case llvm::Triple::x86_64:
   this->MCountName = ".mcount";
+  this->NewAlign = 256;
   break;
 }
   }


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8965,6 +8965,9 @@
 // PS4:#define __x86_64__ 1
 // PS4:#define unix 1
 //
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s
+// PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
+//
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
 // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
 // X86-64-DECLSPEC: #define __declspec{{.*}}
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -485,6 +485,7 @@
 default:
 case llvm::Triple::x86_64:
   this->MCountName = ".mcount";
+  this->NewAlign = 256;
   break;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44174: do not register matcher for objc-only checks when analyzing non-objc sources to save resources

2018-03-07 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326928: do not register matcher for objc-only checks when 
analyzing non-objc sources to… (authored by Wizard, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44174

Files:
  clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp


Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
@@ -18,6 +18,10 @@
 namespace objc {
 
 void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   Finder->addMatcher(objcMessageExpr(hasSelector("init"),
  hasReceiverType(asString("NSError *")))
  .bind("nserrorInit"),
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -170,6 +170,10 @@
   EscapedAcronyms() {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   if (IncludeDefaultAcronyms) {
 EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
 SpecialAcronyms.size());
Index: clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
@@ -77,6 +77,10 @@
 }
 
 void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   Finder->addMatcher(
   objcInterfaceDecl(
   isSubclassOf(
Index: 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -19,6 +19,11 @@
 namespace objc {
 
 void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
+
   Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
   Finder->addMatcher(
   objcMessageExpr(anyOf(hasSelector("raise:format:"),


Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
@@ -18,6 +18,10 @@
 namespace objc {
 
 void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   Finder->addMatcher(objcMessageExpr(hasSelector("init"),
  hasReceiverType(asString("NSError *")))
  .bind("nserrorInit"),
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -170,6 +170,10 @@
   EscapedAcronyms() {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   if (IncludeDefaultAcronyms) {
 EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
 SpecialAcronyms.size());
Index: clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
+++ clang-tools-extra/trunk/cl

Re: r326926 - Push a function scope when parsing function bodies without a declaration

2018-03-07 Thread Nico Weber via cfe-commits
On Wed, Mar 7, 2018 at 1:55 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Wed Mar  7 10:55:10 2018
> New Revision: 326926
>
> URL: http://llvm.org/viewvc/llvm-project?rev=326926&view=rev
> Log:
> Push a function scope when parsing function bodies without a declaration
>
> Summary:
> This is PR36536.
>
> There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null
> Decl. Currently, the parser continues on to attempt to parse the
> statements in the function body without pushing a function scope or
> declaration context. However, lots of statement parsing logic relies on
> getCurFunction() returning something reasonable. It turns out that
> getCurFunction() will never return null today because of an optimization
> where Sema pre-allocates one FunctionScopeInfo and reuses it when
> possible. This goes wrong when something inside the function body causes
> us to push another function scope, such as requiring an implicit
> definition of a special member function. Reusing the state clears it
> out, which will lead to bugs. In PR36536, we found that the SwitchStack
> gets unbalanced, because we push a switch, clear out the stack, and then
> try to pop a switch that isn't there.
>
> As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out
> of the FunctionScopes stack. This means the FunctionScopes stack will
> often be empty, and callers of getCurFunction() will need to check for
> null.
>
> Reviewers: thakis
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D43980
>
> Added:
> cfe/trunk/test/SemaCXX/pr36536.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=326926&r1=326925&r2=326926&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar  7 10:55:10 2018
> @@ -12406,8 +12406,13 @@ static void RebuildLambdaScopeInfo(CXXMe
>
>  Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
>  SkipBodyInfo *SkipBody) {
> -  if (!D)
> +  if (!D) {
> +// Parsing the function declaration failed in some way. Push on a
> fake scope
> +// anyway so we can try to parse the function body.
> +PushFunctionScope();
>  return D;
> +  }
> +
>FunctionDecl *FD = nullptr;
>
>if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
> @@ -12816,6 +12821,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
>getCurFunction()->ObjCWarnForNoInitDelegation = false;
>  }
>} else {
> +// Parsing the function declaration failed in some way. Pop the fake
> scope
> +// we pushed on.
> +PopFunctionScopeInfo(ActivePolicy, dcl);
>  return nullptr;
>}
>
>
> Added: cfe/trunk/test/SemaCXX/pr36536.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/pr36536.cpp?rev=326926&view=auto
> 
> ==
> --- cfe/trunk/test/SemaCXX/pr36536.cpp (added)
> +++ cfe/trunk/test/SemaCXX/pr36536.cpp Wed Mar  7 10:55:10 2018
> @@ -0,0 +1,44 @@
> +// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
> +
> +// These test cases are constructed to make clang call
> ActOnStartOfFunctionDef
> +// with nullptr.
> +
> +struct ImplicitDefaultCtor1 {};
> +struct Foo {
> +  typedef int NameInClass;
> +  void f();
> +};
> +namespace bar {
> +// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
>

(nit: s/Improved/Improve/)


> +// even though this is in the wrong namespace. That will allow name
> lookup to
> +// find NameInClass below. Users are likely to hit this when they forget
> to
> +// close namespaces.
> +// expected-error@+1 {{cannot define or redeclare 'f' here}}
> +void Foo::f() {
> +  switch (0) { case 0: ImplicitDefaultCtor1 o; }
> +  // expected-error@+1 {{unknown type name 'NameInClass'}}
> +  NameInClass var;
> +}
> +} // namespace bar
> +
> +struct ImplicitDefaultCtor2 {};
> +template  class TFoo { void f(); };
> +// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
> +template  void decltype(TFoo())::f() {
> +  switch (0) { case 0: ImplicitDefaultCtor1 o; }
> +}
> +
> +namespace tpl2 {
> +struct ImplicitDefaultCtor3 {};
> +template  class A {
> +  template  class B {
> +void mf2();
> +  };
> +};
> +template 
> +template <>
> +// expected-error@+1 {{nested name specifier 'A::B::'}}
> +void A::B::mf2() {
> +  switch (0) { case 0: ImplicitDefaultCtor3 o; }
> +}
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cf

Re: [libcxx] r323971 - Remove ; use instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-03-07 Thread Nico Weber via cfe-commits
On Sat, Feb 24, 2018 at 7:17 PM, Marshall Clow 
wrote:

> On Thu, Feb 22, 2018 at 7:58 AM, Nico Weber  wrote:
>
>> I have a small personal project where I used to use this. I tried
>> switching to  instead, but that apparently requires -std=c++17.
>> With that, things build fine with my locally-built clang, but latest Xcode
>> clang doesn't accept that flag yet. So I tried -std=c++1z, but latest Xcode
>> (9.2) doesn't even include the  header yet. So now I have no way
>> of being able to build my project with both trunk clang and Xcode clang.
>> Maybe a one-year deprecation period is too short?
>>
>
> Nico --
>
> I'm sorry you were caught out by this.
>
> (It's not a huge deal, I have a optional<> implementation in my project
>> for platforms that don't ship it yet, but things used to be fine on mac
>> until this change at least. It's also not an important project, I just
>> thought I'd point out that this makes life more complicated than it would
>> be if the deletion period was longer.)
>>
>
> Yes, but it also makes life less complicated also.
>
> In fact, optional was the poster child for removing stuff from
> experimental.
> experimental::optional and std::optional have diverged, and are
> significantly different today (and only going to get more different in the
> future)
>
> The cost for someone to move to std::optional will never be lower than it
> is now. (they're only going to become more different).
>
> I really didn't (and don't) want to maintain two closely related (but
> different, and slowly diverging) code bases - and (repeatedly) explain to
> people the difference between them.
>
> As for Apple not shipping std::optional, I too am dismayed by that, but I
> have no control over that. :-(  I don't know when Apple will ship
> std::optional (they don't share their product plans with me), but it
> requires an update to libc++.dylib
>

Does this mean that if I build a mac program with trunk clang and trunk
libc++ using std::optional and -mmacosx-version-min=10.11 (or any other
version), my program will build without problems but then fail to start at
runtime because system libc++.dylib is missing the required optional code?


> , and in the past they have gone *years* without updating the dylib.
>  Hopefully they will update before LLVM 7 ships in August.
>
> -- Marshall
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r326935 - [analyzer] [NFC] Minor refactoring of NonNullParamChecker

2018-03-07 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Mar  7 11:27:32 2018
New Revision: 326935

URL: http://llvm.org/viewvc/llvm-project?rev=326935&view=rev
Log:
[analyzer] [NFC] Minor refactoring of NonNullParamChecker

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp?rev=326935&r1=326934&r2=326935&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp Wed Mar  7 
11:27:32 2018
@@ -44,13 +44,9 @@ public:
 };
 } // end anonymous namespace
 
-void NonNullParamChecker::checkPreCall(const CallEvent &Call,
-   CheckerContext &C) const {
+/// \return Bitvector marking non-null attributes.
+static llvm::SmallBitVector getNonNullAttrs(const CallEvent &Call) {
   const Decl *FD = Call.getDecl();
-  if (!FD)
-return;
-
-  // Merge all non-null attributes
   unsigned NumArgs = Call.getNumArgs();
   llvm::SmallBitVector AttrNonNull(NumArgs);
   for (const auto *NonNull : FD->specific_attrs()) {
@@ -64,43 +60,47 @@ void NonNullParamChecker::checkPreCall(c
   AttrNonNull.set(Val);
 }
   }
+  return AttrNonNull;
+}
 
-  ProgramStateRef state = C.getState();
+void NonNullParamChecker::checkPreCall(const CallEvent &Call,
+   CheckerContext &C) const {
+  if (!Call.getDecl())
+return;
+
+  llvm::SmallBitVector AttrNonNull = getNonNullAttrs(Call);
+  unsigned NumArgs = Call.getNumArgs();
 
-  CallEvent::param_type_iterator TyI = Call.param_type_begin(),
- TyE = Call.param_type_end();
+  ProgramStateRef state = C.getState();
+  ArrayRef parms = Call.parameters();
 
   for (unsigned idx = 0; idx < NumArgs; ++idx) {
+// For vararg functions, a corresponding parameter decl may not exist.
+bool HasParam = idx < parms.size();
 
 // Check if the parameter is a reference. We want to report when reference
 // to a null pointer is passed as a parameter.
-bool haveRefTypeParam = false;
-if (TyI != TyE) {
-  haveRefTypeParam = (*TyI)->isReferenceType();
-  TyI++;
-}
-
+bool haveRefTypeParam =
+HasParam ? parms[idx]->getType()->isReferenceType() : false;
 bool haveAttrNonNull = AttrNonNull[idx];
-if (!haveAttrNonNull) {
-  // Check if the parameter is also marked 'nonnull'.
-  ArrayRef parms = Call.parameters();
-  if (idx < parms.size())
-haveAttrNonNull = parms[idx]->hasAttr();
-}
 
-if (!haveRefTypeParam && !haveAttrNonNull)
+// Check if the parameter is also marked 'nonnull'.
+if (!haveAttrNonNull && HasParam)
+  haveAttrNonNull = parms[idx]->hasAttr();
+
+if (!haveAttrNonNull && !haveRefTypeParam)
   continue;
 
 // If the value is unknown or undefined, we can't perform this check.
 const Expr *ArgE = Call.getArgExpr(idx);
 SVal V = Call.getArgSVal(idx);
-Optional DV = V.getAs();
+auto DV = V.getAs();
 if (!DV)
   continue;
 
-// Process the case when the argument is not a location.
 assert(!haveRefTypeParam || DV->getAs());
 
+// Process the case when the argument is not a location.
 if (haveAttrNonNull && !DV->getAs()) {
   // If the argument is a union type, we want to handle a potential
   // transparent_union GCC extension.
@@ -112,66 +112,63 @@ void NonNullParamChecker::checkPreCall(c
   if (!UT || !UT->getDecl()->hasAttr())
 continue;
 
-  if (Optional CSV =
-  DV->getAs()) {
-nonloc::CompoundVal::iterator CSV_I = CSV->begin();
-assert(CSV_I != CSV->end());
-V = *CSV_I;
-DV = V.getAs();
-assert(++CSV_I == CSV->end());
-// FIXME: Handle (some_union){ some_other_union_val }, which turns into
-// a LazyCompoundVal inside a CompoundVal.
-if (!V.getAs())
-  continue;
-// Retrieve the corresponding expression.
-if (const CompoundLiteralExpr *CE = 
dyn_cast(ArgE))
-  if (const InitListExpr *IE =
-dyn_cast(CE->getInitializer()))
- ArgE = dyn_cast(*(IE->begin()));
+  auto CSV = DV->getAs();
 
-  } else {
-// FIXME: Handle LazyCompoundVals?
+  // FIXME: Handle LazyCompoundVals?
+  if (!CSV)
 continue;
-  }
+
+  V = *(CSV->begin());
+  DV = V.getAs();
+  assert(++CSV->begin() == CSV->end());
+  // FIXME: Handle (some_union){ some_other_union_val }, which turns into
+  // a LazyCompoundVal inside a CompoundVal.
+  if (!V.getAs())
+continue;
+
+  // Retrieve the corresponding expression.
+  if (const auto *CE = dyn_cast(ArgE))
+

[PATCH] D43917: [analyzer] [NFC] Minor refactoring of NonNullParamChecker

2018-03-07 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326935: [analyzer] [NFC] Minor refactoring of 
NonNullParamChecker (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D43917

Files:
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -44,13 +44,9 @@
 };
 } // end anonymous namespace
 
-void NonNullParamChecker::checkPreCall(const CallEvent &Call,
-   CheckerContext &C) const {
+/// \return Bitvector marking non-null attributes.
+static llvm::SmallBitVector getNonNullAttrs(const CallEvent &Call) {
   const Decl *FD = Call.getDecl();
-  if (!FD)
-return;
-
-  // Merge all non-null attributes
   unsigned NumArgs = Call.getNumArgs();
   llvm::SmallBitVector AttrNonNull(NumArgs);
   for (const auto *NonNull : FD->specific_attrs()) {
@@ -64,43 +60,47 @@
   AttrNonNull.set(Val);
 }
   }
+  return AttrNonNull;
+}
 
-  ProgramStateRef state = C.getState();
+void NonNullParamChecker::checkPreCall(const CallEvent &Call,
+   CheckerContext &C) const {
+  if (!Call.getDecl())
+return;
 
-  CallEvent::param_type_iterator TyI = Call.param_type_begin(),
- TyE = Call.param_type_end();
+  llvm::SmallBitVector AttrNonNull = getNonNullAttrs(Call);
+  unsigned NumArgs = Call.getNumArgs();
+
+  ProgramStateRef state = C.getState();
+  ArrayRef parms = Call.parameters();
 
   for (unsigned idx = 0; idx < NumArgs; ++idx) {
+// For vararg functions, a corresponding parameter decl may not exist.
+bool HasParam = idx < parms.size();
 
 // Check if the parameter is a reference. We want to report when reference
 // to a null pointer is passed as a parameter.
-bool haveRefTypeParam = false;
-if (TyI != TyE) {
-  haveRefTypeParam = (*TyI)->isReferenceType();
-  TyI++;
-}
-
+bool haveRefTypeParam =
+HasParam ? parms[idx]->getType()->isReferenceType() : false;
 bool haveAttrNonNull = AttrNonNull[idx];
-if (!haveAttrNonNull) {
-  // Check if the parameter is also marked 'nonnull'.
-  ArrayRef parms = Call.parameters();
-  if (idx < parms.size())
-haveAttrNonNull = parms[idx]->hasAttr();
-}
 
-if (!haveRefTypeParam && !haveAttrNonNull)
+// Check if the parameter is also marked 'nonnull'.
+if (!haveAttrNonNull && HasParam)
+  haveAttrNonNull = parms[idx]->hasAttr();
+
+if (!haveAttrNonNull && !haveRefTypeParam)
   continue;
 
 // If the value is unknown or undefined, we can't perform this check.
 const Expr *ArgE = Call.getArgExpr(idx);
 SVal V = Call.getArgSVal(idx);
-Optional DV = V.getAs();
+auto DV = V.getAs();
 if (!DV)
   continue;
 
-// Process the case when the argument is not a location.
 assert(!haveRefTypeParam || DV->getAs());
 
+// Process the case when the argument is not a location.
 if (haveAttrNonNull && !DV->getAs()) {
   // If the argument is a union type, we want to handle a potential
   // transparent_union GCC extension.
@@ -112,66 +112,63 @@
   if (!UT || !UT->getDecl()->hasAttr())
 continue;
 
-  if (Optional CSV =
-  DV->getAs()) {
-nonloc::CompoundVal::iterator CSV_I = CSV->begin();
-assert(CSV_I != CSV->end());
-V = *CSV_I;
-DV = V.getAs();
-assert(++CSV_I == CSV->end());
-// FIXME: Handle (some_union){ some_other_union_val }, which turns into
-// a LazyCompoundVal inside a CompoundVal.
-if (!V.getAs())
-  continue;
-// Retrieve the corresponding expression.
-if (const CompoundLiteralExpr *CE = dyn_cast(ArgE))
-  if (const InitListExpr *IE =
-dyn_cast(CE->getInitializer()))
- ArgE = dyn_cast(*(IE->begin()));
+  auto CSV = DV->getAs();
 
-  } else {
-// FIXME: Handle LazyCompoundVals?
+  // FIXME: Handle LazyCompoundVals?
+  if (!CSV)
 continue;
-  }
+
+  V = *(CSV->begin());
+  DV = V.getAs();
+  assert(++CSV->begin() == CSV->end());
+  // FIXME: Handle (some_union){ some_other_union_val }, which turns into
+  // a LazyCompoundVal inside a CompoundVal.
+  if (!V.getAs())
+continue;
+
+  // Retrieve the corresponding expression.
+  if (const auto *CE = dyn_cast(ArgE))
+if (const auto *IE = dyn_cast(CE->getInitializer()))
+  ArgE = dyn_cast(*(IE->begin()));
 }
 
 ConstraintManager &CM = C.getConstraintManager();
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-

r326937 - [OpenCL] Remove block invoke function from emitted block literal struct

2018-03-07 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Mar  7 11:32:58 2018
New Revision: 326937

URL: http://llvm.org/viewvc/llvm-project?rev=326937&view=rev
Log:
[OpenCL] Remove block invoke function from emitted block literal struct

OpenCL runtime tracks the invoke function emitted for
any block expression. Due to restrictions on blocks in
OpenCL (v2.0 s6.12.5), it is always possible to know the
block invoke function when emitting call of block expression
or __enqueue_kernel builtin functions. Since __enqueu_kernel
already has an argument for the invoke function, it is redundant
to have invoke function member in the llvm block literal structure.

This patch removes invoke function from the llvm block literal
structure. It also removes the bitcast of block invoke function
to the generic block literal type which is useless for OpenCL.

This will save some space for the kernel argument, and also
eliminate some store instructions.

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
cfe/trunk/test/CodeGenOpenCL/blocks.cl
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=326937&r1=326936&r2=326937&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Mar  7 11:32:58 2018
@@ -307,25 +307,12 @@ static void initializeForBlockHeader(Cod
 
   assert(elementTypes.empty());
   if (CGM.getLangOpts().OpenCL) {
-// The header is basically 'struct { int; int; generic void *;
+// The header is basically 'struct { int; int;
 // custom_fields; }'. Assert that struct is packed.
-auto GenericAS =
-CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic);
-auto GenPtrAlign =
-CharUnits::fromQuantity(CGM.getTarget().getPointerAlign(GenericAS) / 
8);
-auto GenPtrSize =
-CharUnits::fromQuantity(CGM.getTarget().getPointerWidth(GenericAS) / 
8);
-assert(CGM.getIntSize() <= GenPtrSize);
-assert(CGM.getIntAlign() <= GenPtrAlign);
-assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign));
 elementTypes.push_back(CGM.IntTy); /* total size */
 elementTypes.push_back(CGM.IntTy); /* align */
-elementTypes.push_back(
-CGM.getOpenCLRuntime()
-.getGenericVoidPointerType()); /* invoke function */
-unsigned Offset =
-2 * CGM.getIntSize().getQuantity() + GenPtrSize.getQuantity();
-unsigned BlockAlign = GenPtrAlign.getQuantity();
+unsigned Offset = 2 * CGM.getIntSize().getQuantity();
+unsigned BlockAlign = CGM.getIntAlign().getQuantity();
 if (auto *Helper =
 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
   for (auto I : Helper->getCustomFieldTypes()) /* custom fields */ {
@@ -771,20 +758,12 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
 llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
   bool IsOpenCL = CGM.getContext().getLangOpts().OpenCL;
-  auto GenVoidPtrTy =
-  IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : 
VoidPtrTy;
-  LangAS GenVoidPtrAddr = IsOpenCL ? LangAS::opencl_generic : LangAS::Default;
-  auto GenVoidPtrSize = CharUnits::fromQuantity(
-  CGM.getTarget().getPointerWidth(
-  CGM.getContext().getTargetAddressSpace(GenVoidPtrAddr)) /
-  8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
   CodeGenFunction BlockCGF{CGM, true};
   BlockCGF.SanOpts = SanOpts;
   auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
-  auto *blockFn = llvm::ConstantExpr::getPointerCast(InvokeFn, GenVoidPtrTy);
 
   // If there is nothing to capture, we can emit this as a global block.
   if (blockInfo.CanBeGlobal)
@@ -853,11 +832,12 @@ llvm::Value *CodeGenFunction::EmitBlockL
   llvm::ConstantInt::get(IntTy, blockInfo.BlockAlign.getQuantity()),
   getIntSize(), "block.align");
 }
-addHeaderField(blockFn, GenVoidPtrSize, "block.invoke");
-if (!IsOpenCL)
+if (!IsOpenCL) {
+  addHeaderField(llvm::ConstantExpr::getBitCast(InvokeFn, VoidPtrTy),
+ getPointerSize(), "block.invoke");
   addHeaderField(descriptor, getPointerSize(), "block.descriptor");
-else if (auto *Helper =
- CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
+} else if (auto *Helper =
+   CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
   for (auto I : Helper->getCustomFieldValues(*this, blockInfo)) {
 addHeaderField(
 I.first,
@@

[PATCH] D43783: [OpenCL] Remove block invoke function from emitted block literal struct

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326937: [OpenCL] Remove block invoke function from emitted 
block literal struct (authored by yaxunl, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43783

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -1,10 +1,7 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s
 
-// SPIR: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
-// AMDGCN: %struct.__opencl_block_literal_generic = type { i32, i32, i8* }
-// SPIR: @__block_literal_global = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 12, i32 4, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* @block_A_block_invoke to i8*) to i8 addrspace(4)*) }
-// AMDGCN: @__block_literal_global = internal addrspace(1) constant { i32, i32, i8* } { i32 16, i32 8, i8* bitcast (void (i8*, i8 addrspace(3)*)* @block_A_block_invoke to i8*) }
+// COMMON: @__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 }
 // COMMON-NOT: .str
 
 // SPIR-LABEL: define internal {{.*}}void @block_A_block_invoke(i8 addrspace(4)* %.block_descriptor, i8 addrspace(3)* %a)
@@ -20,58 +17,46 @@
   // COMMON-NOT: %block.flags
   // COMMON-NOT: %block.reserved
   // COMMON-NOT: %block.descriptor
-  // SPIR: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %block, i32 0, i32 0
-  // AMDGCN: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i8*, i32 }>, <{ i32, i32, i8*, i32 }> addrspace(5)* %block, i32 0, i32 0
-  // SPIR: store i32 16, i32* %[[block_size]]
-  // AMDGCN: store i32 20, i32 addrspace(5)* %[[block_size]]
-  // SPIR: %[[block_align:.*]] = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %block, i32 0, i32 1
-  // AMDGCN: %[[block_align:.*]] = getelementptr inbounds <{ i32, i32, i8*, i32 }>, <{ i32, i32, i8*, i32 }> addrspace(5)* %block, i32 0, i32 1
+  // SPIR: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i32 }>, <{ i32, i32, i32 }>* %[[block:.*]], i32 0, i32 0
+  // AMDGCN: %[[block_size:.*]] = getelementptr inbounds <{ i32, i32, i32 }>, <{ i32, i32, i32 }> addrspace(5)* %[[block:.*]], i32 0, i32 0
+  // SPIR: store i32 12, i32* %[[block_size]]
+  // AMDGCN: store i32 12, i32 addrspace(5)* %[[block_size]]
+  // SPIR: %[[block_align:.*]] = getelementptr inbounds <{ i32, i32, i32 }>, <{ i32, i32, i32 }>* %[[block]], i32 0, i32 1
+  // AMDGCN: %[[block_align:.*]] = getelementptr inbounds <{ i32, i32, i32 }>, <{ i32, i32, i32 }> addrspace(5)* %[[block]], i32 0, i32 1
   // SPIR: store i32 4, i32* %[[block_align]]
-  // AMDGCN: store i32 8, i32 addrspace(5)* %[[block_align]]
-  // SPIR: %[[block_invoke:.*]] = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block:.*]], i32 0, i32 2
-  // SPIR: store i8 addrspace(4)* addrspacecast (i8* bitcast (i32 (i8 addrspace(4)*)* @__foo_block_invoke to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %[[block_invoke]]
-  // SPIR: %[[block_captured:.*]] = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block]], i32 0, i32 3
+  // AMDGCN: store i32 4, i32 addrspace(5)* %[[block_align]]
+  // SPIR: %[[block_captured:.*]] = getelementptr inbounds <{ i32, i32, i32 }>, <{ i32, i32, i32 }>* %[[block]], i32 0, i32 2
   // SPIR: %[[i_value:.*]] = load i32, i32* %i
   // SPIR: store i32 %[[i_value]], i32* %[[block_captured]],
-  // SPIR: %[[blk_ptr:.*]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block]] to i32 ()*
+  // SPIR: %[[blk_ptr:.*]] = bitcast <{ i32, i32, i32 }>* %[[block]] to i32 ()*
   // SPIR: %[[blk_gen_ptr:.*]] = addrspacecast i32 ()* %[[blk_ptr]] to i32 () addrspace(4)*
   // SPIR: store i32 () addrspace(4)* %[[blk_gen_ptr]], i32 () addrspace(4)** %[[block_B:.*]],
-  // SPIR: %[[blk_gen_ptr:.*]] = load i32 () addrspace(4)*, i32 () addrspace(4)** %[[block_B]]
-  // SPIR: %[[block_literal:.*]] = bitcast i32 () addrspace(4)* %[[blk_gen_ptr]] to %struct.__opencl_block_literal_generic addrspace(4)*
-  // SPIR: %[[invoke_addr:.*]] = getelementptr inbounds %struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* %[[block_literal]], i32 0, i32 2
-  // SPIR: %[[blk_gen_ptr:.*]] = bitcast %struct._

[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD

2018-03-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 137447.

https://reviews.llvm.org/D44069

Files:
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -388,6 +388,21 @@
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 
-fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
 
+// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck --check-prefix=CHECK-UBSAN-OPENBSD
+// CHECK-UBSAN-OPENBSD: -fsanitize=undefined
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
+// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LSAN-OPENBSD
+// CHECK-LSAN-OPENBSD: unsupported option '-fsanitize=leak' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-OPENBSD
+// CHECK-TSAN-OPENBSD: unsupported option '-fsanitize=thread' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-MSAN-OPENBSD
+// CHECK-MSAN-OPENBSD: unsupported option '-fsanitize=memory' for target 
'i386-pc-openbsd'
+
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN
 // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option
 


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -388,6 +388,21 @@
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
 
+// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck --check-prefix=CHECK-UBSAN-OPENBSD
+// CHECK-UBSAN-OPENBSD: -fsanitize=undefined
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
+// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-OPENBSD
+// CHECK-LSAN-OPENBSD: unsupported option '-fsanitize=leak' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-OPENBSD
+// CHECK-TSAN-OPENBSD: unsupported option '-fsanitize=thread' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-OPENBSD
+// CHECK-MSAN-OPENBSD: unsupported option '-fsanitize=memory' for target 'i386-pc-openbsd'
+
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN
 // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43980: Push a function scope when parsing function bodies without a declaration

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks!

John touched this code last in https://reviews.llvm.org/rL112038 in 2010, so 
maybe he has some thoughts on how to clean this and the follow-up. I think I'll 
land this as is since it fixes the crash and we can discuss more improvements 
in https://reviews.llvm.org/D44039.




Comment at: clang/lib/Sema/SemaDecl.cpp:12412
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;

thakis wrote:
> Feels a bit long-term risky since ActOnStartOfFunctionDef() and 
> ActOnFinishFunctionBody() both need to know about this special-case 
> invariant. Maybe it's worth to add a FakeFunctionScopeCount member to sema in 
> +assert builds, and to increment that here, assert it's > 0 in the other 
> place and decrement it there, and then assert it's 0 at end of TU?
Well, it's more like these early returns break the invariant that 
`ActOnStartOfFunctionDef` pushes a function scope. We could try to clean it up 
with an RAII helper or an layer of function call that ensures that we always 
push and pop on start and finish, but I'll leave that for the follow-up.



Comment at: clang/test/SemaCXX/pr36536.cpp:19
+  // this when they forget to close a namespace, and we'd generate far fewer
+  // errors if names in Foo were in scope.
+  // expected-error@+1 {{unknown type name 'NameInClass'}}

thakis wrote:
> Not 100% clear to me what the FIXME is here. Maybe "FIXME: We should improve 
> our recovery to redeclare" if that's what's meant.
I rewrote this to clarify things.


Repository:
  rC Clang

https://reviews.llvm.org/D43980



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


[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD

2018-03-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 137448.

https://reviews.llvm.org/D44069

Files:
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -388,6 +388,25 @@
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 
-fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
 
+// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck --check-prefix=CHECK-UBSAN-OPENBSD
+// CHECK-UBSAN-OPENBSD: -fsanitize=undefined
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
+// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LSAN-OPENBSD
+// CHECK-LSAN-OPENBSD: unsupported option '-fsanitize=leak' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-OPENBSD
+// CHECK-TSAN-OPENBSD: unsupported option '-fsanitize=thread' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-MSAN-OPENBSD
+// CHECK-MSAN-OPENBSD: unsupported option '-fsanitize=memory' for target 
'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=efficiency-cache-frag %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-OPENBSD
+// RUN: %clang -target i386-pc-openbsd -fsanitize=efficiency-working-set %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-OPENBSD
+// CHECK-ESAN-OPENBSD: error: unsupported option 
'-fsanitize=efficiency-{{.*}}' for target 'i386-pc-openbsd'
+
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN
 // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option
 


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -388,6 +388,25 @@
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
 
+// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck --check-prefix=CHECK-UBSAN-OPENBSD
+// CHECK-UBSAN-OPENBSD: -fsanitize=undefined
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
+// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-OPENBSD
+// CHECK-LSAN-OPENBSD: unsupported option '-fsanitize=leak' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-OPENBSD
+// CHECK-TSAN-OPENBSD: unsupported option '-fsanitize=thread' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-OPENBSD
+// CHECK-MSAN-OPENBSD: unsupported option '-fsanitize=memory' for target 'i386-pc-openbsd'
+
+// RUN: %clang -target i386-pc-openbsd -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-OPENBSD
+// RUN: %clang -target i386-pc-openbsd -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-OPENBSD
+// CHECK-ESAN-OPENBSD: error: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-pc-openbsd'
+
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN
 // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44221: Avoid including ScopeInfo.h from Sema.h

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: rjmccall.

This provides no measurable build speedup, but it reinstates an
optimization from r112038 that was lost in r179618.  It requires moving
CapturedScopeInfo::Capture out to clang::sema, which might be too
general since we have plenty of other Capture records in BlockDecl and
other AST nodes.


https://reviews.llvm.org/D44221

Files:
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaLambda.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp

Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4040,32 +4040,29 @@
   return RD;
 }
 
-static void buildCapturedStmtCaptureList(
-SmallVectorImpl &Captures,
-SmallVectorImpl &CaptureInits,
-ArrayRef Candidates) {
-
-  typedef ArrayRef::const_iterator CaptureIter;
-  for (CaptureIter Cap = Candidates.begin(); Cap != Candidates.end(); ++Cap) {
-
-if (Cap->isThisCapture()) {
-  Captures.push_back(CapturedStmt::Capture(Cap->getLocation(),
+static void
+buildCapturedStmtCaptureList(SmallVectorImpl &Captures,
+ SmallVectorImpl &CaptureInits,
+ ArrayRef Candidates) {
+  for (const sema::Capture &Cap : Candidates) {
+if (Cap.isThisCapture()) {
+  Captures.push_back(CapturedStmt::Capture(Cap.getLocation(),
CapturedStmt::VCK_This));
-  CaptureInits.push_back(Cap->getInitExpr());
+  CaptureInits.push_back(Cap.getInitExpr());
   continue;
-} else if (Cap->isVLATypeCapture()) {
+} else if (Cap.isVLATypeCapture()) {
   Captures.push_back(
-  CapturedStmt::Capture(Cap->getLocation(), CapturedStmt::VCK_VLAType));
+  CapturedStmt::Capture(Cap.getLocation(), CapturedStmt::VCK_VLAType));
   CaptureInits.push_back(nullptr);
   continue;
 }
 
-Captures.push_back(CapturedStmt::Capture(Cap->getLocation(),
- Cap->isReferenceCapture()
+Captures.push_back(CapturedStmt::Capture(Cap.getLocation(),
+ Cap.isReferenceCapture()
  ? CapturedStmt::VCK_ByRef
  : CapturedStmt::VCK_ByCopy,
- Cap->getVariable()));
-CaptureInits.push_back(Cap->getInitExpr());
+ Cap.getVariable()));
+CaptureInits.push_back(Cap.getInitExpr());
   }
 }
 
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1388,8 +1388,9 @@
   Class->addDecl(Conversion);
 }
 
-static ExprResult performLambdaVarCaptureInitialization(
-Sema &S, const LambdaScopeInfo::Capture &Capture, FieldDecl *Field) {
+static ExprResult performLambdaVarCaptureInitialization(Sema &S,
+const Capture &Capture,
+FieldDecl *Field) {
   assert(Capture.isVariableCapture() && "not a variable capture");
 
   auto *Var = Capture.getVariable();
@@ -1443,7 +1444,7 @@
   llvm_unreachable("Unknown implicit capture style");
 }
 
-bool Sema::CaptureHasSideEffects(const LambdaScopeInfo::Capture &From) {
+bool Sema::CaptureHasSideEffects(const Capture &From) {
   if (!From.isVLATypeCapture()) {
 Expr *Init = From.getInitExpr();
 if (Init && Init->HasSideEffects(Context))
@@ -1468,7 +1469,7 @@
   return false;
 }
 
-void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture &From) {
+void Sema::DiagnoseUnusedLambdaCapture(const Capture &From) {
   if (CaptureHasSideEffects(From))
 return;
 
@@ -1523,7 +1524,7 @@
 // Translate captures.
 auto CurField = Class->field_begin();
 for (unsigned I = 0, N = LSI->Captures.size(); I != N; ++I, ++CurField) {
-  const LambdaScopeInfo::Capture &From = LSI->Captures[I];
+  const Capture &From = LSI->Captures[I];
   assert(!From.isBlockCapture() && "Cannot capture __block variables");
   bool IsImplicit = I >= LSI->NumExplicitCaptures;
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13045,7 +13045,7 @@
   // Set the captured variables on the block.
   // FIXME: Share capture structure between BlockDecl and CapturingScopeInfo!
   SmallVector Captures;
-  for (CapturingScopeInfo::Capture &Cap : BSI->Captures) {
+  for (Capture &Cap : BSI->Captures) {
 if (Cap.isThisCapture())

[PATCH] D41102: Setup clang-doc frontend framework

2018-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D41102#1028995, @lebedev.ri wrote:

> Some further notes based on the SHA1 nature.


I'm sorry, brainfreeze, i meant `40` chars, not `20`.
Updated comments...




Comment at: clang-doc/BitcodeWriter.cpp:309
+  assert(Ref.USR.size() < (1U << BitCodeConstants::USRLengthSize));
+  Record.push_back(Ref.USR.size());
+  Stream.EmitRecordWithBlob(Abbrevs.get(ID), Record, Ref.USR);

lebedev.ri wrote:
> Now it would make sense to also assert that this sha1(usr).strlen() == 20
40 that is



Comment at: clang-doc/BitcodeWriter.h:46
+  static constexpr unsigned ReferenceTypeSize = 8U;
+  static constexpr unsigned USRLengthSize = 16U;
+};

lebedev.ri wrote:
> Can definitively lower this to `5U` (2^6 == 32, which is more than the 20 
> 8-bit chars of sha1)
Edit: to 6U (2^6 == 64, which is more than the 40 8-bit chars of sha1)



Comment at: clang-doc/Representation.h:59
+
+  SmallString<16> USR;
+  InfoType RefType = InfoType::IT_default;

lebedev.ri wrote:
> Now that USR is sha1'd, this is **always** 20 8-bit characters long.
40 that is



Comment at: clang-doc/Representation.h:107
+
+  SmallString<16> USR;
+  SmallString<16> Name;

lebedev.ri wrote:
> `20`
> Maybe place `using USRString = SmallString<20>; // SHA1 of USR` somewhere and 
> use it everywhere?
40


https://reviews.llvm.org/D41102



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


[PATCH] D44221: Avoid including ScopeInfo.h from Sema.h

2018-03-07 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.


https://reviews.llvm.org/D44221



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


[PATCH] D44222: [AArch64] Add vmulxh_lane FP16 intrinsics

2018-03-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: az, evandro, olista01.
Herald added subscribers: kristof.beyls, javed.absar, rengolin.

Add 2 vmulxh_lane vector intrinsics that were commented out.


https://reviews.llvm.org/D44222

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/aarch64-v8.2a-neon-intrinsics.c


Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1223,27 +1223,25 @@
   return vmulxq_n_f16(a, b);
 }
 
-/* TODO: Not implemented yet (needs scalar intrinsic from arm_fp16.h)
-// CCHECK-LABEL: test_vmulxh_lane_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_lane_f16
+// CHECK: [[CONV0:%.*]] = fpext half %a to float
+// CHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
+// CHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
+// CHECK: [[CONV3:%.*]] = fptrunc float %mul to half
+// CHECK: ret half [[CONV3:%.*]]
 float16_t test_vmulxh_lane_f16(float16_t a, float16x4_t b) {
   return vmulxh_lane_f16(a, b, 3);
 }
 
-// CCHECK-LABEL: test_vmulxh_laneq_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_laneq_f16
+// CHECK: [[CONV0:%.*]] = fpext half %a to float
+// CHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
+// CHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
+// CHECK: [[CONV3:%.*]] = fptrunc float %mul to half
+// CHECK: ret half [[CONV3:%.*]]
 float16_t test_vmulxh_laneq_f16(float16_t a, float16x8_t b) {
   return vmulxh_laneq_f16(a, b, 7);
 }
-*/
 
 // CHECK-LABEL: test_vmaxv_f16
 // CHECK: [[TMP0:%.*]] = bitcast <4 x half> %a to <8 x i8>
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1499,11 +1499,10 @@
   def VMULX_LANEH   : IOpInst<"vmulx_lane", "ddgi", "hQh", OP_MULX_LN>;
   def VMULX_LANEQH  : IOpInst<"vmulx_laneq", "ddji", "hQh", OP_MULX_LN>;
   def VMULX_NH  : IOpInst<"vmulx_n", "dds", "hQh", OP_MULX_N>;
-  // TODO: Scalar floating point multiply extended (scalar, by element)
-  // Below ones are commented out because they need vmulx_f16(float16_t, 
float16_t)
-  // which will be implemented later with fp16 scalar intrinsic (arm_fp16.h)
-  //def SCALAR_FMULX_LANEH : IOpInst<"vmulx_lane", "ssdi", "Sh", 
OP_SCALAR_MUL_LN>;
-  //def SCALAR_FMULX_LANEQH : IOpInst<"vmulx_laneq", "ssji", "Sh", 
OP_SCALAR_MUL_LN>;
+
+  // Scalar floating point multiply extended (scalar, by element)
+  def SCALAR_FMULX_LANEH : IOpInst<"vmulx_lane", "ssdi", "Sh", 
OP_SCALAR_MUL_LN>;
+  def SCALAR_FMULX_LANEQH : IOpInst<"vmulx_laneq", "ssji", "Sh", 
OP_SCALAR_MUL_LN>;
 
   // ARMv8.2-A FP16 reduction vector intrinsics.
   def VMAXVH   : SInst<"vmaxv", "sd", "hQh">;


Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1223,27 +1223,25 @@
   return vmulxq_n_f16(a, b);
 }
 
-/* TODO: Not implemented yet (needs scalar intrinsic from arm_fp16.h)
-// CCHECK-LABEL: test_vmulxh_lane_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_lane_f16
+// CHECK: [[CONV0:%.*]] = fpext half %a to float
+// CHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
+// CHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
+// CHECK: [[CONV3:%.*]] = fptrunc float %mul to half
+// CHECK: ret half [[CONV3:%.*]]
 float16_t test_vmulxh_lane_f16(float16_t a, float16x4_t b) {
   return vmulxh_lane_f16(a, b, 3);
 }
 
-// CCHECK-LABEL: test_vmulxh_laneq_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_laneq_f16
+// CHECK: [[CONV0:%.*]] = fpext half %a to float
+// CHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
+// CHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
+// CHECK: [[CONV3:%.*]] = fptrunc float %mul to half
+// CHECK

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3427
 (void)InitialArgSize;
-RValue RVArg = Args.back().RV;
-EmitNonNullArgCheck(RVArg, ArgTypes[Idx], (*Arg)->getExprLoc(), AC,
-ParamsToSkip + Idx);
-// @llvm.objectsize should never have side-effects and shouldn't need
-// destruction/cleanups, so we can safely "emit" it after its arg,
-// regardless of right-to-leftness
-MaybeEmitImplicitObjectSize(Idx, *Arg, RVArg);
+if (!Args.back().hasLValue()) {
+  RValue RVArg = Args.back().getKnownRValue();

I think it's okay to do this because of a reasonable assumption that pointer 
arguments are never emitted as LValues, but you should leave that as a comment.


https://reviews.llvm.org/D34367



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


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

No effective behavior change, just for cleanliness.

Fixes PR36159.


https://reviews.llvm.org/D44223

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,22 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  // Emit vtordisps in vbase offset order, to have deterministic output.
+  typedef VBOffsets::value_type VBaseEntry;
+  SmallVector VBases(VBaseMap.begin(), VBaseMap.end());
+  std::stable_sort(VBases.begin(), VBases.end(),
+   [](const VBaseEntry &a, const VBaseEntry &b) {
+ return a.second.VBaseOffset < b.second.VBaseOffset;
+   });
+
+  for (const VBaseEntry E : VBases) {
+if (!E.second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, E.first);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(E.first).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,22 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  // Emit vtordisps in vbase offset order, to have deterministic output.
+  typedef VBOffsets::value_type VBaseEntry;
+  SmallVector VBases(VBaseMap.begin(), VBaseMap.end());
+  std::stable_sort(VBases.begin(), VBases.end(),
+   [](const VBaseEntry &a, const VBaseEntry &b) {
+ return a.second.VBaseOffset < b.second.VBaseOffset;
+   });
+
+  for (const VBaseEntry E : VBases) {
+if (!E.second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, E.first);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(E.first).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1207
+
+  for (const VBaseEntry E : VBases) {
+if (!E.second.hasVtorDisp())

(I added the missing `&` here locally.)


https://reviews.llvm.org/D44223



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


Re: [PATCH] D44218: Correct the alignment for the PS4 target

2018-03-07 Thread Eric Christopher via cfe-commits
LGTM.

On Wed, Mar 7, 2018, 11:02 AM Matthew Voss via Phabricator <
revi...@reviews.llvm.org> wrote:

> ormris created this revision.
> ormris added reviewers: rsmith, craig.topper, echristo, erichkeane.
>
> See above.
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D44218
>
> Files:
>   lib/Basic/Targets/OSTargets.h
>   test/Preprocessor/init.c
>
>
> Index: test/Preprocessor/init.c
> ===
> --- test/Preprocessor/init.c
> +++ test/Preprocessor/init.c
> @@ -8965,6 +8965,9 @@
>  // PS4:#define __x86_64__ 1
>  // PS4:#define unix 1
>  //
> +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 <
> /dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s
> +// PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
> +//
>  // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null |
> FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
>  // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32
> < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
>  // X86-64-DECLSPEC: #define __declspec{{.*}}
> Index: lib/Basic/Targets/OSTargets.h
> ===
> --- lib/Basic/Targets/OSTargets.h
> +++ lib/Basic/Targets/OSTargets.h
> @@ -485,6 +485,7 @@
>  default:
>  case llvm::Triple::x86_64:
>this->MCountName = ".mcount";
> +  this->NewAlign = 256;
>break;
>  }
>}
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1202
+  SmallVector VBases(VBaseMap.begin(), VBaseMap.end());
+  std::stable_sort(VBases.begin(), VBases.end(),
+   [](const VBaseEntry &a, const VBaseEntry &b) {

Using stable_sort() here, as opposed to sort(), doesn't do anything useful 
here; VBaseMap is a DenseMap with a pointer key, so the input is in random 
order anyway.


https://reviews.llvm.org/D44223



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 137457.
juliehockett marked 13 inline comments as done.
juliehockett added a comment.

Updating bitcode writer for hashed USRs, and re-running clang-format. Also 
cleaning up a couple of unused fields.


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/Serialize.cpp
  clang-doc/Serialize.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class-in-class.cpp
  test/clang-doc/mapper-class-in-function.cpp
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-comments.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump-mapper --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/0B8A6B938B939B77C63258AA3E938BF9E2E8.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+
+// CHECK: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT:  record string = '0B8A6B938B939B77C63258AA3E938BF9E2E8'
+  // CHECK-NEXT:  blob data = 'D'
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'D::X'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'D::Y'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump-mapper --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/06B5F6A19BA9F6A832E127C9968282B94619B210.bc --dump | FileCheck %s
+
+struct C { int i; };
+
+// CHECK: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT:  record string = '06B5F6A19BA9F6A832E127C9968282B94619B210'
+  // CHECK-NEXT:  blob data = 'C'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'C::i'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump-mapper --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/8D042EFFC98B373450BC6B5B90A330C25A150E9C.bc --dump | FileCheck %s
+
+namespace A {}
+
+// CHECK: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT:  record string = '8D042EFFC98B373450BC6B5B90A330C25A150E9C'
+  // CHECK-NEXT:  blob data = 'A'
+// CHECK-NEXT: 
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump-mapper --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/F0F9FC65FC90F54F690144A7AFB15DFC3D69B6E6.bc --dump | FileCheck %s --check-prefix CHECK-G-F
+// RUN: llvm-bcanalyzer %t/docs/bc/4202E8BF0ECB12AE354C8499C52725B0EE30AED5.bc --dump | FileCheck %s --check-prefix CHECK-G
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+
+// CHECK-G: 
+// CHECK-G-NEXT: 
+  // CHECK-G-NEXT: 
+// CHECK-G-NEXT: 
+// CHECK-G-NEXT: 
+  // CHECK-G-NEXT:  record string = '4202E8BF0ECB12AE354C8499C52725B0EE30AED5'
+  // CHECK-G-NEXT:  blob data = 'G'
+  // CHECK-G-NEXT: 
+// CHECK-G-NEXT: 
+
+// CHECK-G-F: 
+// CHECK-G-F-NEXT: 
+  // CHECK-G-F-NEXT: 
+// CHECK-G-F-NEXT: 
+// CHECK-G-F-NEXT: 
+  // CHECK-G-F-NEXT:  record string = 'F0F9FC65FC90F54F690144A7AFB15DFC3D69B6E6'
+  // CHECK-G-F-NEXT:  blob data = 'Method'
+  // CHECK-G-F-NEXT:  blob data = '4202E8BF0ECB12AE354C8499C52725B0EE30AED5'
+  // CHECK-G-F-NEXT: 
+  // CHECK-G-F-NEXT:  blob data = '4202E8BF0ECB12AE354C8499C52725B0EE30AED5'
+  // CHECK-G-F-NEXT: 
+// CHECK

RE: [PATCH] D44218: Correct the alignment for the PS4 target

2018-03-07 Thread via cfe-commits
Thanks! I’ll commit this.

From: Eric Christopher [mailto:echri...@gmail.com]
Sent: Wednesday, March 7, 2018 12:33 PM
To: reviews+d44218+public+fd8ca19cc9985...@reviews.llvm.org
Cc: cfe-commits@lists.llvm.org; craig.top...@gmail.com; erich.ke...@intel.com; 
filcab+llvm.phabrica...@gmail.com; Voss, Matthew; rich...@metafoo.co.uk
Subject: Re: [PATCH] D44218: Correct the alignment for the PS4 target

LGTM.
On Wed, Mar 7, 2018, 11:02 AM Matthew Voss via Phabricator 
mailto:revi...@reviews.llvm.org>> wrote:
ormris created this revision.
ormris added reviewers: rsmith, craig.topper, echristo, erichkeane.

See above.


Repository:
  rC Clang

https://reviews.llvm.org/D44218

Files:
  lib/Basic/Targets/OSTargets.h
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8965,6 +8965,9 @@
 // PS4:#define __x86_64__ 1
 // PS4:#define unix 1
 //
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < 
/dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s
+// PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
+//
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC %s
 // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
 // X86-64-DECLSPEC: #define __declspec{{.*}}
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -485,6 +485,7 @@
 default:
 case llvm::Triple::x86_64:
   this->MCountName = ".mcount";
+  this->NewAlign = 256;
   break;
 }
   }

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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-03-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Btw, I'm going to be talking about this patch tonight at 7 in Palo Alto. :)
https://www.meetup.com/ACCU-Bay-Area/events/248040207/
https://docs.google.com/presentation/d/18ZRnedocXSQKn9Eh67gGv-ignReHfRD7vj_dxrra1kc/


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


r326942 - Correct the alignment for the PS4 target

2018-03-07 Thread Matthew Voss via cfe-commits
Author: ormris
Date: Wed Mar  7 12:48:16 2018
New Revision: 326942

URL: http://llvm.org/viewvc/llvm-project?rev=326942&view=rev
Log:
Correct the alignment for the PS4 target

https://reviews.llvm.org/D44218

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=326942&r1=326941&r2=326942&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Mar  7 12:48:16 2018
@@ -485,6 +485,7 @@ public:
 default:
 case llvm::Triple::x86_64:
   this->MCountName = ".mcount";
+  this->NewAlign = 256;
   break;
 }
   }

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=326942&r1=326941&r2=326942&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Mar  7 12:48:16 2018
@@ -8965,6 +8965,9 @@
 // PS4:#define __x86_64__ 1
 // PS4:#define unix 1
 //
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < 
/dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s
+// PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
+//
 // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC %s
 // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
 // X86-64-DECLSPEC: #define __declspec{{.*}}


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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 137460.
yaxunl marked an inline comment as done.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Added comment about emit non-null argument check.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMDGCN20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMDGCN-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMDGCN-LABEL: define void @test_indirect_arg_private()
+// AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN-NOT: @llvm.memcpy
+// AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMDGCN-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMDGCN-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/Code

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 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.

Thanks.  LGTM!


https://reviews.llvm.org/D34367



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


[PATCH] D44222: [AArch64] Add vmulxh_lane FP16 intrinsics

2018-03-07 Thread Evandro Menezes via Phabricator via cfe-commits
evandro accepted this revision.
evandro added a comment.
This revision is now accepted and ready to land.

Looks pretty straightforward to me.


https://reviews.llvm.org/D44222



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


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 137463.
thakis added a comment.
Herald added a subscriber: mgrang.

sort unstably


https://reviews.llvm.org/D44223

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,21 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  // Emit vtordisps in vbase offset order, to have deterministic output.
+  typedef VBOffsets::value_type VBase;
+  SmallVector VBases(VBaseMap.begin(), VBaseMap.end());
+  std::sort(VBases.begin(), VBases.end(), [](const VBase &a, const VBase &b) {
+return a.second.VBaseOffset < b.second.VBaseOffset;
+  });
+
+  for (const VBase &V : VBases) {
+if (!V.second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, V.first);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(V.first).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,21 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  // Emit vtordisps in vbase offset order, to have deterministic output.
+  typedef VBOffsets::value_type VBase;
+  SmallVector VBases(VBaseMap.begin(), VBaseMap.end());
+  std::sort(VBases.begin(), VBases.end(), [](const VBase &a, const VBase &b) {
+return a.second.VBaseOffset < b.second.VBaseOffset;
+  });
+
+  for (const VBase &V : VBases) {
+if (!V.second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, V.first);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(V.first).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks for investigating!




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1206
+
+  for (const VBase &V : VBases) {
+if (!V.second.hasVtorDisp())

I think we can avoid the sort altogether if we iterate `RD->vbases()`, which 
should already be in layout order, and then do lookup into `VBaseMap`.


https://reviews.llvm.org/D44223



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


Re: r326602 - [Attr] Fix parameter indexing for several attributes

2018-03-07 Thread Nico Weber via cfe-commits
(I had to revert this since it caused
https://bugs.llvm.org/show_bug.cgi?id=36620)

On Fri, Mar 2, 2018 at 2:03 PM, Joel E. Denny via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jdenny
> Date: Fri Mar  2 11:03:22 2018
> New Revision: 326602
>
> URL: http://llvm.org/viewvc/llvm-project?rev=326602&view=rev
> Log:
> [Attr] Fix parameter indexing for several attributes
>
> The patch fixes a number of bugs related to parameter indexing in
> attributes:
>
> * Parameter indices in some attributes (argument_with_type_tag,
>   pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
>   and ownership_returns) are specified in source as one-origin
>   including any C++ implicit this parameter, were stored as
>   zero-origin excluding any this parameter, and were erroneously
>   printing (-ast-print) and confusingly dumping (-ast-dump) as the
>   stored values.
>
> * For alloc_size, the C++ implicit this parameter was not subtracted
>   correctly in Sema, leading to assert failures or to silent failures
>   of __builtin_object_size to compute a value.
>
> * For argument_with_type_tag, pointer_with_type_tag, and
>   ownership_returns, the C++ implicit this parameter was not added
>   back to parameter indices in some diagnostics.
>
> This patch fixes the above bugs and aims to prevent similar bugs in
> the future by introducing careful mechanisms for handling parameter
> indices in attributes.  ParamIdx stores a parameter index and is
> designed to hide the stored encoding while providing accessors that
> require each use (such as printing) to make explicit the encoding that
> is needed.  Attribute declarations declare parameter index arguments
> as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
> patch rewrites all attribute arguments that are processed by
> checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
> as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
> argument, which is encoded as a count not an index.
>
> Differential Revision: https://reviews.llvm.org/D43248
>
> Added:
> cfe/trunk/test/Sema/attr-ownership.cpp
> Modified:
> cfe/trunk/include/clang/AST/Attr.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
> cfe/trunk/test/CodeGenCXX/alloc-size.cpp
> cfe/trunk/test/Misc/ast-dump-attr.cpp
> cfe/trunk/test/Sema/attr-print.cpp
> cfe/trunk/test/Sema/error-type-safety.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/AST/Attr.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Attr.h?rev=326602&r1=326601&r2=326602&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Fri Mar  2 11:03:22 2018
> @@ -195,6 +195,120 @@ public:
> }
>  };
>
> +/// A single parameter index whose accessors require each use to make
> explicit
> +/// the parameter index encoding needed.
> +class ParamIdx {
> +  // Idx is exposed only via accessors that specify specific encodings.
> +  unsigned Idx : 30;
> +  unsigned HasThis : 1;
> +  unsigned IsValid : 1;
> +
> +  void assertComparable(const ParamIdx &I) const {
> +assert(isValid() && I.isValid() &&
> +   "ParamIdx must be valid to be compared");
> +// It's possible to compare indices from separate functions, but so
> far
> +// it's not proven useful.  Moreover, it might be confusing because a
> +// comparison on the results of getASTIndex might be inconsistent
> with a
> +// comparison on the ParamIdx objects themselves.
> +assert(HasThis == I.HasThis &&
> +   "ParamIdx must be for the same function to be compared");
> +  }
> +
> +public:
> +  /// Construct an invalid parameter index (\c isValid returns false and
> +  /// accessors fail an assert).
> +  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
> +
> +  /// \param Idx is the parameter index as it is normally specified in
> +  /// attributes in the source: one-origin including any C++ implicit this
> +  /// parameter.
> +  ///
> +  /// \param D is the declaration containing the parameters.  It is used
> to
> +  /// determine if there is a C++ implicit this parameter.
> +  ParamIdx(unsigned Idx, const Decl *D)
> +  : Idx(Idx), HasThis(false), IsValid(true) {
> +if (const auto *FD = dyn_cast(D))
> +  HasThis = FD->isCXXInstanceMember();
> +  }
> +
> +  /// \param Idx is the parameter index as it is normally specified in
> +  /// attributes in the source: one-origin including any C++ implic

r326945 - [clang-format] Break consecutive string literals in text protos

2018-03-07 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Mar  7 13:30:38 2018
New Revision: 326945

URL: http://llvm.org/viewvc/llvm-project?rev=326945&view=rev
Log:
[clang-format] Break consecutive string literals in text protos

Summary:
This patch fixes a bug where consecutive string literals in text protos were
put on the same line.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=326945&r1=326944&r2=326945&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Mar  7 13:30:38 2018
@@ -2717,7 +2717,8 @@ bool TokenAnnotator::mustBreakBefore(con
   return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
- Style.Language == FormatStyle::LK_Proto) {
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
   }

Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=326945&r1=326944&r2=326945&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Wed Mar  7 13:30:38 2018
@@ -452,5 +452,11 @@ TEST_F(FormatTestTextProto, AcceptsOpera
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+   " \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D44204: [clang-format] Break consecutive string literals in text protos

2018-03-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326945: [clang-format] Break consecutive string literals in 
text protos (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44204

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestTextProto.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@
   return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
- Style.Language == FormatStyle::LK_Proto) {
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
   }
Index: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+   " \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2717,7 +2717,8 @@
   return true;
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
- Style.Language == FormatStyle::LK_Proto) {
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
   }
Index: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp
@@ -452,5 +452,11 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, BreaksConsecutiveStringLiterals) {
+  verifyFormat("ala: \"str1\"\n"
+   " \"str2\"\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Hmm, i'm missing something about the way store sha1...




Comment at: clang-doc/BitcodeWriter.cpp:53
+{// 0. Fixed-size integer (length of the sha1'd USR)
+ llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR,
+   BitCodeConstants::USRLengthSize),

This is VBR because USRLengthSize is of such strange size, to conserve the bits?



Comment at: clang-doc/BitcodeWriter.cpp:57
+ llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array),
+ llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Char6)});
+}

Looking at the `NumWords` changes (decrease!) in the tests, and this is bugging 
me.
And now that i have realized what we do with USR:
* we first compute SHA1, and get 20x uint8_t
* store/use it internally
* then hex-ify it, getting 40x char (assuming 8-bit char)
* then convert to char6, winning back two bits. but we still loose 2 bits.

Question: *why* do we store sha1 of USR as a string? 
Why can't we just store that USRString (aka USRSha1 binary) directly?
That would be just 20 bytes, you just couldn't go any lower than that.



Comment at: clang-doc/Representation.h:29
+
+using USRString = std::array;
+

Right, of course, internally this is kept in the binary format, which is just 
20 chars.
This is not the string (the hex-ified version of sha1), but the raw sha1, the 
binary.
This should somehow convey that. This should be something closer to `USRSha1`.


https://reviews.llvm.org/D41102



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


[PATCH] D44213: [clangd] Remove unused field in HandlerRegisterer

2018-03-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle accepted this revision.
malaperle added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44213



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


[PATCH] D44189: [RISCV] Verify the input value of -march=

2018-03-07 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:48
+  break;
+default:
+  // First letter should be 'i' or 'g'.

In the switch cases move default to first position.



Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:60
   case 'm':
 Features.push_back("+m");
 break;

So the subsequent features can appear in any order?


Repository:
  rC Clang

https://reviews.llvm.org/D44189



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


r326946 - CodeGen: Fix address space of indirect function argument

2018-03-07 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Mar  7 13:45:40 2018
New Revision: 326946

URL: http://llvm.org/viewvc/llvm-project?rev=326946&view=rev
Log:
CodeGen: Fix address space of indirect function argument

The indirect function argument is in alloca address space in LLVM IR. However,
during Clang codegen for C++, the address space of indirect function argument
should match its address space in the source code, i.e., default addr space, 
even
for indirect argument. This is because destructor of the indirect argument may
be called in the caller function, and address of the indirect argument may be
taken, in either case the indirect function argument is expected to be in 
default
addr space, not the alloca address space.

Therefore, the indirect function argument should be mapped to the temp var
casted to default address space. The caller will cast it to alloca addr space
when passing it to the callee. In the callee, the argument is also casted to the
default address space and used.

CallArg is refactored to facilitate this fix.

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

Added:
cfe/trunk/test/CodeGenCXX/amdgcn-func-arg.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGGPUBuiltin.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
cfe/trunk/test/CodeGenOpenCL/byval.cl

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=326946&r1=326945&r2=326946&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Wed Mar  7 13:45:40 2018
@@ -1160,7 +1160,7 @@ RValue CodeGenFunction::EmitAtomicExpr(A
 if (UseOptimizedLibcall && Res.getScalarVal()) {
   llvm::Value *ResVal = Res.getScalarVal();
   if (PostOp) {
-llvm::Value *LoadVal1 = Args[1].RV.getScalarVal();
+llvm::Value *LoadVal1 = Args[1].getRValue(*this).getScalarVal();
 ResVal = Builder.CreateBinOp(PostOp, ResVal, LoadVal1);
   }
   if (E->getOp() == AtomicExpr::AO__atomic_nand_fetch)

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=326946&r1=326945&r2=326946&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Mar  7 13:45:40 2018
@@ -1040,42 +1040,49 @@ void CodeGenFunction::ExpandTypeFromArgs
 }
 
 void CodeGenFunction::ExpandTypeToArgs(
-QualType Ty, RValue RV, llvm::FunctionType *IRFuncTy,
+QualType Ty, CallArg Arg, llvm::FunctionType *IRFuncTy,
 SmallVectorImpl &IRCallArgs, unsigned &IRCallArgPos) {
   auto Exp = getTypeExpansion(Ty, getContext());
   if (auto CAExp = dyn_cast(Exp.get())) {
-forConstantArrayExpansion(*this, CAExp, RV.getAggregateAddress(),
-  [&](Address EltAddr) {
-  RValue EltRV =
-  convertTempToRValue(EltAddr, CAExp->EltTy, SourceLocation());
-  ExpandTypeToArgs(CAExp->EltTy, EltRV, IRFuncTy, IRCallArgs, 
IRCallArgPos);
-});
+Address Addr = Arg.hasLValue() ? Arg.getKnownLValue().getAddress()
+   : 
Arg.getKnownRValue().getAggregateAddress();
+forConstantArrayExpansion(
+*this, CAExp, Addr, [&](Address EltAddr) {
+  CallArg EltArg = CallArg(
+  convertTempToRValue(EltAddr, CAExp->EltTy, SourceLocation()),
+  CAExp->EltTy);
+  ExpandTypeToArgs(CAExp->EltTy, EltArg, IRFuncTy, IRCallArgs,
+   IRCallArgPos);
+});
   } else if (auto RExp = dyn_cast(Exp.get())) {
-Address This = RV.getAggregateAddress();
+Address This = Arg.hasLValue() ? Arg.getKnownLValue().getAddress()
+   : 
Arg.getKnownRValue().getAggregateAddress();
 for (const CXXBaseSpecifier *BS : RExp->Bases) {
   // Perform a single step derived-to-base conversion.
   Address Base =
   GetAddressOfBaseClass(This, Ty->getAsCXXRecordDecl(), &BS, &BS + 1,
 /*NullCheckValue=*/false, SourceLocation());
-  RValue BaseRV = RValue::getAggregate(Base);
+  CallArg BaseArg = CallArg(RValue::getAggregate(Base), BS->getType());
 
   // Recurse onto bases.
-  ExpandTypeToArgs(BS->getType(), BaseRV, IRFuncTy, IRCallArgs,
+  ExpandTypeToArgs(BS->getType(), BaseArg, IRFuncTy, IRCallArgs,
IRCallArgPos);
 }
 
 L

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326946: CodeGen: Fix address space of indirect function 
argument (authored by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D34367?vs=137460&id=137469#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34367

Files:
  cfe/trunk/lib/CodeGen/CGAtomic.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGCall.h
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGGPUBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/amdgcn-func-arg.cpp
  cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
  cfe/trunk/test/CodeGenOpenCL/byval.cl

Index: cfe/trunk/test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- cfe/trunk/test/CodeGenCXX/amdgcn-func-arg.cpp
+++ cfe/trunk/test/CodeGenCXX/amdgcn-func-arg.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn -emit-llvm %s -o - | FileCheck %s
+
+class A {
+public:
+  int x;
+  A():x(0) {}
+  ~A() {}
+};
+
+class B {
+int x[100];
+};
+
+A g_a;
+B g_b;
+
+void func_with_ref_arg(A &a);
+void func_with_ref_arg(B &b);
+
+// CHECK-LABEL: define void @_Z22func_with_indirect_arg1A(%class.A addrspace(5)* %a)
+// CHECK:  %p = alloca %class.A*, align 8, addrspace(5)
+// CHECK:  %[[r1:.+]] = addrspacecast %class.A* addrspace(5)* %p to %class.A**
+// CHECK:  %[[r0:.+]] = addrspacecast %class.A addrspace(5)* %a to %class.A*
+// CHECK:  store %class.A* %[[r0]], %class.A** %[[r1]], align 8
+void func_with_indirect_arg(A a) {
+  A *p = &a;
+}
+
+// CHECK-LABEL: define void @_Z22test_indirect_arg_autov()
+// CHECK:  %a = alloca %class.A, align 4, addrspace(5)
+// CHECK:  %[[r0:.+]] = addrspacecast %class.A addrspace(5)* %a to %class.A*
+// CHECK:  %agg.tmp = alloca %class.A, align 4, addrspace(5)
+// CHECK:  %[[r1:.+]] = addrspacecast %class.A addrspace(5)* %agg.tmp to %class.A*
+// CHECK:  call void @_ZN1AC1Ev(%class.A* %[[r0]])
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64
+// CHECK:  %[[r4:.+]] = addrspacecast %class.A* %[[r1]] to %class.A addrspace(5)*
+// CHECK:  call void @_Z22func_with_indirect_arg1A(%class.A addrspace(5)* %[[r4]])
+// CHECK:  call void @_ZN1AD1Ev(%class.A* %[[r1]])
+// CHECK:  call void @_Z17func_with_ref_argR1A(%class.A* dereferenceable(4) %[[r0]])
+// CHECK:  call void @_ZN1AD1Ev(%class.A* %[[r0]])
+void test_indirect_arg_auto() {
+  A a;
+  func_with_indirect_arg(a);
+  func_with_ref_arg(a);
+}
+
+// CHECK: define void @_Z24test_indirect_arg_globalv()
+// CHECK:  %agg.tmp = alloca %class.A, align 4, addrspace(5)
+// CHECK:  %[[r0:.+]] = addrspacecast %class.A addrspace(5)* %agg.tmp to %class.A*
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64
+// CHECK:  %[[r2:.+]] = addrspacecast %class.A* %[[r0]] to %class.A addrspace(5)*
+// CHECK:  call void @_Z22func_with_indirect_arg1A(%class.A addrspace(5)* %[[r2]])
+// CHECK:  call void @_ZN1AD1Ev(%class.A* %[[r0]])
+// CHECK:  call void @_Z17func_with_ref_argR1A(%class.A* dereferenceable(4) addrspacecast (%class.A addrspace(1)* @g_a to %class.A*))
+void test_indirect_arg_global() {
+  func_with_indirect_arg(g_a);
+  func_with_ref_arg(g_a);
+}
+
+// CHECK-LABEL: define void @_Z19func_with_byval_arg1B(%class.B addrspace(5)* byval align 4 %b)
+// CHECK:  %p = alloca %class.B*, align 8, addrspace(5)
+// CHECK:  %[[r1:.+]] = addrspacecast %class.B* addrspace(5)* %p to %class.B**
+// CHECK:  %[[r0:.+]] = addrspacecast %class.B addrspace(5)* %b to %class.B*
+// CHECK:  store %class.B* %[[r0]], %class.B** %[[r1]], align 8
+void func_with_byval_arg(B b) {
+  B *p = &b;
+}
+
+// CHECK-LABEL: define void @_Z19test_byval_arg_autov()
+// CHECK:  %b = alloca %class.B, align 4, addrspace(5)
+// CHECK:  %[[r0:.+]] = addrspacecast %class.B addrspace(5)* %b to %class.B*
+// CHECK:  %agg.tmp = alloca %class.B, align 4, addrspace(5)
+// CHECK:  %[[r1:.+]] = addrspacecast %class.B addrspace(5)* %agg.tmp to %class.B*
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64
+// CHECK:  %[[r4:.+]] = addrspacecast %class.B* %[[r1]] to %class.B addrspace(5)*
+// CHECK:  call void @_Z19func_with_byval_arg1B(%class.B addrspace(5)* byval align 4 %[[r4]])
+// CHECK:  call void @_Z17func_with_ref_argR1B(%class.B* dereferenceable(400) %[[r0]])
+void test_byval_arg_auto() {
+  B b;
+  func_with_byval_arg(b);
+  func_with_ref_arg(b);
+}
+
+// CHECK-LABEL: define void @_Z21test_byval_arg_globalv()
+// CHECK:  %agg.tmp = alloca %class.B, align 4, addrspace(5)
+// CHECK:  %[[r0:.+]] = addrspacecast %class.B addrspace(5)* %agg.tmp to %class.B*
+// CHECK:  call void @llvm.memcpy.p0i8.p0i8.i64
+// CHECK:  %[[r2:.+]] = addrspacecast %class.B* %[[r0]] to %class.B 

[PATCH] D44213: [clangd] Remove unused field in HandlerRegisterer

2018-03-07 Thread Simon Marchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE326947: [clangd] Remove unused field in HandlerRegisterer 
(authored by simark, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44213?vs=137410&id=137471#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44213

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h


Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,7 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
   ProtocolCallbacks &Callbacks);
 
 } // namespace clangd
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);


Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -38,16 +38,14 @@
   }
 
   JSONRPCDispatcher &Dispatcher;
-  JSONOutput *Out;
   ProtocolCallbacks *Callbacks;
 };
 
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
-  JSONOutput &Out,
   ProtocolCallbacks &Callbacks) {
-  HandlerRegisterer Register{Dispatcher, &Out, &Callbacks};
+  HandlerRegisterer Register{Dispatcher, &Callbacks};
 
   Register("initialize", &ProtocolCallbacks::onInitialize);
   Register("shutdown", &ProtocolCallbacks::onShutdown);
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,7 +55,7 @@
   virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0;
 };
 
-void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
   ProtocolCallbacks &Callbacks);
 
 } // namespace clangd
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -409,7 +409,7 @@
   JSONRPCDispatcher Dispatcher([](const json::Expr &Params) {
 replyError(ErrorCode::MethodNotFound, "method not found");
   });
-  registerCallbackHandlers(Dispatcher, Out, /*Callbacks=*/*this);
+  registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r326602 - [Attr] Fix parameter indexing for several attributes

2018-03-07 Thread Aaron Ballman via cfe-commits
Joel, can you investigate the issue?

~Aaron

On Wed, Mar 7, 2018 at 4:32 PM, Nico Weber via cfe-commits
 wrote:
> (I had to revert this since it caused
> https://bugs.llvm.org/show_bug.cgi?id=36620)
>
> On Fri, Mar 2, 2018 at 2:03 PM, Joel E. Denny via cfe-commits
>  wrote:
>>
>> Author: jdenny
>> Date: Fri Mar  2 11:03:22 2018
>> New Revision: 326602
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=326602&view=rev
>> Log:
>> [Attr] Fix parameter indexing for several attributes
>>
>> The patch fixes a number of bugs related to parameter indexing in
>> attributes:
>>
>> * Parameter indices in some attributes (argument_with_type_tag,
>>   pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
>>   and ownership_returns) are specified in source as one-origin
>>   including any C++ implicit this parameter, were stored as
>>   zero-origin excluding any this parameter, and were erroneously
>>   printing (-ast-print) and confusingly dumping (-ast-dump) as the
>>   stored values.
>>
>> * For alloc_size, the C++ implicit this parameter was not subtracted
>>   correctly in Sema, leading to assert failures or to silent failures
>>   of __builtin_object_size to compute a value.
>>
>> * For argument_with_type_tag, pointer_with_type_tag, and
>>   ownership_returns, the C++ implicit this parameter was not added
>>   back to parameter indices in some diagnostics.
>>
>> This patch fixes the above bugs and aims to prevent similar bugs in
>> the future by introducing careful mechanisms for handling parameter
>> indices in attributes.  ParamIdx stores a parameter index and is
>> designed to hide the stored encoding while providing accessors that
>> require each use (such as printing) to make explicit the encoding that
>> is needed.  Attribute declarations declare parameter index arguments
>> as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
>> patch rewrites all attribute arguments that are processed by
>> checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
>> as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
>> argument, which is encoded as a count not an index.
>>
>> Differential Revision: https://reviews.llvm.org/D43248
>>
>> Added:
>> cfe/trunk/test/Sema/attr-ownership.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Attr.h
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/CodeGen/CGCall.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
>> cfe/trunk/test/CodeGenCXX/alloc-size.cpp
>> cfe/trunk/test/Misc/ast-dump-attr.cpp
>> cfe/trunk/test/Sema/attr-print.cpp
>> cfe/trunk/test/Sema/error-type-safety.cpp
>> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Attr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=326602&r1=326601&r2=326602&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Attr.h (original)
>> +++ cfe/trunk/include/clang/AST/Attr.h Fri Mar  2 11:03:22 2018
>> @@ -195,6 +195,120 @@ public:
>> }
>>  };
>>
>> +/// A single parameter index whose accessors require each use to make
>> explicit
>> +/// the parameter index encoding needed.
>> +class ParamIdx {
>> +  // Idx is exposed only via accessors that specify specific encodings.
>> +  unsigned Idx : 30;
>> +  unsigned HasThis : 1;
>> +  unsigned IsValid : 1;
>> +
>> +  void assertComparable(const ParamIdx &I) const {
>> +assert(isValid() && I.isValid() &&
>> +   "ParamIdx must be valid to be compared");
>> +// It's possible to compare indices from separate functions, but so
>> far
>> +// it's not proven useful.  Moreover, it might be confusing because a
>> +// comparison on the results of getASTIndex might be inconsistent
>> with a
>> +// comparison on the ParamIdx objects themselves.
>> +assert(HasThis == I.HasThis &&
>> +   "ParamIdx must be for the same function to be compared");
>> +  }
>> +
>> +public:
>> +  /// Construct an invalid parameter index (\c isValid returns false and
>> +  /// accessors fail an assert).
>> +  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
>> +
>> +  /// \param Idx is the parameter index as it is normally specified in
>> +  /// attributes in the source: one-origin including any C++ implicit
>> this
>> +  /// parameter.
>> +  ///
>> +  /// \param D is the declaration containing the parameters.  It is used
>> to
>> +  /// determine if there is a C++ implicit this parameter.
>> +  ParamIdx(unsigned Idx, const Decl *D)
>> +  : Idx(Idx), HasThis(false), IsValid(true) {
>> +if (const auto *FD = dyn_cast(D

[PATCH] D44039: [Sema] Make getCurFunction() return null outside function parsing

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 137472.
rnk added a comment.

Bring back Sema::setFunctionHas* methods which internally do nothing when
called outside function scope. This appears to happen in practice when parsing
invalid code involving things like statement expressions, VLAs at global scope,
etc.


https://reviews.llvm.org/D44039

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp

Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -793,7 +793,7 @@
 ArrayRef Exprs,
 SourceLocation EndLoc) {
   bool IsSimple = (NumOutputs != 0 || NumInputs != 0);
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   MSAsmStmt *NS =
 new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple,
 /*IsVolatile*/ true, AsmToks, NumOutputs, NumInputs,
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -557,7 +557,7 @@
 return StmtError();
 
   if (IsConstexpr || isa(Cond.get().second))
-getCurFunction()->setHasBranchProtectedScope();
+setFunctionHasBranchProtectedScope();
 
   DiagnoseUnusedExprResult(thenStmt);
   DiagnoseUnusedExprResult(elseStmt);
@@ -688,7 +688,7 @@
   if (Cond.isInvalid())
 return StmtError();
 
-  getCurFunction()->setHasBranchIntoScope();
+  setFunctionHasBranchIntoScope();
 
   SwitchStmt *SS = new (Context)
   SwitchStmt(Context, InitStmt, Cond.get().first, Cond.get().second);
@@ -1873,7 +1873,7 @@
 Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
  Stmt *First, Expr *collection,
  SourceLocation RParenLoc) {
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
 
   ExprResult CollectionExprResult =
 CheckObjCForCollectionOperand(ForLoc, collection);
@@ -2784,7 +2784,7 @@
 StmtResult Sema::ActOnGotoStmt(SourceLocation GotoLoc,
SourceLocation LabelLoc,
LabelDecl *TheDecl) {
-  getCurFunction()->setHasBranchIntoScope();
+  setFunctionHasBranchIntoScope();
   TheDecl->markUsed(Context);
   return new (Context) GotoStmt(TheDecl, GotoLoc, LabelLoc);
 }
@@ -2811,7 +2811,7 @@
 return StmtError();
   E = ExprRes.get();
 
-  getCurFunction()->setHasIndirectGoto();
+  setFunctionHasIndirectGoto();
 
   return new (Context) IndirectGotoStmt(GotoLoc, StarLoc, E);
 }
@@ -3607,7 +3607,7 @@
   if (!getLangOpts().ObjCExceptions)
 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@try";
 
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   unsigned NumCatchStmts = CatchStmts.size();
   return ObjCAtTryStmt::Create(Context, AtLoc, Try, CatchStmts.data(),
NumCatchStmts, Finally);
@@ -3698,7 +3698,7 @@
 Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SyncExpr,
   Stmt *SyncBody) {
   // We can't jump into or indirect-jump out of a @synchronized block.
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   return new (Context) ObjCAtSynchronizedStmt(AtLoc, SyncExpr, SyncBody);
 }
 
@@ -3714,7 +3714,7 @@
 
 StmtResult
 Sema::ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body) {
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   return new (Context) ObjCAutoreleasePoolStmt(AtLoc, Body);
 }
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -3572,7 +3572,7 @@
   // longjmp() and throw() must not violate the entry/exit criteria.
   CS->getCapturedDecl()->setNothrow();
 
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
 
   return OMPParallelDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
   DSAStack->isCancelRegion());
@@ -5281,7 +5281,7 @@
   if (checkSimdlenSafelenSpecified(*this, Clauses))
 return StmtError();
 
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   return OMPSimdDirective::Create(Context, StartLoc, EndLoc, NestedLoopCount,
   Clauses, AStmt, B);
 }
@@ -5317,7 +5317,7 @@
 }
   }
 
-  getCurFunction()->setHasBranchProtectedScope();
+  setFunctionHasBranchProtectedScope();
   re

[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 137470.
thakis added a comment.

rnk comment


https://reviews.llvm.org/D44223

Files:
  lib/CodeGen/MicrosoftCXXABI.cpp


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,15 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  for (const CXXBaseSpecifier &S : RD->vbases()) {
+const CXXRecordDecl *VBase = S.getType()->getAsCXXRecordDecl();
+if (!VBaseMap.find(VBase)->second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, VBase);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(VBase).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1196,15 +1196,15 @@
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-I != E; ++I) {
-if (!I->second.hasVtorDisp())
+  for (const CXXBaseSpecifier &S : RD->vbases()) {
+const CXXRecordDecl *VBase = S.getType()->getAsCXXRecordDecl();
+if (!VBaseMap.find(VBase)->second.hasVtorDisp())
   continue;
 
 llvm::Value *VBaseOffset =
-GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
+GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, VBase);
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(VBase).getQuantity();
 
 // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
 llvm::Value *VtorDispValue = Builder.CreateSub(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added inline comments.



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1206
+
+  for (const VBase &V : VBases) {
+if (!V.second.hasVtorDisp())

rnk wrote:
> I think we can avoid the sort altogether if we iterate `RD->vbases()`, which 
> should already be in layout order, and then do lookup into `VBaseMap`.
That's way nicer, thanks. Done.


https://reviews.llvm.org/D44223



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


[PATCH] D44226: [clangd] Add -log-to-stderr option

2018-03-07 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision.
Herald added subscribers: cfe-commits, ioeric, JDevlieghere, jkorous-apple, 
ilya-biryukov, klimek.

Currently, clangd prints all the LSP communication on stderr.  While
this is good for developping, I don't think it's good as a general
default.  For example, we are integrating clangd (and other language
servers) in an IDE, and we print everything the language servers send on
their stderr on our own stderr.  Printing the whole LSP communication
adds a lot of noise.  If there are actual error messages to be printed,
then it makes sense to output them on stderr.

Also, an IDE or tool that integrates many language servers will likely
have its own way of logging LSP communication in a consistent way, so
it's better to leave it to that tool to log the LSP communication if it
wants to.

An alternative would be to introduce log levels (debug, info, warning,
error), and output LSP communications only at the debug log level.

Signed-off-by: Simon Marchi 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44226

Files:
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/tool/ClangdMain.cpp
  test/clangd/protocol.test
  test/clangd/too_large.test

Index: test/clangd/too_large.test
===
--- test/clangd/too_large.test
+++ test/clangd/too_large.test
@@ -1,4 +1,4 @@
-# RUN: not clangd -run-synchronously < %s 2>&1 | FileCheck -check-prefix=STDERR %s
+# RUN: not clangd -run-synchronously -log-to-stderr < %s 2>&1 | FileCheck -check-prefix=STDERR %s
 # vim: fileformat=dos
 # It is absolutely vital that this file has CRLF line endings.
 #
Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -1,5 +1,5 @@
-# RUN: not clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
-# RUN: not clangd -pretty -run-synchronously < %s 2>&1 | FileCheck -check-prefix=STDERR %s
+# RUN: not clangd -pretty -log-to-stderr -run-synchronously < %s | FileCheck -strict-whitespace %s
+# RUN: not clangd -pretty -log-to-stderr -run-synchronously < %s 2>&1 | FileCheck -check-prefix=STDERR %s
 # vim: fileformat=dos
 # It is absolutely vital that this file has CRLF line endings.
 #
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -77,15 +77,20 @@
 llvm::cl::init(JSONStreamStyle::Standard));
 
 static llvm::cl::opt
+LogToStderr("log-to-stderr",
+llvm::cl::desc("Output LSP communication on stderr"),
+llvm::cl::init(false));
+
+static llvm::cl::opt
 PrettyPrint("pretty", llvm::cl::desc("Pretty-print JSON output"),
 llvm::cl::init(false));
 
-static llvm::cl::opt Test(
-"lit-test",
-llvm::cl::desc(
-"Abbreviation for -input-style=delimited -pretty -run-synchronously. "
-"Intended to simplify lit tests."),
-llvm::cl::init(false), llvm::cl::Hidden);
+static llvm::cl::opt
+Test("lit-test",
+ llvm::cl::desc(
+ "Abbreviation for -input-style=delimited -pretty -log-to-stderr "
+ "-run-synchronously. Intended to simplify lit tests."),
+ llvm::cl::init(false), llvm::cl::Hidden);
 
 static llvm::cl::opt PCHStorage(
 "pch-storage",
@@ -140,6 +145,7 @@
   if (Test) {
 RunSynchronously = true;
 InputStyle = JSONStreamStyle::Delimited;
+LogToStderr = true;
 PrettyPrint = true;
   }
 
@@ -190,7 +196,7 @@
 
   JSONOutput Out(llvm::outs(), llvm::errs(),
  InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
- PrettyPrint);
+ LogToStderr, PrettyPrint);
 
   clangd::LoggingSession LoggingSession(Out);
 
Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -30,8 +30,10 @@
   // JSONOutput now that we pass Context everywhere.
 public:
   JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
- llvm::raw_ostream *InputMirror = nullptr, bool Pretty = false)
-  : Pretty(Pretty), Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+ llvm::raw_ostream *InputMirror = nullptr, bool LogToStderr = false,
+ bool Pretty = false)
+  : LogToStderr(LogToStderr), Pretty(Pretty), Outs(Outs), Logs(Logs),
+InputMirror(InputMirror) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const json::Expr &Result);
@@ -44,6 +46,9 @@
   /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
   void mirrorInput(const Twine &Message);
 
+  // Whether to output all LSP communication to stderr.
+  const bool LogToStderr;
+
   // Whether output should be pretty-printed.
   const bool Pretty;
 
Index: clangd/JSONRPCDispatcher.cpp
==

[clang-tools-extra] r326928 - do not register matcher for objc-only checks when analyzing non-objc sources to save resources

2018-03-07 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Wed Mar  7 10:59:25 2018
New Revision: 326928

URL: http://llvm.org/viewvc/llvm-project?rev=326928&view=rev
Log:
do not register matcher for objc-only checks when analyzing non-objc sources to 
save resources

Summary: I did not put lang opt check in AvoidSpinlockCheck since OSSpinLock is 
not objc specific. We won't want to skip it when analyzing some C++ target used 
by other ObjC sources.

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
Wed Mar  7 10:59:25 2018
@@ -19,6 +19,11 @@ namespace google {
 namespace objc {
 
 void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
+
   Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
   Finder->addMatcher(
   objcMessageExpr(anyOf(hasSelector("raise:format:"),

Modified: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp Wed Mar  
7 10:59:25 2018
@@ -18,6 +18,10 @@ namespace tidy {
 namespace objc {
 
 void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   Finder->addMatcher(objcMessageExpr(hasSelector("init"),
  hasReceiverType(asString("NSError *")))
  .bind("nserrorInit"),

Modified: clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp Wed 
Mar  7 10:59:25 2018
@@ -77,6 +77,10 @@ ForbiddenSubclassingCheck::ForbiddenSubc
 }
 
 void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   Finder->addMatcher(
   objcInterfaceDecl(
   isSubclassOf(

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed 
Mar  7 10:59:25 2018
@@ -170,6 +170,10 @@ PropertyDeclarationCheck::PropertyDeclar
   EscapedAcronyms() {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }
   if (IncludeDefaultAcronyms) {
 EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
 SpecialAcronyms.size());


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


[PATCH] D44223: [ms] Emit vtordisp initializers in a deterministic order.

2018-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1207
 uint64_t ConstantVBaseOffset =
-Layout.getVBaseClassOffset(I->first).getQuantity();
+Layout.getVBaseClassOffset(VBase).getQuantity();
 

The `getVBaseClassOffset` call turns around and does the same hashtable lookup 
we just did. Let's keep the iterator around and say 
`I->second.VBaseOffset.getQuantity()`.


https://reviews.llvm.org/D44223



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


r326948 - [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-03-07 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed Mar  7 13:59:50 2018
New Revision: 326948

URL: http://llvm.org/viewvc/llvm-project?rev=326948&view=rev
Log:
[OpenMP] Remove implicit data sharing code gen that aims to use device shared 
memory

Summary: Remove this scheme for now since it will be covered by another more 
generic scheme using global memory. This code will be worked into an 
optimization for the generic data sharing scheme. Removing this completely and 
then adding it via future patches will make all future data sharing patches 
cleaner.

Reviewers: ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

Removed:
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=326948&r1=326947&r2=326948&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Mar  7 13:59:50 2018
@@ -33,11 +33,11 @@ enum OpenMPRTLFunctionNVPTX {
   /// \brief Call to void __kmpc_spmd_kernel_deinit();
   OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
-  /// *outlined_function, void ***args, kmp_int32 nArgs, int16_t
+  /// *outlined_function, int16_t
   /// IsOMPRuntimeInitialized);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
-  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function, void
-  /// ***args, int16_t IsOMPRuntimeInitialized);
+  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function,
+  /// int16_t IsOMPRuntimeInitialized);
   OMPRTL_NVPTX__kmpc_kernel_parallel,
   /// \brief Call to void __kmpc_kernel_end_parallel();
   OMPRTL_NVPTX__kmpc_kernel_end_parallel,
@@ -288,7 +288,6 @@ void CGOpenMPRuntimeNVPTX::emitGenericKe
   EntryFunctionState EST;
   WorkerFunctionState WST(CGM, D.getLocStart());
   Work.clear();
-  WrapperFunctionsMap.clear();
 
   // Emit target region as a standalone region.
   class NVPTXPrePostActionTy : public PrePostActionTy {
@@ -508,11 +507,8 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoo
   CGF.InitTempAlloca(ExecStatus, Bld.getInt8(/*C=*/0));
   CGF.InitTempAlloca(WorkFn, llvm::Constant::getNullValue(CGF.Int8PtrTy));
 
-  // Set up shared arguments
-  Address SharedArgs =
-  CGF.CreateDefaultAlignTempAlloca(CGF.Int8PtrPtrTy, "shared_args");
   // TODO: Optimize runtime initialization and pass in correct value.
-  llvm::Value *Args[] = {WorkFn.getPointer(), SharedArgs.getPointer(),
+  llvm::Value *Args[] = {WorkFn.getPointer(),
  /*RequiresOMPRuntime=*/Bld.getInt16(1)};
   llvm::Value *Ret = CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_parallel), Args);
@@ -532,9 +528,6 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoo
   // Signal start of parallel region.
   CGF.EmitBlock(ExecuteBB);
 
-  // Current context
-  ASTContext &Ctx = CGF.getContext();
-
   // Process work items: outlined parallel functions.
   for (auto *W : Work) {
 // Try to match this outlined function.
@@ -550,19 +543,14 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoo
 // Execute this outlined function.
 CGF.EmitBlock(ExecuteFNBB);
 
-// Insert call to work function via shared wrapper. The shared
-// wrapper takes exactly three arguments:
-//   - the parallelism level;
-//   - the master thread ID;
-//   - the list of references to shared arguments.
-//
-// TODO: Assert that the function is a wrapper function.s
-Address Capture = CGF.EmitLoadOfPointer(SharedArgs,
-   Ctx.getPointerType(
-  Ctx.getPointerType(Ctx.VoidPtrTy)).castAs());
-emitOutlinedFunctionCall(CGF, WST.Loc, W,
- {Bld.getInt16(/*ParallelLevel=*/0),
-  getMasterThreadID(CGF), Capture.getPointer()});
+// Insert call to work function.
+// FIXME: Pass arguments to outlined function from master thread.
+auto *Fn = cast(W);
+Address ZeroAddr =
+CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty, /*Name=*/".zero.addr");
+CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C=*/0));
+llvm::Value *FnArgs[] = {ZeroAddr.getPointer(), ZeroAddr.getPointer()};
+emitCall(CGF, WST.Loc, Fn, FnArgs);
 
 // Go to end of parallel region.
 CGF.EmitBranch(TerminateBB);
@@ -630,10 +618,8 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
   }
   case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: {
 /// Build void __kmpc_kernel_prepare_parallel(
-/// void *outlined_function, void ***args, kmp_int32 n

[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-03-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326948: [OpenMP] Remove implicit data sharing code gen that 
aims to use device shared… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43625?vs=136570&id=137475#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43625

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -78,7 +78,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN1]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN2]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -217,11 +217,11 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN4:@.+]]_wrapper to i8*)
+  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast (void (i32*, i32*)* [[PARALLEL_FN4:@.+]] to i8*)
   // CHECK: br i1 [[WM]], label {{%?}}[[EXEC_PFN:.+]], label {{%?}}[[CHECK_NEXT:.+]]
   //
   // CHECK: [[EXEC_PFN]]
-  // CHECK: call void [[PARALLEL_FN4]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN4]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT]]
@@ -283,7 +283,7 @@
   // CHECK: br i1 [[CMP]], label {{%?}}[[IF_THEN:.+]], label {{%?}}[[IF_ELSE:.+]]
   //
   // CHECK: [[IF_THEN]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN4]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN4]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   

[PATCH] D37994: Implement LWG2946: More ambiguity in `string` vs. `string_view`

2018-03-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 137474.
mclow.lists added a comment.

Added the proposed resolution for https://wg21.link/lwg3075 as well, and some 
deduction guide tests for `string_view`


https://reviews.llvm.org/D37994

Files:
  include/string
  test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp
  test/std/strings/basic.string/string.cons/string_view.pass.cpp
  test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp
  test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
  test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
  test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
  test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.rfind({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_last_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 // test0();
 // test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_last_not_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_first_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find_first_not_of({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
@@ -155,5 +155,10 @@
 test0();
 test1();
 }
+//	LWG 2946
+	{
+	std::string s;
+	assert(s.find({"abc", 1}) == std::string::npos);
+	}
 #endif
 }
Index: test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp

[PATCH] D44226: [clangd] Add -log-lsp-to-stderr option

2018-03-07 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 137478.
simark added a comment.

Changed -log-to-stderr to -log-lsp-to-stderr

The first version disabled a bit too much, this version removes the LSP
communication logging in a more fine grained way.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44226

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -77,6 +77,11 @@
 llvm::cl::init(JSONStreamStyle::Standard));
 
 static llvm::cl::opt
+LogLspToStderr("log-lsp-to-stderr",
+   llvm::cl::desc("Output LSP communication on stderr"),
+   llvm::cl::init(false));
+
+static llvm::cl::opt
 PrettyPrint("pretty", llvm::cl::desc("Pretty-print JSON output"),
 llvm::cl::init(false));
 
@@ -190,7 +195,7 @@
 
   JSONOutput Out(llvm::outs(), llvm::errs(),
  InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
- PrettyPrint);
+ LogLspToStderr, PrettyPrint);
 
   clangd::LoggingSession LoggingSession(Out);
 
@@ -238,5 +243,7 @@
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
-  return LSPServer.run(std::cin, InputStyle) ? 0 : NoShutdownRequestErrorCode;
+  return LSPServer.run(std::cin, InputStyle, LogLspToStderr)
+ ? 0
+ : NoShutdownRequestErrorCode;
 }
Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -30,8 +30,10 @@
   // JSONOutput now that we pass Context everywhere.
 public:
   JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
- llvm::raw_ostream *InputMirror = nullptr, bool Pretty = false)
-  : Pretty(Pretty), Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+ llvm::raw_ostream *InputMirror = nullptr,
+ bool LogLspToStderr = false, bool Pretty = false)
+  : LogLspToStderr(LogLspToStderr), Pretty(Pretty), Outs(Outs), Logs(Logs),
+InputMirror(InputMirror) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const json::Expr &Result);
@@ -44,6 +46,9 @@
   /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
   void mirrorInput(const Twine &Message);
 
+  /// Whether to output all LSP communication to stderr.
+  const bool LogLspToStderr;
+
   // Whether output should be pretty-printed.
   const bool Pretty;
 
@@ -104,7 +109,8 @@
 /// replacements of \r\n with \n.
 void runLanguageServerLoop(std::istream &In, JSONOutput &Out,
JSONStreamStyle InputStyle,
-   JSONRPCDispatcher &Dispatcher, bool &IsDone);
+   JSONRPCDispatcher &Dispatcher, bool LogLspToStderr,
+   bool &IsDone);
 
 } // namespace clangd
 } // namespace clang
Index: clangd/JSONRPCDispatcher.cpp
===
--- clangd/JSONRPCDispatcher.cpp
+++ clangd/JSONRPCDispatcher.cpp
@@ -66,7 +66,9 @@
 Outs << "Content-Length: " << S.size() << "\r\n\r\n" << S;
 Outs.flush();
   }
-  log(llvm::Twine("--> ") + S);
+
+  if (LogLspToStderr)
+log(llvm::Twine("--> ") + S);
 }
 
 void JSONOutput::log(const Twine &Message) {
@@ -299,14 +301,17 @@
 void clangd::runLanguageServerLoop(std::istream &In, JSONOutput &Out,
JSONStreamStyle InputStyle,
JSONRPCDispatcher &Dispatcher,
-   bool &IsDone) {
+   bool LogLspToStderr, bool &IsDone) {
   auto &ReadMessage =
   (InputStyle == Delimited) ? readDelimitedMessage : readStandardMessage;
   while (In.good()) {
 if (auto JSON = ReadMessage(In, Out)) {
   if (auto Doc = json::parse(*JSON)) {
-// Log the formatted message.
-log(llvm::formatv(Out.Pretty ? "<-- {0:2}\n" : "<-- {0}\n", *Doc));
+if (LogLspToStderr) {
+  // Log the formatted message.
+  log(llvm::formatv(Out.Pretty ? "<-- {0:2}\n" : "<-- {0}\n", *Doc));
+}
+
 // Finally, execute the action for this JSON message.
 if (!Dispatcher.call(*Doc, Out))
   log("JSON dispatch failed!\n");
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -42,7 +42,8 @@
   ///
   /// \return Wether we received a 'shutdown' request before an 'exit' request
   bool run(std::istream &In,
-   JSONStreamStyle InputStyle = JSONStreamStyle::Standard);
+   JSONStreamStyle InputStyle = JSONStreamStyle::Standard,

r326951 - [analyzer] Don't crash with assertion failure on structured bindings

2018-03-07 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Mar  7 14:20:35 2018
New Revision: 326951

URL: http://llvm.org/viewvc/llvm-project?rev=326951&view=rev
Log:
[analyzer] Don't crash with assertion failure on structured bindings

Proper modeling still remains to be done.
Note that BindingDecl#getHoldingVar() is almost always null, and this
should probably be handled by dealing with DecompositionDecl beforehand.

rdar://36852163

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

Added:
cfe/trunk/test/Analysis/structured_bindings.cc
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=326951&r1=326950&r2=326951&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Mar  7 14:20:35 2018
@@ -2463,7 +2463,12 @@ void ExprEngine::VisitCommonDeclRefExpr(
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);
 Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V), nullptr,
- ProgramPoint::PostLValueKind);
+  ProgramPoint::PostLValueKind);
+return;
+  }
+  if (const auto* BD = dyn_cast(D)) {
+// FIXME: proper support for bound declarations.
+// For now, let's just prevent crashing.
 return;
   }
 

Added: cfe/trunk/test/Analysis/structured_bindings.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/structured_bindings.cc?rev=326951&view=auto
==
--- cfe/trunk/test/Analysis/structured_bindings.cc (added)
+++ cfe/trunk/test/Analysis/structured_bindings.cc Wed Mar  7 14:20:35 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+struct s { int a; };
+int foo() {
+auto[a] = s{1}; // FIXME: proper modelling
+if (a) {
+}
+}
+


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


r326952 - [analyzer] [PointerArithChecker] do not warn on indexes into vector types

2018-03-07 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Mar  7 14:20:39 2018
New Revision: 326952

URL: http://llvm.org/viewvc/llvm-project?rev=326952&view=rev
Log:
[analyzer] [PointerArithChecker] do not warn on indexes into vector types

rdar://35041502

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
cfe/trunk/test/Analysis/ptr-arith.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp?rev=326952&r1=326951&r2=326952&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp Wed Mar  7 
14:20:39 2018
@@ -308,6 +308,10 @@ void PointerArithChecker::checkPreStmt(c
   // Indexing with 0 is OK.
   if (Idx.isZeroConstant())
 return;
+
+  // Indexing vector-type expressions is also OK.
+  if (SubsExpr->getBase()->getType()->isVectorType())
+return;
   reportPointerArithMisuse(SubsExpr->getBase(), C);
 }
 

Modified: cfe/trunk/test/Analysis/ptr-arith.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-arith.c?rev=326952&r1=326951&r2=326952&view=diff
==
--- cfe/trunk/test/Analysis/ptr-arith.c (original)
+++ cfe/trunk/test/Analysis/ptr-arith.c Wed Mar  7 14:20:39 2018
@@ -347,3 +347,9 @@ void test_no_crash_on_pointer_to_label()
   a[0] = 0;
 label:;
 }
+
+typedef __attribute__((__ext_vector_type__(2))) float simd_float2;
+float test_nowarning_on_vector_deref() {
+  simd_float2 x = {0, 1};
+  return x[1]; // no-warning
+}


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


[PATCH] D44183: [analyzer] Don't crash with assertion failure on structured bindings

2018-03-07 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326951: [analyzer] Don't crash with assertion failure 
on structured bindings (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44183?vs=137304&id=137479#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44183

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/structured_bindings.cc


Index: test/Analysis/structured_bindings.cc
===
--- test/Analysis/structured_bindings.cc
+++ test/Analysis/structured_bindings.cc
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+struct s { int a; };
+int foo() {
+auto[a] = s{1}; // FIXME: proper modelling
+if (a) {
+}
+}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2463,7 +2463,12 @@
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);
 Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V), nullptr,
- ProgramPoint::PostLValueKind);
+  ProgramPoint::PostLValueKind);
+return;
+  }
+  if (const auto* BD = dyn_cast(D)) {
+// FIXME: proper support for bound declarations.
+// For now, let's just prevent crashing.
 return;
   }
 


Index: test/Analysis/structured_bindings.cc
===
--- test/Analysis/structured_bindings.cc
+++ test/Analysis/structured_bindings.cc
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+struct s { int a; };
+int foo() {
+auto[a] = s{1}; // FIXME: proper modelling
+if (a) {
+}
+}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2463,7 +2463,12 @@
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);
 Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V), nullptr,
-		  ProgramPoint::PostLValueKind);
+  ProgramPoint::PostLValueKind);
+return;
+  }
+  if (const auto* BD = dyn_cast(D)) {
+// FIXME: proper support for bound declarations.
+// For now, let's just prevent crashing.
 return;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >