[PATCH] D34865: [ORE] Use LLVM's "diagnostics hotness" spelling

2017-06-30 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

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.


https://reviews.llvm.org/D34865

Files:
  lib/CodeGen/CodeGenAction.cpp


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -228,7 +228,7 @@
   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 @@
 llvm::make_unique(OptRecordFile->os()));
 
 if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-  Ctx.setDiagnosticHotnessRequested(true);
+  Ctx.setDiagnosticsHotnessRequested(true);
   }
 
   // Link each LinkModule into our module.


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -228,7 +228,7 @@
   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 @@
 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] D34868: [Driver] Add -fdiagnostics-hotness-threshold

2017-06-30 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
Herald added a subscriber: fhahn.

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


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
@@ -10,29 +10,39 @@
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-instrument-use-path=%t.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
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // 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 +53,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

r306790 - Add -no-canonical-prefixes to the test line so that we can handle different build modes.

2017-06-30 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Jun 29 23:03:47 2017
New Revision: 306790

URL: http://llvm.org/viewvc/llvm-project?rev=306790=rev
Log:
Add -no-canonical-prefixes to the test line so that we can handle different 
build modes.

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=306790=306789=306790=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Thu Jun 29 23:03:47 2017
@@ -593,7 +593,7 @@
 /// ###
 
 /// Check -fopenmp-is-device is passed when compiling for the device.
-// RUN:   %clang -### -target powerpc64le-linux -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
+// RUN:   %clang -### -no-canonical-prefixes -target powerpc64le-linux 
-fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
 // CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" "powerpc64le--linux" 
{{.*}}.c" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"


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


r306799 - Fold exception-warnings.cpp into warn-throw-out-noexcept-func.cpp

2017-06-30 Thread Stephan Bergmann via cfe-commits
Author: sberg
Date: Fri Jun 30 00:22:02 2017
New Revision: 306799

URL: http://llvm.org/viewvc/llvm-project?rev=306799=rev
Log:
Fold exception-warnings.cpp into warn-throw-out-noexcept-func.cpp

I had failed to notice the latter existed when I recently introduced the former.

Removed:
cfe/trunk/test/SemaCXX/exception-warnings.cpp
Modified:
cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp

Removed: cfe/trunk/test/SemaCXX/exception-warnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/exception-warnings.cpp?rev=306798=auto
==
--- cfe/trunk/test/SemaCXX/exception-warnings.cpp (original)
+++ cfe/trunk/test/SemaCXX/exception-warnings.cpp (removed)
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
-
-struct B {};
-struct D: B {};
-void goodPlain() throw () {
-  try {
-throw D();
-  } catch (B) {}
-}
-void goodReference() throw () {
-  try {
-throw D();
-  } catch (B &) {}
-}
-void goodPointer() throw () {
-  D d;
-  try {
-throw 
-  } catch (B *) {}
-}
-void badPlain() throw () { // expected-note {{non-throwing function declare 
here}}
-  try {
-throw B(); // expected-warning {{'badPlain' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
-  } catch (D) {}
-}
-void badReference() throw () { // expected-note {{non-throwing function 
declare here}}
-  try {
-throw B(); // expected-warning {{'badReference' has a non-throwing 
exception specification but can still throw, resulting in unexpected program 
termination}}
-  } catch (D &) {}
-}
-void badPointer() throw () { // expected-note {{non-throwing function declare 
here}}
-  B b;
-  try {
-throw  // expected-warning {{'badPointer' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
-  } catch (D *) {}
-}

Modified: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp?rev=306799=306798=306799=diff
==
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp Fri Jun 30 00:22:02 
2017
@@ -253,6 +253,43 @@ void with_try_block1() noexcept try { //
 } catch (char *) {
 }
 
