r306948 - Un-revert "[Driver] Add -fdiagnostics-hotness-threshold"

2017-06-30 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Jun 30 22:45:26 2017
New Revision: 306948

URL: http://llvm.org/viewvc/llvm-project?rev=306948=rev
Log:
Un-revert "[Driver] Add -fdiagnostics-hotness-threshold"

Summary:
Un-revert https://reviews.llvm.org/D34868, but with a slight tweak to the
documentation to fix an error -- I had used the wrong syntax for a link.


Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306948=306947=306948=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 22:45:26 2017
@@ -322,18 +322,27 @@ output format of the diagnostics that it
by category, so it should be a high level category. We want dozens
of these, not hundreds or thousands of them.
 
+.. _opt_fsave-optimization-record:
+
+**-fsave-optimization-record**
+   Write optimization remarks to a YAML file.
+
+   This option, which defaults to off, controls whether Clang writes
+   optimization reports to a YAML file. By recording diagnostics in a file,
+   using a structured YAML format, users can parse or sort the remarks in a
+   convenient way.
+
 .. _opt_fdiagnostics-show-hotness:
 
 **-f[no-]diagnostics-show-hotness**
Enable profile hotness information in diagnostic line.
 
-   This option, which defaults to off, controls whether Clang prints the
-   profile hotness associated with a diagnostics in the presence of
-   profile-guided optimization information.  This is currently supported with
-   optimization remarks (see :ref:`Options to Emit Optimization Reports
-   `).  The hotness information allows users to focus on the hot
-   optimization remarks that are likely to be more relevant for run-time
-   performance.
+   This option controls whether Clang prints the profile hotness associated
+   with diagnostics in the presence of profile-guided optimization information.
+   This is currently supported with optimization remarks (see
+   :ref:`Options to Emit Optimization Reports `). The hotness 
information
+   allows users to focus on the hot optimization remarks that are likely to be
+   more relevant for run-time performance.
 
For example, in this output, the block containing the callsite of `foo` was
executed 3000 times according to the profile data:
@@ -344,6 +353,23 @@ output format of the diagnostics that it
sum += foo(x, x - 2);
   ^
 
+   This option is implied when
+   :ref:`-fsave-optimization-record ` is used.
+   Otherwise, it defaults to off.
+
+.. _opt_fdiagnostics-hotness-threshold:
+
+**-fdiagnostics-hotness-threshold**
+   Prevent optimization remarks from being output if they do not have at least
+   this hotness value.
+
+   This option, which defaults to zero, controls the minimum hotness an
+   optimization remark would need in order to be output by Clang. This is
+   currently supported with optimization remarks (see :ref:`Options to Emit
+   Optimization Reports `) when profile hotness information in
+   diagnostics is enabled (see
+   :ref:`-fdiagnostics-show-hotness `).
+
 .. _opt_fdiagnostics-fixit-info:
 
 **-f[no-]diagnostics-fixit-info**

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306948=306947=306948=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 22:45:26 
2017
@@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning<
 def warn_drv_empty_joined_argument : Warning<
   "joined argument expects additional value: '%0'">,
   InGroup;
-def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning<
-  "argument '-fdiagnostics-show-hotness' requires profile-guided optimization 
information">,
+def warn_drv_diagnostics_hotness_requires_pgo : Warning<
+  "argument '%0' requires profile-guided optimization information">,
   InGroup;
 def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=306948=306947=306948=diff
==
--- 

r306946 - Revert "[Driver] Add -fdiagnostics-hotness-threshold"

2017-06-30 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Jun 30 21:54:53 2017
New Revision: 306946

URL: http://llvm.org/viewvc/llvm-project?rev=306946=rev
Log:
Revert "[Driver] Add -fdiagnostics-hotness-threshold"

Summary:
The commit caused a documentation breakage.


Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306946=306945=306946=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 21:54:53 2017
@@ -322,27 +322,18 @@ output format of the diagnostics that it
by category, so it should be a high level category. We want dozens
of these, not hundreds or thousands of them.
 
-.. _opt_fsave-optimization-record:
-
-**-fsave-optimization-record**
-   Write optimization remarks to a YAML file.
-
-   This option, which defaults to off, controls whether Clang writes
-   optimization reports to a YAML file. By recording diagnostics in a file,
-   using a structured YAML format, users can parse or sort the remarks in a
-   convenient way.
-
 .. _opt_fdiagnostics-show-hotness:
 
 **-f[no-]diagnostics-show-hotness**
Enable profile hotness information in diagnostic line.
 
-   This option controls whether Clang prints the profile hotness associated
-   with diagnostics in the presence of profile-guided optimization information.
-   This is currently supported with optimization remarks (see
-   :ref:`Options to Emit Optimization Reports `). The hotness 
information
-   allows users to focus on the hot optimization remarks that are likely to be
-   more relevant for run-time performance.
+   This option, which defaults to off, controls whether Clang prints the
+   profile hotness associated with a diagnostics in the presence of
+   profile-guided optimization information.  This is currently supported with
+   optimization remarks (see :ref:`Options to Emit Optimization Reports
+   `).  The hotness information allows users to focus on the hot
+   optimization remarks that are likely to be more relevant for run-time
+   performance.
 
For example, in this output, the block containing the callsite of `foo` was
executed 3000 times according to the profile data:
@@ -353,23 +344,6 @@ output format of the diagnostics that it
sum += foo(x, x - 2);
   ^
 
-   This option is implied when
-   :ref:`-fsave-optimization-record ` is used.
-   Otherwise, it defaults to off.
-
-.. _opt_fdiagnostics-hotness-threshold
-
-**-fdiagnostics-hotness-threshold**
-   Prevent optimization remarks from being output if they do not have at least
-   this hotness value.
-
-   This option, which defaults to zero, controls the minimum hotness an
-   optimization remark would need in order to be output by Clang. This is
-   currently supported with optimization remarks (see :ref:`Options to Emit
-   Optimization Reports `) when profile hotness information in
-   diagnostics is enabled (see
-   :ref:`-fdiagnostics-show-hotness `).
-
 .. _opt_fdiagnostics-fixit-info:
 
 **-f[no-]diagnostics-fixit-info**

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306946=306945=306946=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 21:54:53 
2017
@@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning<
 def warn_drv_empty_joined_argument : Warning<
   "joined argument expects additional value: '%0'">,
   InGroup;
-def warn_drv_diagnostics_hotness_requires_pgo : Warning<
-  "argument '%0' requires profile-guided optimization information">,
+def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning<
+  "argument '-fdiagnostics-show-hotness' requires profile-guided optimization 
information">,
   InGroup;
 def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=306946=306945=306946=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jun 30 21:54:53 2017
@@ -723,9 +723,6 

[PATCH] D34868: [Driver] Add -fdiagnostics-hotness-threshold

2017-06-30 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Awesome, thank you for all the reviews!


https://reviews.llvm.org/D34868



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


r306945 - [Driver] Add -fdiagnostics-hotness-threshold

2017-06-30 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Jun 30 21:44:38 2017
New Revision: 306945

URL: http://llvm.org/viewvc/llvm-project?rev=306945=rev
Log:
[Driver] Add -fdiagnostics-hotness-threshold

Summary:
Depends on https://reviews.llvm.org/D34867.

Add a Clang frontend option to enable optimization remark hotness
thresholds, which were added to LLVM in https://reviews.llvm.org/D34867.
This prevents diagnostics that do not meet a minimum hotness
threshold from being output. When generating optimization remarks for large
codebases with a ton of cold code paths, this option can be used
to limit the optimization remark output at a reasonable size.
Discussion of this change can be read here:
http://lists.llvm.org/pipermail/llvm-dev/2017-June/114377.html

Reviewers: anemet, davidxl, hfinkel

Reviewed By: anemet

Subscribers: fhahn, cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306945=306944=306945=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 21:44:38 2017
@@ -322,18 +322,27 @@ output format of the diagnostics that it
by category, so it should be a high level category. We want dozens
of these, not hundreds or thousands of them.
 
+.. _opt_fsave-optimization-record:
+
+**-fsave-optimization-record**
+   Write optimization remarks to a YAML file.
+
+   This option, which defaults to off, controls whether Clang writes
+   optimization reports to a YAML file. By recording diagnostics in a file,
+   using a structured YAML format, users can parse or sort the remarks in a
+   convenient way.
+
 .. _opt_fdiagnostics-show-hotness:
 
 **-f[no-]diagnostics-show-hotness**
Enable profile hotness information in diagnostic line.
 
-   This option, which defaults to off, controls whether Clang prints the
-   profile hotness associated with a diagnostics in the presence of
-   profile-guided optimization information.  This is currently supported with
-   optimization remarks (see :ref:`Options to Emit Optimization Reports
-   `).  The hotness information allows users to focus on the hot
-   optimization remarks that are likely to be more relevant for run-time
-   performance.
+   This option controls whether Clang prints the profile hotness associated
+   with diagnostics in the presence of profile-guided optimization information.
+   This is currently supported with optimization remarks (see
+   :ref:`Options to Emit Optimization Reports `). The hotness 
information
+   allows users to focus on the hot optimization remarks that are likely to be
+   more relevant for run-time performance.
 
For example, in this output, the block containing the callsite of `foo` was
executed 3000 times according to the profile data:
@@ -344,6 +353,23 @@ output format of the diagnostics that it
sum += foo(x, x - 2);
   ^
 
+   This option is implied when
+   :ref:`-fsave-optimization-record ` is used.
+   Otherwise, it defaults to off.
+
+.. _opt_fdiagnostics-hotness-threshold
+
+**-fdiagnostics-hotness-threshold**
+   Prevent optimization remarks from being output if they do not have at least
+   this hotness value.
+
+   This option, which defaults to zero, controls the minimum hotness an
+   optimization remark would need in order to be output by Clang. This is
+   currently supported with optimization remarks (see :ref:`Options to Emit
+   Optimization Reports `) when profile hotness information in
+   diagnostics is enabled (see
+   :ref:`-fdiagnostics-show-hotness `).
+
 .. _opt_fdiagnostics-fixit-info:
 
 **-f[no-]diagnostics-fixit-info**

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306945=306944=306945=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 21:44:38 
2017
@@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning<
 def warn_drv_empty_joined_argument : Warning<
   "joined argument expects additional value: '%0'">,
   InGroup;
-def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning<
-  "argument '-fdiagnostics-show-hotness' requires profile-guided 

r306944 - Fix indentation.

2017-06-30 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Jun 30 21:37:54 2017
New Revision: 306944

URL: http://llvm.org/viewvc/llvm-project?rev=306944=rev
Log:
Fix indentation.

This is an attempt to fix a failing bot:

http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=306944=306943=306944=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Jun 30 21:37:54 2017
@@ -1342,13 +1342,13 @@ void Darwin::AddDeploymentTarget(Derived
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   getDriver().Diag(diag::err_drv_invalid_version_number)
   << iOSVersion->getAsString(Args);
-  // iOS 10 is the maximum deployment target for 32-bit targets. If the
-  // inferred deployment target is iOS 11 or later, set it to 10.99.
-  if (getTriple().isArch32Bit() && Major >= 11) {
-Major = 10;
-Minor = 99;
-Micro = 99;
-  }
+// iOS 10 is the maximum deployment target for 32-bit targets. If the
+// inferred deployment target is iOS 11 or later, set it to 10.99.
+if (getTriple().isArch32Bit() && Major >= 11) {
+  Major = 10;
+  Minor = 99;
+  Micro = 99;
+}
   } else if (Platform == TvOS) {
 if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
Micro, HadExtra) || HadExtra ||


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


r306928 - Update clang support for -mexecute-only/-mpure-code for backend change to use subtarget feature rather than command line option.

2017-06-30 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Jun 30 19:55:23 2017
New Revision: 306928

URL: http://llvm.org/viewvc/llvm-project?rev=306928=rev
Log:
Update clang support for -mexecute-only/-mpure-code for backend change to use 
subtarget feature rather than command line option.

Added:
cfe/trunk/test/CodeGen/arm-execute-only.c
  - copied, changed from r306926, cfe/trunk/test/Driver/arm-execute-only.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-execute-only.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=306928=306927=306928=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Fri Jun 30 19:55:23 2017
@@ -392,9 +392,7 @@ void arm::getARMTargetFeatures(const Too
   if (B->getOption().matches(options::OPT_mlong_calls))
 D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) 
<< B->getAsString(Args);
 }
-
-CmdArgs.push_back("-backend-option");
-CmdArgs.push_back("-arm-execute-only");
+   Features.push_back("+execute-only");
   }
 }
   }

Copied: cfe/trunk/test/CodeGen/arm-execute-only.c (from r306926, 
cfe/trunk/test/Driver/arm-execute-only.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-execute-only.c?p2=cfe/trunk/test/CodeGen/arm-execute-only.c=cfe/trunk/test/Driver/arm-execute-only.c=306926=306928=306928=diff
==
--- cfe/trunk/test/Driver/arm-execute-only.c (original)
+++ cfe/trunk/test/CodeGen/arm-execute-only.c Fri Jun 30 19:55:23 2017
@@ -34,15 +34,6 @@
 // RUN: %clang -target armv8m.main-eabi -### -mexecute-only -mno-execute-only 
%s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
 
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
-// RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
-
-// RUN: not %clang -target armv8m.main-eabi -mexecute-only -mno-movt %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-NO-MOVT
-
-// RUN: not %clang -target armv8m.main-eabi -mexecute-only -mlong-calls %s 
2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
-
 
 // -mpure-code flag for GCC compatibility
 // RUN: %clang -target armv6t2-eabi -### %s 2>&1 \
@@ -81,23 +72,7 @@
 // RUN: %clang -target armv8m.main-eabi -### -mpure-code -mno-pure-code %s 
2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
 
-// RUN: not %clang -c -target thumbv6m-eabi -mpure-code %s 2>&1 | \
-// RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
-
-// RUN: not %clang -target armv8m.main-eabi -mpure-code -mno-movt %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-NO-MOVT
-
-// RUN: not %clang -target armv8m.main-eabi -mpure-code -mlong-calls %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
+// CHECK-NO-EXECUTE-ONLY-NOT: "+execute-only"
+// CHECK-EXECUTE-ONLY: "+execute-only"
 
-// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 
\
-// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY -check-prefix 
CHECK-NO-EXECUTE-ONLY-ASM
-
-//
-// CHECK-NO-EXECUTE-ONLY-NOT: "-backend-option" "-arm-execute-only"
-// CHECK-EXECUTE-ONLY: "-backend-option" "-arm-execute-only"
-
-// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the thumbv6m sub-architecture
-// CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be 
specified with '-mno-movt'
-// CHECK-EXECUTE-ONLY-LONG-CALLS: error: option '-mexecute-only' cannot be 
specified with '-mlong-calls'
-// CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: 
'-mexecute-only'
+void a() {}

Modified: cfe/trunk/test/Driver/arm-execute-only.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-execute-only.c?rev=306928=306927=306928=diff
==
--- cfe/trunk/test/Driver/arm-execute-only.c (original)
+++ cfe/trunk/test/Driver/arm-execute-only.c Fri Jun 30 19:55:23 2017
@@ -1,39 +1,3 @@
-// RUN: %clang -target armv6t2-eabi -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
-
-// RUN: %clang -target armv6t2-eabi -### -mexecute-only %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY
-
-// RUN: %clang -target armv6t2-eabi -### -mexecute-only -mno-execute-only %s 
2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
-
-// RUN: %clang -target armv7m-eabi -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
-
-// RUN: %clang -target armv7m-eabi -### -mexecute-only %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY

r306926 - [ODRHash] Revert r305104 - Skip inline namespaces when hashing.

2017-06-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun 30 19:00:05 2017
New Revision: 306926

URL: http://llvm.org/viewvc/llvm-project?rev=306926=rev
Log:
[ODRHash] Revert r305104 - Skip inline namespaces when hashing.

Test inline namespaces and handle them in the ODR hash again.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=306926=306925=306926=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun 30 19:00:05 2017
@@ -82,25 +82,13 @@ void ODRHash::AddDeclarationName(Declara
 }
 
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-  // Unlike the other pointer handling functions, allow null pointers here.
-  if (!NNS) {
-AddBoolean(false);
-return;
+  assert(NNS && "Expecting non-null pointer.");
+  const auto *Prefix = NNS->getPrefix();
+  AddBoolean(Prefix);
+  if (Prefix) {
+AddNestedNameSpecifier(Prefix);
   }
-
-  // Skip inlined namespaces.
   auto Kind = NNS->getKind();
-  if (Kind == NestedNameSpecifier::Namespace) {
-if (NNS->getAsNamespace()->isInline()) {
-  return AddNestedNameSpecifier(NNS->getPrefix());
-}
-  }
-
-  AddBoolean(true);
-
-  // Process prefix
-  AddNestedNameSpecifier(NNS->getPrefix());
-
   ID.AddInteger(Kind);
   switch (Kind) {
   case NestedNameSpecifier::Identifier:
@@ -441,7 +429,10 @@ public:
   }
 
   void AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-Hash.AddNestedNameSpecifier(NNS);
+Hash.AddBoolean(NNS);
+if (NNS) {
+  Hash.AddNestedNameSpecifier(NNS);
+}
   }
 
   void AddIdentifierInfo(const IdentifierInfo *II) {

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=306926=306925=306926=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Jun 30 19:00:05 2017
@@ -186,7 +186,10 @@ namespace {
   Hash.AddTemplateName(Name);
 }
 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
-  Hash.AddNestedNameSpecifier(NNS);
+  ID.AddBoolean(NNS);
+  if (NNS) {
+Hash.AddNestedNameSpecifier(NNS);
+  }
 }
   };
 }

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=306926=306925=306926=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun 30 19:00:05 2017
@@ -968,6 +968,24 @@ S9 s9;
 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S9' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found field 'x' with type 'P9::I' (aka 'int')}}
 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 
'O9::I' (aka 'int')}}
 #endif