+namespace derived {
+struct B {};
+struct D: B {};
+void goodPlain() noexcept {
+  try {
+throw D();
+  } catch (B) {}
+}
+void goodReference() noexcept {
+  try {
+throw D();
+  } catch (B &) {}
+}
+void goodPointer() noexcept {
+  D d;
+  try {
+throw 
+  } catch (B *) {}
+}
+void badPlain() noexcept { // expected-note {{non-throwing function declare 
here}}
+  try {
+throw B(); // expected-warning {{'badPlain' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
+  } catch (D) {}
+}
+void badReference() noexcept { // expected-note {{non-throwing function 
declare here}}
+  try {
+throw B(); // expected-warning {{'badReference' has a non-throwing 
exception specification but can still throw, resulting in unexpected program 
termination}}
+  } catch (D &) {}
+}
+void badPointer() noexcept { // expected-note {{non-throwing function declare 
here}}
+  B b;
+  try {
+throw  // expected-warning {{'badPointer' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
+  } catch (D *) {}
+}
+}
+
 int main() {
   R1_ShouldDiag o; //expected-note {{in instantiation of member function}}
   S1_ShouldDiag b; //expected-note {{in instantiation of member function}}


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


[PATCH] D34686: [AArch64] ARMV8-A archkind and target defines helper functions

2017-06-30 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 accepted this revision.
rogfer01 added a comment.
This revision is now accepted and ready to land.

This LGTM. Thanks for the refactoring and the fix.


https://reviews.llvm.org/D34686



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

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

Please re-upload the patch with full context (see 
http://llvm.org/docs/Phabricator.html).




Comment at: lib/Tooling/CommonOptionsParser.cpp:119
   cl::HideUnrelatedOptions(Category);
-
+  //Expand response files before loading compilation database from command line
+  SmallVector newArgv(argv, argv + argc);

Add a space after `//` and a trailing period.



Comment at: unittests/Tooling/CommonOptionsParserTest.cpp:69
+}
\ No newline at end of file


Please fix the `No newline at end of file`.


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

2017-06-30 Thread Joey Gouly via Phabricator via cfe-commits
joey created this revision.
Herald added subscribers: Anastasia, yaxunl.

Slightly improve the diagnostic by including the function name.

This has been separated out from https://reviews.llvm.org/D33945.


https://reviews.llvm.org/D34871

Files:
  Sema/Sema.cpp
  SemaOpenCL/extension-begin.cl
  clang/Basic/DiagnosticSemaKinds.td
  clang/Sema/Sema.h


Index: SemaOpenCL/extension-begin.cl
===
--- SemaOpenCL/extension-begin.cl
+++ SemaOpenCL/extension-begin.cl
@@ -46,7 +46,7 @@
   const struct A test_A_local; // expected-error {{use of type 'struct A' 
requires my_ext extension to be enabled}}
   TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 
'struct A') requires my_ext extension to be enabled}}
   PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 
'const struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration requires my_ext extension to be 
enabled}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext extension to 
be enabled}}
   g(0); // expected-error {{no matching function for call to 'g'}}
 // expected-note@-26 {{candidate disabled due to OpenCL extension}}
 // expected-note@-22 {{candidate function not viable: requires 0 
arguments, but 1 was provided}}
Index: Sema/Sema.cpp
===
--- Sema/Sema.cpp
+++ Sema/Sema.cpp
@@ -1688,7 +1688,8 @@
QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl , const Expr ) {
-  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const FunctionDecl , const Expr ) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), FnName,
OpenCLDeclExtMap, 1, 
D.getSourceRange());
 }
Index: clang/Sema/Sema.h
===
--- clang/Sema/Sema.h
+++ clang/Sema/Sema.h
@@ -8432,7 +8432,7 @@
   /// is disabled due to required OpenCL extensions being disabled. If so,
   /// emit diagnostics.
   /// \return true if type is disabled.
-  bool checkOpenCLDisabledDecl(const Decl , const Expr );
+  bool checkOpenCLDisabledDecl(const FunctionDecl , const Expr );
 
   
//======//
   // OpenMP directives and clauses.
Index: clang/Basic/DiagnosticSemaKinds.td
===
--- clang/Basic/DiagnosticSemaKinds.td
+++ clang/Basic/DiagnosticSemaKinds.td
@@ -8404,7 +8404,7 @@
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
-  "use of %select{type |declaration}0%1 requires %2 extension to be enabled">;
+  "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


Index: SemaOpenCL/extension-begin.cl
===
--- SemaOpenCL/extension-begin.cl
+++ SemaOpenCL/extension-begin.cl
@@ -46,7 +46,7 @@
   const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
   TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
   PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}}
   g(0); // expected-error {{no matching function for call to 'g'}}
 // expected-note@-26 {{candidate disabled due to OpenCL extension}}
 // expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
Index: Sema/Sema.cpp
===
--- Sema/Sema.cpp
+++ Sema/Sema.cpp
@@ -1688,7 +1688,8 @@
QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl , const Expr ) {
-  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const FunctionDecl , const Expr ) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), FnName,
OpenCLDeclExtMap, 1, D.getSourceRange());
 }
Index: clang/Sema/Sema.h
===
--- clang/Sema/Sema.h
+++ clang/Sema/Sema.h
@@ -8432,7 +8432,7 @@
   /// is disabled due to required 

[PATCH] D34404: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

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

Please upload a diff with full context (http://llvm.org/docs/Phabricator.html).




Comment at: include/clang/Tooling/DiagnosticsYaml.h:86-95
-std::vector Diagnostics;
-for (auto  : Doc.Diagnostics) {
-  // FIXME: Export all diagnostics, not just the ones with fixes.
-  // Update MappingTraits::mapping.
-  if (Diagnostic.Fix.size() > 0) {
-Diagnostics.push_back(Diagnostic);
-  }

We should ensure clang-apply-fixes still works correctly in the presence of 
diagnostics with no fixes. It would be best to add a lit test for that.



Comment at: unittests/Tooling/DiagnosticsYamlTest.cpp:171
+}
\ No newline at end of file


Please add a newline.


Repository:
  rL LLVM

https://reviews.llvm.org/D34404



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


[PATCH] D34686: [AArch64] ARMV8-A archkind and target defines helper functions

2017-06-30 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306805: ARMV8-A archkind and target defines helper functions 
(authored by SjoerdMeijer).

Changed prior to commit:
  https://reviews.llvm.org/D34686?vs=104393=104830#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34686

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/aarch64-target-features.c
  cfe/trunk/test/Preprocessor/arm-target-features.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5615,6 +5615,17 @@
 
   bool setFPMath(StringRef Name) override;
 
+  void getTargetDefinesARMV81A(const LangOptions ,
+   MacroBuilder ) const {
+Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  }
+
+  void getTargetDefinesARMV82A(const LangOptions ,
+   MacroBuilder ) const {
+// Also include the ARMv8.1-A defines
+getTargetDefinesARMV81A(Opts, Builder);
+  }
+
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 // Target identification.
@@ -5813,8 +5824,15 @@
 if (Opts.UnsafeFPMath)
   Builder.defineMacro("__ARM_FP_FAST", "1");
 
-if (ArchKind == llvm::ARM::AK_ARMV8_1A)
-  Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+switch(ArchKind) {
+default: break;
+case llvm::ARM::AK_ARMV8_1A:
+  getTargetDefinesARMV81A(Opts, Builder);
+  break;
+case llvm::ARM::AK_ARMV8_2A:
+  getTargetDefinesARMV82A(Opts, Builder);
+  break;
+}
   }
 
   ArrayRef getTargetBuiltins() const override {
@@ -6207,9 +6225,8 @@
   unsigned CRC;
   unsigned Crypto;
   unsigned Unaligned;
-  unsigned V8_1A;
-  unsigned V8_2A;
   unsigned HasFullFP16;
+  llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
 
@@ -6275,6 +6292,20 @@
static_cast(llvm::AArch64::ArchKind::AK_INVALID);
   }
 
+  void getTargetDefinesARMV81A(const LangOptions ,
+MacroBuilder ) const {
+Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  }
+
+  void getTargetDefinesARMV82A(const LangOptions ,
+MacroBuilder ) const {
+// Also include the ARMv8.1 defines
+getTargetDefinesARMV81A(Opts, Builder);
+
+if (FPU == NeonMode && HasFullFP16)
+  Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
+  }
+
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 // Target identification.
@@ -6339,10 +6370,15 @@
 if (Unaligned)
   Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
-if (V8_1A)
-  Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
-if (V8_2A && FPU == NeonMode && HasFullFP16)
-  Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
+switch(ArchKind) {
+default: break;
+case llvm::AArch64::ArchKind::AK_ARMV8_1A:
+  getTargetDefinesARMV81A(Opts, Builder);
+  break;
+case llvm::AArch64::ArchKind::AK_ARMV8_2A:
+  getTargetDefinesARMV82A(Opts, Builder);
+  break;
+}
 
 // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -6369,9 +6405,8 @@
 CRC = 0;
 Crypto = 0;
 Unaligned = 1;
-V8_1A = 0;
-V8_2A = 0;
 HasFullFP16 = 0;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8A;
 
 for (const auto  : Features) {
   if (Feature == "+neon")
@@ -6383,9 +6418,9 @@
   if (Feature == "+strict-align")
 Unaligned = 0;
   if (Feature == "+v8.1a")
-V8_1A = 1;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_1A;
   if (Feature == "+v8.2a")
-V8_2A = 1;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_2A;
   if (Feature == "+fullfp16")
 HasFullFP16 = 1;
 }
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -71,8 +71,9 @@
 // CHECK-NEON: __ARM_NEON 1
 // CHECK-NEON: __ARM_NEON_FP 0xE
 
-// RUN: %clang -target aarch64-none-eabi -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V81A %s
-// CHECK-V81A: __ARM_FEATURE_QRDMX 1
+// RUN: %clang -target aarch64-none-eabi -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-QRDMX %s
+// RUN: %clang -target aarch64-none-eabi -march=armv8.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-QRDMX %s
+// CHECK-QRDMX: __ARM_FEATURE_QRDMX 1
 
 // RUN: %clang -target aarch64 -march=arm64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
 // RUN: %clang -target aarch64 -march=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
Index: 

r306805 - ARMV8-A archkind and target defines helper functions

2017-06-30 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Fri Jun 30 01:07:34 2017
New Revision: 306805

URL: http://llvm.org/viewvc/llvm-project?rev=306805=rev
Log:
ARMV8-A archkind and target defines helper functions