+
+namespace N10 {
+#if defined(FIRST)
+inline namespace A { struct X {}; }
+struct S10 {
+  A::X x;
+};
+#elif defined(SECOND)
+inline namespace B { struct X {}; }
+struct S10 {
+  B::X x;
+};
+#else
+S10 s10;
+// expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from 
module 'SecondModule' is not present in definition of 
'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+}
 }
 
 namespace TemplateSpecializationType {


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


[PATCH] D34770: [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

2017-06-30 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

@teemperor

> I think we want to support completing both -cc1 and normal driver invocation. 
> Most people use the driver, but for example during debugging people use the 
> cc1 version, so both are valid use cases. I just saw we actually have the 
> completion code in the Driver, so what do you think about moving the code to 
> the Frontend part and call it from the Driver/Frontend part?

I'm not sure what you refer to by ` I just saw we actually have the completion 
code in the Driver`. We are already auto completing both cc1 options and driver 
options, right?
I'm sorry but I don't understand your main point. What am I missing?

> I think it makes the most sense if we complete cc1 options but return 
> "-Xclang OPTION" when we encounter a cc1 option from the Driver (because it's 
> the least intrusive thing to do and the cc1 options are the ones everyone 
> forgets about :) ).

What about completing cc1 options only when -cc1 is passed or -Xclang is passed 
before current input?


https://reviews.llvm.org/D34770



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


[PATCH] D34913: [clang-tidy] Add a new Android check "android-cloexec-socket"

2017-06-30 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko requested changes to this revision.
Eugene.Zelenko added a comment.
This revision now requires changes to proceed.

Please wait for Alexander, Aaron or Haojian approval.




Comment at: clang-tidy/android/CloexecOpenCheck.cpp:22
 
 namespace {
 static constexpr const char *O_CLOEXEC = "O_CLOEXEC";

Anonymous namespaces should contain only class declarations. static is enough.



Comment at: clang-tidy/android/CloexecSocketCheck.cpp:21
+
+namespace {
+static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";

Anonymous namespaces should contain only class declarations. static is enough.



Comment at: docs/ReleaseNotes.rst:79
+
+  Checks if the required file flag ``SOCK_CLOEXEC`` exists in ``socket()``.
+

Maybe present in arguments of instead of exist will sound better?



Comment at: docs/clang-tidy/checks/android-cloexec-socket.rst:5
+==
+``socket()`` should include ``SOCK_CLOEXEC`` in its type argument to avoid the
+file descriptor leakage.

Please add empty line there.


Repository:
  rL LLVM

https://reviews.llvm.org/D34913



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


r306922 - [Driver] Check that the iOS deployment target is iOS 10 or earlier if

2017-06-30 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Jun 30 17:57:52 2017
New Revision: 306922

URL: http://llvm.org/viewvc/llvm-project?rev=306922=rev
Log:
[Driver] Check that the iOS deployment target is iOS 10 or earlier if
the target is 32-bit.

The following changes are made to the driver since 32-bit apps do not
run on iOS 11 or later:

- If the deployment target is set explicitly, either with a command-line
  option or an environment variable, the driver should report an error
  if the version is greater than iOS 10.

- In the case where the deployment target is not set explicitly and the
  default is inferred from the target triple or SDK version, it should
  use a maximum default of iOS 10.99.99.

rdar://problem/32230613

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306922=306921=306922=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 17:57:52 
2017
@@ -138,6 +138,9 @@ def err_drv_cc_print_options_failure : E
 def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
+def err_invalid_ios_deployment_target : Error<
+  "invalid iOS deployment version '%0', iOS 10 is the maximum deployment "
+  "target for 32-bit targets">;
 def err_drv_conflicting_deployment_targets : Error<
   "conflicting deployment targets, both '%0' and '%1' are present in 
environment">;
 def err_arc_unsupported_on_runtime : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=306922=306921=306922=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Jun 30 17:57:52 2017
@@ -1150,6 +1150,17 @@ void Darwin::AddDeploymentTarget(Derived
   Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
   options::OPT_mwatchos_simulator_version_min_EQ);
 
+  unsigned Major, Minor, Micro;
+  bool HadExtra;
+
+  // iOS 10 is the maximum deployment target for 32-bit targets.
+  if (iOSVersion && getTriple().isArch32Bit() &&
+  Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
+HadExtra) &&
+  Major > 10)
+getDriver().Diag(diag::err_invalid_ios_deployment_target)
+<< iOSVersion->getAsString(Args);
+
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y 
and
   // -m(iphone|tv|watch)simulator-version-min=X.Y.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
@@ -1191,6 +1202,14 @@ void Darwin::AddDeploymentTarget(Derived
 if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
   WatchOSTarget = env;
 
+// iOS 10 is the maximum deployment target for 32-bit targets.
+if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
+Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
+  HadExtra) &&
+Major > 10)
+  getDriver().Diag(diag::err_invalid_ios_deployment_target)
+  << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
+
 // If there is no command-line argument to specify the Target version and
 // no environment variable defined, see if we can set the default based
 // on -isysroot.
@@ -1308,8 +1327,6 @@ void Darwin::AddDeploymentTarget(Derived
 llvm_unreachable("Unable to infer Darwin variant");
 
   // Set the tool chain target information.
-  unsigned Major, Minor, Micro;
-  bool HadExtra;
   if (Platform == MacOS) {
 assert((!iOSVersion && !TvOSVersion && !WatchOSVersion) &&
"Unknown target platform!");
@@ -1325,6 +1342,13 @@ void Darwin::AddDeploymentTarget(Derived
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   getDriver().Diag(diag::err_drv_invalid_version_number)
   << iOSVersion->getAsString(Args);
+  // iOS 10 is the maximum deployment target for 32-bit targets. If the
+  // inferred deployment target is iOS 11 or later, set it to 10.99.
+  if (getTriple().isArch32Bit() && Major >= 11) {
+Major = 10;
+Minor = 99;
+Micro = 99;
+  }
   } else if (Platform == TvOS) {
 if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
Micro, HadExtra) || HadExtra ||

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 

[PATCH] D34529: [Driver] Check that the iOS deployment target is iOS 10 or earlier if the target is 32-bit

2017-06-30 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306922: [Driver] Check that the iOS deployment target is iOS 
10 or earlier if (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D34529?vs=104958=104972#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34529

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/test/Driver/darwin-version.c

Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -1150,6 +1150,17 @@
   Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
   options::OPT_mwatchos_simulator_version_min_EQ);
 
+  unsigned Major, Minor, Micro;
+  bool HadExtra;
+
+  // iOS 10 is the maximum deployment target for 32-bit targets.
+  if (iOSVersion && getTriple().isArch32Bit() &&
+  Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
+HadExtra) &&
+  Major > 10)
+getDriver().Diag(diag::err_invalid_ios_deployment_target)
+<< iOSVersion->getAsString(Args);
+
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
   // -m(iphone|tv|watch)simulator-version-min=X.Y.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
@@ -1191,6 +1202,14 @@
 if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
   WatchOSTarget = env;
 
+// iOS 10 is the maximum deployment target for 32-bit targets.
+if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
+Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
+  HadExtra) &&
+Major > 10)
+  getDriver().Diag(diag::err_invalid_ios_deployment_target)
+  << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
+
 // If there is no command-line argument to specify the Target version and
 // no environment variable defined, see if we can set the default based
 // on -isysroot.
@@ -1308,8 +1327,6 @@
 llvm_unreachable("Unable to infer Darwin variant");
 
   // Set the tool chain target information.
-  unsigned Major, Minor, Micro;
-  bool HadExtra;
   if (Platform == MacOS) {
 assert((!iOSVersion && !TvOSVersion && !WatchOSVersion) &&
"Unknown target platform!");
@@ -1325,6 +1342,13 @@
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   getDriver().Diag(diag::err_drv_invalid_version_number)
   << iOSVersion->getAsString(Args);
+  // iOS 10 is the maximum deployment target for 32-bit targets. If the
+  // inferred deployment target is iOS 11 or later, set it to 10.99.
+  if (getTriple().isArch32Bit() && Major >= 11) {
+Major = 10;
+Minor = 99;
+Micro = 99;
+  }
   } else if (Platform == TvOS) {
 if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
Micro, HadExtra) || HadExtra ||
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -138,6 +138,9 @@
 def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
+def err_invalid_ios_deployment_target : Error<
+  "invalid iOS deployment version '%0', iOS 10 is the maximum deployment "
+  "target for 32-bit targets">;
 def err_drv_conflicting_deployment_targets : Error<
   "conflicting deployment targets, both '%0' and '%1' are present in environment">;
 def err_arc_unsupported_on_runtime : Error<
Index: cfe/trunk/test/Driver/darwin-version.c
===
--- cfe/trunk/test/Driver/darwin-version.c
+++ cfe/trunk/test/Driver/darwin-version.c
@@ -10,6 +10,41 @@
 // RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS3 %s
 // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0"
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
+// RUN:   %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err
+// RUN:   FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s
+// CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0'
+
+// RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s
+// CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0'
+
+// RUN: %clang -target i386-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err 

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: include/clang/Driver/Options.td:453
+def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
+  HelpText<"Pass arguments to target offloading toolchain.">;
+def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,

Can this be?

HelpText<"Pass  to the target offloading toolchain.">,
MetaVarName<"">;



Comment at: include/clang/Driver/Options.td:455
+def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
+  HelpText<"Pass arguments to target offloading toolchain. First entry is a 
triple that identifies the toolchain.">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,

  HelpText<"Pass  to the specified target offloading toolchain. The triple 
that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;



Comment at: lib/Driver/ToolChains/Cuda.cpp:443
+
+// Get the compute capability from the -fopenmp-targets flag.
+// The default compute capability is sm_20 since this is a CUDA

Is this first sentence accurate?



Comment at: lib/Driver/ToolChains/Cuda.cpp:444
+// Get the compute capability from the -fopenmp-targets flag.
+// The default compute capability is sm_20 since this is a CUDA
+// tool chain.

This comment should be moved down to where the sm_20 default is added.



Comment at: lib/Driver/ToolChains/Cuda.cpp:446
+// tool chain.
+auto OptList = Args.getAllArgValues(options::OPT_Xopenmp_target_EQ);
+

Why is this logic in this function? Don't you need the same logic in 
Generic_GCC::TranslateArgs to handle non-CUDA offloading toolchains?




Comment at: lib/Driver/ToolChains/Cuda.cpp:469
+// toolchain specified).
+assert(Args.getAllArgValues(options::OPT_fopenmp_targets_EQ).size() == 1 &&
+"Target toolchain not specified on -Xopenmp-target and cannot be 
deduced.");

A user can trigger this assert, right? Please make this a diagnostic error 
instead.



Comment at: lib/Driver/ToolChains/Cuda.cpp:474
+for (StringRef Opt : OptList) {
+  AddMArchOption(DAL, Opts, Opt);
+}

Shouldn't you be adding all of the options, not just the -march= ones?



Comment at: lib/Driver/ToolChains/Cuda.cpp:478
+auto MArchList = DAL->getAllArgValues(options::OPT_march_EQ);
+assert(MArchList.size() < 2 && "At most one GPU arch allowed.");
+if (MArchList.empty())

Can a user hit this? If so, it must be an actual diagnostic.



Comment at: test/Driver/openmp-offload.c:607
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} argument unused during compilation: 
'-Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8'
+

I don't see why you'd check that the arguments are unused. They should be used. 
One exception might be that you might want to force -Xopenmp-target=foo to be 
unused if foo is not a currently-targeted offloading triple. There could be a 
separate test case for that.

Otherwise, I think you should be able to check the relevant backend commands, 
no? (something like where CHK-COMMANDS is used above in this file).


https://reviews.llvm.org/D34784



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


[PATCH] D34510: Teach clang how to merge typedef over anonymous structs in C mode.

2017-06-30 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Tested it locally, we actually need all these changes on top of 
https://reviews.llvm.org/D31778.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D34510



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


[PATCH] D34671: This is to address more command from Richard Smith for my change of https://reviews.llvm.org/D33333

2017-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 104966.
jyu2 added a comment.

Hi Richard,

Thank you so much for your review.  I just update patch to address you new 
comment.

Please let me know if you see more problems.

Thanks.
Jennifer


Repository:
  rL LLVM

https://reviews.llvm.org/D34671

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -394,15 +394,21 @@
 
 static void EmitDiagForCXXThrowInNonThrowingFunc(Sema , SourceLocation OpLoc,
  const FunctionDecl *FD) {
-  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc) &&
+  FD->getTypeSourceInfo()) {
 S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
 if (S.getLangOpts().CPlusPlus11 &&
 (isa(FD) ||
  FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
- FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
-  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
-else
-  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) {
+  if (const auto *Ty = FD->getTypeSourceInfo()->getType()->
+ getAs())
+S.Diag(FD->getLocation(), diag::note_throw_in_dtor)
+<< !isa(FD) << !Ty->hasExceptionSpec()
+<< FD->getExceptionSpecSourceRange();
+} else 
+  S.Diag(FD->getLocation(), diag::note_throw_in_function)
+  << FD->getExceptionSpecSourceRange();
   }
 }
 
@@ -420,8 +426,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->getExceptionSpecType() != EST_None &&
-  FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()))
 return true;
   return false;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6351,15 +6351,13 @@
   "cannot use '%0' with exceptions disabled">;
 def err_objc_exceptions_disabled : Error<
   "cannot use '%0' with Objective-C exceptions disabled">;
-def warn_throw_in_noexcept_func 
-: Warning<"%0 has a non-throwing exception specification but can still "
-  "throw, resulting in unexpected program termination">,
-  InGroup;
-def note_throw_in_dtor 
-: Note<"destructor or deallocator has a (possibly implicit) non-throwing "
-  "excepton specification">;
-def note_throw_in_function 
-: Note<"non-throwing function declare here">;
+def warn_throw_in_noexcept_func : Warning<
+  "%0 has a non-throwing exception specification but can still throw">,
+  InGroup;
+def note_throw_in_dtor : Note<
+  "%select{destructor|deallocator}0 has a %select{non-throwing|implicit "
+  "non-throwing}1 exception specification">;
+def note_throw_in_function : Note<"function declared non-throwing here">;
 def err_seh_try_outside_functions : Error<
   "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">;
 def err_mixing_cxx_try_seh_try : Error<
Index: test/SemaCXX/warn-throw-out-noexcept-func.cpp
===
--- test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -2,16 +2,16 @@
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
-A_ShouldDiag::~A_ShouldDiag() { // expected-note {{destructor or deallocator has a (possibly implicit) non-throwing excepton specification}}
-  throw 1; // expected-warning {{has a non-throwing exception specification but can still throw, resulting in unexpected program termination}}
+A_ShouldDiag::~A_ShouldDiag() { // expected-note {{destructor has a implicit non-throwing exception specification}}
+  throw 1; // expected-warning {{has a non-throwing exception specification but can still throw}}
 }
 struct B_ShouldDiag {
   int i;
   ~B_ShouldDiag() noexcept(true) {} //no disg, no throw stmt
 };
 struct R_ShouldDiag : A_ShouldDiag {
   B_ShouldDiag b;
-  ~R_ShouldDiag() { // expected-note  {{destructor or deallocator has a}}
+  ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification but}}
   }
 };
@@ -30,18 +30,18 @@
   ~N_ShouldDiag(); //implicitly noexcept(true)
 };
 
-N_ShouldDiag::~N_ShouldDiag() {  // expected-note  {{destructor or deallocator has a}}
+N_ShouldDiag::~N_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing 

[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-30 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306918: [Modules] Implement ODR-like semantics for tag types 
in C/ObjC (authored by bruno).

Changed prior to commit:
  https://reviews.llvm.org/D31778?vs=104881=104965#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31778

Files:
  cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
  cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/Modules/Inputs/F.framework/Headers/F.h
  cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.modulemap
  cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.private.modulemap
  cfe/trunk/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
  cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
  cfe/trunk/test/Modules/redefinition-c-tagtypes.m
  cfe/trunk/test/Modules/redefinition-same-header.m

Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -4319,8 +4319,15 @@
 return;
   }
 
-  if (Tok.is(tok::l_brace) && TUK != Sema::TUK_Reference)
-ParseEnumBody(StartLoc, TagDecl);
+  if (Tok.is(tok::l_brace) && TUK != Sema::TUK_Reference) {
+Decl *D = SkipBody.CheckSameAsPrevious ? SkipBody.New : TagDecl;
+ParseEnumBody(StartLoc, D);
+if (SkipBody.CheckSameAsPrevious &&
+!Actions.ActOnDuplicateDefinition(DS, TagDecl, SkipBody)) {
+  DS.SetTypeSpecError();
+  return;
+}
+  }
 
   if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc,
  NameLoc.isValid() ? NameLoc : StartLoc,
@@ -4392,11 +4399,9 @@
 }
 
 // Install the enumerator constant into EnumDecl.
-Decl *EnumConstDecl = Actions.ActOnEnumConstant(getCurScope(), EnumDecl,
-LastEnumConstDecl,
-IdentLoc, Ident,
-attrs.getList(), EqualLoc,
-AssignedVal.get());
+Decl *EnumConstDecl = Actions.ActOnEnumConstant(
+getCurScope(), EnumDecl, LastEnumConstDecl, IdentLoc, Ident,
+attrs.getList(), EqualLoc, AssignedVal.get());
 EnumAvailabilityDiags.back().done();
 
 EnumConstantDecls.push_back(EnumConstDecl);
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1910,8 +1910,18 @@
 else if (getLangOpts().CPlusPlus)
   ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
   TagOrTempResult.get());
-else
-  ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
+else {
+  Decl *D =
+  SkipBody.CheckSameAsPrevious ? SkipBody.New : TagOrTempResult.get();
+  // Parse the definition body.
+  ParseStructUnionBody(StartLoc, TagType, D);
+  if (SkipBody.CheckSameAsPrevious &&
+  !Actions.ActOnDuplicateDefinition(DS, TagOrTempResult.get(),
+SkipBody)) {
+DS.SetTypeSpecError();
+return;
+  }
+}
   }
 
   if (!TagOrTempResult.isInvalid())
Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
===
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
@@ -735,13 +735,28 @@
   // Check for equivalent field names.
   IdentifierInfo *Name1 = Field1->getIdentifier();
   IdentifierInfo *Name2 = Field2->getIdentifier();
-  if (!::IsStructurallyEquivalent(Name1, Name2))
+  if (!::IsStructurallyEquivalent(Name1, Name2)) {
+if (Context.Complain) {
+  Context.Diag2(Owner2->getLocation(),
+Context.ErrorOnTagTypeMismatch
+? diag::err_odr_tag_type_inconsistent
+: diag::warn_odr_tag_type_inconsistent)
+  << Context.ToCtx.getTypeDeclType(Owner2);
+  Context.Diag2(Field2->getLocation(), diag::note_odr_field_name)
+  << Field2->getDeclName();
+  Context.Diag1(Field1->getLocation(), diag::note_odr_field_name)
+  << Field1->getDeclName();
+}
 return false;
+  }
 
   if (!IsStructurallyEquivalent(Context, Field1->getType(),
 Field2->getType())) {
 if (Context.Complain) {
-  Context.Diag2(Owner2->getLocation(), diag::warn_odr_tag_type_inconsistent)
+  Context.Diag2(Owner2->getLocation(),
+Context.ErrorOnTagTypeMismatch
+? 

r306918 - [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 30 17:06:47 2017
New Revision: 306918

URL: http://llvm.org/viewvc/llvm-project?rev=306918=rev
Log:
[Modules] Implement ODR-like semantics for tag types in C/ObjC

Allow ODR for ObjC/C in the sense that we won't keep more that
one definition around (merge them). However, ensure the decl
pass the structural compatibility check in C11 6.2.7/1, for that,
reuse the structural equivalence checks used by the ASTImporter.

Few other considerations:
- Create error diagnostics for tag types mismatches and thread
them into the structural equivalence checks.
- Note that by doing this we only support redefinition between types
that are considered "compatible types" by C.

This is mixed approach of the suggestions discussed in
http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html

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

rdar://problem/31909368

Added:
cfe/trunk/test/Modules/Inputs/F.framework/
cfe/trunk/test/Modules/Inputs/F.framework/Headers/
cfe/trunk/test/Modules/Inputs/F.framework/Headers/F.h
cfe/trunk/test/Modules/Inputs/F.framework/Modules/
cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/F.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
cfe/trunk/test/Modules/redefinition-c-tagtypes.m
Modified:
cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
cfe/trunk/test/Modules/redefinition-same-header.m

Modified: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h (original)
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h Fri Jun 30 17:06:47 
2017
@@ -62,9 +62,11 @@ struct StructuralEquivalenceContext {
   StructuralEquivalenceContext(
   ASTContext , ASTContext ,
   llvm::DenseSet ,
-  bool StrictTypeSpelling = false, bool Complain = true)
+  bool StrictTypeSpelling = false, bool Complain = true,
+  bool ErrorOnTagTypeMismatch = false)
   : FromCtx(FromCtx), ToCtx(ToCtx), NonEquivalentDecls(NonEquivalentDecls),
-StrictTypeSpelling(StrictTypeSpelling), Complain(Complain),
+StrictTypeSpelling(StrictTypeSpelling),
+ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain),
 LastDiagFromC2(false) {}
 
   DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID);

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri Jun 30 17:06:47 2017
@@ -200,12 +200,17 @@ def note_odr_defined_here : Note<"also d
 def err_odr_function_type_inconsistent : Error<
   "external function %0 declared with incompatible types in different "
   "translation units (%1 vs. %2)">;
-def warn_odr_tag_type_inconsistent : Warning<
-  "type %0 has incompatible definitions in different translation units">,
-  InGroup>;
+def warn_odr_tag_type_inconsistent
+: Warning<"type %0 has incompatible definitions in different translation "
+  "units">,
+  InGroup>;
+def err_odr_tag_type_inconsistent
+: Error<"type %0 has incompatible definitions in different translation "
+"units">;
 def note_odr_tag_kind_here: Note<
   "%0 is a %select{struct|interface|union|class|enum}1 here">;
 def note_odr_field : Note<"field %0 has type %1 here">;
+def note_odr_field_name : Note<"field has name %0 here">;
 def note_odr_missing_field : Note<"no corresponding field here">;
 def note_odr_bit_field : Note<"bit-field %0 with type %1 and length %2 here">;
 def note_odr_not_bit_field : Note<"field %0 is not a bit-field">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jun 30 17:06:47 2017
@@ -1542,6 +1542,10 @@ public:
 
   bool 

r306917 - Change enumerator default linkage type for C

2017-06-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 30 17:06:27 2017
New Revision: 306917

URL: http://llvm.org/viewvc/llvm-project?rev=306917=rev
Log:
Change enumerator default linkage type for C

Redeclaration lookup should never find hidden enumerators in C, because
they do not have linkage (C11 6.2.2/6)

The linkage of an enumerator should be VisibleNoLinkage, and
isHiddenDeclarationVisible should be checking hasExternalFormalLinkage.

This is was reviewed as part of D31778, but splitted into a different
commit for clarity.

rdar://problem/31909368

Modified:
cfe/trunk/include/clang/Basic/Visibility.h
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/Index/linkage.c

Modified: cfe/trunk/include/clang/Basic/Visibility.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Visibility.h?rev=306917=306916=306917=diff
==
--- cfe/trunk/include/clang/Basic/Visibility.h (original)
+++ cfe/trunk/include/clang/Basic/Visibility.h Fri Jun 30 17:06:27 2017
@@ -75,6 +75,9 @@ public:
   static LinkageInfo none() {
 return LinkageInfo(NoLinkage, DefaultVisibility, false);
   }
+  static LinkageInfo visible_none() {
+return LinkageInfo(VisibleNoLinkage, DefaultVisibility, false);
+  }
 
   Linkage getLinkage() const { return (Linkage)linkage_; }
   Visibility getVisibility() const { return (Visibility)visibility_; }

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306917=306916=306917=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Jun 30 17:06:27 2017
@@ -275,7 +275,7 @@ public:
   /// declarations, such as those in modules that have not yet been imported.
   bool isHiddenDeclarationVisible(NamedDecl *ND) const {
 return AllowHidden ||
-   (isForRedeclaration() && ND->isExternallyVisible());
+   (isForRedeclaration() && ND->hasExternalFormalLinkage());
   }
 
   /// Sets whether tag declarations should be hidden by non-tag

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=306917=306916=306917=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jun 30 17:06:27 2017
@@ -1251,7 +1251,9 @@ static LinkageInfo computeLVForDecl(cons
 
 case Decl::EnumConstant:
   // C++ [basic.link]p4: an enumerator has the linkage of its enumeration.
-  return getLVForDecl(cast(D->getDeclContext()), computation);
+  if (D->getASTContext().getLangOpts().CPlusPlus)
+return getLVForDecl(cast(D->getDeclContext()), computation);
+  return LinkageInfo::visible_none();
 
 case Decl::Typedef:
 case Decl::TypeAlias:

Modified: cfe/trunk/test/Index/linkage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/linkage.c?rev=306917=306916=306917=diff
==
--- cfe/trunk/test/Index/linkage.c (original)
+++ cfe/trunk/test/Index/linkage.c Fri Jun 30 17:06:27 2017
@@ -20,7 +20,7 @@ void f16(void) {
 
 
 // CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External
-// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External
+// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=NoLinkage
 // CHECK: VarDecl=x:4:5linkage=External
 // CHECK: FunctionDecl=foo:5:6linkage=External
 // CHECK: VarDecl=w:6:12linkage=Internal


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


[PATCH] D34868: [Driver] Add -fdiagnostics-hotness-threshold

2017-06-30 Thread Adam Nemet via Phabricator via cfe-commits
anemet accepted this revision.
anemet added a comment.
This revision is now accepted and ready to land.

Looks great, thank you!


https://reviews.llvm.org/D34868



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


[PATCH] D34868: [Driver] Add -fdiagnostics-hotness-threshold

2017-06-30 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 104964.
modocache marked 4 inline comments as done.
modocache added a comment.

Address comments, for the most part. As for the documentation: I think this is 
OK for now, but there are definitely a few more options that I'd like to 
document, and those will require updating some of the existing docs as well 
(one example that comes to mind is '-foptimization-record-file='). If it's 
alright with you, I'd like to do this in a future diff.


https://reviews.llvm.org/D34868

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
  test/Frontend/optimization-remark-with-hotness.c

Index: test/Frontend/optimization-remark-with-hotness.c
===
--- test/Frontend/optimization-remark-with-hotness.c
+++ test/Frontend/optimization-remark-with-hotness.c
@@ -15,24 +15,33 @@
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -verify
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
+// RUN: -verify
 // The clang version of the previous test.
 // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
 // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -Xclang -verify
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
+// RUN: -Xclang -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
-// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness  2>&1 | FileCheck \
+// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
 // RUN: -check-prefix=HOTNESS_OFF %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -Rpass=inline -Rpass-analysis=inline -fdiagnostics-show-hotness  2>&1 \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
+// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
+// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -Rpass=inline -Rpass-analysis=inline \
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
 // RUN: | FileCheck -check-prefix=NO_PGO %s
 
 int foo(int x, int y) __attribute__((always_inline));
@@ -43,7 +52,10 @@
 void bar(int x) {
   // HOTNESS_OFF: foo inlined into bar
   // HOTNESS_OFF-NOT: hotness:
+  // THRESHOLD-NOT: inlined
+  // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
+  // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
   // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}}
   // expected-remark@+1 {{foo inlined into bar (hotness: 30)}}
   sum += foo(x, x - 2);
Index: test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
===
--- test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
+++ test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
@@ -1,7 +1,7 @@
 foo:0:0
  0: 0
 bar:29:29
- 6: foo:0
+ 9: foo:0
 main:0:0
  0: 0 bar:0
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -906,12 +906,18 @@
   Opts.DiagnosticsWithHotness =
   Args.hasArg(options::OPT_fdiagnostics_show_hotness);
   bool UsingSampleProfile = !Opts.SampleProfileFile.empty();
-
-  if (Opts.DiagnosticsWithHotness &&
-  Opts.getProfileUse() == CodeGenOptions::ProfileNone &&
-  !UsingSampleProfile) {
-Diags.Report(diag::warn_drv_fdiagnostics_show_hotness_requires_pgo);
-  }
+  bool UsingProfile = UsingSampleProfile 

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

@hfinkel I've add the flag as suggested. There is one minor change, I used "=" 
instead of ":" when specifying the toolchain/triple. I also support the triple 
being omitted when there is only one offloading toolchain specified with 
-fopenmp-targets.


https://reviews.llvm.org/D34784



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


[PATCH] D34671: This is to address more command from Richard Smith for my change of https://reviews.llvm.org/D33333

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:409
+<< (Ty->hasExceptionSpec() ? FD->getExceptionSpecSourceRange()
+   : FD->getSourceRange());
+} else 

Underlining the entire function is probably not useful; I would just use 
`FD->getExceptionSpecSourceRange()` here -- that way you just won't get any 
highlighting if there isn't an explicit exception spec.


Repository:
  rL LLVM

https://reviews.llvm.org/D34671



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 104962.
gtbercea added a comment.

Check -fopenmp-targets has one entry when using default toolchain in 
-Xopenmp-target.


https://reviews.llvm.org/D34784

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -597,3 +597,19 @@
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
 // CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" "powerpc64le-unknown-linux-gnu" {{.*}}.c" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"
+
+/// ###
+
+/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} argument unused during compilation: '-Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8'
+
+/// ###
+
+/// Check -Xopenmp-target -march=pwr8 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -march=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
+
+// CHK-FOPENMP-TARGET: clang{{.*}} argument unused during compilation: '-Xopenmp-target -march=pwr8'
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -212,8 +212,20 @@
   static_cast(getToolChain());
   assert(TC.getTriple().isNVPTX() && "Wrong platform");
 
+  StringRef GPUArchName;
+  std::vector GPUArchNames;
+  // If this is an OpenMP action we need to extract the device architecture from
+  // the -fopenmp-target-arch option.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP)) {
+GPUArchNames = Args.getAllArgValues(options::OPT_march_EQ);
+assert(GPUArchNames.size() == 1 &&
+   "Exactly one GPU Arch required for ptxas.");
+GPUArchName = GPUArchNames[0];
+  } else
+GPUArchName = JA.getOffloadingArch();
+
   // Obtain architecture from the action.
-  CudaArch gpu_arch = StringToCudaArch(JA.getOffloadingArch());
+  CudaArch gpu_arch = StringToCudaArch(GPUArchName);
   assert(gpu_arch != CudaArch::UNKNOWN &&
  "Device action expected to have an architecture.");
 
@@ -392,6 +404,15 @@
   CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
 }
 
+void AddMArchOption(DerivedArgList *DAL,
+const OptTable ,
+StringRef Opt) {
+  if (Opt.startswith("-march="))
+DAL->AddJoinedArg(nullptr,
+Opts.getOption(options::OPT_march_EQ),
+Opt.split("=").second);
+}
+
 llvm::opt::DerivedArgList *
 CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList ,
  StringRef BoundArch,
@@ -405,7 +426,7 @@
 
   // For OpenMP device offloading, append derived arguments. Make sure
   // flags are not duplicated.
-  // TODO: Append the compute capability.
+  // Also append the compute capability.
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 for (Arg *A : Args){
   bool IsDuplicate = false;
@@ -418,6 +439,47 @@
   if (!IsDuplicate)
 DAL->append(A);
 }
+
+// Get the compute capability from the -fopenmp-targets flag.
+// The default compute capability is sm_20 since this is a CUDA
+// tool chain.
+auto OptList = Args.getAllArgValues(options::OPT_Xopenmp_target_EQ);
+
+// For each OPT_Xopenmp_target_EQ option, the function returns
+// two strings, the triple and the option.
+// The following format is assumed:
+//
+// -Xopenmp-target=nvptx64-nvidia-cuda -opt=val
+for (unsigned i = 0; i < OptList.size(); i+=2) {
+  StringRef Opt = OptList[i+1];
+  if (OptList[i] == getTripleString())
+AddMArchOption(DAL, Opts, Opt);
+}
+
+OptList = Args.getAllArgValues(options::OPT_Xopenmp_target);
+// When there is only one option in the list, the following format
+// is assumed:
+//
+// -Xopenmp-target -opt=val
+
+// By default, if no triple is explicitely specified, we
+// associate -opt=val with the toolchain specified under the
+// -fopenmp-targets flag (provided that there is only one such
+// toolchain specified).
+assert(Args.getAllArgValues(options::OPT_fopenmp_targets_EQ).size() == 1 &&
+"Target toolchain not specified on -Xopenmp-target and cannot be deduced.");
+
+// Add arch
+for (StringRef Opt : OptList) {
+  AddMArchOption(DAL, Opts, Opt);
+}
+
+auto MArchList = 

[PATCH] D34913: [clang-tidy] Add a new Android check "android-cloexec-socket"

2017-06-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh accepted this revision.
chh added a comment.
This revision is now accepted and ready to land.

LGTM. If nobody needs this during the long weekend, it's better to submit after 
the long weekend.


Repository:
  rL LLVM

https://reviews.llvm.org/D34913



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


[PATCH] D34568: [Sema] Make BreakContinueFinder handle nested loops.

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

I'm not particularly happy with the number of different places where we 
duplicate the knowledge of how break/continue bind to enclosing loops, but 
fixing that seems beyond the scope of this change.




Comment at: lib/Sema/SemaStmt.cpp:1610
+Visit(End);
+}
+

In CodeGen, we don't evaluate the condition within the continue/break scope of 
the loop... but I'm pretty sure that doesn't matter because only the range 
statement can contain a break or continue anyway.


Repository:
  rL LLVM

https://reviews.llvm.org/D34568



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


[PATCH] D34529: [Driver] Check that the iOS deployment target is iOS 10 or earlier if the target is 32-bit

2017-06-30 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson accepted this revision.
bob.wilson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D34529



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 104960.
gtbercea retitled this revision from "[OpenMP] Add flag for specifying the 
target device architecture for OpenMP device offloading " to "[OpenMP] Add flag 
for specifying the target device architecture for OpenMP device offloading".
gtbercea added a comment.

Pass OpenMP target options.


https://reviews.llvm.org/D34784

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -597,3 +597,19 @@
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
 // CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" "powerpc64le-unknown-linux-gnu" {{.*}}.c" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"
+
+/// ###
+
+/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} argument unused during compilation: '-Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr8'
+
+/// ###
+
+/// Check -Xopenmp-target -march=pwr8 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -march=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
+
+// CHK-FOPENMP-TARGET: clang{{.*}} argument unused during compilation: '-Xopenmp-target -march=pwr8'
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -212,8 +212,20 @@
   static_cast(getToolChain());
   assert(TC.getTriple().isNVPTX() && "Wrong platform");
 
+  StringRef GPUArchName;
+  std::vector GPUArchNames;
+  // If this is an OpenMP action we need to extract the device architecture from
+  // the -fopenmp-target-arch option.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP)) {
+GPUArchNames = Args.getAllArgValues(options::OPT_march_EQ);
+assert(GPUArchNames.size() == 1 &&
+   "Exactly one GPU Arch required for ptxas.");
+GPUArchName = GPUArchNames[0];
+  } else
+GPUArchName = JA.getOffloadingArch();
+
   // Obtain architecture from the action.
-  CudaArch gpu_arch = StringToCudaArch(JA.getOffloadingArch());
+  CudaArch gpu_arch = StringToCudaArch(GPUArchName);
   assert(gpu_arch != CudaArch::UNKNOWN &&
  "Device action expected to have an architecture.");
 
@@ -392,6 +404,15 @@
   CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
 }
 
+void AddMArchOption(DerivedArgList *DAL,
+const OptTable ,
+StringRef Opt) {
+  if (Opt.startswith("-march="))
+DAL->AddJoinedArg(nullptr,
+Opts.getOption(options::OPT_march_EQ),
+Opt.split("=").second);
+}
+
 llvm::opt::DerivedArgList *
 CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList ,
  StringRef BoundArch,
@@ -405,7 +426,7 @@
 
   // For OpenMP device offloading, append derived arguments. Make sure
   // flags are not duplicated.
-  // TODO: Append the compute capability.
+  // Also append the compute capability.
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 for (Arg *A : Args){
   bool IsDuplicate = false;
@@ -418,6 +439,39 @@
   if (!IsDuplicate)
 DAL->append(A);
 }
+
+// Get the compute capability from the -fopenmp-targets flag.
+// The default compute capability is sm_20 since this is a CUDA
+// tool chain.
+auto OptList = Args.getAllArgValues(options::OPT_Xopenmp_target_EQ);
+// For each OPT_Xopenmp_target_EQ option, the function returns
+// two strings, the triple and the option.
+// The following format is assumed:
+//
+// -Xopenmp-target=nvptx64-nvidia-cuda -opt=val
+//
+for (unsigned i = 0; i < OptList.size(); i+=2) {
+  StringRef Opt = OptList[i+1];
+  if (OptList[i] == getTripleString())
+AddMArchOption(DAL, Opts, Opt);
+}
+
+OptList = Args.getAllArgValues(options::OPT_Xopenmp_target);
+// When there is only one option in the list, the following format
+// is assumed:
+//
+// -Xopenmp-target -opt=val
+//
+for (StringRef Opt : OptList) {
+  AddMArchOption(DAL, Opts, Opt);
+}
+
+auto MArchList = DAL->getAllArgValues(options::OPT_march_EQ);
+assert(MArchList.size() < 2 && "At most one GPU arch allowed.");
+if (MArchList.empty())
+  DAL->AddJoinedArg(nullptr,
+  Opts.getOption(options::OPT_march_EQ), "sm_20");
+
 

[PATCH] D34671: This is to address more command from Richard Smith for my change of https://reviews.llvm.org/D33333

2017-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 104959.
jyu2 added a comment.

Hi Aaron,
Thank you so much for your review.  I just update change to address your 
comments.

Let me kwon if you see more problems.

Thanks again.

Jennifer


Repository:
  rL LLVM

https://reviews.llvm.org/D34671

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -394,15 +394,22 @@
 
 static void EmitDiagForCXXThrowInNonThrowingFunc(Sema , SourceLocation OpLoc,
  const FunctionDecl *FD) {
-  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc) &&
+  FD->getTypeSourceInfo()) {
 S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
 if (S.getLangOpts().CPlusPlus11 &&
 (isa(FD) ||
  FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
- FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
-  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
-else
-  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) {
+  if (const auto *Ty = FD->getTypeSourceInfo()->getType()->
+ getAs())
+S.Diag(FD->getLocation(), diag::note_throw_in_dtor)
+<< !isa(FD) << !Ty->hasExceptionSpec()
+<< (Ty->hasExceptionSpec() ? FD->getExceptionSpecSourceRange()
+   : FD->getSourceRange());
+} else 
+  S.Diag(FD->getLocation(), diag::note_throw_in_function)
+  << FD->getExceptionSpecSourceRange();
   }
 }
 
@@ -420,8 +427,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->getExceptionSpecType() != EST_None &&
-  FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()))
 return true;
   return false;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6351,15 +6351,13 @@
   "cannot use '%0' with exceptions disabled">;
 def err_objc_exceptions_disabled : Error<
   "cannot use '%0' with Objective-C exceptions disabled">;
-def warn_throw_in_noexcept_func 
-: Warning<"%0 has a non-throwing exception specification but can still "
-  "throw, resulting in unexpected program termination">,
-  InGroup;
-def note_throw_in_dtor 
-: Note<"destructor or deallocator has a (possibly implicit) non-throwing "
-  "excepton specification">;
-def note_throw_in_function 
-: Note<"non-throwing function declare here">;
+def warn_throw_in_noexcept_func : Warning<
+  "%0 has a non-throwing exception specification but can still throw">,
+  InGroup;
+def note_throw_in_dtor : Note<
+  "%select{destructor|deallocator}0 has a %select{non-throwing|implicit "
+  "non-throwing}1 exception specification">;
+def note_throw_in_function : Note<"function declared non-throwing here">;
 def err_seh_try_outside_functions : Error<
   "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">;
 def err_mixing_cxx_try_seh_try : Error<
Index: test/SemaCXX/warn-throw-out-noexcept-func.cpp
===
--- test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -2,16 +2,16 @@
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
-A_ShouldDiag::~A_ShouldDiag() { // expected-note {{destructor or deallocator has a (possibly implicit) non-throwing excepton specification}}
-  throw 1; // expected-warning {{has a non-throwing exception specification but can still throw, resulting in unexpected program termination}}
+A_ShouldDiag::~A_ShouldDiag() { // expected-note {{destructor has a implicit non-throwing exception specification}}
+  throw 1; // expected-warning {{has a non-throwing exception specification but can still throw}}
 }
 struct B_ShouldDiag {
   int i;
   ~B_ShouldDiag() noexcept(true) {} //no disg, no throw stmt
 };
 struct R_ShouldDiag : A_ShouldDiag {
   B_ShouldDiag b;
-  ~R_ShouldDiag() { // expected-note  {{destructor or deallocator has a}}
+  ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification but}}
   }
 };
@@ -30,18 +30,18 @@
   ~N_ShouldDiag(); //implicitly noexcept(true)
 };
 
-N_ShouldDiag::~N_ShouldDiag() {  // expected-note  {{destructor or deallocator has a}}

[PATCH] D34671: This is to address more command from Richard Smith for my change of https://reviews.llvm.org/D33333

2017-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6356-6357
+: Warning<
+  "%0 has a non-throwing exception specification but can " "still "
+   "throw">,
+  InGroup;

aaron.ballman wrote:
> The formatting here is quite strange, especially the string concat.
But that is from clang-format...

For sure I did not invent that format.  I change to this.  Hope that okay.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6359
+  InGroup;
+def note_throw_in_dtor : Note<"%select{destructor|deallocator}0 has a "
+  "%select{non-throwing|implicit "

aaron.ballman wrote:
> Formatting here is also a bit off (see other examples in the file for how we 
> usually format diagnostics).
Same here, it is also from clang-format.

I change to this.  



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:403
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) {
+  // No point to emit diagnoistic for no-user declared function.
+  if (FD->getTypeSourceInfo()) {

aaron.ballman wrote:
> Typo "diagnoistic", but the comment doesn't appear to match the code.
:-( remove it.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:414
+  S.Diag(FD->getLocation(), diag::note_throw_in_function)
+  << FD->getExceptionSpecSourceRange();
   }

aaron.ballman wrote:
> In the event `FD->getTypeSourceInfo()` returns null, 
> `getExceptionSpecSourceRange()` will return an empty source range.
Good point.  Thanks.  I move FD->getTypeSourceInfo() check up.


Repository:
  rL LLVM

https://reviews.llvm.org/D34671



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


[PATCH] D34529: [Driver] Check that the iOS deployment target is iOS 10 or earlier if the target is 32-bit

2017-06-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 104958.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Set Micro to 99 too.


https://reviews.llvm.org/D34529

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -10,6 +10,41 @@
 // RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS3 %s
 // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0"
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
+// RUN:   %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err
+// RUN:   FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s
+// CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0'
+
+// RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s
+// CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0'
+
+// RUN: %clang -target i386-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS6 %s
+// CHECK-VERSION-IOS6: invalid iOS deployment version '-mios-simulator-version-min=11.0'
+
+// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
+// CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
+// RUN:   %clang -target arm64-apple-ios11.0 -c -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS8 %s
+// CHECK-VERSION-IOS8: arm64-apple-ios11.0.0
+
+// RUN: %clang -target arm64-apple-ios11.0 -miphoneos-version-min=11.0 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS9 %s
+// CHECK-VERSION-IOS9: arm64-apple-ios11.0.0
+
+// RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
+// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0
+
+// RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
+// CHECK-VERSION-IOS11: arm64-apple-ios11.1.0
+
 // RUN: %clang -target i686-apple-darwin8 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 2>&1 | \
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1150,6 +1150,17 @@
   Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
   options::OPT_mwatchos_simulator_version_min_EQ);
 
+  unsigned Major, Minor, Micro;
+  bool HadExtra;
+
+  // iOS 10 is the maximum deployment target for 32-bit targets.
+  if (iOSVersion && getTriple().isArch32Bit() &&
+  Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
+HadExtra) &&
+  Major > 10)
+getDriver().Diag(diag::err_invalid_ios_deployment_target)
+<< iOSVersion->getAsString(Args);
+
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
   // -m(iphone|tv|watch)simulator-version-min=X.Y.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
@@ -1191,6 +1202,14 @@
 if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
   WatchOSTarget = env;
 
+// iOS 10 is the maximum deployment target for 32-bit targets.
+if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
+Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
+  HadExtra) &&
+Major > 10)
+  getDriver().Diag(diag::err_invalid_ios_deployment_target)
+  << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
+
 // If there is no command-line argument to specify the Target version and
 // no environment variable defined, see if we can set the default based
 // on -isysroot.
@@ -1308,8 +1327,6 @@
 llvm_unreachable("Unable to infer Darwin variant");
 
   // Set the tool chain target information.
-  unsigned Major, Minor, Micro;
-  bool HadExtra;
   if (Platform == MacOS) {
 assert((!iOSVersion && !TvOSVersion && !WatchOSVersion) &&
"Unknown target platform!");
@@ -1325,6 +1342,13 @@
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   getDriver().Diag(diag::err_drv_invalid_version_number)
   << iOSVersion->getAsString(Args);
+  // iOS 10 is the maximum deployment target for 32-bit targets. If the
+  // inferred deployment target is iOS 11 or later, set it to 10.99.
+  if 

r306905 - Fix PR 33189: Clang assertion on template destructor declaration

2017-06-30 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Fri Jun 30 15:43:54 2017
New Revision: 306905

URL: http://llvm.org/viewvc/llvm-project?rev=306905=rev
Log:
Fix PR 33189: Clang assertion on template destructor declaration

Summary:
This patch aims to fix the bug reported at
https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hits an assertion
when a template destructor declaration is present. This is caused by
later processing that does not expect to encounter a template when
looking at a destructor. The resolution is to treat the destructor as
being not declared when later processing is interested in the properties
of the destructor of a class.

Reviewers: rcraik, hubert.reinterpretcast, aaron.ballman, rsmith

Reviewed By: rsmith

Subscribers: rsmith, cfe-commits

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

Patch by Kuang He!

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaTemplate/destructor-template.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=306905=306904=306905=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Jun 30 15:43:54 2017
@@ -1417,11 +1417,8 @@ CXXDestructorDecl *CXXRecordDecl::getDes
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
-return nullptr;
 
-  CXXDestructorDecl *Dtor = cast(R.front());
-  return Dtor;
+  return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
 bool CXXRecordDecl::isAnyDestructorNoReturn() const {

Modified: cfe/trunk/test/SemaTemplate/destructor-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/destructor-template.cpp?rev=306905=306904=306905=diff
==
--- cfe/trunk/test/SemaTemplate/destructor-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/destructor-template.cpp Fri Jun 30 15:43:54 2017
@@ -86,3 +86,9 @@ namespace PR16852 {
   template decltype(S().~S()) f(); // expected-note {{candidate 
template ignored: couldn't infer template argument 'T'}}
   void g() { f(); } // expected-error {{no matching function for call to 'f'}}
 }
+
+class PR33189
+{
+  template 
+  ~PR33189() { } // expected-error{{destructor cannot be declared as a 
template}}
+};


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


r306904 - [ODRHash] Support Type TemplateArgument

2017-06-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun 30 15:40:33 2017
New Revision: 306904

URL: http://llvm.org/viewvc/llvm-project?rev=306904=rev
Log:
[ODRHash] Support Type TemplateArgument

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=306904=306903=306904=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun 30 15:40:33 2017
@@ -146,7 +146,10 @@ void ODRHash::AddTemplateArgument(Templa
 
   switch (Kind) {
 case TemplateArgument::Null:
+  llvm_unreachable("Expected valid TemplateArgument");
 case TemplateArgument::Type:
+  AddQualType(TA.getAsType());
+  break;
 case TemplateArgument::Declaration:
 case TemplateArgument::NullPtr:
 case TemplateArgument::Integral:

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=306904=306903=306904=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun 30 15:40:33 2017
@@ -1070,6 +1070,40 @@ S4 s4;
 // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 
'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'x' does not match}}
 #endif
+
+#if defined(FIRST)
+template  struct U5 {};
+struct S5 {
+  U5 x;
+};
+#elif defined(SECOND)
+template  struct U5 {};
+struct S5 {
+  U5 x;
+};
+#else
+S5 s5;
+// expected-error@first.h:* {{'TemplateArgument::S5::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+template  struct U6 {};
+struct S6 {
+  U6 x;
+  U6 y;
+};
+#elif defined(SECOND)
+template  struct U6 {};
+struct S6 {
+  U6 y;
+  U6 x;
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'TemplateArgument::S6' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found field 'y'}}
+// expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
+#endif
 }
 
 namespace TemplateTypeParmType {


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


r306903 - Reinstate "Load lazily the template specialization in multi-module setups."

2017-06-30 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun 30 15:40:17 2017
New Revision: 306903

URL: http://llvm.org/viewvc/llvm-project?rev=306903=rev
Log:
Reinstate "Load lazily the template specialization in multi-module setups."

It was reverted in r305460 but the issue appears to only break our self-host
libcxx modules bot. Reapplying it will give us a chance to get a reproducer and
fix the issue.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=306903=306902=306903=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jun 30 15:40:17 2017
@@ -219,6 +219,30 @@ namespace clang {
   TypedefNameForLinkage(nullptr), HasPendingBody(false),
   IsDeclMarkedUsed(false) {}
 
+template  static
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  if (IDs.empty())
+return;
+
+  // FIXME: We should avoid this pattern of getting the ASTContext.
+  ASTContext  = D->getASTContext();
+
+  auto * = D->getCommonPtr()->LazySpecializations;
+
+  if (auto  = LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  LazySpecializations = Result;
+}
+
 template 
 static Decl *getMostRecentDeclImpl(Redeclarable *D);
 static Decl *getMostRecentDeclImpl(...);
@@ -247,7 +271,7 @@ namespace clang {
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D);
+void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1971,21 +1995,6 @@ ASTDeclReader::VisitRedeclarableTemplate
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext , DeclID *Old,
- SmallVectorImpl ) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1994,12 +2003,7 @@ void ASTDeclReader::VisitClassTemplateDe
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2026,12 +2030,7 @@ void ASTDeclReader::VisitVarTemplateDecl
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2137,12 +2136,7 @@ void ASTDeclReader::VisitFunctionTemplat
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3688,6 +3682,9 @@ void ASTReader::loadDeclUpdateRecords(Pe
   Decl *D = Record.D;
   ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
   DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
+
+  llvm::SmallVector PendingLazySpecializationIDs;
+
   if (UpdI != DeclUpdateOffsets.end()) {
 auto UpdateOffsets = std::move(UpdI->second);
 DeclUpdateOffsets.erase(UpdI);
@@ -3712,7 +3709,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
SourceLocation());
-  Reader.UpdateDecl(D);
+  

[PATCH] D34568: [Sema] Make BreakContinueFinder handle nested loops.

2017-06-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D34568



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


[PATCH] D34891: Replace assert(0) with llvm_unreachable.

2017-06-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Sure, I can do this, as long as this semantic change is ok.


Repository:
  rL LLVM

https://reviews.llvm.org/D34891



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


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Thanks, do you need someone to commit this for you?


https://reviews.llvm.org/D33833



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


[PATCH] D34891: Replace assert(0) with llvm_unreachable.

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

You should remove the code after the `assert(0)`, or you'll trigger 
"unreachable code" warnings.


Repository:
  rL LLVM

https://reviews.llvm.org/D34891



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


r306899 - [Parse] Use normalized attr name for late-parsing checks.

2017-06-30 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Jun 30 15:33:24 2017
New Revision: 306899

URL: http://llvm.org/viewvc/llvm-project?rev=306899=rev
Log:
[Parse] Use normalized attr name for late-parsing checks.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Sema/diagnose_if.c

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=306899=306898=306899=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jun 30 15:33:24 2017
@@ -71,11 +71,18 @@ TypeResult Parser::ParseTypeName(SourceR
   return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
 }
 
+/// \brief Normalizes an attribute name by dropping prefixed and suffixed __.
+static StringRef normalizeAttrName(StringRef Name) {
+  if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
+return Name.drop_front(2).drop_back(2);
+  return Name;
+}
+
 /// isAttributeLateParsed - Return true if the attribute has arguments that
 /// require late parsing.
 static bool isAttributeLateParsed(const IdentifierInfo ) {
 #define CLANG_ATTR_LATE_PARSED_LIST
-return llvm::StringSwitch(II.getName())
+return llvm::StringSwitch(normalizeAttrName(II.getName()))
 #include "clang/Parse/AttrParserStringSwitches.inc"
 .Default(false);
 #undef CLANG_ATTR_LATE_PARSED_LIST
@@ -200,13 +207,6 @@ void Parser::ParseGNUAttributes(ParsedAt
   }
 }
 
-/// \brief Normalizes an attribute name by dropping prefixed and suffixed __.
-static StringRef normalizeAttrName(StringRef Name) {
-  if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
-Name = Name.drop_front(2).drop_back(2);
-  return Name;
-}
-
 /// \brief Determine whether the given attribute has an identifier argument.
 static bool attributeHasIdentifierArg(const IdentifierInfo ) {
 #define CLANG_ATTR_IDENTIFIER_ARG_LIST

Modified: cfe/trunk/test/Sema/diagnose_if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diagnose_if.c?rev=306899=306898=306899=diff
==
--- cfe/trunk/test/Sema/diagnose_if.c (original)
+++ cfe/trunk/test/Sema/diagnose_if.c Fri Jun 30 15:33:24 2017
@@ -153,3 +153,7 @@ void runAlwaysWarnWithArg(int a) {
 
 // Test that diagnose_if warnings generated in system headers are not ignored.
 #include "Inputs/diagnose-if-warn-system-header.h"
+
+// Bug: we would complain about `a` being undeclared if this was spelled
+// __diagnose_if__.
+void underbarName(int a) __attribute__((__diagnose_if__(a, "", "warning")));


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


[PATCH] D34891: Replace assert(0) with llvm_unreachable.

2017-06-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Ok, thanks! I was hesitant for the changes in libclang, because of the return 
statements.


Repository:
  rL LLVM

https://reviews.llvm.org/D34891



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


[PATCH] D34891: Replace assert(0) with llvm_unreachable.

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, post-commit review is fine for changes like this.


Repository:
  rL LLVM

https://reviews.llvm.org/D34891



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


[PATCH] D34913: [clang-tidy] Add a new Android check "android-cloexec-socket"

2017-06-30 Thread Yan Wang via Phabricator via cfe-commits
yawanng created this revision.
yawanng added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny, srhines.

socket() is better to include SOCK_CLOEXEC in its type argument to avoid the 
file descriptor leakage.


Repository:
  rL LLVM

https://reviews.llvm.org/D34913

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecOpenCheck.cpp
  clang-tidy/android/CloexecSocketCheck.cpp
  clang-tidy/android/CloexecSocketCheck.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/CloexecFlagChecker.cpp
  clang-tidy/utils/CloexecFlagChecker.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-socket.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-socket.cpp

Index: test/clang-tidy/android-cloexec-socket.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-socket.cpp
@@ -0,0 +1,92 @@
+// RUN: %check_clang_tidy %s android-cloexec-socket %t
+
+#define SOCK_STREAM 1
+#define SOCK_DGRAM 2
+#define __O_CLOEXEC 3
+#define SOCK_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+
+extern "C" int socket(int domain, int type, int protocol);
+
+void a() {
+  socket(0, SOCK_STREAM, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'socket' should use SOCK_CLOEXEC where possible [android-cloexec-socket]
+  // CHECK-FIXES: SOCK_STREAM | SOCK_CLOEXEC
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM, 0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: 'socket'
+  // CHECK-FIXES: SOCK_STREAM | SOCK_CLOEXEC
+  socket(0, SOCK_STREAM | SOCK_DGRAM, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'socket'
+  // CHECK-FIXES: SOCK_STREAM | SOCK_DGRAM | SOCK_CLOEXEC
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM | SOCK_DGRAM, 0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: 'socket'
+  // CHECK-FIXES: SOCK_STREAM | SOCK_DGRAM | SOCK_CLOEXEC
+}
+
+void f() {
+  socket(0, 3, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'socket'
+  // CHECK-FIXES: 3 | SOCK_CLOEXEC
+  TEMP_FAILURE_RETRY(socket(0, 3, 0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: 'socket'
+  // CHECK-FIXES: 3 | SOCK_CLOEXEC
+
+  int flag = 3;
+  socket(0, flag, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, flag, 0));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int socket(int domain, int type, int protocol);
+
+void d() {
+  socket(0, SOCK_STREAM, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM, 0));
+  // CHECK-MESSAGES-NOT: warning:
+  socket(0, SOCK_STREAM | SOCK_DGRAM, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM | SOCK_DGRAM, 0));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  socket(0, SOCK_CLOEXEC, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, SOCK_CLOEXEC, 0));
+  // CHECK-MESSAGES-NOT: warning:
+  socket(0, SOCK_STREAM | SOCK_CLOEXEC, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM | SOCK_CLOEXEC, 0));
+  // CHECK-MESSAGES-NOT: warning:
+  socket(0, SOCK_STREAM | SOCK_CLOEXEC | SOCK_DGRAM, 0);
+  // CHECK-MESSAGES-NOT: warning:
+  TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM | SOCK_CLOEXEC | SOCK_DGRAM, 0));
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int socket(int domain, int type, int protocol);
+  void d() {
+socket(0, SOCK_STREAM, 0);
+// CHECK-MESSAGES-NOT: warning:
+TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM, 0));
+// CHECK-MESSAGES-NOT: warning:
+socket(0, SOCK_STREAM | SOCK_DGRAM, 0);
+// CHECK-MESSAGES-NOT: warning:
+TEMP_FAILURE_RETRY(socket(0, SOCK_STREAM | SOCK_DGRAM, 0));
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -7,6 +7,7 @@
android-cloexec-creat
android-cloexec-fopen
android-cloexec-open
+   android-cloexec-socket
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
cert-dcl21-cpp
Index: docs/clang-tidy/checks/android-cloexec-socket.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-socket.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - android-cloexec-socket
+
+android-cloexec-socket
+==
+``socket()`` should include ``SOCK_CLOEXEC`` in its type argument to avoid the
+file descriptor leakage.
+
+Examples:
+
+.. code-block:: c++
+
+  socket(domain, type, SOCK_STREAM);
+
+  // becomes
+
+  socket(domain, type, SOCK_STREAM | SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst

[PATCH] D34671: This is to address more command from Richard Smith for my change of https://reviews.llvm.org/D33333

2017-06-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6356-6357
+: Warning<
+  "%0 has a non-throwing exception specification but can " "still "
+   "throw">,
+  InGroup;

The formatting here is quite strange, especially the string concat.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6359
+  InGroup;
+def note_throw_in_dtor : Note<"%select{destructor|deallocator}0 has a "
+  "%select{non-throwing|implicit "

Formatting here is also a bit off (see other examples in the file for how we 
usually format diagnostics).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:403
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) {
+  // No point to emit diagnoistic for no-user declared function.
+  if (FD->getTypeSourceInfo()) {

Typo "diagnoistic", but the comment doesn't appear to match the code.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:404-406
+  if (FD->getTypeSourceInfo()) {
+const auto *Ty =
+FD->getTypeSourceInfo()->getType()->getAs();

I think a more clear way to write this might be:
```
if (const auto *Ty = FD->getType()->getAs()) {
  // ...
}
```
There's no need to go through the type source infor to get the function's 
prototype.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:414
+  S.Diag(FD->getLocation(), diag::note_throw_in_function)
+  << FD->getExceptionSpecSourceRange();
   }

In the event `FD->getTypeSourceInfo()` returns null, 
`getExceptionSpecSourceRange()` will return an empty source range.


Repository:
  rL LLVM

https://reviews.llvm.org/D34671



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


[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.

2017-06-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev planned changes to this revision.
v.g.vassilev added a comment.

Waiting for @karies for a test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D34912



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


[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.

2017-06-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

Patch by Axel Naumann!


Repository:
  rL LLVM

https://reviews.llvm.org/D34912

Files:
  lib/AST/TemplateBase.cpp


Index: lib/AST/TemplateBase.cpp
===
--- lib/AST/TemplateBase.cpp
+++ lib/AST/TemplateBase.cpp
@@ -62,6 +62,12 @@
 Out << "'";
   } else {
 Out << Val;
+// Handle cases where the value is too large to fit into the underlying 
type
+// i.e. where the unsignedness matters.
+if (const BuiltinType *BT = T->getAs()) {
+  if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.isNegative())
+Out << "ull";
+}
   }
 }
 


Index: lib/AST/TemplateBase.cpp
===
--- lib/AST/TemplateBase.cpp
+++ lib/AST/TemplateBase.cpp
@@ -62,6 +62,12 @@
 Out << "'";
   } else {
 Out << Val;
+// Handle cases where the value is too large to fit into the underlying type
+// i.e. where the unsignedness matters.
+if (const BuiltinType *BT = T->getAs()) {
+  if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.isNegative())
+Out << "ull";
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34909: Driver: consume -nostdinc++ along with -nostdinc

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D34909#797252, @kastiglione wrote:

> There are other drivers with the same issue. If there's no opposition to 
> this, I can update those here as well.


Yes, that'd be great, thanks :)


https://reviews.llvm.org/D34909



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


[PATCH] D34909: Driver: consume -nostdinc++ along with -nostdinc

2017-06-30 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

There are other drivers with the same issue. If there's no opposition to this, 
I can update those here as well.


https://reviews.llvm.org/D34909



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


[PATCH] D34909: Driver: consume -nostdinc++ along with -nostdinc

2017-06-30 Thread Dave Lee via Phabricator via cfe-commits
kastiglione created this revision.

Using both -nostdinc and -nostdinc++ should not emit diagnostics.


https://reviews.llvm.org/D34909

Files:
  lib/Driver/ToolChains/CrossWindows.cpp
  test/Driver/windows-cross.c


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -85,3 +85,7 @@
 // CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" 
"[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
+
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -nostdinc++ -x c++ 
-c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-NOSTDINCXX
+// CHECK-NOSTDINC-NOSTDINCXX-NOT: argument unused during compilation: 
'-nostdinc++'
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -264,8 +264,7 @@
   const llvm::Triple  = getTriple();
   const std::string  = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdincxx))
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -85,3 +85,7 @@
 // CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
+
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -nostdinc++ -x c++ -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-NOSTDINCXX
+// CHECK-NOSTDINC-NOSTDINCXX-NOT: argument unused during compilation: '-nostdinc++'
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -264,8 +264,7 @@
   const llvm::Triple  = getTriple();
   const std::string  = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdincxx))
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaDecl.cpp:13693-13694
+  // passes the structural compatibility check in C11 6.2.7/1.
+  bool AllowODR = getLangOpts().CPlusPlus || getLangOpts().ObjC1 ||
+  getLangOpts().C11;
   NamedDecl *Hidden = nullptr;

I don't think this should require C11 -- in C89 the corresponding rule is in 
6.1.2.6/1, so the rule exists in all languages that Clang supports.


https://reviews.llvm.org/D31778



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


[PATCH] D34680: clang-cl crashes with -fprofile-instr-use flag

2017-06-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for the stack trace. Clang shouldn't ever be assigning counters to decls 
without bodies. As far as I can tell, this has only been happening when the 
microsoft ABI is in use, which may explain why we don't hit the issue more 
often. The fix required changing the way we assign and use profile counters 
(r306883). Give it a try and let us know how it goes.


https://reviews.llvm.org/D34680



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


r306882 - Fix a typo. NFC.

2017-06-30 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jun 30 14:02:14 2017
New Revision: 306882

URL: http://llvm.org/viewvc/llvm-project?rev=306882=rev
Log:
Fix a typo. NFC.

Modified:
cfe/trunk/test/Profile/cxx-structors.cpp

Modified: cfe/trunk/test/Profile/cxx-structors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-structors.cpp?rev=306882=306881=306882=diff
==
--- cfe/trunk/test/Profile/cxx-structors.cpp (original)
+++ cfe/trunk/test/Profile/cxx-structors.cpp Fri Jun 30 14:02:14 2017
@@ -33,7 +33,7 @@ Baz baz;
 Baz baz2(1);
 Quux qux("fi", "fo", "fum");
 
-// Profile data for complete constructors and destructors must absent.
+// Profile data for complete constructors and destructors must be absent.
 
 // INSTR: @__profc__ZN3BazC1Ev =
 // INSTR: @__profc__ZN3BazC1Ei =


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


[PATCH] D34907: fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Committed as r306878-360881.


Repository:
  rL LLVM

https://reviews.llvm.org/D34907



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


r306881 - Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun 30 13:57:39 2017
New Revision: 306881

URL: http://llvm.org/viewvc/llvm-project?rev=306881=rev
Log:
Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

This is a short-term fix for PR33650 aimed to get the modules build bots green 
again.

Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
macros to try to locally specialize a global template for a global type. That's
not how C++ works.

Instead, we now centrally define how to format vectors of fundamental types and
of string (std::string and StringRef). We use flow formatting for the former
cases, since that's the obvious right thing to do; in the latter case, it's
less clear what the right choice is, but flow formatting is really bad for some
cases (due to very long strings), so we pick block formatting. (Many of the
cases that were using flow formatting for strings are improved by this change.)

Other than the flow -> block formatting change for some vectors of strings,
this should result in no functionality change.

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

Corresponding LLVM change is r306878.

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=306881=306880=306881=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jun 30 13:57:39 2017
@@ -44,7 +44,6 @@
 
 using clang::format::FormatStyle;
 
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::IncludeCategory)
 
 namespace llvm {

Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=306881=306880=306881=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Fri Jun 30 13:57:39 2017
@@ -12,7 +12,6 @@
 #include "llvm/Support/YAMLTraits.h"
 #include 
 
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::AtomicChange)
 
 namespace {

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=306881=306880=306881=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Fri Jun 30 13:57:39 2017
@@ -1123,8 +1123,10 @@ TEST_F(AtomicChangeTest, AtomicChangeToY
"Key: 'input.cpp:20'\n"
"FilePath:input.cpp\n"
"Error:   ''\n"
-   "InsertedHeaders: [ a.h ]\n"
-   "RemovedHeaders:  [ b.h ]\n"
+   "InsertedHeaders: \n" // Extra whitespace here!
+   "  - a.h\n"
+   "RemovedHeaders:  \n" // Extra whitespace here!
+   "  - b.h\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:input.cpp\n"
"Offset:  20\n"
@@ -1143,8 +1145,10 @@ TEST_F(AtomicChangeTest, YAMLToAtomicCha
 "Key: 'input.cpp:20'\n"
 "FilePath:input.cpp\n"
 "Error:   'ok'\n"
-"InsertedHeaders: [ a.h ]\n"
-"RemovedHeaders:  [ b.h ]\n"
+"InsertedHeaders: \n" // Extra whitespace here!
+"  - a.h\n"
+"RemovedHeaders:  \n" // Extra whitespace here!
+"  - b.h\n"
 "Replacements:\n" // Extra whitespace here!
 "  - FilePath:input.cpp\n"
 "Offset:  20\n"


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


[clang-tools-extra] r306879 - Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun 30 13:57:16 2017
New Revision: 306879

URL: http://llvm.org/viewvc/llvm-project?rev=306879=rev
Log:
Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

This is a short-term fix for PR33650 aimed to get the modules build bots green 
again.

Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
macros to try to locally specialize a global template for a global type. That's
not how C++ works.

Instead, we now centrally define how to format vectors of fundamental types and
of string (std::string and StringRef). We use flow formatting for the former
cases, since that's the obvious right thing to do; in the latter case, it's
less clear what the right choice is, but flow formatting is really bad for some
cases (due to very long strings), so we pick block formatting. (Many of the
cases that were using flow formatting for strings are improved by this change.)

Other than the flow -> block formatting change for some vectors of strings,
this should result in no functionality change.

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

Corresponding LLVM change is r306878.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=306879=306878=306879=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Fri Jun 30 13:57:16 
2017
@@ -27,8 +27,6 @@ using OptionsSource = clang::tidy::Clang
 
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
-LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair)
-LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
 
 namespace llvm {
 namespace yaml {

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=306879=306878=306879=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Fri 
Jun 30 13:57:16 2017
@@ -22,7 +22,6 @@ using clang::find_all_symbols::SymbolAnd
 using SymbolKind = clang::find_all_symbols::SymbolInfo::SymbolKind;
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(SymbolAndSignals)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_SEQUENCE_VECTOR(SymbolInfo::Context)
 
 namespace llvm {

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=306879=306878=306879=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Fri Jun 30 
13:57:16 2017
@@ -28,7 +28,6 @@ using namespace llvm;
 using clang::include_fixer::IncludeFixerContext;
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(IncludeFixerContext)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(IncludeFixerContext::HeaderInfo)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(IncludeFixerContext::QuerySymbolInfo)
 


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


[PATCH] D34907: fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306878: Fix ODR violations due to abuse of 
LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D34907?vs=104923=104928#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34907

Files:
  llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h
  llvm/trunk/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h
  llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h
  llvm/trunk/include/llvm/Support/YAMLTraits.h
  llvm/trunk/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
  llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
  llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
  llvm/trunk/lib/Support/AMDGPUCodeObjectMetadata.cpp
  llvm/trunk/test/CodeGen/AMDGPU/code-object-metadata-from-llvm-ir-full.ll
  llvm/trunk/test/MC/AMDGPU/code-object-metadata-kernel-args.s
  llvm/trunk/test/MC/AMDGPU/code-object-metadata-kernel-attrs.s
  llvm/trunk/test/Transforms/LowerTypeTests/export-icall.ll
  llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp
  llvm/trunk/unittests/Support/YAMLIOTest.cpp

Index: llvm/trunk/lib/Support/AMDGPUCodeObjectMetadata.cpp
===
--- llvm/trunk/lib/Support/AMDGPUCodeObjectMetadata.cpp
+++ llvm/trunk/lib/Support/AMDGPUCodeObjectMetadata.cpp
@@ -20,8 +20,6 @@
 using namespace llvm::AMDGPU;
 using namespace llvm::AMDGPU::CodeObject;
 
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Arg::Metadata)
 LLVM_YAML_IS_SEQUENCE_VECTOR(Kernel::Metadata)
 
Index: llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
===
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
@@ -29,7 +29,6 @@
 using namespace llvm::yaml;
 
 LLVM_YAML_IS_SEQUENCE_VECTOR(OneMethodRecord)
-LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
 LLVM_YAML_IS_SEQUENCE_VECTOR(VFTableSlotKind)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
 
Index: llvm/trunk/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
===
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
@@ -48,9 +48,7 @@
 LLVM_YAML_IS_SEQUENCE_VECTOR(InlineeInfo)
 LLVM_YAML_IS_SEQUENCE_VECTOR(CrossModuleExport)
 LLVM_YAML_IS_SEQUENCE_VECTOR(YAMLCrossModuleImport)
-LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
 LLVM_YAML_IS_SEQUENCE_VECTOR(YAMLFrameData)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
 
 LLVM_YAML_DECLARE_SCALAR_TRAITS(HexFormattedString, false)
 LLVM_YAML_DECLARE_ENUM_TRAITS(DebugSubsectionKind)
Index: llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
===
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
@@ -27,7 +27,6 @@
 using namespace llvm::CodeViewYAML::detail;
 using namespace llvm::yaml;
 
-LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
 
 // We only need to declare these, the definitions are in CodeViewYAMLTypes.cpp
Index: llvm/trunk/unittests/Support/YAMLIOTest.cpp
===
--- llvm/trunk/unittests/Support/YAMLIOTest.cpp
+++ llvm/trunk/unittests/Support/YAMLIOTest.cpp
@@ -1029,7 +1029,8 @@
 
 LLVM_YAML_STRONG_TYPEDEF(int, MyNumber)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(MyNumber)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::StringRef)
+LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, MyString)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(MyString)
 
 namespace llvm {
 namespace yaml {
@@ -1049,12 +1050,23 @@
 
 static bool mustQuote(StringRef) { return false; }
   };
+
+  template <> struct ScalarTraits {
+using Impl = ScalarTraits;
+static void output(const MyString , void *Ctx, raw_ostream ) {
+  Impl::output(V, Ctx, OS);
+}
+static StringRef input(StringRef S, void *Ctx, MyString ) {
+  return Impl::input(S, Ctx, V.value);
+}
+static bool mustQuote(StringRef S) { return Impl::mustQuote(S); }
+  };
 }
 }
 
 struct NameAndNumbers {
   llvm::StringRef   name;
-  std::vector  strings;
+  std::vector strings;
   std::vector single;
   std::vector numbers;
 };
@@ -1128,8 +1140,8 @@
 EXPECT_FALSE(yin.error());
 EXPECT_TRUE(map2.name.equals("hello"));
 EXPECT_EQ(map2.strings.size(), 2UL);
-EXPECT_TRUE(map2.strings[0].equals("one"));
-EXPECT_TRUE(map2.strings[1].equals("two"));
+EXPECT_TRUE(map2.strings[0].value.equals("one"));
+EXPECT_TRUE(map2.strings[1].value.equals("two"));
 EXPECT_EQ(map2.single.size(), 1UL);
 EXPECT_EQ(1,   map2.single[0]);
 EXPECT_EQ(map2.numbers.size(), 3UL);
@@ -1739,7 +1751,6 @@
 //
 // Test error handling reading 

[PATCH] D34907: fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Zachary Turner via Phabricator via cfe-commits
zturner accepted this revision.
zturner added a comment.
This revision is now accepted and ready to land.

I don't have any comments, this seems fine to me.  Long term I think the best 
solution is to get rid of these global specializations entirely, and instead 
provide adapters called `flow` and `block`, and instead of just saying 
`IO.mapOptional("Foo", Sequence);` and having it be picked up by a 
specialization, you would say `IO.mapOptional("Foo", flow(Sequence));`


Repository:
  rL LLVM

https://reviews.llvm.org/D34907



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


[PATCH] D34907: fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR

2017-06-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
Herald added subscribers: aheejin, hiraditya, sbc100, nhaehnle, sanjoy, klimek.

This is a short-term fix for PR33650 aimed to get the modules build bots green 
again.

Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR 
macros to try to locally specialize a global template for a global type. That's 
not how C++ works.

Instead, we now centrally define how to format vectors of fundamental types and 
of string (std::string and StringRef). We use flow formatting for the former 
cases, since that's the obvious right thing to do; in the latter case, it's 
less clear what the right choice is, but flow formatting is really bad for some 
cases (due to very long strings), so we pick that. (Many of the cases that were 
using flow formatting for strings are improved by this change.)

Other than the flow -> block formatting change for some vectors of strings, 
this should result in no functionality change.


Repository:
  rL LLVM

https://reviews.llvm.org/D34907

Files:
  cfe/lib/Format/Format.cpp
  cfe/lib/Tooling/Refactoring/AtomicChange.cpp
  cfe/unittests/Tooling/RefactoringTest.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
  llvm/include/llvm/ObjectYAML/DWARFYAML.h
  llvm/include/llvm/ObjectYAML/MachOYAML.h
  llvm/include/llvm/ObjectYAML/WasmYAML.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
  llvm/lib/Support/AMDGPUCodeObjectMetadata.cpp
  llvm/test/CodeGen/AMDGPU/code-object-metadata-from-llvm-ir-full.ll
  llvm/test/MC/AMDGPU/code-object-metadata-kernel-args.s
  llvm/test/MC/AMDGPU/code-object-metadata-kernel-attrs.s
  llvm/test/Transforms/LowerTypeTests/export-icall.ll
  llvm/tools/llvm-pdbutil/PdbYaml.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
===
--- lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
+++ lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
@@ -44,7 +44,6 @@
 LLVM_YAML_IS_SEQUENCE_VECTOR(RebaseLocation)
 LLVM_YAML_IS_SEQUENCE_VECTOR(BindLocation)
 LLVM_YAML_IS_SEQUENCE_VECTOR(Export)
-LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
 LLVM_YAML_IS_SEQUENCE_VECTOR(DataInCode)
 
 
Index: clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp
@@ -28,7 +28,6 @@
 using clang::include_fixer::IncludeFixerContext;
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(IncludeFixerContext)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(IncludeFixerContext::HeaderInfo)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(IncludeFixerContext::QuerySymbolInfo)
 
Index: clang-tools-extra/include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- clang-tools-extra/include-fixer/find-all-symbols/SymbolInfo.cpp
+++ clang-tools-extra/include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -22,7 +22,6 @@
 using SymbolKind = clang::find_all_symbols::SymbolInfo::SymbolKind;
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(SymbolAndSignals)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
 LLVM_YAML_IS_SEQUENCE_VECTOR(SymbolInfo::Context)
 
 namespace llvm {
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -27,8 +27,6 @@
 
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
-LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair)
-LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
 
 namespace llvm {
 namespace yaml {
Index: cfe/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/unittests/Tooling/RefactoringTest.cpp
+++ cfe/unittests/Tooling/RefactoringTest.cpp
@@ -1123,8 +1123,10 @@
"Key: 'input.cpp:20'\n"
"FilePath:input.cpp\n"
"Error:   ''\n"
-   "InsertedHeaders: [ a.h ]\n"
-   "RemovedHeaders:  [ b.h ]\n"
+   "InsertedHeaders: \n" // Extra whitespace here!
+   "  - a.h\n"
+   "RemovedHeaders:  \n" // Extra whitespace here!
+   "  - b.h\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:input.cpp\n"
"Offset:  

[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: test/clang-tidy/modernize-make-shared-header.cpp:1
+// RUN: cp %S/Inputs/modernize-smart-ptr/shared_ptr.h %T/shared_ptr.h
+// RUN: %check_clang_tidy %s modernize-make-shared %t -- \

alexfh wrote:
> Maybe just add "-I%S/Inputs/modernize-smart-ptr/" flag to the clang-tidy 
> invocation?
Good idea!


https://reviews.llvm.org/D34206



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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 104922.
hokein marked 2 inline comments as done.
hokein added a comment.
Herald added a subscriber: JDevlieghere.

Rebase and address review comments.


https://reviews.llvm.org/D34206

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  docs/clang-tidy/checks/modernize-make-shared.rst
  docs/clang-tidy/checks/modernize-make-unique.rst
  test/clang-tidy/Inputs/modernize-smart-ptr/shared_ptr.h
  test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
  test/clang-tidy/modernize-make-shared-header.cpp
  test/clang-tidy/modernize-make-shared.cpp
  test/clang-tidy/modernize-make-unique-header.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -1,32 +1,8 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
 
-namespace std {
-
-template 
-class default_delete {};
-
-template >
-class unique_ptr {
-public:
-  unique_ptr();
-  unique_ptr(type *ptr);
-  unique_ptr(const unique_ptr ) = delete;
-  unique_ptr(unique_ptr &);
-  ~unique_ptr();
-  type *() { return *ptr; }
-  type *operator->() { return ptr; }
-  type *release();
-  void reset();
-  void reset(type *pt);
-  void reset(type pt);
-  unique_ptr =(unique_ptr &&);
-  template 
-  unique_ptr =(unique_ptr &&);
-
-private:
-  type *ptr;
-};
-}
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
 
 struct Base {
   Base();
Index: test/clang-tidy/modernize-make-unique-header.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-header.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-make-unique.MakeSmartPtrFunction, \
+// RUN:   value: 'my::MakeUnique'}, \
+// RUN:  {key: modernize-make-unique.MakeSmartPtrFunctionHeader, \
+// RUN:   value: 'make_unique_util.h'} \
+// RUN: ]}" \
+// RUN:   -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include "make_unique_util.h"
+
+void f() {
+  std::unique_ptr P1 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeUnique instead
+  // CHECK-FIXES: std::unique_ptr P1 = my::MakeUnique();
+}
Index: test/clang-tidy/modernize-make-shared.cpp
===
--- test/clang-tidy/modernize-make-shared.cpp
+++ test/clang-tidy/modernize-make-shared.cpp
@@ -1,28 +1,8 @@
-// RUN: %check_clang_tidy %s modernize-make-shared %t
+// RUN: %check_clang_tidy %s modernize-make-shared %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
 
-namespace std {
-
-template 
-class shared_ptr {
-public:
-  shared_ptr();
-  shared_ptr(type *ptr);
-  shared_ptr(const shared_ptr ) {}
-  shared_ptr(shared_ptr &) {}
-  ~shared_ptr();
-  type *() { return *ptr; }
-  type *operator->() { return ptr; }
-  type *release();
-  void reset();
-  void reset(type *pt);
-  shared_ptr =(shared_ptr &&);
-  template 
-  shared_ptr =(shared_ptr &&);
-
-private:
-  type *ptr;
-};
-}
+#include "shared_ptr.h"
+// CHECK-FIXES: #include 
 
 struct Base {
   Base();
Index: test/clang-tidy/modernize-make-shared-header.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-shared-header.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s modernize-make-shared %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-make-shared.MakeSmartPtrFunction, \
+// RUN:   value: 'my::MakeShared'}, \
+// RUN:  {key: modernize-make-shared.MakeSmartPtrFunctionHeader, \
+// RUN:   value: 'make_shared_util.h'} \
+// RUN: ]}" \
+// RUN:   -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "shared_ptr.h"
+// CHECK-FIXES: #include "make_shared_util.h"
+
+void f() {
+  std::shared_ptr P1 = std::shared_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeShared instead
+  // CHECK-FIXES: std::shared_ptr P1 = my::MakeShared();
+}
Index: test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
@@ -0,0 +1,28 @@
+namespace std {
+
+template 
+class default_delete {};
+
+template >
+class unique_ptr {
+public:
+  unique_ptr();
+  unique_ptr(type *ptr);
+  unique_ptr(const unique_ptr ) = delete;
+  unique_ptr(unique_ptr &);
+  ~unique_ptr();
+  type *() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release();
+  void reset();
+  void reset(type *pt);
+  void 

[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-06-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 104911.
mibintc added a subscriber: ilya-biryukov.
mibintc added a comment.

The previous (n-1) version didn't work: I wanted to iterate through the system 
include directories to check for the existence of stdc-predef.h but clang is 
using a different kind of system include option for /usr and /usr/include so 
the iterator didn't find any system includes at all, i don't think there is an 
iterator which will iterate through these special kind of include directories. 
[Kind of embarrassing that I posted that patch which didn't work at all, sorry 
about that.]

This one behaves more like gcc anyway. gcc puts the -include option in there 
regardless, and to suppress the behavior you are to use the -ffreestanding 
option.

I responded to the remarks from Jonas Hahnfeld, making the patch only for Linux.

I'm having trouble with one of the existing tests. These are the ones that 
fail. I don't know how to fix the text. It's a google test and it is using a 
dummy file system with whitelisted directories. @ilya-biryukov Is there a way 
to pass in a command line argument? if so, I could fix it these failures by 
adding -ffreestanding option which suppresses the new behavior. That's how I 
fixed the many test failures which I encountered with this new behavior.

  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.Parse
  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.ParseWithHeader
  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.Reparse

The other test that fails is my own new test! It fails because I don't know how 
to set it up so the test thinks it has a gcc toolchain with version > 4.8. I 
tried using gcc-toolchain set to various other Linux toolchains that i see in 
the test/Driver/Inputs - none of them cause the gcc version to be in the range. 
I also tried using -ccc-installation=Inputs/ which I see being used for gcc 
version parsing. How can I set up the test so that the GCCInstallation has a 
Version >= 4.8?  I test the new functionality from the console on Linux and can 
confirm it's working.

Failing Tests (4): -- the 3 listed above, as well as

  Clang :: Driver/gcc-predef.c -- my new test, the 3rd run which confirms that 
the include is added


Repository:
  rL LLVM

https://reviews.llvm.org/D34158

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/Inputs/basic_linux_tree/usr/include/stdc-predef.h
  test/Driver/clang_cpp.c
  test/Driver/crash-report.c
  test/Driver/gcc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  unittests/Tooling/TestVisitor.h

Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
+  void AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const;
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2329,6 +2329,19 @@
   }
 }
 
+void Generic_GCC::addGnuIncludeArgs(const ArgList , 
+ArgStringList ) const {
+  const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
+  if (!DriverArgs.hasArg(options::OPT_ffreestanding) &&
+  !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  !Version.isOlderThan(4, 8, 0)) {
+// For gcc >= 4.8.x, gcc will preinclude 
+// -ffreestanding suppresses this behavior.
+CC1Args.push_back("-include");
+CC1Args.push_back("stdc-predef.h");
+  }
+}
+
 void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList ,
ArgStringList ) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -705,6 +705,8 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -743,6 +745,13 @@
   return "";
 }
 
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  

[PATCH] D34395: clang-format: add options to merge empty record body

2017-06-30 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306874: clang-format: add options to merge empty record body 
(authored by Typz).

Repository:
  rL LLVM

https://reviews.llvm.org/D34395

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -717,7 +717,29 @@
 ///   }
 /// \endcode
 ///
-bool SplitEmptyFunctionBody;
+bool SplitEmptyFunction;
+/// \brief If ``false``, empty record (e.g. class, struct or union) body
+/// can be put on a single line. This option is used only if the opening
+/// brace of the record has already been wrapped, i.e. the `AfterClass`
+/// (for classes) brace wrapping mode is set.
+/// \code
+///   class Foo   vs.  class Foo
+///   {}   {
+///}
+/// \endcode
+///
+bool SplitEmptyRecord;
+/// \brief If ``false``, empty namespace body can be put on a single line.
+/// This option is used only if the opening brace of the namespace has
+/// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
+/// set.
+/// \code
+///   namespace Foo   vs.  namespace Foo
+///   {}   {
+///}
+/// \endcode
+///
+bool SplitEmptyNamespace;
   };
 
   /// \brief Control of individual brace wrapping cases.
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -136,10 +136,7 @@
 
 bool isNamespaceDeclaration(const AnnotatedLine *Line) {
   const FormatToken *NamespaceTok = Line->First;
-  // Detect "(inline)? namespace" in the beginning of a line.
-  if (NamespaceTok->is(tok::kw_inline))
-NamespaceTok = NamespaceTok->getNextNonComment();
-  return NamespaceTok && NamespaceTok->is(tok::kw_namespace);
+  return NamespaceTok && NamespaceTok->getNamespaceToken();
 }
 
 bool isEndOfNamespace(const AnnotatedLine *Line,
@@ -216,10 +213,31 @@
 
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First == TheLine->Last &&
-!Style.BraceWrapping.SplitEmptyFunctionBody &&
+!Style.BraceWrapping.SplitEmptyFunction &&
 I[1]->First->is(tok::r_brace))
   return tryMergeSimpleBlock(I, E, Limit);
 
+// Handle empty record blocks where the brace has already been wrapped
+if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last &&
+I != AnnotatedLines.begin()) {
+  bool EmptyBlock = I[1]->First->is(tok::r_brace);
+
+  const FormatToken *Tok = I[-1]->First;
+  if (Tok && Tok->is(tok::comment))
+Tok = Tok->getNextNonComment();
+
+  if (Tok && Tok->getNamespaceToken())
+return !Style.BraceWrapping.SplitEmptyNamespace && EmptyBlock
+? tryMergeSimpleBlock(I, E, Limit) : 0;
+
+  if (Tok && Tok->is(tok::kw_typedef))
+Tok = Tok->getNextNonComment();
+  if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union,
+  Keywords.kw_interface))
+return !Style.BraceWrapping.SplitEmptyRecord && EmptyBlock
+? tryMergeSimpleBlock(I, E, Limit) : 0;
+}
+
 // FIXME: TheLine->Level != 0 might or might not be the right check to do.
 // If necessary, change to something smarter.
 bool MergeShortFunctions =
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -476,6 +476,19 @@
 return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style);
   }
 
+  /// \brief Return the actual namespace token, if this token starts a namespace
+  /// block.
+  const FormatToken *getNamespaceToken() const {
+const FormatToken *NamespaceTok = this;
+if (is(tok::comment))
+  NamespaceTok = NamespaceTok->getNextNonComment();
+// Detect "(inline)? namespace" in the beginning of a line.
+if (NamespaceTok && NamespaceTok->is(tok::kw_inline))
+  NamespaceTok = NamespaceTok->getNextNonComment();
+return NamespaceTok && NamespaceTok->is(tok::kw_namespace) ? NamespaceTok
+   : nullptr;
+  }
+
 private:
   // Disallow copying.
   FormatToken(const FormatToken &) = delete;
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ 

r306874 - clang-format: add options to merge empty record body

2017-06-30 Thread Francois Ferrand via cfe-commits
Author: typz
Date: Fri Jun 30 13:25:55 2017
New Revision: 306874

URL: http://llvm.org/viewvc/llvm-project?rev=306874=rev
Log:
clang-format: add options to merge empty record body

Summary:
This patch introduces a few extra BraceWrapping options, similar to
`SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g.
class, struct, union and namespace):
* SplitEmptyClass
* SplitEmptyStruct
* SplitEmptyUnion
* SplitEmptyNamespace

The `SplitEmptyFunction` option name has also been simplified/
shortened (from `SplitEmptyFunctionBody`).

These options are helpful when the correspond AfterXXX option is
enabled, to allow merging the empty record:

  class Foo
  {};

In addition, this fixes an unexpected merging of short records, when
the After options are used, which caused to be formatted like
this:

  class Foo
  { void Foo(); };

This is now properly formatted as:

  class Foo
  {
 void Foo();
  };

Reviewers: djasper, krasimir

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=306874=306873=306874=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri Jun 30 13:25:55 2017
@@ -717,7 +717,29 @@ struct FormatStyle {
 ///   }
 /// \endcode
 ///
-bool SplitEmptyFunctionBody;
+bool SplitEmptyFunction;
+/// \brief If ``false``, empty record (e.g. class, struct or union) body
+/// can be put on a single line. This option is used only if the opening
+/// brace of the record has already been wrapped, i.e. the `AfterClass`
+/// (for classes) brace wrapping mode is set.
+/// \code
+///   class Foo   vs.  class Foo
+///   {}   {
+///}
+/// \endcode
+///
+bool SplitEmptyRecord;
+/// \brief If ``false``, empty namespace body can be put on a single line.
+/// This option is used only if the opening brace of the namespace has
+/// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
+/// set.
+/// \code
+///   namespace Foo   vs.  namespace Foo
+///   {}   {
+///}
+/// \endcode
+///
+bool SplitEmptyNamespace;
   };
 
   /// \brief Control of individual brace wrapping cases.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=306874=306873=306874=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jun 30 13:25:55 2017
@@ -414,7 +414,9 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=306874=306873=306874=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Fri Jun 30 13:25:55 2017
@@ -476,6 +476,19 @@ struct FormatToken {
 return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style);
   }
 