This introduces helper functions that set target defines for different ARMV8-A
architecture kinds. It fixes an issue that the v8.1 define ARM_FEATURE_QRDMX
was not set for v8.2. These helper functions make things more “scalable” if we
want to add ARMv8.3 at some point, and a cleanup has been done to hold the
architecture kind in one variable (instead of one for each).

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306805=306804=306805=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun 30 01:07:34 2017
@@ -5615,6 +5615,17 @@ public:
 
   bool setFPMath(StringRef Name) override;
 
+  void getTargetDefinesARMV81A(const LangOptions ,
+   MacroBuilder ) const {
+Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  }
+
+  void getTargetDefinesARMV82A(const LangOptions ,
+   MacroBuilder ) const {
+// Also include the ARMv8.1-A defines
+getTargetDefinesARMV81A(Opts, Builder);
+  }
+
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 // Target identification.
@@ -5813,8 +5824,15 @@ public:
 if (Opts.UnsafeFPMath)
   Builder.defineMacro("__ARM_FP_FAST", "1");
 
-if (ArchKind == llvm::ARM::AK_ARMV8_1A)
-  Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+switch(ArchKind) {
+default: break;
+case llvm::ARM::AK_ARMV8_1A:
+  getTargetDefinesARMV81A(Opts, Builder);
+  break;
+case llvm::ARM::AK_ARMV8_2A:
+  getTargetDefinesARMV82A(Opts, Builder);
+  break;
+}
   }
 
   ArrayRef getTargetBuiltins() const override {
@@ -6207,9 +6225,8 @@ class AArch64TargetInfo : public TargetI
   unsigned CRC;
   unsigned Crypto;
   unsigned Unaligned;
-  unsigned V8_1A;
-  unsigned V8_2A;
   unsigned HasFullFP16;
+  llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
 
@@ -6275,6 +6292,20 @@ public:
static_cast(llvm::AArch64::ArchKind::AK_INVALID);
   }
 
+  void getTargetDefinesARMV81A(const LangOptions ,
+MacroBuilder ) const {
+Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  }
+
+  void getTargetDefinesARMV82A(const LangOptions ,
+MacroBuilder ) const {
+// Also include the ARMv8.1 defines
+getTargetDefinesARMV81A(Opts, Builder);
+
+if (FPU == NeonMode && HasFullFP16)
+  Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
+  }
+
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 // Target identification.
@@ -6339,10 +6370,15 @@ public:
 if (Unaligned)
   Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
 
-if (V8_1A)
-  Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
-if (V8_2A && FPU == NeonMode && HasFullFP16)
-  Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
+switch(ArchKind) {
+default: break;
+case llvm::AArch64::ArchKind::AK_ARMV8_1A:
+  getTargetDefinesARMV81A(Opts, Builder);
+  break;
+case llvm::AArch64::ArchKind::AK_ARMV8_2A:
+  getTargetDefinesARMV82A(Opts, Builder);
+  break;
+}
 
 // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -6369,9 +6405,8 @@ public:
 CRC = 0;
 Crypto = 0;
 Unaligned = 1;
-V8_1A = 0;
-V8_2A = 0;
 HasFullFP16 = 0;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8A;
 
 for (const auto  : Features) {
   if (Feature == "+neon")
@@ -6383,9 +6418,9 @@ public:
   if (Feature == "+strict-align")
 Unaligned = 0;
   if (Feature == "+v8.1a")
-V8_1A = 1;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_1A;
   if (Feature == "+v8.2a")
-V8_2A = 1;
+ArchKind = llvm::AArch64::ArchKind::AK_ARMV8_2A;
   if (Feature == "+fullfp16")
 HasFullFP16 = 1;
 }

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=306805=306804=306805=diff
==
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Fri Jun 30 01:07:34 
2017
@@ -71,8 +71,9 @@
 // CHECK-NEON: 

Re: r306692 - Initialize variable and silence potentially uninitialized warning.

2017-06-30 Thread Vassil Vassilev via cfe-commits

On 30/06/17 01:03, Evgenii Stepanov wrote:

This change broke clang/ubsan bot.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6047/steps/check-clang%20ubsan/logs/stdio

It looks like the value you are initializing SavedAK with may itself 
be uninitialized? I see a few constructors that do not mention it.
Indeed. Do you have a solution in mind? The only way I see to fix this 
is by using an llvm::Optional.



On Thu, Jun 29, 2017 at 9:08 AM, Vassil Vassilev via cfe-commits 
> wrote:


Author: vvassilev
Date: Thu Jun 29 09:08:10 2017
New Revision: 306692

URL: http://llvm.org/viewvc/llvm-project?rev=306692=rev

Log:
Initialize variable and silence potentially uninitialized warning.

Patch by Liza Sakellari!

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306692=306691=306692=diff



==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Jun 29 09:08:10 2017
@@ -465,10 +465,9 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK;
+  AmbiguityKind SavedAK = Ambiguity;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
-SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;