+  /// \brief Return the actual namespace token, if this token starts a 
namespace
+  /// block.
+  const FormatToken *getNamespaceToken() const {
+const FormatToken *NamespaceTok = this;
+if (is(tok::comment))
+  NamespaceTok = NamespaceTok->getNextNonComment();
+// Detect "(inline)? namespace" in the beginning of a line.
+if (NamespaceTok && NamespaceTok->is(tok::kw_inline))
+  NamespaceTok = NamespaceTok->getNextNonComment();
+return NamespaceTok && NamespaceTok->is(tok::kw_namespace) ? NamespaceTok
+   : nullptr;
+  }
+
 private:
   // Disallow copying.
   FormatToken(const FormatToken &) = delete;

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=306874=306873=306874=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Fri Jun 30 13:25:55 2017
@@ -136,10 +136,7 @@ private:
 
 bool isNamespaceDeclaration(const AnnotatedLine *Line) {
   const FormatToken *NamespaceTok = Line->First;
-  // Detect "(inline)? namespace" in the beginning of a line.
-  if (NamespaceTok->is(tok::kw_inline))
-NamespaceTok = NamespaceTok->getNextNonComment();
-  return 

r306873 - [clang-rename] Just return instead of calling exit(3) from main.

2017-06-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun 30 13:24:32 2017
New Revision: 306873

URL: http://llvm.org/viewvc/llvm-project?rev=306873=rev
Log:
[clang-rename] Just return instead of calling exit(3) from main.

Modified:
cfe/trunk/tools/clang-rename/ClangRename.cpp

Modified: cfe/trunk/tools/clang-rename/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-rename/ClangRename.cpp?rev=306873=306872=306873=diff
==
--- cfe/trunk/tools/clang-rename/ClangRename.cpp (original)
+++ cfe/trunk/tools/clang-rename/ClangRename.cpp Fri Jun 30 13:24:32 2017
@@ -33,7 +33,6 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
 #include 
 #include 
 
@@ -127,13 +126,13 @@ int main(int argc, const char **argv) {
   // Check the arguments for correctness.
   if (NewNames.empty()) {
 errs() << "clang-rename: -new-name must be specified.\n\n";
-exit(1);
+return 1;
   }
 
   if (SymbolOffsets.empty() == QualifiedNames.empty()) {
 errs() << "clang-rename: -offset and -qualified-name can't be present at "
   "the same time.\n";
-exit(1);
+return 1;
   }
 
   // Check if NewNames is a valid identifier in C++17.
@@ -145,7 +144,7 @@ int main(int argc, const char **argv) {
 auto NewNameTokKind = Table.get(NewName).getTokenID();
 if (!tok::isAnyIdentifier(NewNameTokKind)) {
   errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
-  exit(1);
+  return 1;
 }
   }
 
@@ -155,7 +154,7 @@ int main(int argc, const char **argv) {
<< ") must be equal to number of new names(" << NewNames.size()
<< ").\n\n";
 cl::PrintHelpMessage();
-exit(1);
+return 1;
   }
 
   auto Files = OP.getSourcePathList();
@@ -173,13 +172,13 @@ int main(int argc, const char **argv) {
 
   if (FindingAction.errorOccurred()) {
 // Diagnostics are already issued at this point.
-exit(1);
+return 1;
   }
 
   if (Force && PrevNames.size() < NewNames.size()) {
 // No matching PrevName for all NewNames. Without Force this is an error
 // above already.
-exit(0);
+return 0;
   }
 
   // Perform the renaming.
@@ -199,7 +198,7 @@ int main(int argc, const char **argv) {
   llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
   if (EC) {
 llvm::errs() << "Error opening output file: " << EC.message() << '\n';
-exit(1);
+return 1;
   }
 
   // Export replacements.
@@ -212,7 +211,7 @@ int main(int argc, const char **argv) {
   yaml::Output YAML(OS);
   YAML << TUR;
   OS.close();
-  exit(0);
+  return 0;
 }
 
 // Write every file to stdout. Right now we just barf the files without any
@@ -236,5 +235,5 @@ int main(int argc, const char **argv) {
 }
   }
 
-  exit(ExitCode);
+  return ExitCode;
 }


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


[PATCH] D34529: [Driver] Check that the iOS deployment target is iOS 10 or earlier if the target is 32-bit

2017-06-30 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added inline comments.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1350
+Minor = 99;
+  }
   } else if (Platform == TvOS) {

What about Micro = 99?


https://reviews.llvm.org/D34529



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


[PATCH] D34238: clang-format: Do not binpack initialization lists

2017-06-30 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306868: clang-format: Do not binpack initialization lists 
(authored by Typz).

Changed prior to commit:
  https://reviews.llvm.org/D34238?vs=103057=104914#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34238

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestJava.cpp


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1063,12 +1063,12 @@
Current.MatchingParen->Previous &&
Current.MatchingParen->Previous->is(tok::comma);
 AvoidBinPacking =
-(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) ||
-Current.is(TT_DictLiteral) ||
+EndsInComma || Current.is(TT_DictLiteral) ||
 Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
 (NextNoComment &&
  NextNoComment->isOneOf(TT_DesignatedInitializerPeriod,
 TT_DesignatedInitializerLSquare));
+BreakBeforeParameter = EndsInComma;
 if (Current.ParameterCount > 1)
   NestedBlockIndent = std::max(NestedBlockIndent, State.Column + 1);
   } else {
Index: cfe/trunk/unittests/Format/FormatTestJava.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJava.cpp
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp
@@ -237,7 +237,10 @@
 TEST_F(FormatTestJava, ArrayInitializers) {
   verifyFormat("new int[] {1, 2, 3, 4};");
   verifyFormat("new int[] {\n"
-   "1, 2, 3, 4,\n"
+   "1,\n"
+   "2,\n"
+   "3,\n"
+   "4,\n"
"};");
 
   FormatStyle Style = getStyleWithColumns(65);
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -6004,7 +6004,10 @@
 TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   verifyFormat("vector x{1, 2, 3, 4};");
   verifyFormat("vector x{\n"
-   "1, 2, 3, 4,\n"
+   "1,\n"
+   "2,\n"
+   "3,\n"
+   "4,\n"
"};");
   verifyFormat("vector x{{}, {}, {}, {}};");
   verifyFormat("f({1, 2});");
@@ -6049,6 +6052,17 @@
"};");
   verifyFormat("#define A {a, a},");
 
+  // Binpacking only if there is no trailing comma
+  verifyFormat("const Aa a = {aa, bb,\n"
+   "  cc, dd};",
+  getLLVMStyleWithColumns(50));
+  verifyFormat("const Aa a = {\n"
+   "aaa,\n"
+   "bbb,\n"
+   "ccc,\n"
+   "ddd,\n"
+   "};", getLLVMStyleWithColumns(50));
+
   // Cases where distinguising braced lists and blocks is hard.
   verifyFormat("vector v{12} GUARDED_BY(mutex);");
   verifyFormat("void f() {\n"
@@ -6128,10 +6142,12 @@
"   // Second element:\n"
"   2};",
getLLVMStyleWithColumns(30)));
-  // A trailing comma should still lead to an enforced line break.
+  // A trailing comma should still lead to an enforced line break and no
+  // binpacking.
   EXPECT_EQ("vector SomeVector = {\n"
 "// aaa\n"
-"1, 2,\n"
+"1,\n"
+"2,\n"
 "};",
 format("vector SomeVector = { // aaa\n"
"1, 2, };"));
@@ -6297,7 +6313,7 @@
   " , a, aa, a, aaa}};");
 
   // No column layout should be used here.
-  verifyFormat("aaa = {aaa, 0, 0,\n"
+  verifyFormat("aaa = {a, 0, 0,\n"
"   b};");
 
   verifyNoCrash("a<,");


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1063,12 +1063,12 @@
Current.MatchingParen->Previous &&
Current.MatchingParen->Previous->is(tok::comma);
 AvoidBinPacking =
-(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) ||
-Current.is(TT_DictLiteral) ||
+EndsInComma || Current.is(TT_DictLiteral) ||
 Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
 (NextNoComment &&
 

r306868 - clang-format: Do not binpack initialization lists

2017-06-30 Thread Francois Ferrand via cfe-commits
Author: typz
Date: Fri Jun 30 13:00:02 2017
New Revision: 306868

URL: http://llvm.org/viewvc/llvm-project?rev=306868=rev
Log:
clang-format: Do not binpack initialization lists

Summary:
This patch tries to avoid binpacking when initializing lists/arrays, to allow 
things like:

  static int types[] = {
  registerType1(),
  registerType2(),
  registerType3(),
  };
  std::map x = {
  { 0, "foo fjakfjaklf kljj" },
  { 1, "bar fjakfjaklf kljj" },
  { 2, "stuff fjakfjaklf kljj" },
  };

This is similar to how dictionnaries are formatted, and actually corresponds to 
the same conditions: when initializing a container (and not just 'calling' a 
constructor).

Such formatting involves 2 things:
* Line breaks around the content of the block. This can be forced by adding a 
comma or comment after the last element
* Elements should not be binpacked

This patch considers the block is an initializer list if it either ends with a 
comma, or follows an assignment, which seems to provide a sensible 
approximation.

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: malcolm.parsons, klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=306868=306867=306868=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Jun 30 13:00:02 2017
@@ -1063,12 +1063,12 @@ void ContinuationIndenter::moveStatePast
Current.MatchingParen->Previous &&
Current.MatchingParen->Previous->is(tok::comma);
 AvoidBinPacking =
-(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) ||
-Current.is(TT_DictLiteral) ||
+EndsInComma || Current.is(TT_DictLiteral) ||
 Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
 (NextNoComment &&
  NextNoComment->isOneOf(TT_DesignatedInitializerPeriod,
 TT_DesignatedInitializerLSquare));
+BreakBeforeParameter = EndsInComma;
 if (Current.ParameterCount > 1)
   NestedBlockIndent = std::max(NestedBlockIndent, State.Column + 1);
   } else {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=306868=306867=306868=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jun 30 13:00:02 2017
@@ -6004,7 +6004,10 @@ TEST_F(FormatTest, LayoutBraceInitialize
 TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   verifyFormat("vector x{1, 2, 3, 4};");
   verifyFormat("vector x{\n"
-   "1, 2, 3, 4,\n"
+   "1,\n"
+   "2,\n"
+   "3,\n"
+   "4,\n"
"};");
   verifyFormat("vector x{{}, {}, {}, {}};");
   verifyFormat("f({1, 2});");
@@ -6049,6 +6052,17 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
"};");
   verifyFormat("#define A {a, a},");
 
+  // Binpacking only if there is no trailing comma
+  verifyFormat("const Aa a = {aa, bb,\n"
+   "  cc, dd};",
+  getLLVMStyleWithColumns(50));
+  verifyFormat("const Aa a = {\n"
+   "aaa,\n"
+   "bbb,\n"
+   "ccc,\n"
+   "ddd,\n"
+   "};", getLLVMStyleWithColumns(50));
+
   // Cases where distinguising braced lists and blocks is hard.
   verifyFormat("vector v{12} GUARDED_BY(mutex);");
   verifyFormat("void f() {\n"
@@ -6128,10 +6142,12 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
"   // Second element:\n"
"   2};",
getLLVMStyleWithColumns(30)));
-  // A trailing comma should still lead to an enforced line break.
+  // A trailing comma should still lead to an enforced line break and no
+  // binpacking.
   EXPECT_EQ("vector SomeVector = {\n"
 "// aaa\n"
-"1, 2,\n"
+"1,\n"
+"2,\n"
 "};",
 format("vector SomeVector = { // aaa\n"
"1, 2, };"));
@@ -6297,7 +6313,7 @@ TEST_F(FormatTest, FormatsBracedListsInC
   " , a, aa, a, aaa}};");
 
   // No column layout should be used here.
-  verifyFormat("aaa = 

r306862 - [ORE] Use LLVM's "diagnostics hotness" spelling

2017-06-30 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Jun 30 12:37:11 2017
New Revision: 306862

URL: http://llvm.org/viewvc/llvm-project?rev=306862=rev
Log:
[ORE] Use LLVM's "diagnostics hotness" spelling

Summary:
Depends on https://reviews.llvm.org/D34864.

To unify Clang and LLVM's spelling of "diagnostic[s] hotness", use the
new "diagnostics hotness" spelling in LLVM, which was added in
https://reviews.llvm.org/D34864.

Reviewers: anemet, davidxl

Reviewed By: anemet

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=306862=306861=306862=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Jun 30 12:37:11 2017
@@ -228,7 +228,7 @@ namespace clang {
   Ctx.getDiagnosticHandler();
   void *OldDiagnosticContext = Ctx.getDiagnosticContext();
   Ctx.setDiagnosticHandler(DiagnosticHandler, this);
-  Ctx.setDiagnosticHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
+  Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
 
   std::unique_ptr OptRecordFile;
   if (!CodeGenOpts.OptRecordFile.empty()) {
@@ -246,7 +246,7 @@ namespace clang {
 llvm::make_unique(OptRecordFile->os()));
 
 if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-  Ctx.setDiagnosticHotnessRequested(true);
+  Ctx.setDiagnosticsHotnessRequested(true);
   }
 
   // Link each LinkModule into our module.


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


[PATCH] D34529: [Driver] Check that the iOS deployment target is iOS 10 or earlier if the target is 32-bit

2017-06-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 104906.
ahatanak added a comment.

Address review comments.

- Change the error message from "invalid iOS deployment version '%0', maximum 
allowable version is iOS 10" to "invalid iOS deployment version '%0', iOS 10 is 
the maximum deployment target for 32-bit targets"

- If the inferred version is iOS 11 or later, reset it to 10.99.


https://reviews.llvm.org/D34529

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -10,6 +10,41 @@
 // RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS3 %s
 // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0"
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
+// RUN:   %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err
+// RUN:   FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s
+// CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0'
+
+// RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s
+// CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0'
+
+// RUN: %clang -target i386-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS6 %s
+// CHECK-VERSION-IOS6: invalid iOS deployment version '-mios-simulator-version-min=11.0'
+
+// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
+// CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.0
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
+// RUN:   %clang -target arm64-apple-ios11.0 -c -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS8 %s
+// CHECK-VERSION-IOS8: arm64-apple-ios11.0.0
+
+// RUN: %clang -target arm64-apple-ios11.0 -miphoneos-version-min=11.0 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS9 %s
+// CHECK-VERSION-IOS9: arm64-apple-ios11.0.0
+
+// RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
+// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0
+
+// RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
+// CHECK-VERSION-IOS11: arm64-apple-ios11.1.0
+
 // RUN: %clang -target i686-apple-darwin8 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 2>&1 | \
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1150,6 +1150,17 @@
   Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
   options::OPT_mwatchos_simulator_version_min_EQ);
 
+  unsigned Major, Minor, Micro;
+  bool HadExtra;
+
+  // iOS 10 is the maximum deployment target for 32-bit targets.
+  if (iOSVersion && getTriple().isArch32Bit() &&
+  Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
+HadExtra) &&
+  Major > 10)
+getDriver().Diag(diag::err_invalid_ios_deployment_target)
+<< iOSVersion->getAsString(Args);
+
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
   // -m(iphone|tv|watch)simulator-version-min=X.Y.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
@@ -1191,6 +1202,14 @@
 if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
   WatchOSTarget = env;
 
+// iOS 10 is the maximum deployment target for 32-bit targets.
+if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
+Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
+  HadExtra) &&
+Major > 10)
+  getDriver().Diag(diag::err_invalid_ios_deployment_target)
+  << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
+
 // If there is no command-line argument to specify the Target version and
 // no environment variable defined, see if we can set the default based
 // on -isysroot.