___
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


[PATCH] D34810: [Sema] -Wcomma should not warn for expressions that return void

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

Ah, I see, so this is more of a stylistic warning rather than "suspicious" use 
one.

In https://reviews.llvm.org/D34810#795926, @rtrieu wrote:

>   What is the reason to exclude void expressions now?  For the function case, 
> it is more consistent to warn on all function calls since we can't determine 
> if a function returns void just by looking at the call site.


We've had an issue with -Wcomma adoption internally and have thought that this 
was a bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D34810



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


r306804 - Fix heap use after free introduced by r306769.

2017-06-30 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jun 30 01:02:37 2017
New Revision: 306804

URL: http://llvm.org/viewvc/llvm-project?rev=306804=rev
Log:
Fix heap use after free introduced by r306769.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=306804=306803=306804=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jun 30 01:02:37 2017
@@ -1319,7 +1319,7 @@ void Clang::AddARMTargetArgs(const llvm:
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
 ABIName = A->getValue();
   else {
-StringRef CPU = getCPUName(Args, Triple, /*FromAs*/ false);
+std::string CPU = getCPUName(Args, Triple, /*FromAs*/ false);
 ABIName = llvm::ARM::computeDefaultTargetABI(Triple, CPU).data();
   }
 


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


r306809 - Ambiguity might be also uninitialized. Use llvm::Optional.

2017-06-30 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun 30 02:25:43 2017
New Revision: 306809

URL: http://llvm.org/viewvc/llvm-project?rev=306809=rev
Log:
Ambiguity might be also uninitialized. Use llvm::Optional.


Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306809=306808=306809=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Jun 30 02:25:43 2017
@@ -18,6 +18,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/ADT/Optional.h"
+
 namespace clang {
 
 /// @brief Represents the results of name lookup.
@@ -465,9 +467,10 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK = Ambiguity;
+  llvm::Optional SavedAK;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
+SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;
@@ -478,7 +481,7 @@ public:
   if (ResultKind == Ambiguous) {
 (void)WasAmbiguous;
 assert(WasAmbiguous);
-Ambiguity = SavedAK;
+Ambiguity = SavedAK.getValue();
   } else if (Paths) {
 deletePaths(Paths);
 Paths = nullptr;


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


[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

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

LGTM.
Just one minor comment.
Thanks.




Comment at: clang/Sema/Sema.h:8435
   /// \return true if type is disabled.
-  bool checkOpenCLDisabledDecl(const Decl , const Expr );
+  bool checkOpenCLDisabledDecl(const FunctionDecl , const Expr );
 

I think it's better to use NamedDecl to allow this function be used for 
declarations other than FunctionDecl.


https://reviews.llvm.org/D34871



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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-30 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I didn't have time to have a close look at this patch, but it seems you're 
interested in the specific TU-independent data of a Stmt to compare them. So if 
you are interested in the such data and don't want to write your own function 
to collect data it for each Stmt subclass, there is the `StmtDataCollector` in 
the CloneDetection.cpp here 
 and a 
example how to use it is here 
.

I'm fine with moving this into a header and make it more usable for this use 
case if you think it makes sense to use it here. The main advantage would be 
that we don't get yet another of these classes in clang (we already have 3 of 
them: One in the Stmt profiler code, another one in the ODRHash code for 
modules and another one in the CloneDetection code).


https://reviews.llvm.org/D34329



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


[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

2017-06-30 Thread Joey Gouly via Phabricator via cfe-commits
joey added a comment.

Thanks!

Making that change, going to re-run the tests and then I'll commit.


https://reviews.llvm.org/D34871



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


[PATCH] D34304: Allow CompilerInvocations to generate .d files.

2017-06-30 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG, thx for bearing with me, this looks great.
(and sorry if I didn't send this earlier, just noticed I forgot to hit submit 
:( )




Comment at: lib/Tooling/ArgumentsAdjusters.cpp:66
+  (Arg == "-MD") || (Arg == "-MMD")) {
+// Output is specified as -MX foo. Skip the next argument also.
+++i;

s/ also/, too/?


https://reviews.llvm.org/D34304



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


[PATCH] D34329: [clang-diff] Initial implementation.

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

I think that it's pretty much ready. I think that the test should be expanded 
though. At the very least it should check that all of the node types that are 
supported by `SyntaxTreeImpl::getNodeValueImpl` get matched.


https://reviews.llvm.org/D34329



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


[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-06-30 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

With that patch applied my 32-bit libclang.dll built with mingw does not crash 
anymore
unit tests are not affected by that change


https://reviews.llvm.org/D34873

Files:
  lib/AST/ExprConstant.cpp


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -433,7 +433,7 @@
   /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
   /// evaluate the expression regardless of what the RHS is, but C only allows
   /// certain things in certain situations.
-  struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo {
+  struct EvalInfo {
 ASTContext 
 
 /// EvalStatus - Contains information about the evaluation.
@@ -471,7 +471,7 @@
 
 /// The current array initialization index, if we're performing array
 /// initialization.
-uint64_t ArrayInitIndex = -1;
+uint32_t ArrayInitIndex = -1;
 
 /// HasActiveDiagnostic - Was the previous diagnostic stored? If so, 
further
 /// notes attached to it will also be stored, otherwise they will not be.
@@ -810,7 +810,7 @@
 
 class ArrayInitLoopIndex {
   EvalInfo 
-  uint64_t OuterIndex;
+  uint32_t OuterIndex;
 
 public:
   ArrayInitLoopIndex(EvalInfo )
@@ -819,7 +819,7 @@
   }
   ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
 
-  operator uint64_t&() { return Info.ArrayInitIndex; }
+  operator uint32_t&() { return Info.ArrayInitIndex; }
 };
   };
 
@@ -6299,7 +6299,7 @@
 
   auto *CAT = cast(E->getType()->castAsArrayTypeUnsafe());
 
-  uint64_t Elements = CAT->getSize().getZExtValue();
+  uint32_t Elements = CAT->getSize().getZExtValue();
   Result = APValue(APValue::UninitArray(), Elements, Elements);
 
   LValue Subobject = This;
@@ -6477,7 +6477,7 @@
   }
 
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) {
-if (Info.ArrayInitIndex == uint64_t(-1)) {
+if (Info.ArrayInitIndex == uint32_t(-1)) {
   // We were asked to evaluate this subexpression independent of the
   // enclosing ArrayInitLoopExpr. We can't do that.
   Info.FFDiag(E);


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -433,7 +433,7 @@
   /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
   /// evaluate the expression regardless of what the RHS is, but C only allows
   /// certain things in certain situations.
-  struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo {
+  struct EvalInfo {
 ASTContext 
 
 /// EvalStatus - Contains information about the evaluation.
@@ -471,7 +471,7 @@
 
 /// The current array initialization index, if we're performing array
 /// initialization.
-uint64_t ArrayInitIndex = -1;
+uint32_t ArrayInitIndex = -1;
 
 /// HasActiveDiagnostic - Was the previous diagnostic stored? If so, further
 /// notes attached to it will also be stored, otherwise they will not be.
@@ -810,7 +810,7 @@
 
 class ArrayInitLoopIndex {
   EvalInfo 
-  uint64_t OuterIndex;
+  uint32_t OuterIndex;
 
 public:
   ArrayInitLoopIndex(EvalInfo )
@@ -819,7 +819,7 @@
   }
   ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
 
-  operator uint64_t&() { return Info.ArrayInitIndex; }
+  operator uint32_t&() { return Info.ArrayInitIndex; }
 };
   };
 
@@ -6299,7 +6299,7 @@
 
   auto *CAT = cast(E->getType()->castAsArrayTypeUnsafe());
 
-  uint64_t Elements = CAT->getSize().getZExtValue();
+  uint32_t Elements = CAT->getSize().getZExtValue();
   Result = APValue(APValue::UninitArray(), Elements, Elements);
 
   LValue Subobject = This;
@@ -6477,7 +6477,7 @@
   }
 
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) {
-if (Info.ArrayInitIndex == uint64_t(-1)) {
+if (Info.ArrayInitIndex == uint32_t(-1)) {
   // We were asked to evaluate this subexpression independent of the
   // enclosing ArrayInitLoopExpr. We can't do that.
   Info.FFDiag(E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34696: [refactor] Move the core of clang-rename to lib/Tooling/Refactoring

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

I think I'd rather move `clang-rename` first.




Comment at: tools/extra/clang-rename/tool/ClangRename.cpp:167
   FindingAction.getUSRList();
   const std::vector  = FindingAction.getUSRSpellings();
   if (PrintName) {

alexshap wrote:
> 1. nit: this line caught my eye (not directly related to the main purpose of 
> this diff):
> getUSRSpellings returns ArrayRef, and ArrayRef has (see the line 271 in 
> include/llvm/ADT/ArrayRef.h) a conversion operator to std::vector (by 
> value). So while it's correct this copy seems to be unnecessary (pls, correct 
> me if i am missing smth) and the fix is easy. If you want i can send a 
> separate diff or i don't mind smb else fixing it.
> 2. nit: USRFindingAction  public methods (getUSRSpellings etc) except 
> newASTConsumer should be const
Thanks for the feedback! I agree with your comments, but would prefer to leave 
them for a separate patch. I have some similar fixes for some of this code as 
well.


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] D34865: [ORE] Use LLVM's "diagnostics hotness" spelling

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.

LGTM, thanks!


https://reviews.llvm.org/D34865



___
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 added a comment.

Great!




Comment at: docs/UsersManual.rst:330-332
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

While you're here, could you please update this information.  This option is 
implied by -fsave-optimization-record so it's not generally true that it's off 
by default.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:198-203
 def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning<
   "argument '-fdiagnostics-show-hotness' requires profile-guided optimization 
information">,
   InGroup;
+def warn_drv_fdiagnostics_hotness_threshold_requires_pgo : Warning<
+  "argument '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information">,
+  InGroup;

Can you merge these two by taking the name of the option as the parameter %0?



Comment at: include/clang/Driver/Options.td:728
+Group, Flags<[CC1Option]>, MetaVarName<"">,
+HelpText<"Prevent optimization remarks from being output if they do not 
have at least this hotness value">;
 def fdiagnostics_show_option : Flag<["-"], "fdiagnostics-show-option">, 
Group,

Switch "hotness value" to "profile count"?



Comment at: lib/Frontend/CompilerInvocation.cpp:912-914
+  if (Opts.DiagnosticsWithHotness && !UsingProfile) {
 Diags.Report(diag::warn_drv_fdiagnostics_show_hotness_requires_pgo);
   }

There is no {} for single statement blocks.



Comment at: test/Frontend/optimization-remark-with-hotness.c:9-20
 // 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 -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -verify
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
+// RUN: -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \

I think that one of these (or additional tests) should also cover the default 
value (i.e. omitted -fdiagnostics-hotness-threshold=).


https://reviews.llvm.org/D34868



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


r306825 - [OPENMP] Initial support for taskloop reductions.

2017-06-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 30 06:50:13 2017
New Revision: 306825

URL: http://llvm.org/viewvc/llvm-project?rev=306825=rev
Log:
[OPENMP] Initial support for taskloop reductions.

Add sema/parsupping ort for taskloop [simd] reductions.

Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=306825=306824=306825=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Fri Jun 30 06:50:13 2017
@@ -552,6 +552,7 @@ OPENMP_TASKLOOP_CLAUSE(priority)
 OPENMP_TASKLOOP_CLAUSE(grainsize)
 OPENMP_TASKLOOP_CLAUSE(nogroup)
 OPENMP_TASKLOOP_CLAUSE(num_tasks)
+OPENMP_TASKLOOP_CLAUSE(reduction)
 
 // Clauses allowed for OpenMP directive 'taskloop simd'.
 OPENMP_TASKLOOP_SIMD_CLAUSE(if)
@@ -572,6 +573,7 @@ OPENMP_TASKLOOP_SIMD_CLAUSE(simdlen)
 OPENMP_TASKLOOP_SIMD_CLAUSE(grainsize)
 OPENMP_TASKLOOP_SIMD_CLAUSE(nogroup)
 OPENMP_TASKLOOP_SIMD_CLAUSE(num_tasks)
+OPENMP_TASKLOOP_SIMD_CLAUSE(reduction)
 
 // Clauses allowed for OpenMP directive 'critical'.
 OPENMP_CRITICAL_CLAUSE(hint)

Modified: cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_ast_print.cpp?rev=306825=306824=306825=diff
==
--- cfe/trunk/test/OpenMP/taskloop_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_ast_print.cpp Fri Jun 30 06:50:13 2017
@@ -13,14 +13,14 @@ T tmain(T argc) {
   T b = argc, c, d, e, f, g;
   static T a;
 // CHECK: static T a;
-#pragma omp taskloop if(taskloop: argc > N) default(shared) untied priority(N) 
grainsize(N)
-  // CHECK-NEXT: #pragma omp taskloop if(taskloop: argc > N) default(shared) 
untied priority(N) grainsize(N)
+#pragma omp taskloop if(taskloop: argc > N) default(shared) untied priority(N) 
grainsize(N) reduction(+:g)
+  // CHECK-NEXT: #pragma omp taskloop if(taskloop: argc > N) default(shared) 
untied priority(N) grainsize(N) reduction(+: g)
   for (int i = 0; i < 2; ++i)
 a = 2;
 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
 // CHECK-NEXT: a = 2;
 #pragma omp parallel
-#pragma omp taskloop private(argc, b), firstprivate(c, d), lastprivate(d, f) 
collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup num_tasks(N)
+#pragma omp taskloop private(argc, b), firstprivate(c, d), lastprivate(d, f) 
collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup 
num_tasks(N) reduction(min:a)
   for (int i = 0; i < 2; ++i)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
@@ -33,7 +33,7 @@ T tmain(T argc) {
   for (int j = 0; j < 2; ++j)
 foo();
   // CHECK-NEXT: #pragma omp parallel
-  // CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(c,d) 
lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) 
nogroup num_tasks(N)
+  // CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(c,d) 
lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) 
nogroup num_tasks(N) reduction(min: a)
   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
@@ -53,19 +53,19 @@ int main(int argc, char **argv) {
   int b = argc, c, d, e, f, g;
   static int a;
 // CHECK: static int a;
-#pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) 
priority(5) nogroup num_tasks(argc)
-  // CHECK-NEXT: #pragma omp taskloop if(taskloop: a) default(none) shared(a) 
final(b) priority(5) nogroup num_tasks(argc)
+#pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) 
priority(5) nogroup num_tasks(argc) reduction(*: g)
+  // CHECK-NEXT: #pragma omp taskloop if(taskloop: a) default(none) shared(a) 
final(b) priority(5) nogroup num_tasks(argc) reduction(*: g)
   for (int i = 0; i < 2; ++i)
 a = 2;
 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
 // CHECK-NEXT: a = 2;
 #pragma omp parallel
-#pragma omp taskloop private(argc, b), firstprivate(argv, c), lastprivate(d, 
f) collapse(2) shared(g) if(argc) mergeable priority(argc) grainsize(argc)
+#pragma omp taskloop private(argc, b), firstprivate(argv, c), lastprivate(d, 
f) collapse(2) shared(g) if(argc) mergeable priority(argc) grainsize(argc) 
reduction(max: a, e)
   for (int i = 0; i < 10; ++i)
 for (int j = 0; j < 10; ++j)
   foo();
   // CHECK-NEXT: #pragma omp parallel
-  // CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(argv,c) 
lastprivate(d,f) collapse(2) shared(g) if(argc) mergeable priority(argc) 
grainsize(argc)
+  // CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(argv,c) 
lastprivate(d,f) collapse(2) 

[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-30 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Yes, it does indeed skip identifiers and literals for this reason :). It was 
planned to make this template more configurable for use cases like yours, so 
I'm totally fine with adding configuration parameters. I just opened 
https://reviews.llvm.org/D34880 where I make this template public as a first 
step.


https://reviews.llvm.org/D34329



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


[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-06-30 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Can you add a test? Tests for this kind of behavior of the clang-format command 
line go in test/Format/.




Comment at: tools/clang-format/ClangFormat.cpp:380
+if (Verbose.getNumOccurrences() != 0)
+outs() << "Formatting " << FileNames[0] << '\n';
 break;

As clang-format often returns the result on stdout, maybe it'd be better to use 
errs() here?


https://reviews.llvm.org/D34824



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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-30 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes marked an inline comment as done.
johannes added a comment.

In https://reviews.llvm.org/D34329#796574, @teemperor wrote:

> I didn't have time to have a close look at this patch, but it seems you're 
> interested in the specific TU-independent data of a Stmt to compare them. So 
> if you are interested in such data and don't want to write your own function 
> to collect it for each Stmt subclass, there is the `StmtDataCollector` in the 
> CloneDetection.cpp here 
>  and a 
> example how to use it is here 
> .
>
> I'm fine with moving this into a header and make it more usable for this use 
> case if you think it makes sense to use it here. The main advantage would be 
> that we don't get yet another of these classes in clang (we already have 3 of 
> them: One in the Stmt profiler code, another one in the ODRHash code for 
> modules and another one in the CloneDetection code).


Looking at this again now, it seems to make sense to consolidate this. It 
collects a lot of data I currently don't.
Does it include the values of literals / identifiers? It seems not (since it is 
geared towards detecting structural clones only).  So we could make that 
optional, or I could do that myself.


https://reviews.llvm.org/D34329



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


[clang-tools-extra] r306823 - Revert "Modify test so that it looks for patterns in stderr as well"

2017-06-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun 30 06:23:24 2017
New Revision: 306823

URL: http://llvm.org/viewvc/llvm-project?rev=306823=rev
Log:
Revert "Modify test so that it looks for patterns in stderr as well"

This reverts commit r303735. No longer needed after r306822 sends the
diagnostics to the proper output again.

Modified:
clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp?rev=306823=306822=306823=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp Fri Jun 30 06:23:24 
2017
@@ -1,11 +1,11 @@
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | 
FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: error reading '{{.*}}.nonexistent.cpp' 
[clang-diagnostic-error]
-// CHECK2: error: unknown argument: '-fan-unknown-option'
-// CHECK3: error: unknown argument: '-fan-unknown-option'
+// CHECK2: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
+// CHECK3: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
 
 // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' 
changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
 // CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' 
changes value


___
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 

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] 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


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


[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;
 

[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] 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


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] 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


[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] 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] 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


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] 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


[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


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


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] 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] 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


[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


[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] 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


[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] 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


[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


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 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] 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] 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


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


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


[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] 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


[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


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] 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] 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)
   

[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 

[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] 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


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 = 

[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 &&
 

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] 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


[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, 

[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] 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


[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 

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


[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


[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] 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] 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

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

[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] 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 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] 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] 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 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] 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


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 

  1   2   >