@@ -1308,8 +1327,6 @@
 llvm_unreachable("Unable to infer Darwin variant");
 
   // Set the tool chain target information.
-  unsigned Major, Minor, Micro;
-  bool HadExtra;
   if (Platform == MacOS) {
 assert((!iOSVersion && !TvOSVersion && !WatchOSVersion) &&
"Unknown target platform!");
@@ -1325,6 +1342,12 @@
 HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
   

[libcxx] r306859 - Revert "[libcxx] Annotate c++17 aligned new/delete operators with availability"

2017-06-30 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Jun 30 11:50:23 2017
New Revision: 306859

URL: http://llvm.org/viewvc/llvm-project?rev=306859=rev
Log:
Revert "[libcxx] Annotate c++17 aligned new/delete operators with availability"

This reverts commit r306310.

r306310 causes clang to reject a call to an aligned allocation or
deallocation function if it is not implemented in the standard library
of the deployment target. This is not the desired behavior when users
have defined their own aligned functions.

rdar://problem/32664169

Removed:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/new

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=306859=306858=306859=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jun 30 11:50:23 2017
@@ -1176,11 +1176,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR 
\
   __attribute__((availability(macosx,strict,introduced=10.9))) 
\
   __attribute__((availability(ios,strict,introduced=7.0)))
-#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
\
-  __attribute__((availability(macosx,strict,introduced=10.13)))
\
-  __attribute__((availability(ios,strict,introduced=11.0)))
\
-  __attribute__((availability(tvos,strict,introduced=11.0)))   
\
-  __attribute__((availability(watchos,strict,introduced=4.0)))
 #else
 #define _LIBCPP_AVAILABILITY_SHARED_MUTEX
 #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
@@ -1192,7 +1187,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
 #define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
 #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
 #endif
 
 // Define availability that depends on _LIBCPP_NO_EXCEPTIONS.

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=306859=306858=306859=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Fri Jun 30 11:50:23 2017
@@ -193,20 +193,20 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVA
 #endif
 
 #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
 #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  
operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #endif
 
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* 
operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) 
_NOEXCEPT _NOALIAS;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void  
operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t) _THROW_BAD_ALLOC;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, 
std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t) _NOEXCEPT;
+_LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete[](void* __p, 
std::align_val_t, 

r306851 - [X86] Add RDRND feature to Goldmont. Add MOVBE to all Atom CPUs.

2017-06-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Jun 30 11:14:04 2017
New Revision: 306851

URL: http://llvm.org/viewvc/llvm-project?rev=306851=rev
Log:
[X86] Add RDRND feature to Goldmont. Add MOVBE to all Atom CPUs.

Diffential Revision: https://reviews.llvm.org/D34842

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306851=306850=306851=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun 30 11:14:04 2017
@@ -3288,6 +3288,7 @@ bool X86TargetInfo::initFeatureMap(
 break;
   case CK_Goldmont:
 setFeatureEnabledImpl(Features, "sha", true);
+setFeatureEnabledImpl(Features, "rdrnd", true);
 setFeatureEnabledImpl(Features, "rdseed", true);
 setFeatureEnabledImpl(Features, "xsave", true);
 setFeatureEnabledImpl(Features, "xsaveopt", true);
@@ -3302,6 +3303,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "sse4.2", true);
 LLVM_FALLTHROUGH;
   case CK_Bonnell:
+setFeatureEnabledImpl(Features, "movbe", true);
 setFeatureEnabledImpl(Features, "ssse3", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=306851=306850=306851=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Fri Jun 30 11:14:04 
2017
@@ -996,6 +996,7 @@
 // CHECK_GLM_M32: #define __MPX__ 1
 // CHECK_GLM_M32: #define __PCLMUL__ 1
 // CHECK_GLM_M32: #define __POPCNT__ 1
+// CHECK_GLM_M32: #define __RDRND__ 1
 // CHECK_GLM_M32: #define __RDSEED__ 1
 // CHECK_GLM_M32: #define __SHA__ 1
 // CHECK_GLM_M32: #define __SSE2__ 1
@@ -1034,6 +1035,7 @@
 // CHECK_GLM_M64: #define __MPX__ 1
 // CHECK_GLM_M64: #define __PCLMUL__ 1
 // CHECK_GLM_M64: #define __POPCNT__ 1
+// CHECK_GLM_M64: #define __RDRND__ 1
 // CHECK_GLM_M64: #define __RDSEED__ 1
 // CHECK_GLM_M64: #define __SSE2__ 1
 // CHECK_GLM_M64: #define __SSE3__ 1


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


r306850 - [X86] Add a break to the last case of a few switches to prevent accidents in the future. NFC

2017-06-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Jun 30 11:14:02 2017
New Revision: 306850

URL: http://llvm.org/viewvc/llvm-project?rev=306850=rev
Log:
[X86] Add a break to the last case of a few switches to prevent accidents in 
the future. NFC

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306850=306849=306850=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun 30 11:14:02 2017
@@ -3545,6 +3545,7 @@ void X86TargetInfo::setSSELevel(llvm::St
 Features["avx512pf"] = Features["avx512dq"] = Features["avx512bw"] =
 Features["avx512vl"] = Features["avx512vbmi"] =
 Features["avx512ifma"] = Features["avx512vpopcntdq"] = false;
+break;
   }
 }
 
@@ -3577,6 +3578,7 @@ void X86TargetInfo::setMMXLevel(llvm::St
 LLVM_FALLTHROUGH;
   case AMD3DNowAthlon:
 Features["3dnowa"] = false;
+break;
   }
 }
 
@@ -3611,6 +3613,7 @@ void X86TargetInfo::setXOPLevel(llvm::St
 LLVM_FALLTHROUGH;
   case XOP:
 Features["xop"] = false;
+break;
   }
 }
 
@@ -4180,6 +4183,7 @@ void X86TargetInfo::getTargetDefines(con
   break;
 default:
   Builder.defineMacro("_M_IX86_FP", Twine(0));
+  break;
 }
   }
 


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


r306849 - [X86] Move all atom CPUs to the same section of the switch and use fallthroughs like we do for other CPU generations. NFC

2017-06-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Jun 30 11:14:01 2017
New Revision: 306849

URL: http://llvm.org/viewvc/llvm-project?rev=306849=rev
Log:
[X86] Move all atom CPUs to the same section of the switch and use fallthroughs 
like we do for other CPU generations. NFC

This is prep work to add MOVBE to all Atom CPUs. This instruction didn't come 
in to the Nehalem/Westmere/SandyBridge/etc. line until later so there's no 
natural place to overlap the Atom CPUs into that part of the switch.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306849=306848=306849=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun 30 11:14:01 2017
@@ -3224,7 +3224,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
   case CK_Core2:
-  case CK_Bonnell:
 setFeatureEnabledImpl(Features, "ssse3", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
@@ -3279,7 +3278,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "xsaveopt", true);
 LLVM_FALLTHROUGH;
   case CK_Westmere:
-  case CK_Silvermont:
 setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 LLVM_FALLTHROUGH;
@@ -3297,12 +3295,17 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "xsaves", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "mpx", true);
+LLVM_FALLTHROUGH;
+  case CK_Silvermont:
 setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 setFeatureEnabledImpl(Features, "sse4.2", true);
+LLVM_FALLTHROUGH;
+  case CK_Bonnell:
+setFeatureEnabledImpl(Features, "ssse3", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
-  break;
+break;
   case CK_KNL:
 setFeatureEnabledImpl(Features, "avx512f", true);
 setFeatureEnabledImpl(Features, "avx512cd", true);


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


[PATCH] D34886: Add a fixit for -Wobjc-protocol-property-synthesis

2017-06-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

lgtm with a nitpick.




Comment at: include/clang/Sema/Sema.h:3351
+   ObjCInterfaceDecl *IDecl, SourceRange 
AtEnd);
+  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceRange AtEnd);
 

Is a range required? We're only using a single sloc.


Repository:
  rL LLVM

https://reviews.llvm.org/D34886



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


[PATCH] D18240: Asm preprocessor fix for unknown hash-lines

2017-06-30 Thread Andrew Zhogin via Phabricator via cfe-commits
andrew.zhogin updated this revision to Diff 104893.
andrew.zhogin added a comment.
Herald added a subscriber: aprantl.

Updated to the current repository state.


https://reviews.llvm.org/D18240

Files:
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Misc/asm_hash_comments.s


Index: test/Misc/asm_hash_comments.s
===
--- test/Misc/asm_hash_comments.s
+++ test/Misc/asm_hash_comments.s
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -x assembler-with-cpp %s | FileCheck --strict-whitespace 
%s
+// CHECK: # some comment 1
+// CHECK-NEXT: # some comment 2
+// CHECK-NEXT: # some comment 3
+
+# some comment 1
+# some comment 2
+# some comment 3
+
+
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -96,6 +96,7 @@
   bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
+  bool NewLinesInTokenHandled;
 public:
   PrintPPOutputPPCallbacks(Preprocessor , raw_ostream , bool lineMarkers,
bool defines, bool DumpIncludeDirectives,
@@ -111,6 +112,7 @@
 FileType = SrcMgr::C_User;
 Initialized = false;
 IsFirstFileEntered = false;
+NewLinesInTokenHandled = false;
   }
 
   void setEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
@@ -164,7 +166,7 @@
   void WriteLineInfo(unsigned LineNo, const char *Extra=nullptr,
  unsigned ExtraLen=0);
   bool LineMarkersAreDisabled() const { return DisableLineMarkers; }
-  void HandleNewlinesInToken(const char *TokStr, unsigned Len);
+  void HandleNewlinesInToken(const char *TokStr, unsigned Len, bool IsSp);
 
   /// MacroDefined - This hook is called whenever a macro definition is seen.
   void MacroDefined(const Token ,
@@ -213,11 +215,13 @@
 bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo) {
   // If this line is "close enough" to the original line, just print newlines,
   // otherwise print a #line directive.
+  bool WasNewLines = NewLinesInTokenHandled;
+  NewLinesInTokenHandled = false;
   if (LineNo-CurLine <= 8) {
 if (LineNo-CurLine == 1)
   OS << '\n';
 else if (LineNo == CurLine)
-  return false;// Spelling line moved, but expansion line didn't.
+  return WasNewLines;// Spelling line moved, but expansion line didn't.
 else {
   const char *NewLines = "\n\n\n\n\n\n\n\n";
   OS.write(NewLines, LineNo-CurLine);
@@ -588,7 +592,7 @@
 }
 
 void PrintPPOutputPPCallbacks::HandleNewlinesInToken(const char *TokStr,
- unsigned Len) {
+ unsigned Len, bool IsSp) {
   unsigned NumNewlines = 0;
   for (; Len; --Len, ++TokStr) {
 if (*TokStr != '\n' &&
@@ -609,6 +613,7 @@
   if (NumNewlines == 0) return;
 
   CurLine += NumNewlines;
+  if (IsSp) NewLinesInTokenHandled = true;
 }
 
 
@@ -736,15 +741,19 @@
   // Tokens that can contain embedded newlines need to adjust our current
   // line number.
   if (Tok.getKind() == tok::comment || Tok.getKind() == tok::unknown)
-Callbacks->HandleNewlinesInToken(TokPtr, Len);
+Callbacks->HandleNewlinesInToken(TokPtr, Len, false);
+  if (Tok.getKind() == tok::eod)
+Callbacks->HandleNewlinesInToken(TokPtr, Len, true);
 } else {
   std::string S = PP.getSpelling(Tok);
   OS.write([0], S.size());
 
   // Tokens that can contain embedded newlines need to adjust our current
   // line number.
   if (Tok.getKind() == tok::comment || Tok.getKind() == tok::unknown)
-Callbacks->HandleNewlinesInToken([0], S.size());
+Callbacks->HandleNewlinesInToken([0], S.size(), false);
+  if (Tok.getKind() == tok::eod)
+Callbacks->HandleNewlinesInToken([0], S.size(), true);
 }
 Callbacks->setEmittedTokensOnThisLine();
 


Index: test/Misc/asm_hash_comments.s
===
--- test/Misc/asm_hash_comments.s
+++ test/Misc/asm_hash_comments.s
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -x assembler-with-cpp %s | FileCheck --strict-whitespace %s
+// CHECK: # some comment 1
+// CHECK-NEXT: # some comment 2
+// CHECK-NEXT: # some comment 3
+
+# some comment 1
+# some comment 2
+# some comment 3
+
+
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -96,6 +96,7 @@
   bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
+  bool NewLinesInTokenHandled;
 public:
   PrintPPOutputPPCallbacks(Preprocessor , raw_ostream , bool lineMarkers,
bool defines, bool DumpIncludeDirectives,
@@ -111,6 +112,7 @@
 FileType = SrcMgr::C_User;
 Initialized = false;
 

Re: r306844 - Attempt to fix the linkage error caused by r306840 on the mingw-RA-on-linux bot

2017-06-30 Thread Alex L via cfe-commits
It worked!

On 30 June 2017 at 18:15, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Fri Jun 30 10:15:48 2017
> New Revision: 306844
>
> URL: http://llvm.org/viewvc/llvm-project?rev=306844=rev
> Log:
> Attempt to fix the linkage error caused by r306840 on the
> mingw-RA-on-linux bot
>
> Modified:
> cfe/trunk/tools/clang-rename/CMakeLists.txt
>
> Modified: cfe/trunk/tools/clang-rename/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> rename/CMakeLists.txt?rev=306844=306843=306844=diff
> 
> ==
> --- cfe/trunk/tools/clang-rename/CMakeLists.txt (original)
> +++ cfe/trunk/tools/clang-rename/CMakeLists.txt Fri Jun 30 10:15:48 2017
> @@ -1,3 +1,8 @@
> +set(LLVM_LINK_COMPONENTS
> +  Option
> +  Support
> +  )
> +
>  add_clang_executable(clang-rename ClangRename.cpp)
>
>  target_link_libraries(clang-rename
>
>
> ___
> 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/cfe-commits


r306844 - Attempt to fix the linkage error caused by r306840 on the mingw-RA-on-linux bot

2017-06-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 30 10:15:48 2017
New Revision: 306844

URL: http://llvm.org/viewvc/llvm-project?rev=306844=rev
Log:
Attempt to fix the linkage error caused by r306840 on the mingw-RA-on-linux bot

Modified:
cfe/trunk/tools/clang-rename/CMakeLists.txt

Modified: cfe/trunk/tools/clang-rename/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-rename/CMakeLists.txt?rev=306844=306843=306844=diff
==
--- cfe/trunk/tools/clang-rename/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-rename/CMakeLists.txt Fri Jun 30 10:15:48 2017
@@ -1,3 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  Option
+  Support
+  )
+
 add_clang_executable(clang-rename ClangRename.cpp)
 
 target_link_libraries(clang-rename


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


[PATCH] D34896: Enable the new PM + SamlePGO + ThinLTO testing.

2017-06-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D34896



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


[PATCH] D34696: [refactor] Move clang-rename to Clang

2017-06-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I didn't notice that ClassReplacements.cpp had a dependency on 
clang-apply-replacements. I moved it back to clang-tools-extra to the 
clang-apply-replacements tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D34696



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


[PATCH] D34510: Teach clang how to merge typedef over anonymous structs in C mode.

2017-06-30 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi @v.g.vassilev, sorry for the delay.

Just updated https://reviews.llvm.org/D31778. I agree with Richard's 
observations, do you think you can extend it to work in the same way as 
https://reviews.llvm.org/D31778 does? The structural checking is already 
abstracted there (should be straightforward to use).


Repository:
  rL LLVM

https://reviews.llvm.org/D34510



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


[PATCH] D34896: Enable the new PM + SamlePGO + ThinLTO testing.

2017-06-30 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
Herald added subscribers: eraman, inglorion, mehdi_amini, sanjoy.

This patch should be enabled after https://reviews.llvm.org/D34895


https://reviews.llvm.org/D34896

Files:
  test/CodeGen/pgo-sample-thinlto-summary.c


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
 // RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
 // RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// FIXME: Run the following command once LTOPreLinkDefaultPipeline is
-//customized.
-// %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
 // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
 // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// FIXME: Run the following command once LTOPreLinkDefaultPipeline is
-//customized.
-// %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r306843 - Move ClassReplacements.cpp test from clang-rename tests to the

2017-06-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 30 09:58:36 2017
New Revision: 306843

URL: http://llvm.org/viewvc/llvm-project?rev=306843=rev
Log:
Move ClassReplacements.cpp test from clang-rename tests to the
clang-apply-replacements tests

The ClassReplacements.cpp test in the clang-rename tests uses
clang-apply-replacements. I moved it back to the clang-tools-extra repository
for now to ensure that the clang-rename tests can pass when clang is compiled
without clang-tools-extra.

Added:

clang-tools-extra/trunk/test/clang-apply-replacements/ClangRenameClassReplacements.cpp
Modified:
clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=306843=306842=306843=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Fri Jun 30 09:58:36 2017
@@ -36,6 +36,8 @@ set(CLANG_TOOLS_TEST_DEPS
 
   # For the clang-tidy libclang integration test.
   c-index-test
+  # For the clang-apply-replacements test that uses clang-rename.
+  clang-rename
 
   # Individual tools we test.
   clang-apply-replacements

Added: 
clang-tools-extra/trunk/test/clang-apply-replacements/ClangRenameClassReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/ClangRenameClassReplacements.cpp?rev=306843=auto
==
--- 
clang-tools-extra/trunk/test/clang-apply-replacements/ClangRenameClassReplacements.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-apply-replacements/ClangRenameClassReplacements.cpp
 Fri Jun 30 09:58:36 2017
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/fixes
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=254 -new-name=Bar 
-export-fixes=%t/fixes/clang-rename.yaml %t.cpp --
+// RUN: clang-apply-replacements %t
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {}; // CHECK: class Bar {};
+
+// Use grep -FUbo 'Foo'  to get the correct offset of Cla when changing
+// this file.


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


r306843 - Move ClassReplacements.cpp test from clang-rename tests to the

2017-06-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 30 09:58:36 2017
New Revision: 306843

URL: http://llvm.org/viewvc/llvm-project?rev=306843=rev
Log:
Move ClassReplacements.cpp test from clang-rename tests to the
clang-apply-replacements tests

The ClassReplacements.cpp test in the clang-rename tests uses
clang-apply-replacements. I moved it back to the clang-tools-extra repository
for now to ensure that the clang-rename tests can pass when clang is compiled
without clang-tools-extra.

Removed:
cfe/trunk/test/clang-rename/ClassReplacements.cpp

Removed: cfe/trunk/test/clang-rename/ClassReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/clang-rename/ClassReplacements.cpp?rev=306842=auto
==
--- cfe/trunk/test/clang-rename/ClassReplacements.cpp (original)
+++ cfe/trunk/test/clang-rename/ClassReplacements.cpp (removed)
@@ -1,11 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t/fixes
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=254 -new-name=Bar 
-export-fixes=%t/fixes/clang-rename.yaml %t.cpp --
-// RUN: clang-apply-replacements %t
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
-class Foo {}; // CHECK: class Bar {};
-
-// Use grep -FUbo 'Foo'  to get the correct offset of Cla when changing
-// this file.


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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-30 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 104881.
bruno added a comment.



> Digging into this a bit more, I think the root of the problem is that the 
> `ND->isExternallyVisible()` call in 
> `LookupResult::isHiddenDeclarationVisible` is wrong. Redeclaration lookup 
> should never find hidden enumerators in C, because they do not have linkage 
> (C11 6.2.2/6). (The same is true in C++, but I don't know whether we can 
> apply the same thing there too, due to the different

merging rules.) A function foo in some source file should not conflict with an 
enumerator foo in a non-imported module, for instance.

> The linkage of an enumerator should probably be VisibleNoLinkage, and 
> isHiddenDeclarationVisible should probably be checking 
> hasExternalFormalLinkage...

Implemented this suggestions from last round of review. Change didn't seem to 
have side effects (at least from clang tests). @rsmith, what do you think? (I 
should probably split this small change into a different commit when the patch 
is accepted)


https://reviews.llvm.org/D31778

Files:
  include/clang/AST/ASTStructuralEquivalence.h
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Basic/Visibility.h
  include/clang/Sema/Lookup.h
  include/clang/Sema/Sema.h
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/Decl.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/Index/linkage.c
  test/Modules/Inputs/F.framework/Headers/F.h
  test/Modules/Inputs/F.framework/Modules/module.modulemap
  test/Modules/Inputs/F.framework/Modules/module.private.modulemap
  test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
  test/Modules/elaborated-type-specifier-from-hidden-module.m
  test/Modules/redefinition-c-tagtypes.m
  test/Modules/redefinition-same-header.m

Index: test/Modules/redefinition-same-header.m
===
--- test/Modules/redefinition-same-header.m
+++ test/Modules/redefinition-same-header.m
@@ -6,15 +6,7 @@
 // expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
 // expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
 // expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
+// expected-warning@Inputs/SameHeader/C.h:9 {{typedef requires a name}}
 
-// expected-error@Inputs/SameHeader/C.h:5 {{redefinition of 'aaa'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
-
-// expected-error@Inputs/SameHeader/C.h:9 {{redefinition of 'fd_set'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
 #include "A.h" // maps to a modular
 #include "C.h" // textual include
Index: test/Modules/redefinition-c-tagtypes.m
===
--- /dev/null
+++ test/Modules/redefinition-c-tagtypes.m
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
+#include "F/F.h"
+
+#ifndef CHANGE_TAGS
+// expected-no-diagnostics
+#endif
+
+struct NS {
+  int a;
+#ifndef CHANGE_TAGS
+  int b;
+#else
+  int c; // expected-note {{field has name 'c' here}}
+  // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
+#endif
+};
+
+enum NSE {
+  FST = 22,
+#ifndef CHANGE_TAGS
+  SND = 43,
+#else
+  SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
+  // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
+#endif
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+#ifndef CHANGE_TAGS
+  MinXOther = MinX,
+#else
+  MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
+  // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
+  // 

[PATCH] D34842: [X86] Add RDRND to Goldmont. Add MOVBE to all Atom CPUs

2017-06-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

There's a separate review for X86.d https://reviews.llvm.org/D34828


https://reviews.llvm.org/D34842



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


r306841 - Use add_clang_unittest in the CMakeLists.txt for the moved unittest

2017-06-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 30 09:43:00 2017
New Revision: 306841

URL: http://llvm.org/viewvc/llvm-project?rev=306841=rev
Log:
Use add_clang_unittest in the CMakeLists.txt for the moved unittest

The unittest was moved in r306840

Modified:
cfe/trunk/unittests/Rename/CMakeLists.txt

Modified: cfe/trunk/unittests/Rename/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rename/CMakeLists.txt?rev=306841=306840=306841=diff
==
--- cfe/trunk/unittests/Rename/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Rename/CMakeLists.txt Fri Jun 30 09:43:00 2017
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
 # We'd like clang/unittests/Tooling/RewriterTestContext.h in the test.
 include_directories(${CLANG_SOURCE_DIR})
 
-add_extra_unittest(ClangRenameTests
+add_clang_unittest(ClangRenameTests
   RenameClassTest.cpp
   )
 


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


[clang-tools-extra] r306840 - [refactor] Move clang-rename into the clang repository

2017-06-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 30 09:36:09 2017
New Revision: 306840

URL: http://llvm.org/viewvc/llvm-project?rev=306840=rev
Log:
[refactor] Move clang-rename into the clang repository

The core engine of clang-rename will be used for local and global renames in the
new refactoring engine, as mentioned in
http://lists.llvm.org/pipermail/cfe-dev/2017-June/054286.html.

The clang-rename tool is still supported but might get deprecated in the future.

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

Removed:
clang-tools-extra/trunk/clang-rename/
clang-tools-extra/trunk/test/clang-rename/
clang-tools-extra/trunk/unittests/clang-rename/
Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/unittests/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=306840=306839=306840=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Fri Jun 30 09:36:09 2017
@@ -1,5 +1,4 @@
 add_subdirectory(clang-apply-replacements)
-add_subdirectory(clang-rename)
 add_subdirectory(clang-reorder-fields)
 add_subdirectory(modularize)
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=306840=306839=306840=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Fri Jun 30 09:36:09 2017
@@ -44,7 +44,6 @@ set(CLANG_TOOLS_TEST_DEPS
   clang-include-fixer
   clang-move
   clang-query
-  clang-rename
   clang-reorder-fields
   clang-tidy
   find-all-symbols

Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=306840=306839=306840=diff
==
--- clang-tools-extra/trunk/unittests/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/CMakeLists.txt Fri Jun 30 09:36:09 2017
@@ -10,6 +10,5 @@ add_subdirectory(clang-apply-replacement
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
 add_subdirectory(clang-tidy)
-add_subdirectory(clang-rename)
 add_subdirectory(clangd)
 add_subdirectory(include-fixer)


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


[PATCH] D34842: [X86] Add RDRND to Goldmont. Add MOVBE to all Atom CPUs

2017-06-30 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM with a couple of comments.

On the LLVM side, X86.td GoldMont class looks like it needs RDRAND as well.




Comment at: lib/Basic/Targets.cpp:3310
 setFeatureEnabledImpl(Features, "cx16", true);
-  break;
+break;
   case CK_KNL:

Is it worth doing the reordering first as an NFC? Then add MOVBE?


https://reviews.llvm.org/D34842



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


r306837 - [objc] Don't require null-check and don't emit memset when result is ignored for struct-returning method calls [clang part]

2017-06-30 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Fri Jun 30 09:28:15 2017
New Revision: 306837

URL: http://llvm.org/viewvc/llvm-project?rev=306837=rev
Log:
[objc] Don't require null-check and don't emit memset when result is ignored 
for struct-returning method calls [clang part]

This fixes an issue with the emission of lifetime markers for struct-returning 
Obj-C msgSend calls. When the result of a struct-returning call is ignored, the 
temporary storage is only marked with lifetime markers in one of the two 
branches of the nil-receiver-check. The check is, however, not required when 
the result is unused. If we still need to emit the check (due to consumer 
arguments), let's not emit the memset to zero out the result if it's unused. 
This fixes a use-after-scope false positive with AddressSanitizer.

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


Added:
cfe/trunk/test/CodeGenObjC/stret-lifetime.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/stret-1.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=306837=306836=306837=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Jun 30 09:28:15 2017
@@ -1678,7 +1678,10 @@ struct NullReturnState {
 
   /// Complete the null-return operation.  It is valid to call this
   /// regardless of whether 'init' has been called.
-  RValue complete(CodeGenFunction , RValue result, QualType resultType,
+  RValue complete(CodeGenFunction ,
+  ReturnValueSlot returnSlot,
+  RValue result,
+  QualType resultType,
   const CallArgList ,
   const ObjCMethodDecl *Method) {
 // If we never had to do a null-check, just use the raw result.
@@ -1745,7 +1748,8 @@ struct NullReturnState {
 // memory or (2) agg values in registers.
 if (result.isAggregate()) {
   assert(result.isAggregate() && "null init of non-aggregate result?");
-  CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
+  if (!returnSlot.isUnused())
+CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
   if (contBB) CGF.EmitBlock(contBB);
   return result;
 }
@@ -2117,11 +2121,11 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 }
   }
 
-  NullReturnState nullReturn;
+  bool RequiresNullCheck = false;
 
   llvm::Constant *Fn = nullptr;
   if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) {
-if (ReceiverCanBeNull) nullReturn.init(CGF, Arg0);
+if (ReceiverCanBeNull) RequiresNullCheck = true;
 Fn = (ObjCABI == 2) ?  ObjCTypes.getSendStretFn2(IsSuper)
   : ObjCTypes.getSendStretFn(IsSuper);
   } else if (CGM.ReturnTypeUsesFPRet(ResultType)) {
@@ -2134,23 +2138,30 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 // arm64 uses objc_msgSend for stret methods and yet null receiver check
 // must be made for it.
 if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo))
-  nullReturn.init(CGF, Arg0);
+  RequiresNullCheck = true;
 Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper)
   : ObjCTypes.getSendFn(IsSuper);
   }
 
+  // We don't need to emit a null check to zero out an indirect result if the
+  // result is ignored.
+  if (Return.isUnused())
+RequiresNullCheck = false;
+
   // Emit a null-check if there's a consumed argument other than the receiver.
-  bool RequiresNullCheck = false;
-  if (ReceiverCanBeNull && CGM.getLangOpts().ObjCAutoRefCount && Method) {
+  if (!RequiresNullCheck && CGM.getLangOpts().ObjCAutoRefCount && Method) {
 for (const auto *ParamDecl : Method->parameters()) {
   if (ParamDecl->hasAttr()) {
-if (!nullReturn.NullBB)
-  nullReturn.init(CGF, Arg0);
 RequiresNullCheck = true;
 break;
   }
 }
   }
+
+  NullReturnState nullReturn;
+  if (RequiresNullCheck) {
+nullReturn.init(CGF, Arg0);
+  }
   
   llvm::Instruction *CallSite;
   Fn = llvm::ConstantExpr::getBitCast(Fn, MSI.MessengerType);
@@ -2164,7 +2175,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen
 llvm::CallSite(CallSite).setDoesNotReturn();
   }
 
-  return nullReturn.complete(CGF, rvalue, ResultType, CallArgs,
+  return nullReturn.complete(CGF, Return, rvalue, ResultType, CallArgs,
  RequiresNullCheck ? Method : nullptr);
 }
 
@@ -7073,7 +7084,7 @@ CGObjCNonFragileABIMac::EmitVTableMessag
   CGCallee callee(CGCalleeInfo(), calleePtr);
 
   RValue result = CGF.EmitCall(MSI.CallInfo, callee, returnSlot, args);
-  return nullReturn.complete(CGF, result, resultType, formalArgs,
+  return nullReturn.complete(CGF, returnSlot, result, resultType, formalArgs,
  requiresnullCheck ? method : nullptr);
 }
 

Modified: cfe/trunk/test/CodeGenObjC/stret-1.m
URL: 

[PATCH] D34714: [MS] Don't statically initialize dllimport member function pointers

2017-06-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Have a minute to get to this? My attempt to work around the bug in Chromium was 
incomplete.


https://reviews.llvm.org/D34714



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


[PATCH] D34891: Replace assert(0) with llvm_unreachable.

2017-06-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D34891

Files:
  include/clang/AST/Redeclarable.h
  lib/AST/ExprConstant.cpp
  lib/Basic/SourceManager.cpp
  lib/Lex/PreprocessingRecord.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -1280,12 +1280,12 @@
   TemplateArgument TA;
   if (clang_Cursor_getTemplateArgument(C, I, ) !=
   CXGetTemplateArgumentStatus_Success) {
-assert(0 && "Unable to retrieve TemplateArgument");
+llvm_unreachable("Unable to retrieve TemplateArgument");
 return 0;
   }
 
   if (TA.getKind() != TemplateArgument::Integral) {
-assert(0 && "Passed template argument is not Integral");
+llvm_unreachable("Passed template argument is not Integral");
 return 0;
   }
 
@@ -1297,12 +1297,12 @@
   TemplateArgument TA;
   if (clang_Cursor_getTemplateArgument(C, I, ) !=
   CXGetTemplateArgumentStatus_Success) {
-assert(0 && "Unable to retrieve TemplateArgument");
+llvm_unreachable("Unable to retrieve TemplateArgument");
 return 0;
   }
 
   if (TA.getKind() != TemplateArgument::Integral) {
-assert(0 && "Passed template argument is not Integral");
+llvm_unreachable("Passed template argument is not Integral");
 return 0;
   }
 
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -3114,7 +3114,7 @@
   case CXIdxEntity_CXXTypeAlias: return "type-alias";
   case CXIdxEntity_CXXInterface: return "c++-__interface";
   }
-  assert(0 && "Garbage entity kind");
+  llvm_unreachable("Garbage entity kind");
   return 0;
 }
 
@@ -3126,7 +3126,7 @@
 return "-template-partial-spec";
   case CXIdxEntity_TemplateSpecialization: return "-template-spec";
   }
-  assert(0 && "Garbage entity kind");
+  llvm_unreachable("Garbage entity kind");
   return 0;
 }
 
@@ -3138,7 +3138,7 @@
   case CXIdxEntityLang_CXX: return "C++";
   case CXIdxEntityLang_Swift: return "Swift";
   }
-  assert(0 && "Garbage language kind");
+  llvm_unreachable("Garbage language kind");
   return 0;
 }
 
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -2492,7 +2492,7 @@
 MacroID ID = MacroInfosToEmit[I].ID;
 
 if (ID < FirstMacroID) {
-  assert(0 && "Loaded MacroInfo entered MacroInfosToEmit ?");
+  llvm_unreachable("Loaded MacroInfo entered MacroInfosToEmit ?");
   continue;
 }
 
@@ -5328,7 +5328,7 @@
 TypeIdx  = TypeIdxs[T];
 if (Idx.getIndex() == 0) {
   if (DoneWritingDeclsAndTypes) {
-assert(0 && "New type seen after serializing all the types to emit!");
+llvm_unreachable("New type seen after serializing all the types to emit!");
 return TypeIdx();
   }
 
@@ -5374,7 +5374,7 @@
   DeclID  = DeclIDs[D];
   if (ID == 0) {
 if (DoneWritingDeclsAndTypes) {
-  assert(0 && "New decl seen after serializing all the decls to emit!");
+  llvm_unreachable("New decl seen after serializing all the decls to emit!");
   return 0;
 }
 
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -7032,7 +7032,7 @@
   unsigned Index = ID - NUM_PREDEF_DECL_IDS;
 
   if (Index >= DeclsLoaded.size()) {
-assert(0 && "declaration ID out-of-range for AST file");
+llvm_unreachable("declaration ID out-of-range for AST file");
 Error("declaration ID out-of-range for AST file");
 return nullptr;
   }
@@ -7047,7 +7047,7 @@
   unsigned Index = ID - NUM_PREDEF_DECL_IDS;
 
   if (Index >= DeclsLoaded.size()) {
-assert(0 && "declaration ID out-of-range for AST file");
+llvm_unreachable("declaration ID out-of-range for AST file");
 Error("declaration ID out-of-range for AST file");
 return nullptr;
   }
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6775,7 +6775,7 @@
   break;
   #include "clang/Basic/OpenCLImageTypes.def"
 default:
-  assert(0 && "Unable to find corresponding image type.");
+  llvm_unreachable("Unable to find corresponding image type.");
 }
 
 S.Diag(TypedefTy->getDecl()->getLocStart(),
Index: lib/Lex/PreprocessingRecord.cpp
===
--- lib/Lex/PreprocessingRecord.cpp
+++ lib/Lex/PreprocessingRecord.cpp
@@ -86,7 +86,7 @@
   int Pos = std::distance(iterator(this, 0), PPEI);
   if (Pos < 0) {
  

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

...

>   
 
 Okay, good, this is exactly where I was going when I said I was worried 
 about generalization. -march seems like one of many flags I might want to 
 pass to the target compilation. Moreover, it doesn't seem special in what 
 regard.
 
 We have -Xclang and -mllvm, etc. to pass flags through to other stages of 
 compilation. Could we do something similar here? Maybe something like: 
 ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7``. That's 
 unfortunately long, but if there's only one target, we could omit the 
 triple?
>>> 
>>> The triple could be omitted, absolutely.
>>> 
>>> If you have the following:
>>> 
>>> -fopenmp-targets=openmp-powerpc64le-ibm-linux-gnu 
>>> ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7`` 
>>> ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr8``
>>> 
>>> This would end up having a toolchain called for each one of the 
>>> -Xopenmp-target sets of flags even though a single triple was specified 
>>> under the -fopenmp-targets. Would this be ok?
>> 
>> Why? That does not sound desirable. And could you even use these multiple 
>> outputs? I think you'd want to pass all of the arguments for each target 
>> triple to the one toolchain invocation for that target triple. Is that 
>> possible?
> 
> I agree, I don't think that is something we want (i.e. having one triple lead 
> to two toolchains), with the current flags you can't do that today. I wanted 
> to check with you though that's why i mentioned it.
> 
> I think appending all options for a particular triple together is more 
> desirable.

Good, let's do that.


Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


r306836 - [MS] Test that deleting destructor thunks are not exported

2017-06-30 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Jun 30 09:12:14 2017
New Revision: 306836

URL: http://llvm.org/viewvc/llvm-project?rev=306836=rev
Log:
[MS] Test that deleting destructor thunks are not exported

The MSVC linker emits the LNK4102 warning if they are.

Added:
cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp

Added: cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp?rev=306836=auto
==
--- cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp Fri Jun 30 09:12:14 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -mconstructor-aliases -fms-extensions %s -emit-llvm -o - 
-triple x86_64-windows-msvc | FileCheck %s
+
+struct __declspec(dllexport) A { virtual ~A(); };
+struct __declspec(dllexport) B { virtual ~B(); };
+struct __declspec(dllexport) C : A, B { virtual ~C(); };
+C::~C() {}
+
+// This thunk should *not* be dllexport.
+// CHECK: define linkonce_odr i8* @"\01??_EC@@W7EAAPEAXI@Z"
+// CHECK: define dllexport void @"\01??1C@@UEAA@XZ"


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


r306835 - Revert "[CodeGen] Propagate dllexport to thunks"

2017-06-30 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Jun 30 09:11:49 2017
New Revision: 306835

URL: http://llvm.org/viewvc/llvm-project?rev=306835=rev
Log:
Revert "[CodeGen] Propagate dllexport to thunks"

This reverts r306770, it causes LNK4102 warnings in MSVC builds.

Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=306835=306834=306835=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Fri Jun 30 09:11:49 2017
@@ -64,10 +64,6 @@ static void setThunkProperties(CodeGenMo
   const CXXMethodDecl *MD = cast(GD.getDecl());
   setThunkVisibility(CGM, MD, Thunk, ThunkFn);
 
-  // Propagate dllexport storage.
-  if (MD->hasAttr())
-ThunkFn->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-
   if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
 ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
 }

Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp?rev=306835=306834=306835=diff
==
--- cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp Fri Jun 30 09:11:49 
2017
@@ -53,12 +53,3 @@ USEMEMFUNC(outer::inner, f)
 
 // CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
 // CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
-
-struct base {
-  virtual ~base();
-};
-struct __declspec(dllexport) derived : public virtual base {
-  virtual ~derived() {}
-};
-
-// CHECK: define {{.*}} dllexport {{.*}} @_ZTv0_n12_N7derivedD0Ev


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


[PATCH] D34850: [CodeGen] Propagate dllexport to thunks

2017-06-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Sorry about the breakage. I'll redo this limiting it to windows-itanium (and 
add a comment explaining why we want it).


Repository:
  rL LLVM

https://reviews.llvm.org/D34850



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


[PATCH] D34850: [CodeGen] Propagate dllexport to thunks

2017-06-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This appears to affect our behavior under the MS ABI. We still seem to use this 
logic from CGVTables, even though that code is primarily Itanium related. In 
http://crbug.com/738468 we're seeing the LNK4102 linker warning, which says: 
"export of deleting destructor (name); image may not run correctly". You might 
want to take a look at that warning and reconsider whether this is something 
you want to do or not. MSVC makes it possible to allocate objects in different 
DLLs with different allocators, pass them across DLL boundaries, and deallocate 
them correctly if they are deleted through the vtable.

I'm going to revert for now to fix things.


Repository:
  rL LLVM

https://reviews.llvm.org/D34850



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


[PATCH] D34888: [OpenMP] Fix mapping of scalars for combined directives

2017-06-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D34888



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


[PATCH] D34839: [Driver] Honor -nostdinc and -isystem-after on CrossWindows

2017-06-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r306829


https://reviews.llvm.org/D34839



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


r306830 - Driver: fix option declaration

2017-06-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jun 30 08:15:39 2017
New Revision: 306830

URL: http://llvm.org/viewvc/llvm-project?rev=306830=rev
Log:
Driver: fix option declaration

The option is a "joined" argument.  Fix silly copy-paste error.  This
allows the parsing to work at runtime.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=306830=306829=306830=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun 30 08:15:39 2017
@@ -145,7 +145,7 @@ def dwarf_debug_flags : Separate<["-"],
   HelpText<"The string to embed in the Dwarf debug flags record.">;
 def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">,
 HelpText<"DWARF debug sections compression">;
-def compress_debug_sections_EQ : Flag<["-"], "compress-debug-sections=">,
+def compress_debug_sections_EQ : Joined<["-"], "compress-debug-sections=">,
 HelpText<"DWARF debug sections compression type">;
 def mno_exec_stack : Flag<["-"], "mnoexecstack">,
   HelpText<"Mark the file as not needing an executable stack">;


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


r306829 - Driver: honor -nostdinc and -isystem-after on CrossWindows

2017-06-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jun 30 08:15:38 2017
New Revision: 306829

URL: http://llvm.org/viewvc/llvm-project?rev=306829=rev
Log:
Driver: honor -nostdinc and -isystem-after on CrossWindows

This changes CrossWindows to look for -nostdinc instead of -nostdlibinc.
In addition, fixes a bug where -isystem-after options would be dropped
when called with -nostdinc.

Patch by Dave Lee!

Modified:
cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp?rev=306829=306828=306829=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp Fri Jun 30 08:15:38 2017
@@ -238,8 +238,15 @@ AddClangSystemIncludeArgs(const llvm::op
   const Driver  = getDriver();
   const std::string  = D.SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+  auto AddSystemAfterIncludes = [&]() {
+for (const auto  : 
DriverArgs.getAllArgValues(options::OPT_isystem_after))
+  addSystemInclude(DriverArgs, CC1Args, P);
+  };
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc)) {
+AddSystemAfterIncludes();
 return;
+  }
 
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
@@ -247,8 +254,7 @@ AddClangSystemIncludeArgs(const llvm::op
 llvm::sys::path::append(ResourceDir, "include");
 addSystemInclude(DriverArgs, CC1Args, ResourceDir);
   }
-  for (const auto  : DriverArgs.getAllArgValues(options::OPT_isystem_after))
-addSystemInclude(DriverArgs, CC1Args, P);
+  AddSystemAfterIncludes();
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
@@ -258,7 +264,7 @@ AddClangCXXStdlibIncludeArgs(const llvm:
   const llvm::Triple  = getTriple();
   const std::string  = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 

Modified: cfe/trunk/test/Driver/windows-cross.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=306829=306828=306829=diff
==
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Fri Jun 30 08:15:38 2017
@@ -80,3 +80,8 @@
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
 
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after 
"Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" 
"[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"


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


[PATCH] D34888: [OpenMP] Fix mapping of scalars for combined directives

2017-06-30 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

Combined directives like 'target parallel' have two captured statements. Sema 
has to check the right one from the right direction.

Previously, Sema::IsOpenMPCapturedByRef would return false for mapped scalars 
on combined directives. This results in a wrong signature of the outlined 
function which triggers an assertion:

  void llvm::CallInst::init(llvm::FunctionType *, llvm::Value *, 
ArrayRef, ArrayRef, const llvm::Twine &): 
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.

Fixes PR30975 (and PR31985). New function was taken from clang-ykt.


https://reviews.llvm.org/D34888

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -1056,6 +1056,9 @@
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] 
[i[[Z:64|32]] 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i32] [i32 32]
 
+// CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] 
[i[[Z:64|32]] 4]
+// CK19: [[MTYPE00n:@.+]] = private {{.*}}constant [1 x i32] [i32 32]
+
 // CK19: [[SIZE01:@.+]] = private {{.*}}constant [1 x i[[Z]]] [i[[Z]] 400]
 // CK19: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i32] [i32 33]
 
@@ -1194,6 +1197,28 @@
 ++a;
   }
 
+  // Map of a scalar in nested region.
+  int b = a;
+
+  // Region 00n
+  // CK19-DAG: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 1, 
i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* 
[[SIZE00n]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00n]]{{.+}})
+  // CK19-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK19-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK19-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, 
i{{.+}} 0
+  // CK19-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, 
i{{.+}} 0
+  // CK19-DAG: [[CBP0:%.+]] = bitcast i8** [[BP0]] to i32**
+  // CK19-DAG: [[CP0:%.+]] = bitcast i8** [[P0]] to i32**
+  // CK19-DAG: store i32* [[VAR0:%.+]], i32** [[CBP0]]
+  // CK19-DAG: store i32* [[VAR0]], i32** [[CP0]]
+
+  // CK19: call void [[CALL00n:@.+]](i32* {{[^,]+}})
+  #pragma omp target map(alloc:b)
+  #pragma omp parallel
+  {
+++b;
+  }
+
   // Map of an array.
   int arra[100];
 
@@ -2388,6 +2413,7 @@
 }
 
 // CK19: define {{.+}}[[CALL00]]
+// CK19: define {{.+}}[[CALL00n]]
 // CK19: define {{.+}}[[CALL01]]
 // CK19: define {{.+}}[[CALL02]]
 // CK19: define {{.+}}[[CALL03]]
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -412,6 +412,30 @@
 return false;
   }
 
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+if (isStackEmpty())
+  return false;
+
+auto StartI = Stack.back().first.begin();
+auto EndI = Stack.back().first.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
+return false;
+  }
+
   /// Create a new mappable expression component list associated with a given
   /// declaration and initialize it with the provided list of components.
   void addMappableExpressionComponents(
@@ -994,9 +1018,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -1056,6 +1056,9 @@
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i32] [i32 32]
 
+// CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D34784#795988, @hfinkel wrote:

> In https://reviews.llvm.org/D34784#795980, @gtbercea wrote:
>
> > In https://reviews.llvm.org/D34784#795934, @hfinkel wrote:
> >
> > > In https://reviews.llvm.org/D34784#795871, @gtbercea wrote:
> > >
> > > > In https://reviews.llvm.org/D34784#795367, @hfinkel wrote:
> > > >
> > > > > In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:
> > > > >
> > > > > > In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
> > > > > >
> > > > > > > What happens if you have multiple targets? Maybe this should be 
> > > > > > > -fopenmp-targets-arch=foo,bar,whatever?
> > > > > > >
> > > > > > > Once this all lands, please make sure that you add additional 
> > > > > > > test cases here. Make sure that the arch is passed through to the 
> > > > > > > ptx and cuda tools as it should be. Make sure that the defaults 
> > > > > > > work. Make sure that something reasonable happens if the user 
> > > > > > > specifies the option more than once (if they're all the same).
> > > > > >
> > > > > >
> > > > > > Hi Hal,
> > > > > >
> > > > > > At the moment only one arch is supported and it would apply to all 
> > > > > > the target triples under -fopenmp-targets.
> > > > > >
> > > > > > I was planning to address the multiple archs problem in a future 
> > > > > > patch.
> > > > > >
> > > > > > I am assuming that in the case of multiple archs, each arch in 
> > > > > > -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple 
> > > > > > in -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. 
> > > > > > Is this a practical interpretation of what should happen?
> > > > >
> > > > >
> > > > > Yea, that's what I was thinking. I'm a bit concerned that none of 
> > > > > this generalizes well. To take a step back, under what circumstances 
> > > > > do we support multiple targets right now?
> > > >
> > > >
> > > > We allow -fopenmp-targets to get a list of triples. I am not aware of 
> > > > any limitations in terms of how many of these triples you can have. 
> > > > Even in the test file of this patch we have the following: 
> > > > "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
> > > >
> > > > > 
> > > > > 
> > > > >> Regarding tests: more tests can be added as a separate patch once 
> > > > >> offloading is enabled by the patch following this one (i.e. 
> > > > >> https://reviews.llvm.org/D29654). There actually is a test in 
> > > > >> https://reviews.llvm.org/D29654 where I check that the arch is 
> > > > >> passed to ptxas and nvlink correctly using this flag. I will add 
> > > > >> some more test cases to cover the other situations you mentioned.
> > > > > 
> > > > > Sounds good.
> > > > > 
> > > > >> Thanks,
> > > > >> 
> > > > >> --Doru
> > > >
> > > > In our previous solution there might be a problem.  The same triple 
> > > > might be used multiple times just so that you can have several archs in 
> > > > the other flag (T1 and T2 being the same). There are some alternatives 
> > > > which I have discussed with @ABataev.
> > > >
> > > > One solution could be to associate an arch with each triple to avoid 
> > > > positional matching of triples in one flag with archs in another flag:
> > > >
> > > >   -fopenmp-targets=T1:A1,T2,T3:A2
> > > >
> > > >
> > > > ":A1" is optional, also, in the future, we can pass other things to the 
> > > > toolchain such as "-L/a/b/c/d":
> > > >
> > > >   -fopenmp-targets=T1:A1: -L/a/b/c/d,T2,T3:A2
> > > >
> > >
> > >
> > > Okay, good, this is exactly where I was going when I said I was worried 
> > > about generalization. -march seems like one of many flags I might want to 
> > > pass to the target compilation. Moreover, it doesn't seem special in what 
> > > regard.
> > >
> > > We have -Xclang and -mllvm, etc. to pass flags through to other stages of 
> > > compilation. Could we do something similar here? Maybe something like: 
> > > ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7``. That's 
> > > unfortunately long, but if there's only one target, we could omit the 
> > > triple?
> >
> >
> > The triple could be omitted, absolutely.
> >
> > If you have the following:
> >
> > -fopenmp-targets=openmp-powerpc64le-ibm-linux-gnu 
> > ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7`` 
> > ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr8``
> >
> > This would end up having a toolchain called for each one of the 
> > -Xopenmp-target sets of flags even though a single triple was specified 
> > under the -fopenmp-targets. Would this be ok?
>
>
> Why? That does not sound desirable. And could you even use these multiple 
> outputs? I think you'd want to pass all of the arguments for each target 
> triple to the one toolchain invocation for that target triple. Is that 
> possible?


I agree, I don't think that is something we want (i.e. having one triple lead 
to two toolchains), with the current 

[PATCH] D34886: Add a fixit for -Wobjc-protocol-property-synthesis

2017-06-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

The fixit inserts `@synthesize` directives into the implementation.


Repository:
  rL LLVM

https://reviews.llvm.org/D34886

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Parse/ParseObjc.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/FixIt/fixit-add-synthesize-to-property.m

Index: test/FixIt/fixit-add-synthesize-to-property.m
===
--- /dev/null
+++ test/FixIt/fixit-add-synthesize-to-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+@protocol P1
+
+@property int prop;
+
+@end
+
+@interface I 
+
+@end
+
+@implementation I
+@end // CHECK: fix-it:{{.*}}:{[[@LINE]]:1-[[@LINE]]:1}:"@synthesize prop;\n\n"
Index: lib/Sema/SemaObjCProperty.cpp
===
--- lib/Sema/SemaObjCProperty.cpp
+++ lib/Sema/SemaObjCProperty.cpp
@@ -1676,8 +1676,9 @@
 
 /// \brief Default synthesizes all properties which must be synthesized
 /// in class's \@implementation.
-void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
-   ObjCInterfaceDecl *IDecl) {
+void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
+   ObjCInterfaceDecl *IDecl,
+   SourceRange AtEnd) {
   ObjCInterfaceDecl::PropertyMap PropMap;
   ObjCInterfaceDecl::PropertyDeclOrder PropertyOrder;
   IDecl->collectPropertiesToImplement(PropMap, PropertyOrder);
@@ -1725,6 +1726,11 @@
  diag::warn_auto_synthesizing_protocol_property)
   << Prop << Proto;
 Diag(Prop->getLocation(), diag::note_property_declare);
+std::string FixIt =
+(Twine("@synthesize ") + Prop->getName() + ";\n\n").str();
+SourceLocation Loc = AtEnd.getBegin();
+Diag(Loc, diag::note_add_synthesize_directive)
+<< FixItHint::CreateInsertion(Loc, FixIt);
   }
   continue;
 }
@@ -1764,15 +1770,15 @@
   }
 }
 
-void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D) {
+void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D, SourceRange AtEnd) {
   if (!LangOpts.ObjCDefaultSynthProperties || LangOpts.ObjCRuntime.isFragile())
 return;
   ObjCImplementationDecl *IC=dyn_cast_or_null(D);
   if (!IC)
 return;
   if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
 if (!IDecl->isObjCRequiresPropertyDefs())
-  DefaultSynthesizeProperties(S, IC, IDecl);
+  DefaultSynthesizeProperties(S, IC, IDecl, AtEnd);
 }
 
 static void DiagnoseUnimplementedAccessor(
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -2255,7 +2255,7 @@
 
 void Parser::ObjCImplParsingDataRAII::finish(SourceRange AtEnd) {
   assert(!Finished);
-  P.Actions.DefaultSynthesizeProperties(P.getCurScope(), Dcl);
+  P.Actions.DefaultSynthesizeProperties(P.getCurScope(), Dcl, AtEnd);
   for (size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], 
true/*Methods*/);
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3346,9 +3346,9 @@
 
   /// DefaultSynthesizeProperties - This routine default synthesizes all
   /// properties which must be synthesized in the class's \@implementation.
-  void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
-ObjCInterfaceDecl *IDecl);
-  void DefaultSynthesizeProperties(Scope *S, Decl *D);
+  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
+   ObjCInterfaceDecl *IDecl, SourceRange AtEnd);
+  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceRange AtEnd);
 
   /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
   /// an ivar synthesized for 'Method' and 'Method' is a property accessor
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1029,6 +1029,8 @@
   "auto property synthesis will not synthesize property %0"
   " declared in protocol %1">,
   InGroup>;
+def note_add_synthesize_directive : Note<
+  "add a '@synthesize' directive">;
 def warn_no_autosynthesis_shared_ivar_property : Warning <
   "auto property synthesis will not synthesize property "
   "%0 because it cannot share an ivar with another synthesized property">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >