[libcxx] r329484 - Use void() to create a void expression type

2018-04-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Apr  6 21:28:11 2018
New Revision: 329484

URL: http://llvm.org/viewvc/llvm-project?rev=329484=rev
Log:
Use void() to create a void expression type

Modified:
libcxx/trunk/include/compare

Modified: libcxx/trunk/include/compare
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/compare?rev=329484=329483=329484=diff
==
--- libcxx/trunk/include/compare (original)
+++ libcxx/trunk/include/compare Fri Apr  6 21:28:11 2018
@@ -639,7 +639,7 @@ constexpr auto __get_comp_type() {
   constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
   : __compute_comp_type(__type_kinds);
   if constexpr (_Cat == _None)
-return ((void)0);
+return void();
   else if constexpr (_Cat == _WeakEq)
 return weak_equality::equivalent;
   else if constexpr (_Cat == _StrongEq)


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


r329481 - Sort source lists in lib/StaticAnalyzer.

2018-04-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr  6 21:25:01 2018
New Revision: 329481

URL: http://llvm.org/viewvc/llvm-project?rev=329481=rev
Log:
Sort source lists in lib/StaticAnalyzer.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt?rev=329481=329480=329481=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt Fri Apr  6 21:25:01 2018
@@ -13,7 +13,6 @@ add_clang_library(clangStaticAnalyzerCor
   AnalyzerOptions.cpp
   BasicValueFactory.cpp
   BlockCounter.cpp
-  IssueHash.cpp
   BugReporter.cpp
   BugReporterVisitors.cpp
   CallEvent.cpp
@@ -35,6 +34,7 @@ add_clang_library(clangStaticAnalyzerCor
   ExprEngineObjC.cpp
   FunctionSummary.cpp
   HTMLDiagnostics.cpp
+  IssueHash.cpp
   LoopUnrolling.cpp
   LoopWidening.cpp
   MemRegion.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt?rev=329481=329480=329481=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt Fri Apr  6 21:25:01 
2018
@@ -7,8 +7,8 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangStaticAnalyzerFrontend
   AnalysisConsumer.cpp
   CheckerRegistration.cpp
-  ModelConsumer.cpp
   FrontendActions.cpp
+  ModelConsumer.cpp
   ModelInjector.cpp
 
   LINK_LIBS


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


[PATCH] D45382: [CodeGen] Avoid destructing a struct type that has already been destructed by a delegated constructor

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If that's the problem, then I think the right design is for CallArg to include 
an optional cleanup reference for a cleanup that can be deactivated at the 
instant of the call (we should assert that this exists for parameters that are 
destroyed in the callee), and then for forwarding it's just a matter of getting 
that cleanup from parameter emission to forwarding-argument emission.


Repository:
  rC Clang

https://reviews.llvm.org/D45382



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


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Just a couple minor requests; if you accept them, feel free to commit.




Comment at: include/clang/AST/Decl.h:3556
+/// indirectly. This value is used only in C++.
+APK_CannotPassInRegs,
+

I think it's probably worth spelling out why this can happen in C++, something 
like:

  This value in required by C++ because, in uncommon situations, it is possible 
for a class to have only trivial copy/move constructors even when one of its 
subobjects has a non-trivial copy/move constructor (if e.g. the corresponding 
copy/move constructor in the derived class is deleted).



Comment at: include/clang/AST/Decl.h:3601
+  /// Represents the way this type is passed to a function.
+  ArgPassingKind ArgPassingStyle : 2;
+

I think maybe "ArgPassingRestrictions" would be better, since we don't 
necessarily honor this in the ABI.


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


r329477 - Make CodeGen depend just once on clangAnalysis.

2018-04-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr  6 20:29:47 2018
New Revision: 329477

URL: http://llvm.org/viewvc/llvm-project?rev=329477=rev
Log:
Make CodeGen depend just once on clangAnalysis.

Modified:
cfe/trunk/lib/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=329477=329476=329477=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Fri Apr  6 20:29:47 2018
@@ -94,7 +94,6 @@ add_clang_library(clangCodeGen
   LINK_LIBS
   clangAnalysis
   clangAST
-  clangAnalysis
   clangBasic
   clangFrontend
   clangLex


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


[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This looks okay to me, but I think it would better if someone with more 
expertise in the design of the driver and frontend code could review this.




Comment at: lib/Driver/Driver.cpp:2267
+if ((IA->getType() != types::TY_CUDA) &&
+IA->getType() != types::TY_HIP) {
   // The builder will ignore this input.

The extra parens are weird here.


https://reviews.llvm.org/D45212



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


Re: r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"

2018-04-06 Thread Nico Weber via cfe-commits
Hi Yuka,

sorry about the late review comment on this. I just happened to see that
this lets Driver's Option.inc depend on StaticAnalyzer/Checker's
Checker.inc. However, Driver does not depend on StaticAnalyzer/Checker. In
practice, it works ok because of all tablegen targets being collected
into clang-tablegen-targets and driver depending on that (
http://llvm-cs.pcc.me.uk/tools/clang/CMakeLists.txt#442), but it still
feels a bit hacky that Driver's tablegen output depends on code generated
by StaticAnalyzer/Checker. Maybe we should move Checker.td into Driver now?

Nico

On Mon, Aug 28, 2017 at 8:09 PM, Yuka Takahashi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yamaguchi
> Date: Mon Aug 28 17:09:31 2017
> New Revision: 311958
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311958=rev
> Log:
> Revert "Revert r311552: [Bash-autocompletion] Add support for static
> analyzer flags"
>
> This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e.
>
> r311552 broke lld buildbot because I've changed OptionInfos type from
> ArrayRef to vector. However the bug is fixed, so I'll commit this again.
>
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/lib/Driver/DriverOptions.cpp
> cfe/trunk/test/Driver/autocomplete.c
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/CC1Options.td?rev=311958=311957=311958=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 2017
> @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz
>HelpText<"Print internal analyzer statistics.">;
>
>  def analyzer_checker : Separate<["-"], "analyzer-checker">,
> -  HelpText<"Choose analyzer checkers to enable">;
> +  HelpText<"Choose analyzer checkers to enable">,
> +  ValuesCode<[{
> +const char *Values =
> +#define GET_CHECKERS
> +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H)  FULLNAME ","
> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
> +#undef GET_CHECKERS
> +#define GET_PACKAGES
> +#define PACKAGE(FULLNAME, G, D)  FULLNAME ","
> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
> +#undef GET_PACKAGES
> +;
> +  }]>;
>  def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">,
>Alias;
>
>
> Modified: cfe/trunk/lib/Driver/DriverOptions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> DriverOptions.cpp?rev=311958=311957=311958=diff
> 
> ==
> --- cfe/trunk/lib/Driver/DriverOptions.cpp (original)
> +++ cfe/trunk/lib/Driver/DriverOptions.cpp Mon Aug 28 17:09:31 2017
> @@ -11,6 +11,7 @@
>  #include "llvm/ADT/STLExtras.h"
>  #include "llvm/Option/OptTable.h"
>  #include "llvm/Option/Option.h"
> +#include 
>
>  using namespace clang::driver;
>  using namespace clang::driver::options;
> @@ -40,5 +41,13 @@ public:
>  }
>
>  std::unique_ptr clang::driver::createDriverOptTable() {
> -  return llvm::make_unique();
> +  auto Result = llvm::make_unique();
> +  // Options.inc is included in DriverOptions.cpp, and calls OptTable's
> +  // addValues function.
> +  // Opt is a variable used in the code fragment in Options.inc.
> +  OptTable  = *Result;
> +#define OPTTABLE_ARG_INIT
> +#include "clang/Driver/Options.inc"
> +#undef OPTTABLE_ARG_INIT
> +  return std::move(Result);
>  }
>
> Modified: cfe/trunk/test/Driver/autocomplete.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/
> autocomplete.c?rev=311958=311957=311958=diff
> 
> ==
> --- cfe/trunk/test/Driver/autocomplete.c (original)
> +++ cfe/trunk/test/Driver/autocomplete.c Mon Aug 28 17:09:31 2017
> @@ -93,3 +93,5 @@
>  // WARNING-NEXT: -Wmax-unsigned-zero
>  // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s
> -check-prefix=NOWARNING
>  // NOWARNING: -Wno-invalid-pp-token
> +// RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s
> -check-prefix=ANALYZER
> +// ANALYZER: unix.Malloc
>
>
> ___
> 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


RE: [clang-tools-extra] r329454 - [clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: find_if predicate

2018-04-06 Thread via cfe-commits
Hi Zinovy,

The PS4 Windows bot is still failing to compile this file after your latest 
change. Can you take a look?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16316

FAILED: 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/clangTidyBugproneModule.dir/ParentVirtualCallCheck.cpp.obj
 
C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 
-D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_LARGEFILE_SOURCE 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools\clang\tools\extra\clang-tidy\bugprone 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\clang-tidy\bugprone
 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\include
 -Itools\clang\include -Iinclude 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include
 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
-wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 
-wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 
-wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 
-wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 
-we4238 /MD /O2 /Ob2   -UNDEBUG  /EHs-c- /GR- /showIncludes 
/Fotools\clang\tools\extra\clang-tidy\bugprone\CMakeFiles\clangTidyBugproneModule.dir\ParentVirtualCallCheck.cpp.obj
 
/Fdtools\clang\tools\extra\clang-tidy\bugprone\CMakeFiles\clangTidyBugproneModule.dir\clangTidyBugproneModule.pdb
 /FS -c 
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\clang-tidy\bugprone\ParentVirtualCallCheck.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\algorithm(95): 
error C2719: '_Pred': formal parameter with requested alignment of 8 won't be 
aligned
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\clang-tidy\bugprone\ParentVirtualCallCheck.cpp(36):
 note: see reference to function template instantiation '_InIt 
*std::find_if(_InIt,_InIt,_Pr)'
 being compiled
with
[
_InIt=clang::CXXRecordDecl::base_class_const_iterator,
IteratorT=clang::CXXRecordDecl::base_class_const_iterator,

_Pr=clang::tidy::bugprone::isParentOf::
]

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Zinovy Nis via cfe-commits
> Sent: Friday, April 06, 2018 14:00
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r329454 - [clang-tidy] One more fix compilation
> for ParentVirtualCallCheck.cpp: find_if predicate
> 
> Author: zinovy.nis
> Date: Fri Apr  6 14:00:18 2018
> New Revision: 329454
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329454=rev
> Log:
> [clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: find_if
> predicate
> 
> 
> Modified:
> clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
> 
> Modified: clang-tools-extra/trunk/clang-
> tidy/bugprone/ParentVirtualCallCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329454=329453=329454=d
> iff
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.c
> +++ pp Fri Apr  6 14:00:18 2018
> @@ -76,8 +76,11 @@ static std::string getNameAsString(const  static
> std::string getExprAsString(const clang::Expr ,
> clang::ASTContext ) {
>std::string Text = tooling::fixit::getText(E, AC).str();
> -  Text.erase(std::remove_if(Text.begin(), Text.end(), std::isspace),
> - Text.end());
> +  Text.erase(
> +  std::remove_if(
> +  Text.begin(), Text.end(),
> +  [](char c) { return std::isspace(static_cast(c));
> }),
> +  Text.end());
>return Text;
>  }
> 
> 
> 
> ___
> 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] D44988: [Sema] Fix decrement availability for built-in types

2018-04-06 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: test/SemaCXX/overloaded-builtin-operators.cpp:95-99
   // C++ [over.built]p3
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;

Looks like p3 for `lr--` is a typo because p3 is about `++` while p4 is about 
`--`. It means the existing test didn't catch this bug. Not sure that adding 
another positive test will reliably prevent a regression in the future. 
Currently `FloatRef` is the type to expose the bug because `FloatTy` is the 
first type in `ArithmeticTypes`.

What if we add a negative test? I.e. something that would fail like
```
cannot decrement value of type 'BoolRef'
```
Also we can improve testing for p3 and test that `BoolRef` does support 
increment.


Repository:
  rC Clang

https://reviews.llvm.org/D44988



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


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 141471.
ahatanak added a comment.

Replace flags CanPassInRegisters and CannotPassInRegisters with a 2-bit enum in 
RecordDecl.


Repository:
  rC Clang

https://reviews.llvm.org/D45384

Files:
  include/clang/AST/Decl.h
  include/clang/AST/Type.h
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Index: test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -8,6 +8,8 @@
 // pointer fields are passed directly.
 
 // CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
+// CHECK: %[[STRUCT_CONTAINSSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
+// CHECK: %[[STRUCT_DERIVEDSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
 // CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
 // CHECK: %[[STRUCT_S:.*]] = type { i8* }
 // CHECK: %[[STRUCT_CONTAINSNONTRIVIAL:.*]] = type { %{{.*}}, i8* }
@@ -21,6 +23,21 @@
   __weak id fweak;
 };
 
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) ContainsStrongWeak {
+#else
+struct ContainsStrongWeak {
+#endif
+  StrongWeak sw;
+};
+
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) DerivedStrongWeak : StrongWeak {
+#else
+struct DerivedStrongWeak : StrongWeak {
+#endif
+};
+
 #ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) Strong {
 #else
@@ -84,6 +101,18 @@
   return *a;
 }
 
+// CHECK: define void @_Z27testParamContainsStrongWeak18ContainsStrongWeak(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_CONTAINSSTRONGWEAK]]* @_ZN18ContainsStrongWeakD1Ev(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A]])
+
+void testParamContainsStrongWeak(ContainsStrongWeak a) {
+}
+
+// CHECK: define void @_Z26testParamDerivedStrongWeak17DerivedStrongWeak(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_DERIVEDSTRONGWEAK]]* @_ZN17DerivedStrongWeakD1Ev(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A]])
+
+void testParamDerivedStrongWeak(DerivedStrongWeak a) {
+}
+
 // CHECK: define void @_Z15testParamStrong6Strong(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONG]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[A]], i32 0, i32 0
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -469,8 +469,8 @@
   Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
   Record.push_back(D->isNonTrivialToPrimitiveCopy());
   Record.push_back(D->isNonTrivialToPrimitiveDestroy());
-  Record.push_back(D->canPassInRegisters());
   Record.push_back(D->isParamDestroyedInCallee());
+  Record.push_back(D->getArgPassingStyle());
 
   if (D->getDeclContext() == D->getLexicalDeclContext() &&
   !D->hasAttrs() &&
@@ -1913,9 +1913,9 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
   // isNonTrivialToPrimitiveDestroy
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // canPassInRegisters
   // isParamDestroyedInCallee
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getArgPassingStyle
 
   // DC
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));   // LexicalOffset
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5193,8 +5193,8 @@
   case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
 auto *RD = cast(D);
 UpdatedDeclContexts.insert(RD->getPrimaryContext());
-Record.push_back(RD->canPassInRegisters());
 Record.push_back(RD->isParamDestroyedInCallee());
+Record.push_back(RD->getArgPassingStyle());
 Record.AddCXXDefinitionData(RD);
 Record.AddOffset(WriteDeclContextLexicalBlock(
 *Context, const_cast(RD)));
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -742,8 +742,8 @@
   RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
   RD->setNonTrivialToPrimitiveCopy(Record.readInt());
   RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
-  RD->setCanPassInRegisters(Record.readInt());
   RD->setParamDestroyedInCallee(Record.readInt());
+  RD->setArgPassingStyle((RecordDecl::ArgPassingKind)Record.readInt());
   return Redecl;
 }
 
@@ -4114,8 +4114,8 @@
   bool HadRealDefinition =
   OldDD && (OldDD->Definition != RD ||
 

r329476 - Remove another unnecessary -I flag passed to clang-tblgen.

2018-04-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr  6 18:34:36 2018
New Revision: 329476

URL: http://llvm.org/viewvc/llvm-project?rev=329476=rev
Log:
Remove another unnecessary -I flag passed to clang-tblgen.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/CMakeLists.txt?rev=329476=329475=329476=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/CMakeLists.txt Fri Apr  6 
18:34:36 2018
@@ -1,4 +1,3 @@
 clang_tablegen(Checkers.inc -gen-clang-sa-checkers
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../
   SOURCE Checkers.td
   TARGET ClangSACheckers)

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=329476=329475=329476=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Fri Apr  6 
18:34:36 2018
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-include "clang/StaticAnalyzer/Checkers/CheckerBase.td"
+include "CheckerBase.td"
 
 
//===--===//
 // Packages.


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


[libcxx] r329474 - Work around missing braces in init warning

2018-04-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Apr  6 18:28:54 2018
New Revision: 329474

URL: http://llvm.org/viewvc/llvm-project?rev=329474=rev
Log:
Work around missing braces in init warning

Modified:
libcxx/trunk/include/compare

Modified: libcxx/trunk/include/compare
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/compare?rev=329474=329473=329474=diff
==
--- libcxx/trunk/include/compare (original)
+++ libcxx/trunk/include/compare Fri Apr  6 18:28:54 2018
@@ -635,7 +635,7 @@ __compute_comp_type(std::array<_Classify
 template 
 constexpr auto __get_comp_type() {
   using _CCC = _ClassifyCompCategory;
-  constexpr array<_CCC, sizeof...(_Ts)> 
__type_kinds{__comp_detail::__type_to_enum<_Ts>()...};
+  constexpr array<_CCC, sizeof...(_Ts)> 
__type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
   constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
   : __compute_comp_type(__type_kinds);
   if constexpr (_Cat == _None)


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


[PATCH] D43957: Fixing issue where a space was not added before a global namespace variable when SpacesInParentheses is set

2018-04-06 Thread Darby Payne via Phabricator via cfe-commits
dpayne added a comment.

Hi

Bumping this commit. I do not have commit access so I cannot merge myself, if 
you have the time could you merge this commit?


Repository:
  rC Clang

https://reviews.llvm.org/D43957



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


r329467 - Generalize test for 32-bit targets.

2018-04-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr  6 17:28:32 2018
New Revision: 329467

URL: http://llvm.org/viewvc/llvm-project?rev=329467=rev
Log:
Generalize test for 32-bit targets.

Modified:
cfe/trunk/test/CodeGenCXX/tail-padding.cpp

Modified: cfe/trunk/test/CodeGenCXX/tail-padding.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/tail-padding.cpp?rev=329467=329466=329467=diff
==
--- cfe/trunk/test/CodeGenCXX/tail-padding.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/tail-padding.cpp Fri Apr  6 17:28:32 2018
@@ -11,7 +11,7 @@ namespace Implicit {
   // CHECK: define {{.*}} @_ZN8Implicit1CC1EOS0_
   // CHECK: call {{.*}} @_ZN8Implicit1AC2ERKS0_(
   // Note: this must memcpy 7 bytes, not 8, to avoid trampling over the 
virtual base class.
-  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 
7, i1 false)
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i{{32|64}}(i8* {{.*}}, i8* 
{{.*}}, i{{32|64}} 7, i1 false)
   // CHECK: store i32 {{.*}} @_ZTVN8Implicit1CE
 }
 
@@ -28,7 +28,7 @@ namespace InitWithinNVSize {
   // CHECK: define {{.*}} @_ZN16InitWithinNVSize1CC1EOS0_
   // CHECK: call {{.*}} @_ZN16InitWithinNVSize1AC2ERKS0_(
   // This copies over the 'C::x' member, but that's OK because we've not 
initialized it yet.
-  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 
8, i1 false)
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i{{32|64}}(i8* {{.*}}, i8* 
{{.*}}, i{{32|64}} 8, i1 false)
   // CHECK: store i32 {{.*}} @_ZTVN16InitWithinNVSize1CE
   // CHECK: store i8
 }


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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

If this is Apple guideline, check name should reflect this. I think will be 
good idea to have general check for Apple naming conventions instead of 
separate checks for specific situations like //objc-ivar-declaration// and 
//objc-property-declaration//.




Comment at: clang-tidy/objc/IvarDeclarationCheck.cpp:23
+
+FixItHint generateFixItHint(const ObjCIvarDecl *Decl) {
+  auto IvarName = Decl->getName();

Please use static instead of anonymous namespace.



Comment at: clang-tidy/objc/IvarDeclarationCheck.cpp:24
+FixItHint generateFixItHint(const ObjCIvarDecl *Decl) {
+  auto IvarName = Decl->getName();
+  if (IvarName[0] != '_') {

Please don't use auto when type could not be deduced from statement. Same in 
other places.



Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`objc-ivar-declaration
+  ` check

Please place in new check list in alphabetical order.



Comment at: docs/ReleaseNotes.rst:63
+
+  New check that finds Objective-C ivars that do not have a '_' prefix.
+

Please remove //New check that//.



Comment at: docs/clang-tidy/checks/objc-ivar-declaration.rst:6
+
+Finds ivar declarations in Objective-C files that do not follow the pattern
+in Apple's programming guide. The ivar name should be fixed with '_'.

Please synchronize first statement with Release Notes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


r329465 - Recommit r329442: Generate Libclang invocation reproducers using a new

2018-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr  6 17:03:27 2018
New Revision: 329465

URL: http://llvm.org/viewvc/llvm-project?rev=329465=rev
Log:
Recommit r329442: Generate Libclang invocation reproducers using a new
-cc1gen-reproducer driver option

The recommit fixes:
- An MSAN failure (CCPrintOptions wasn't initialized in the Driver)
- Ensures that the strings in the libclang invocation files are escaped

Original message:

This commit is a follow up to the previous work that recorded Libclang 
invocations
into temporary files: r319702.

It adds a new -cc1 mode to clang: -cc1gen-reproducer. The goal of this mode is 
to generate
Clang reproducer files for Libclang tool invocation. The JSON format in the 
invocation
files is not really intended to be stable, so Libclang and Clang should be of 
the same version
when generating reproducers.
The new mode emits the information about the temporary files and 
Libclang-specific information
to stdout using JSON.

rdar://35322614

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

Added:
cfe/trunk/test/Index/create-libclang-completion-reproducer.c
cfe/trunk/test/Index/create-libclang-parsing-reproducer.c
cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/tools/driver/driver.cpp
cfe/trunk/tools/libclang/CIndexer.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=329465=329464=329465=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Apr  6 17:03:27 2018
@@ -405,11 +405,19 @@ public:
   int ExecuteCompilation(Compilation ,
  SmallVectorImpl< std::pair > );
 
-  /// generateCompilationDiagnostics - Generate diagnostics information 
+  /// Contains the files in the compilation diagnostic report generated by
+  /// generateCompilationDiagnostics.
+  struct CompilationDiagnosticReport {
+llvm::SmallVector TemporaryFiles;
+  };
+
+  /// generateCompilationDiagnostics - Generate diagnostics information
   /// including preprocessed source file(s).
-  /// 
-  void generateCompilationDiagnostics(Compilation ,
-  const Command );
+  ///
+  void generateCompilationDiagnostics(
+  Compilation , const Command ,
+  StringRef AdditionalInformation = "",
+  CompilationDiagnosticReport *GeneratedReport = nullptr);
 
   /// @}
   /// @name Helper Methods

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=329465=329464=329465=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Apr  6 17:03:27 2018
@@ -89,14 +89,14 @@ Driver::Driver(StringRef ClangExecutable
 : Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)),
   Mode(GCCMode), SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
   LTOMode(LTOK_None), ClangExecutable(ClangExecutable),
-  SysRoot(DEFAULT_SYSROOT), 
-  DriverTitle("clang LLVM compiler"), CCPrintOptionsFilename(nullptr),
-  CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
-  CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false),
+  SysRoot(DEFAULT_SYSROOT), DriverTitle("clang LLVM compiler"),
+  CCPrintOptionsFilename(nullptr), CCPrintHeadersFilename(nullptr),
+  CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false),
+  CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), DefaultTargetTriple(DefaultTargetTriple),
-  CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), CCCUsePCH(true),
-  GenReproducer(false), SuppressMissingInputWarning(false) {
+  CCCGenericGCCName(""), Saver(Alloc), CheckInputsExist(true),
+  CCCUsePCH(true), GenReproducer(false),
+  SuppressMissingInputWarning(false) {
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -,8 +,9 @@ bool Driver::getCrashDiagnosticFile(Stri
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
-void Driver::generateCompilationDiagnostics(Compilation ,
-const Command ) {
+void Driver::generateCompilationDiagnostics(
+Compilation , const Command ,
+StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
@@ -1238,6 +1239,8 @@ void Driver::generateCompilationDiagnost
   

[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName

2018-04-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

There is no unittest but I have verified with a C++ language server on Arch 
Linux. Without using this function, cquery/ccls will not be able to index 
system header files because of excessive .. in the path returned by 
clang_getFileName.


Repository:
  rC Clang

https://reviews.llvm.org/D42893



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


r329464 - Remove two unnecessary -I flags passed to clang-tblgen.

2018-04-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr  6 16:36:50 2018
New Revision: 329464

URL: http://llvm.org/viewvc/llvm-project?rev=329464=rev
Log:
Remove two unnecessary -I flags passed to clang-tblgen.

Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=329464=329463=329464=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Fri Apr  6 16:36:50 2018
@@ -43,10 +43,8 @@ clang_tablegen(AttrHasAttributeImpl.inc
 
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE arm_neon.td
   TARGET ClangARMNeon)
 clang_tablegen(arm_fp16.inc -gen-arm-neon-sema
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE arm_fp16.td
   TARGET ClangARMFP16)


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


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D45384#1060369, @ahatanak wrote:

> Yes. I intended it as a property that propagates to classes that contain or 
> derive from the type.
>
> Would it make it less confusing if I merged CXXRecordDecl::CanPassInRegisters 
> and RecordDecl::CannotPassInRegisters into a single enum? For example, the 
> enum could have three enumerators, "CanPass", "CannotPass", "CanNeverPass", 
> or something. Both "CannotPass" and "CanNeverPass" would force the type to be 
> passed indirectly, and the only difference is that "CanNeverPass" propagates 
> its property outwards and "CannotPass" doesn't. C structs are either 
> "CanPass" or "CanNeverPass" while C++ structs can take any of the three 
> values.


Yes, I think that would help a lot.


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-06 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 141450.
DHowett-MSFT added a comment.

Added a test per @rjmccall's suggestion. I chose to test this by emitting 
assembly because the llvm ir is significantly harder to pick apart for the true 
_size_ of the protocol.


Repository:
  rC Clang

https://reviews.llvm.org/D45305

Files:
  lib/CodeGen/CGObjCGNU.cpp
  test/CodeGenObjC/undefined-protocol-v3.m


Index: test/CodeGenObjC/undefined-protocol-v3.m
===
--- /dev/null
+++ test/CodeGenObjC/undefined-protocol-v3.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -S -o 
- %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK-DAG: .objc_protocol:
+// CHECK-DAG:   .long 3
+// CHECK-DAG:   .size   .objc_protocol, 36
Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1813,11 +1813,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }


Index: test/CodeGenObjC/undefined-protocol-v3.m
===
--- /dev/null
+++ test/CodeGenObjC/undefined-protocol-v3.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -S -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK-DAG: .objc_protocol:
+// CHECK-DAG:   .long 3
+// CHECK-DAG:   .size   .objc_protocol, 36
Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1813,11 +1813,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-04-06 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

Thanks! I don't have the means to check this in myself.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D45382: [CodeGen] Avoid destructing a struct type that has already been destructed by a delegated constructor

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D45382#1060163, @rjmccall wrote:

> Hmm.  I'm not actually sure *why* it's not okay to forward callee-cleanup 
> arguments.  Do we just not have the necessary logic to disable the cleanup in 
> the caller?


It seems that it would be OK if there was a way to disable the cleanup in the 
caller when we know that we are delegating to another constructor, possibly by 
setting the DelegateCXXConstructorCall here too. But maybe there are other 
reasons for not doing so.

Perhaps Richard (who committed r274049) knows why we can't call the delegated 
constructor when there are callee-cleanup arguments?


Repository:
  rC Clang

https://reviews.llvm.org/D45382



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


[PATCH] D44449: [Parser] Fix assertion-on-invalid for unexpected typename.

2018-04-06 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 141448.
vsapsai added a comment.

- Add a comment.


https://reviews.llvm.org/D9

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/cxx-decl.cpp


Index: clang/test/Parser/cxx-decl.cpp
===
--- clang/test/Parser/cxx-decl.cpp
+++ clang/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 
'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration 
specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all 
declarations}}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3799,7 +3799,8 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  // After an error the next token can be an annotation token.
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }


Index: clang/test/Parser/cxx-decl.cpp
===
--- clang/test/Parser/cxx-decl.cpp
+++ clang/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3799,7 +3799,8 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  // After an error the next token can be an annotation token.
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45357: [XRay][llvm+clang] Consolidate attribute list files

2018-04-06 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich accepted this revision.
vlad.tsyrklevich added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/docs/XRayExample.rst:196
+``-fxray-attr-list=`` flag to clang. You can have multiple files, each defining
+different sets of attribute sets, to be cobined into a single list by clang.
 

combined*


https://reviews.llvm.org/D45357



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


[PATCH] D45392: add new check to find out objc ivars which do not have prefix '_'

2018-04-06 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 141444.
Wizard added a comment.

fix doc


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/IvarDeclarationCheck.cpp
  clang-tidy/objc/IvarDeclarationCheck.h
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-ivar-declaration.rst
  test/clang-tidy/objc-ivar-declaration.m

Index: test/clang-tidy/objc-ivar-declaration.m
===
--- /dev/null
+++ test/clang-tidy/objc-ivar-declaration.m
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s objc-ivar-declaration %t
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: instance variable 'barWithoutPrefix' not using '_' as prefix [objc-ivar-declaration]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: docs/clang-tidy/checks/objc-ivar-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-ivar-declaration.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - objc-ivar-declaration
+
+objc-ivar-declaration
+=
+
+Finds ivar declarations in Objective-C files that do not follow the pattern
+in Apple's programming guide. The ivar name should be fixed with '_'.
+
+For code of ivar declaration:
+
+.. code-block:: objc
+
+   int barWithoutPrefix;
+
+The fix will be:
+
+.. code-block:: objc
+
+   int _barWithoutPrefix;
+
+The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -187,6 +187,7 @@
objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
+   objc-ivar-declaration
objc-property-declaration
performance-faster-string-find
performance-for-range-copy
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`objc-ivar-declaration
+  ` check
+
+  New check that finds Objective-C ivars that do not have a '_' prefix.
+
 - New module `abseil` for checks related to the `Abseil `_
   library.
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
+#include "IvarDeclarationCheck.h"
 #include "PropertyDeclarationCheck.h"
 
 using namespace clang::ast_matchers;
@@ -30,6 +31,8 @@
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
 "objc-forbidden-subclassing");
+CheckFactories.registerCheck(
+"objc-ivar-declaration");
 CheckFactories.registerCheck(
 "objc-property-declaration");
   }
Index: clang-tidy/objc/IvarDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- IvarDeclarationCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds Objective-C ivars which do not have '_' prefix.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-ivar-declaration.html
+class IvarDeclarationCheck : public ClangTidyCheck {
+public:
+  IvarDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace objc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
Index: clang-tidy/objc/IvarDeclarationCheck.cpp
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.cpp
@@ -0,0 +1,52 @@
+//===--- IvarDeclarationCheck.cpp - 

[PATCH] D45392: add new check to find out objc ivars which do not have prefix '_'

2018-04-06 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added subscribers: cfe-commits, mgorny, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/IvarDeclarationCheck.cpp
  clang-tidy/objc/IvarDeclarationCheck.h
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-ivar-declaration.rst
  test/clang-tidy/objc-ivar-declaration.m

Index: test/clang-tidy/objc-ivar-declaration.m
===
--- /dev/null
+++ test/clang-tidy/objc-ivar-declaration.m
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s objc-ivar-declaration %t
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: instance variable 'barWithoutPrefix' not using '_' as prefix [objc-ivar-declaration]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: docs/clang-tidy/checks/objc-ivar-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-ivar-declaration.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - objc-ivar-declaration
+
+objc-ivar-declaration
+=
+
+Finds ivar declarations in Objective-C files that do not follow the pattern
+in Apple's programming guide. The ivar name should be fixed with '_'.
+
+For code of ivar declaration:
+
+.. code-block:: objc
+
+   int barWithoutPrefix;
+
+The fix will be:
+
+.. code-block:: objc
+
+   int _barWithoutPrefix;
+
+The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -187,6 +187,7 @@
objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
+   objc-ivar-declaration
objc-property-declaration
performance-faster-string-find
performance-for-range-copy
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`objc-ivar-declaration
+  ` check
+
+  New check that finds Objective-C ivars that do not have a '_' prefix.
+
 - New module `abseil` for checks related to the `Abseil `_
   library.
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
+#include "IvarDeclarationCheck.h"
 #include "PropertyDeclarationCheck.h"
 
 using namespace clang::ast_matchers;
@@ -30,6 +31,8 @@
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
 "objc-forbidden-subclassing");
+CheckFactories.registerCheck(
+"objc-ivar-declaration");
 CheckFactories.registerCheck(
 "objc-property-declaration");
   }
Index: clang-tidy/objc/IvarDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- IvarDeclarationCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds Objective-C ivars which do not have '_' prefix.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-ivar-declaration.html
+class IvarDeclarationCheck : public ClangTidyCheck {
+public:
+  IvarDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace objc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_IVARDECLARATIONCHECK_H
Index: clang-tidy/objc/IvarDeclarationCheck.cpp
===
--- /dev/null
+++ clang-tidy/objc/IvarDeclarationCheck.cpp
@@ -0,0 +1,52 @@
+//===--- 

[PATCH] D44449: [Parser] Fix assertion-on-invalid for unexpected typename.

2018-04-06 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:3076
 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
 ConsumeAnnotationToken(); // The typename
   }

rsmith wrote:
> vsapsai wrote:
> > Here we potentially can leave annotation token unconsumed. But I wasn't 
> > able to create a test case that would trigger a problem at this point.
> I think you're talking about the `break` a few lines back?
> 
> I think we actually get away with this, but only because `SetTypeSpecType` 
> can only fail if there was already a type specifier, which we checked for on 
> line 3019, so `isInvalid` is never `true`.
You are right, I was talking about `break` on the line 3071.



Comment at: clang/lib/Parse/ParseDecl.cpp:3148
   DS.SetRangeEnd(Tok.getAnnotationEndLoc());
   ConsumeAnnotationToken(); // The typename
 

rsmith wrote:
> vsapsai wrote:
> > We didn't consume the annotation token because of `break` on `isInvalid` a 
> > few lines above.
> I wonder if our error recovery would be improved by changing line 3134 to just
> 
> ```if (DS.hasTypeSpecifier())```
> 
> (which would likewise render the `break` here unreachable given the current 
> rules enforced by `SetTypeSpecType`).
Change in if condition fixes the assertion too and the diagnostics are
```
repro.cpp:1:18: error: expected a qualified name after 'typename'
class A typename A;
 ^
repro.cpp:1:18: error: expected unqualified-id
2 errors generated.
```

With the currently reviewed change diagnostics are
```
repro.cpp:1:18: error: expected a qualified name after 'typename'
class A typename A;
 ^
repro.cpp:1:18: error: cannot combine with previous 'class' declaration 
specifier
2 errors generated.
```

This is for the file
```
$ cat repro.cpp 
class A typename A;
```

This small test isn't representable but I find showing next to each other
> expected a qualified name
> expected unqualified-id
confusing and contradictory at the first glance.

If there are no further comments, I'll commit the change as is (after adding a 
comment for ConsumeAnyToken).



Comment at: clang/lib/Parse/ParseDecl.cpp:3802
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  ConsumeAnyToken();
 

rsmith wrote:
> Maybe add a comment here saying we can get here with an annotation token 
> after an error?
Will do.


https://reviews.llvm.org/D9



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


[PATCH] D44773: [CMake] Use custom command and target to install libc++ headers

2018-04-06 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 141442.
phosek marked an inline comment as done.

Repository:
  rCXX libc++

https://reviews.llvm.org/D44773

Files:
  libcxx/NOTES.TXT
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/lib/CMakeLists.txt

Index: libcxx/lib/CMakeLists.txt
===
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -283,7 +283,8 @@
 endif()
 
 # Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS} ${generated_config_deps})
+add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS})
+add_dependencies(cxx cxx-headers)
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
Index: libcxx/include/CMakeLists.txt
===
--- libcxx/include/CMakeLists.txt
+++ libcxx/include/CMakeLists.txt
@@ -1,5 +1,181 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+set(files
+  __bit_reference
+  __bsd_locale_defaults.h
+  __bsd_locale_fallbacks.h
+  __debug
+  __functional_03
+  __functional_base
+  __functional_base_03
+  __hash_table
+  __libcpp_version
+  __locale
+  __mutex_base
+  __nullptr
+  __split_buffer
+  __sso_allocator
+  __std_stream
+  __string
+  __threading_support
+  __tree
+  __tuple
+  __undef_macros
+  algorithm
+  any
+  array
+  atomic
+  bitset
+  cassert
+  ccomplex
+  cctype
+  cerrno
+  cfenv
+  cfloat
+  chrono
+  cinttypes
+  ciso646
+  climits
+  clocale
+  cmath
+  codecvt
+  complex
+  complex.h
+  condition_variable
+  csetjmp
+  csignal
+  cstdarg
+  cstdbool
+  cstddef
+  cstdint
+  cstdio
+  cstdlib
+  cstring
+  ctgmath
+  ctime
+  ctype.h
+  cwchar
+  cwctype
+  deque
+  errno.h
+  exception
+  experimental/__config
+  experimental/__memory
+  experimental/algorithm
+  experimental/any
+  experimental/chrono
+  experimental/coroutine
+  experimental/deque
+  experimental/dynarray
+  experimental/filesystem
+  experimental/forward_list
+  experimental/functional
+  experimental/iterator
+  experimental/list
+  experimental/map
+  experimental/memory_resource
+  experimental/numeric
+  experimental/optional
+  experimental/propagate_const
+  experimental/ratio
+  experimental/regex
+  experimental/set
+  experimental/string
+  experimental/string_view
+  experimental/system_error
+  experimental/tuple
+  experimental/type_traits
+  experimental/unordered_map
+  experimental/unordered_set
+  experimental/utility
+  experimental/vector
+  ext/__hash
+  ext/hash_map
+  ext/hash_set
+  float.h
+  forward_list
+  fstream
+  functional
+  future
+  initializer_list
+  inttypes.h
+  iomanip
+  ios
+  iosfwd
+  iostream
+  istream
+  iterator
+  limits
+  limits.h
+  list
+  locale
+  locale.h
+  map
+  math.h
+  memory
+  module.modulemap
+  mutex
+  new
+  numeric
+  optional
+  ostream
+  queue
+  random
+  ratio
+  regex
+  scoped_allocator
+  set
+  setjmp.h
+  shared_mutex
+  sstream
+  stack
+  stdbool.h
+  stddef.h
+  stdexcept
+  stdint.h
+  stdio.h
+  stdlib.h
+  streambuf
+  string
+  string.h
+  string_view
+  strstream
+  system_error
+  tgmath.h
+  thread
+  tuple
+  type_traits
+  typeindex
+  typeinfo
+  unordered_map
+  unordered_set
+  utility
+  valarray
+  variant
+  vector
+  wchar.h
+  wctype.h
+  )
+
+if(LIBCXX_INSTALL_SUPPORT_HEADERS)
+  set(files
+${files}
+support/android/locale_bionic.h
+support/fuchsia/xlocale.h
+support/ibm/limits.h
+support/ibm/locale_mgmt_aix.h
+support/ibm/support.h
+support/ibm/xlocale.h
+support/musl/xlocale.h
+support/newlib/xlocale.h
+support/solaris/floatingpoint.h
+support/solaris/wchar.h
+support/solaris/xlocale.h
+support/win32/limits_msvc_win32.h
+support/win32/locale_win32.h
+support/xlocale/__nop_locale_mgmt.h
+support/xlocale/__posix_l_fallback.h
+support/xlocale/__strtonum_fallback.h
+support/xlocale/xlocale.h
+)
 endif()
 
 if (LIBCXX_NEEDS_SITE_CONFIG)
@@ -14,44 +190,56 @@
 ${LIBCXX_BINARY_DIR}/__config_site
   )
   # Add a target that executes the generation commands.
-  add_custom_target(generate_config_header ALL
+  add_custom_target(cxx-generated-config ALL
 DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
-  set(generated_config_deps generate_config_header)
+  set(generated_config_deps cxx-generated-config)
+else()
+  set(files
+${files}
+__config
+)
 endif()
 
-set(LIBCXX_HEADER_PATTERN
-  PATTERN "*"
-  PATTERN "CMakeLists.txt" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  PATTERN "__config_site.in" EXCLUDE
-  ${LIBCXX_SUPPORT_HEADER_PATTERN}
-  )
-
 if(NOT LIBCXX_USING_INSTALLED_LLVM AND LLVM_BINARY_DIR)
-  file(COPY .
-DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
-FILES_MATCHING
-${LIBCXX_HEADER_PATTERN}
-)
+  set(output_dir ${LLVM_BINARY_DIR}/include/c++/v1)
+
+  set(out_files)
+  foreach(f 

[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Yes. I intended it as a property that propagates to classes that contain or 
derive from the type.

Would it make it less confusing if I merged CXXRecordDecl::CanPassInRegisters 
and RecordDecl::CannotPassInRegisters into a single enum? For example, the enum 
could have three enumerators, "CanPass", "CannotPass", "CanNeverPass", or 
something. Both "CannotPass" and "CanNeverPass" would force the type to be 
passed indirectly, and the only difference is that "CanNeverPass" propagates 
its property outwards and "CannotPass" doesn't. C structs are either "CanPass" 
or "CanNeverPass" while C++ structs can take any of the three values.


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-06 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 141436.
timshen marked an inline comment as done.
timshen added a comment.

Update file comments copy-paste error.


https://reviews.llvm.org/D41148

Files:
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/include/module.modulemap
  libcxx/test/libcxx/double_include.sh.cpp
  libcxx/test/std/experimental/simd/nothing_to_do.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/genertor.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
@@ -0,0 +1,133 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.traits]
+// template  struct is_simd_mask;
+// template  inline constexpr bool is_simd_mask_v = is_simd_mask::value;
+
+#include 
+#include 
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+struct UserType {};
+
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");

[libclc] r329462 - select: simplify implementation and fix fp16

2018-04-06 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Apr  6 15:00:00 2018
New Revision: 329462

URL: http://llvm.org/viewvc/llvm-project?rev=329462=rev
Log:
select: simplify implementation and fix fp16

Fix half precision implementation
Vector ?: operator should behave exactly as select
Passes CTS on carrizo

Signed-off-by: Jan Vesely 
Reviewer: Jeroen Ketema 

Modified:
libclc/trunk/generic/lib/relational/select.inc

Modified: libclc/trunk/generic/lib/relational/select.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/select.inc?rev=329462=329461=329462=diff
==
--- libclc/trunk/generic/lib/relational/select.inc (original)
+++ libclc/trunk/generic/lib/relational/select.inc Fri Apr  6 15:00:00 2018
@@ -9,39 +9,25 @@
 #define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
 #define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
 #elif __CLC_FPSIZE == 16
-#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
-#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
-#endif
-#ifdef __CLC_FPSIZE
-#define __CLC_GENSIZE   __CLC_FPSIZE
+#define __CLC_S_GENTYPE __CLC_XCONCAT(short, __CLC_VECSIZE)
+#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
 #endif
 
-#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(as_, __CLC_S_GENTYPE)
-#define __CLC_AS_GENTYPE __CLC_XCONCAT(as_, __CLC_GENTYPE)
-
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, 
__CLC_S_GENTYPE z)
 {
-#ifdef __CLC_SCALAR
return z ? y : x;
-#else
-   __CLC_S_GENTYPE bitmask = z >> (__CLC_GENSIZE - 1);
-   return __CLC_AS_GENTYPE(bitselect(__CLC_AS_S_GENTYPE(x), 
__CLC_AS_S_GENTYPE(y), bitmask));
-#endif
 }
 
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, 
__CLC_U_GENTYPE z)
 {
-   return select(x, y, __CLC_AS_S_GENTYPE(z));
+   return z ? y : x;
 }
 
-#undef __CLC_AS_S_GENTYPE
-#undef __CLC_AS_GENTYPE
-
 #ifdef __CLC_FPSIZE
 #undef __CLC_S_GENTYPE
 #undef __CLC_U_GENTYPE
-#undef __CLC_GENSIZE
 #endif
+
 #ifdef __CLC_SCALAR
 #undef __CLC_VECSIZE
 #endif


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


[PATCH] D45294: [libcxx] [test] Remove non-portable assertions from filebuf tests

2018-04-06 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 141433.
BillyONeal retitled this revision from "[libcxx] [test] Remove non-portable 
assertions from filebuf's seekoff.pass.cpp test" to "[libcxx] [test] Remove 
non-portable assertions from filebuf tests".
BillyONeal edited the summary of this revision.
BillyONeal added a comment.

Added pbackfail.pass.cpp changes.


https://reviews.llvm.org/D45294

Files:
  
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
  test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp


Index: 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
===
--- 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
+++ 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
@@ -14,11 +14,11 @@
 // pos_type seekpos(pos_type sp,
 //  ios_base::openmode which = ios_base::in | ios_base::out);
 
-// This test is not entirely portable
-
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 {
@@ -30,7 +30,7 @@
| std::ios_base::trunc) 
!= 0);
 assert(f.is_open());
 f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
-assert(buf[0] == 'v');
+LIBCPP_ASSERT(buf[0] == 'v');
 pos_type p = f.pubseekoff(-15, std::ios_base::cur);
 assert(p == 11);
 assert(f.sgetc() == 'l');
@@ -51,7 +51,7 @@
| std::ios_base::trunc) 
!= 0);
 assert(f.is_open());
 f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
-assert(buf[0] == L'v');
+LIBCPP_ASSERT(buf[0] == L'v');
 pos_type p = f.pubseekoff(-15, std::ios_base::cur);
 assert(p == 11);
 assert(f.sgetc() == L'l');
Index: 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
===
--- 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
+++ 
test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
@@ -11,11 +11,11 @@
 
 // int_type pbackfail(int_type c = traits::eof());
 
-// This test is not entirely portable
-
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct test_buf
 : public std::basic_filebuf
@@ -41,16 +41,24 @@
 assert(f.is_open());
 assert(f.sbumpc() == '1');
 assert(f.sgetc() == '2');
-assert(f.pbackfail('a') == -1);
+typename test_buf::int_type pbackResult = f.pbackfail('a');
+LIBCPP_ASSERT(pbackResult == -1);
+if (pbackResult != -1) {
+assert(f.sbumpc() == 'a');
+assert(f.sgetc() == '2');
+}
 }
 {
 test_buf f;
 assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) 
!= 0);
 assert(f.is_open());
 assert(f.sbumpc() == '1');
 assert(f.sgetc() == '2');
-assert(f.pbackfail('a') == 'a');
-assert(f.sbumpc() == 'a');
-assert(f.sgetc() == '2');
+typename test_buf::int_type pbackResult = f.pbackfail('a');
+LIBCPP_ASSERT(pbackResult == 'a');
+if (pbackResult != -1) {
+assert(f.sbumpc() == 'a');
+assert(f.sgetc() == '2');
+}
 }
 }


Index: test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
===
--- test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
+++ test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
@@ -14,11 +14,11 @@
 // pos_type seekpos(pos_type sp,
 //  ios_base::openmode which = ios_base::in | ios_base::out);
 
-// This test is not entirely portable
-
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 {
@@ -30,7 +30,7 @@
| std::ios_base::trunc) != 0);
 assert(f.is_open());
 f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
-assert(buf[0] == 'v');
+LIBCPP_ASSERT(buf[0] == 'v');
 pos_type p = f.pubseekoff(-15, std::ios_base::cur);
 assert(p == 11);
 assert(f.sgetc() == 'l');
@@ -51,7 +51,7 @@
| std::ios_base::trunc) != 0);
 assert(f.is_open());
 f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
-assert(buf[0] == L'v');
+LIBCPP_ASSERT(buf[0] == L'v');
 pos_type p = f.pubseekoff(-15, std::ios_base::cur);
 assert(p == 11);
 assert(f.sgetc() == L'l');
Index: test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
===
--- 

[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

How could this patch possibly affect vprintf?


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[libcxx] r329460 - Implement P0768r1: Library support for the Spaceship Operator.

2018-04-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Apr  6 14:37:23 2018
New Revision: 329460

URL: http://llvm.org/viewvc/llvm-project?rev=329460=rev
Log:
Implement P0768r1: Library support for the Spaceship Operator.

this patch adds the  header and implements all of it
except for [comp.alg].

As I understand it, the header is needed by the compiler in
when implementing the semantics of operator<=>. For that reason
I feel it's important to land this header early, despite
all compilers lacking support.

Added:
libcxx/trunk/include/compare
libcxx/trunk/test/libcxx/language.support/cmp/
libcxx/trunk/test/libcxx/language.support/cmp/version.pass.cpp
libcxx/trunk/test/std/language.support/cmp/
libcxx/trunk/test/std/language.support/cmp/cmp.common/

libcxx/trunk/test/std/language.support/cmp/cmp.common/common_comparison_category.pass.cpp
libcxx/trunk/test/std/language.support/cmp/cmp.partialord/

libcxx/trunk/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
libcxx/trunk/test/std/language.support/cmp/cmp.strongeq/

libcxx/trunk/test/std/language.support/cmp/cmp.strongeq/cmp.strongeq.pass.cpp
libcxx/trunk/test/std/language.support/cmp/cmp.strongord/
libcxx/trunk/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
libcxx/trunk/test/std/language.support/cmp/cmp.weakeq/
libcxx/trunk/test/std/language.support/cmp/cmp.weakeq/cmp.weakeq.pass.cpp
libcxx/trunk/test/std/language.support/cmp/cmp.weakord/
libcxx/trunk/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
Modified:
libcxx/trunk/include/CMakeLists.txt
libcxx/trunk/include/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=329460=329459=329460=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Fri Apr  6 14:37:23 2018
@@ -77,5 +77,4 @@ if (LIBCXX_INSTALL_HEADERS)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
 add_custom_target(install-libcxx-headers-stripped DEPENDS 
install-cxx-headers-stripped)
   endif()
-
 endif()

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=329460=329459=329460=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Apr  6 14:37:23 2018
@@ -1196,6 +1196,11 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_HAS_NO_COROUTINES
 #endif
 
+// FIXME: Correct this macro when either (A) a feature test macro for the
+// spaceship operator is provided, or (B) a compiler provides a complete
+// implementation.
+#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
+
 // Decide whether to use availability macros.
 #if !defined(_LIBCPP_BUILDING_LIBRARY) &&  
\
 !defined(_LIBCPP_DISABLE_AVAILABILITY) &&  
\

Added: libcxx/trunk/include/compare
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/compare?rev=329460=auto
==
--- libcxx/trunk/include/compare (added)
+++ libcxx/trunk/include/compare Fri Apr  6 14:37:23 2018
@@ -0,0 +1,679 @@
+// -*- C++ -*-
+//===-- compare 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_COMPARE
+#define _LIBCPP_COMPARE
+
+/*
+compare synopsis
+
+namespace std {
+  // [cmp.categories], comparison category types
+  class weak_equality;
+  class strong_equality;
+  class partial_ordering;
+  class weak_ordering;
+  class strong_ordering;
+
+  // named comparison functions
+  constexpr bool is_eq  (weak_equality cmp) noexcept{ return cmp == 0; }
+  constexpr bool is_neq (weak_equality cmp) noexcept{ return cmp != 0; }
+  constexpr bool is_lt  (partial_ordering cmp) noexcept { return cmp < 0; }
+  constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
+  constexpr bool is_gt  (partial_ordering cmp) noexcept { return cmp > 0; }
+  constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
+
+  // [cmp.common], common comparison category type
+  template
+  struct common_comparison_category {
+using type = see below;
+  };
+  template
+using common_comparison_category_t = typename 
common_comparison_category::type;
+
+  // [cmp.alg], comparison algorithms
+  template constexpr 

[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D45384#1060192, @ahatanak wrote:

> In https://reviews.llvm.org/D45384#1060164, @rjmccall wrote:
>
> > Well, but I think CanPassInRegisters==false in the base class does always 
> > mean CanPassInRegisters==false in the subclass.
>
>
> I think there are cases that is not true. If I compile the following code, S0 
> (base class) is passed indirectly and S1 (derived class) is passed directly.


Yes, I think you're right.  That's exciting.

So "cannot pass in registers" is tracking whether there's a primitive reason 
that the class cannot be passed in registers, something that's above and beyond 
the C++ rules?  Okay.




Comment at: include/clang/AST/DeclCXX.h:486
+/// for this class to be passed in registers.
+unsigned CannotPassInRegisters : 1;
+

You should definitely explain the semantic difference with CanPassInRegisters 
in this comment, and I think the field/method names should underline that.  
Maybe this is a place to pull out "Primitive" again?


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D45383#1060275, @efriedma wrote:

> By "builtins" I meant specifically the stuff that that user code isn't 
> allowed to declare, like __builtin_*, since they often have weird/incomplete 
> signatures.


Unfortunately, the problem shows in vprintf as well, not just __builtin 
functions.  So that would solve the original bug report, but not the rest of 
the similar issues.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D44616: Update existed CodeGen TBAA tests

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

Yes, this is fine.


Repository:
  rC Clang

https://reviews.llvm.org/D44616



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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

By "builtins" I meant specifically the stuff that that user code isn't allowed 
to declare, like __builtin_*, since they often have weird/incomplete signatures.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[clang-tools-extra] r329454 - [clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: find_if predicate

2018-04-06 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Fri Apr  6 14:00:18 2018
New Revision: 329454

URL: http://llvm.org/viewvc/llvm-project?rev=329454=rev
Log:
[clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: find_if 
predicate


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329454=329453=329454=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri 
Apr  6 14:00:18 2018
@@ -76,8 +76,11 @@ static std::string getNameAsString(const
 static std::string getExprAsString(const clang::Expr ,
clang::ASTContext ) {
   std::string Text = tooling::fixit::getText(E, AC).str();
-  Text.erase(std::remove_if(Text.begin(), Text.end(), std::isspace),
- Text.end());
+  Text.erase(
+  std::remove_if(
+  Text.begin(), Text.end(),
+  [](char c) { return std::isspace(static_cast(c)); }),
+  Text.end());
   return Text;
 }
 


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


[clang-tools-extra] r329452 - [clang-tidy] Fix compilation for ParentVirtualCallCheck.cpp

2018-04-06 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Fri Apr  6 13:39:23 2018
New Revision: 329452

URL: http://llvm.org/viewvc/llvm-project?rev=329452=rev
Log:
[clang-tidy] Fix compilation for ParentVirtualCallCheck.cpp


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329452=329451=329452=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri 
Apr  6 13:39:23 2018
@@ -11,8 +11,8 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/FixIt.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include 
 #include 
 
 using namespace clang::ast_matchers;
@@ -27,11 +27,13 @@ static bool isParentOf(const CXXRecordDe
const CXXRecordDecl ) {
   if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
 return true;
-  const auto ClassIter = llvm::find_if(ThisClass.bases(), [=](auto ) {
-auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
-assert(BaseDecl);
-return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
-  });
+  const auto ClassIter = std::find_if(
+  ThisClass.bases().begin(), ThisClass.bases().end(),
+  [=](const CXXBaseSpecifier ) {
+auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+assert(BaseDecl);
+return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
+  });
   return ClassIter != ThisClass.bases_end();
 }
 
@@ -74,7 +76,8 @@ static std::string getNameAsString(const
 static std::string getExprAsString(const clang::Expr ,
clang::ASTContext ) {
   std::string Text = tooling::fixit::getText(E, AC).str();
-  Text.erase(llvm::remove_if(Text, std::isspace), Text.end());
+  Text.erase(std::remove_if(Text.begin(), Text.end(), std::isspace),
+ Text.end());
   return Text;
 }
 


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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

One big issue with just disallowing redecls of builtins is we have is that a 
number of these are actually expected to be in the system headers/libraries 
(such as vprintf).  A ton of the math.h functions are also builtins.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45387: [CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D45387#1060194, @tra wrote:

> You may want to mention in the commit log that this is a partial unroll of 
> r329232 / https://reviews.llvm.org/D45277.


Will do. Thanks.


https://reviews.llvm.org/D45387



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


r329449 - Don't assume constructors return void.

2018-04-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr  6 13:06:02 2018
New Revision: 329449

URL: http://llvm.org/viewvc/llvm-project?rev=329449=rev
Log:
Don't assume constructors return void.

Should fix ARM buildbot.

Modified:
cfe/trunk/test/CodeGenCXX/tail-padding.cpp

Modified: cfe/trunk/test/CodeGenCXX/tail-padding.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/tail-padding.cpp?rev=329449=329448=329449=diff
==
--- cfe/trunk/test/CodeGenCXX/tail-padding.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/tail-padding.cpp Fri Apr  6 13:06:02 2018
@@ -9,7 +9,7 @@ namespace Implicit {
   C f(C c) { return c; }
 
   // CHECK: define {{.*}} @_ZN8Implicit1CC1EOS0_
-  // CHECK: call void @_ZN8Implicit1AC2ERKS0_(
+  // CHECK: call {{.*}} @_ZN8Implicit1AC2ERKS0_(
   // Note: this must memcpy 7 bytes, not 8, to avoid trampling over the 
virtual base class.
   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 
7, i1 false)
   // CHECK: store i32 {{.*}} @_ZTVN8Implicit1CE
@@ -26,7 +26,7 @@ namespace InitWithinNVSize {
   C f(C c) { return c; }
 
   // CHECK: define {{.*}} @_ZN16InitWithinNVSize1CC1EOS0_
-  // CHECK: call void @_ZN16InitWithinNVSize1AC2ERKS0_(
+  // CHECK: call {{.*}} @_ZN16InitWithinNVSize1AC2ERKS0_(
   // This copies over the 'C::x' member, but that's OK because we've not 
initialized it yet.
   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 
8, i1 false)
   // CHECK: store i32 {{.*}} @_ZTVN16InitWithinNVSize1CE


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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D45383#1060104, @efriedma wrote:

> Rather than adding weird hacks to merging, can we just reject any attempt to 
> redeclare a builtin?


I don't believe we can.  I think things often re-declare them, particularly 
when it comes to va_end.  I'd love to move the 'builtinID' check higher and 
reject any attempts to redeclare in C, but I'd like some further guidance.  Do 
you know of anyone who can help us make that decision?


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[clang-tools-extra] r329448 - [clang-tidy] Check if grand-..parent's virtual method was called instead of overridden parent's.

2018-04-06 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Fri Apr  6 13:02:50 2018
New Revision: 329448

URL: http://llvm.org/viewvc/llvm-project?rev=329448=rev
Log:
[clang-tidy] Check if grand-..parent's virtual method was called instead of 
overridden parent's. 

class A {...int virtual foo() {...}...}; 
class B: public A {...int foo() override {...}...}; 
class C: public B {...int foo() override {... A::foo()...}};
   warning: qualified name 
A::foo refers to a member overridden in subclass; did you mean 'B'? 
[bugprone-parent-virtual-call] 

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp   
(with props)
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.h   
(with props)

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst 
  (with props)
clang-tools-extra/trunk/test/clang-tidy/bugprone-parent-virtual-call.cpp   
(with props)
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=329448=329447=329448=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Fri Apr  
6 13:02:50 2018
@@ -28,6 +28,7 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
+#include "ParentVirtualCallCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
 #include "StringConstructorCheck.h"
@@ -90,6 +91,8 @@ public:
 "bugprone-move-forwarding-reference");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
+CheckFactories.registerCheck(
+"bugprone-parent-virtual-call");
 CheckFactories.registerCheck(
 "bugprone-sizeof-container");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=329448=329447=329448=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Fri Apr  6 
13:02:50 2018
@@ -20,6 +20,7 @@ add_clang_library(clangTidyBugproneModul
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
   MultipleStatementMacroCheck.cpp
+  ParentVirtualCallCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp
   StringConstructorCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329448=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri 
Apr  6 13:02:50 2018
@@ -0,0 +1,154 @@
+//===--- ParentVirtualCallCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ParentVirtualCallCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+using BasesVector = llvm::SmallVector;
+
+static bool isParentOf(const CXXRecordDecl ,
+   const CXXRecordDecl ) {
+  if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
+return true;
+  const auto ClassIter = llvm::find_if(ThisClass.bases(), [=](auto ) {
+auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+assert(BaseDecl);
+return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
+  });
+  return ClassIter != ThisClass.bases_end();
+}
+
+static BasesVector getParentsByGrandParent(const CXXRecordDecl ,
+   const CXXRecordDecl ,
+   const CXXMethodDecl ) {
+  BasesVector Result;
+ 

[PATCH] D44295: [clang-tidy] Detect and fix calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-04-06 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE329448: [clang-tidy] Check if grand-..parents 
virtual method was called instead of… (authored by zinovy.nis, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44295?vs=141199=141408#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ParentVirtualCallCheck.cpp
  clang-tidy/bugprone/ParentVirtualCallCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-parent-virtual-call.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-parent-virtual-call.cpp

Index: test/clang-tidy/bugprone-parent-virtual-call.cpp
===
--- test/clang-tidy/bugprone-parent-virtual-call.cpp
+++ test/clang-tidy/bugprone-parent-virtual-call.cpp
@@ -0,0 +1,179 @@
+// RUN: %check_clang_tidy %s bugprone-parent-virtual-call %t
+
+extern int foo();
+
+class A {
+public:
+  A() = default;
+  virtual ~A() = default;
+
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+
+  int non_virt() { return foo() + 3; }
+  static int stat() { return foo() + 4; }
+};
+
+class B : public A {
+public:
+  B() = default;
+
+  // Nothing to fix: calls to direct parent.
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+
+class C : public B {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return B::virt_1() + B::virt_1(); }
+
+  // Test that non-virtual and static methods are not affected by this cherker.
+  int method_c() { return A::stat() + A::non_virt(); }
+};
+
+// Check aliased type names
+using A1 = A;
+typedef A A2;
+#define A3 A
+
+class C2 : public B {
+public:
+  int virt_1() override { return A1::virt_1() + A2::virt_1() + A3::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A1::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: qualified name 'A2::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-3]]:64: warning: qualified name 'A3::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1() + B::virt_1(); }
+};
+
+// Test that the check affects grand-grand..-parent calls too.
+class D : public C {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+};
+
+// Test classes in namespaces.
+namespace {
+class BN : public A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace
+
+namespace N1 {
+class A {
+public:
+  A() = default;
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+};
+} // namespace N1
+
+namespace N2 {
+class BN : public N1::A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace N2
+
+class CN : public BN {
+public:
+  int virt_1() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'BN'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return BN::virt_1() + BN::virt_1(); }
+  int virt_2() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'BN'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return BN::virt_1() + BN::virt_1(); }
+};
+
+class CNN : public N2::BN {
+public:
+  int virt_1() override { return N1::A::virt_1() + N2::BN::virt_1(); }
+  // CHECK-MESSAGES: 

[PATCH] D45387: [CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets

2018-04-06 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

You may want to mention in the commit log that this is a partial unroll of 
r329232 / https://reviews.llvm.org/D45277.


https://reviews.llvm.org/D45387



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


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D45384#1060164, @rjmccall wrote:

> Well, but I think CanPassInRegisters==false in the base class does always 
> mean CanPassInRegisters==false in the subclass.


I think there are cases that is not true. If I compile the following code, S0 
(base class) is passed indirectly and S1 (derived class) is passed directly.

  struct S0 {
S0();
S0(const S0 &) = default;
S0(S0 &&);
~S0() = default;
int *p;
  };
  
  struct S1 : S0 {
S1();
S1(const S1 &) = default;
S1(S1 &&) = delete;
~S1() = default;
int a;
  };
  
  void foo1(S0);
  void foo1(S1);
  
  void test0(S0 *a) {
foo1(*a);
  }
  
  void test1(S1 *a) {
foo1(*a);
  }

By the way, I meant to say "CanPassInRegisters=true in the *base class*" not 
"CanPassInRegisters=true in the subclass".


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


[PATCH] D45387: [CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: nhaehnle, jholewinski.

amdgcn targets only support HIP, which does not define `__CUDA_ARCH__`.

`__HIP_DEVICE_COMPILE__` depends on HIP language mode, therefore it needs to be 
added
in a different patch.

refer to discussions in https://reviews.llvm.org/D45277


https://reviews.llvm.org/D45387

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets.h
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/Basic/Targets/NVPTX.cpp

Index: lib/Basic/Targets/NVPTX.cpp
===
--- lib/Basic/Targets/NVPTX.cpp
+++ lib/Basic/Targets/NVPTX.cpp
@@ -153,8 +153,61 @@
MacroBuilder ) const {
   Builder.defineMacro("__PTX__");
   Builder.defineMacro("__NVPTX__");
-  if (Opts.CUDAIsDevice)
-defineCudaArchMacro(GPU, Builder);
+  if (Opts.CUDAIsDevice) {
+// Set __CUDA_ARCH__ for the GPU specified.
+std::string CUDAArchCode = [this] {
+  switch (GPU) {
+  case CudaArch::GFX600:
+  case CudaArch::GFX601:
+  case CudaArch::GFX700:
+  case CudaArch::GFX701:
+  case CudaArch::GFX702:
+  case CudaArch::GFX703:
+  case CudaArch::GFX704:
+  case CudaArch::GFX801:
+  case CudaArch::GFX802:
+  case CudaArch::GFX803:
+  case CudaArch::GFX810:
+  case CudaArch::GFX900:
+  case CudaArch::GFX902:
+  case CudaArch::LAST:
+break;
+  case CudaArch::UNKNOWN:
+assert(false && "No GPU arch when compiling CUDA device code.");
+return "";
+  case CudaArch::SM_20:
+return "200";
+  case CudaArch::SM_21:
+return "210";
+  case CudaArch::SM_30:
+return "300";
+  case CudaArch::SM_32:
+return "320";
+  case CudaArch::SM_35:
+return "350";
+  case CudaArch::SM_37:
+return "370";
+  case CudaArch::SM_50:
+return "500";
+  case CudaArch::SM_52:
+return "520";
+  case CudaArch::SM_53:
+return "530";
+  case CudaArch::SM_60:
+return "600";
+  case CudaArch::SM_61:
+return "610";
+  case CudaArch::SM_62:
+return "620";
+  case CudaArch::SM_70:
+return "700";
+  case CudaArch::SM_72:
+return "720";
+  }
+  llvm_unreachable("unhandled CudaArch");
+}();
+Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
+  }
 }
 
 ArrayRef NVPTXTargetInfo::getTargetBuiltins() const {
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 
-#include "clang/Basic/Cuda.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/StringSet.h"
@@ -175,7 +174,6 @@
   static bool isAMDGCN(const llvm::Triple ) {
 return TT.getArch() == llvm::Triple::amdgcn;
   }
-  CudaArch GCN_Subarch;
 
 public:
   AMDGPUTargetInfo(const llvm::Triple , const TargetOptions );
@@ -332,7 +330,6 @@
 else
   GPU = parseR600Name(Name);
 
-GCN_Subarch = StringToCudaArch(Name);
 return GK_NONE != GPU.Kind;
   }
 
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -12,7 +12,6 @@
 //===--===//
 
 #include "AMDGPU.h"
-#include "Targets.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MacroBuilder.h"
@@ -264,7 +263,6 @@
   resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
 : DataLayoutStringR600);
   assert(DataLayout->getAllocaAddrSpace() == Private);
-  GCN_Subarch = CudaArch::GFX803; // Default to fiji
 
   setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
  !isAMDGCN(Triple));
@@ -309,9 +307,6 @@
   if (GPU.Kind != GK_NONE)
 Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
 
-  if (Opts.CUDAIsDevice)
-defineCudaArchMacro(GCN_Subarch, Builder);
-
   // TODO: __HAS_FMAF__, __HAS_LDEXPF__, __HAS_FP64__ are deprecated and will be
   // removed in the near future.
   if (GPU.HasFMAF)
Index: lib/Basic/Targets.h
===
--- lib/Basic/Targets.h
+++ lib/Basic/Targets.h
@@ -16,7 +16,6 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_H
 
-#include "clang/Basic/Cuda.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetInfo.h"
@@ -47,9 +46,6 @@
 LLVM_LIBRARY_VISIBILITY
 void addCygMingDefines(const clang::LangOptions ,
clang::MacroBuilder );
-

r329447 - Revert r329442 "Generate Libclang invocation reproducers using a new

2018-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr  6 12:45:29 2018
New Revision: 329447

URL: http://llvm.org/viewvc/llvm-project?rev=329447=rev
Log:
Revert r329442 "Generate Libclang invocation reproducers using a new
-cc1gen-reproducer driver option"

The tests are failing on some bots

Removed:
cfe/trunk/test/Index/create-libclang-completion-reproducer.c
cfe/trunk/test/Index/create-libclang-parsing-reproducer.c
cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=329447=329446=329447=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Apr  6 12:45:29 2018
@@ -405,19 +405,11 @@ public:
   int ExecuteCompilation(Compilation ,
  SmallVectorImpl< std::pair > );
 
-  /// Contains the files in the compilation diagnostic report generated by
-  /// generateCompilationDiagnostics.
-  struct CompilationDiagnosticReport {
-llvm::SmallVector TemporaryFiles;
-  };
-
-  /// generateCompilationDiagnostics - Generate diagnostics information
+  /// generateCompilationDiagnostics - Generate diagnostics information 
   /// including preprocessed source file(s).
-  ///
-  void generateCompilationDiagnostics(
-  Compilation , const Command ,
-  StringRef AdditionalInformation = "",
-  CompilationDiagnosticReport *GeneratedReport = nullptr);
+  /// 
+  void generateCompilationDiagnostics(Compilation ,
+  const Command );
 
   /// @}
   /// @name Helper Methods

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=329447=329446=329447=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Apr  6 12:45:29 2018
@@ -,9 +,8 @@ bool Driver::getCrashDiagnosticFile(Stri
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
-void Driver::generateCompilationDiagnostics(
-Compilation , const Command ,
-StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
+void Driver::generateCompilationDiagnostics(Compilation ,
+const Command ) {
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
@@ -1239,8 +1238,6 @@ void Driver::generateCompilationDiagnost
   SmallString<128> ReproCrashFilename;
   for (const char *TempFile : TempFiles) {
 Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
-if (Report)
-  Report->TemporaryFiles.push_back(TempFile);
 if (ReproCrashFilename.empty()) {
   ReproCrashFilename = TempFile;
   llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
@@ -1269,11 +1266,6 @@ void Driver::generateCompilationDiagnost
 ScriptOS << "# Original command: ";
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true, );
-if (!AdditionalInformation.empty())
-  ScriptOS << "\n# Additional information: " << AdditionalInformation
-   << "\n";
-if (Report)
-  Report->TemporaryFiles.push_back(Script);
 Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
   }
 

Removed: cfe/trunk/test/Index/create-libclang-completion-reproducer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/create-libclang-completion-reproducer.c?rev=329446=auto
==
--- cfe/trunk/test/Index/create-libclang-completion-reproducer.c (original)
+++ cfe/trunk/test/Index/create-libclang-completion-reproducer.c (removed)
@@ -1,14 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test 
-code-completion-at=%s:10:1 
"-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s
-// RUN: %clang -cc1gen-reproducer %t/libclang-* -v | FileCheck %s
-
-// Invocation file must be removed by clang:
-// RUN: ls %t | count 0
-
-// CHECK: REPRODUCER METAINFO: {"libclang.operation": "complete", 
"libclang.opts": "1", "invocation-args": 
["-code-completion-at={{.*}}create-libclang-completion-reproducer.c:10:1"]}
-
-// CHECK: REPRODUCER:
-// CHECK-NEXT: {
-// CHECK-NEXT: "files":["{{.*}}.c","{{.*}}.sh"]
-// CHECK-NEXT: }

Removed: cfe/trunk/test/Index/create-libclang-parsing-reproducer.c
URL: 

[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Well, but I think CanPassInRegisters==false in the base class does always mean 
CanPassInRegisters==false in the subclass.


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


Re: r329342 - PR36992: do not store beyond the dsize of a class object unless we know

2018-04-06 Thread Richard Smith via cfe-commits
Thanks, I see the problem.

On Fri, 6 Apr 2018, 11:56 via cfe-commits, 
wrote:

> Hi Richard,
>
> I don't know if you are aware, but the test you added in this commit,
> tail-padding.cpp is currently failing on one of the ARM bots. Can you take
> a look?
>
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/178
>
>  TEST 'Clang :: CodeGenCXX/tail-padding.cpp' FAILED
> 
> Script:
> --
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang
> -cc1 -internal-isystem
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/7.0.0/include
> -nostdsysteminc -triple armv7l-unknown-linux-gnueabihf -emit-llvm -o -
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp
> |
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:8:47:
> warning: static_assert with no message is a C++17 extension
>   static_assert(sizeof(C) == sizeof(void*) + 8);
>   ^
>   , ""
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:25:46:
> warning: static_assert with no message is a C++17 extension
>   static_assert(sizeof(C) > sizeof(void*) + 8);
>  ^
>  , ""
> 2 warnings generated.
> /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:12:12:
> error: expected string not found in input
>  // CHECK: call void @_ZN8Implicit1AC2ERKS0_(
>^
> :78:66: note: scanning from here
> define linkonce_odr %"struct.Implicit::C"*
> @_ZN8Implicit1CC1EOS0_(%"struct.Implicit::C"* returned %this,
> %"struct.Implicit::C"* dereferenceable(12)) unnamed_addr #0 comdat align 2 {
>  ^
> :97:28: note: possible intended match here
>  %call = call %"struct.Implicit::A"*
> @_ZN8Implicit1AC2ERKS0_(%"struct.Implicit::A"* %3, %"struct.Implicit::A"*
> dereferenceable(1) %8)
>^
>
> --
>
> 
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Richard Smith via cfe-commits
> > Sent: Thursday, April 05, 2018 13:53
> > To: cfe-commits@lists.llvm.org
> > Subject: r329342 - PR36992: do not store beyond the dsize of a class
> object
> > unless we know
> >
> > Author: rsmith
> > Date: Thu Apr  5 13:52:58 2018
> > New Revision: 329342
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=329342=rev
> > Log:
> > PR36992: do not store beyond the dsize of a class object unless we know
> the
> > tail padding is not reused.
> >
> > We track on the AggValueSlot (and through a couple of other
> initialization
> > actions) whether we're dealing with an object that might share its tail
> > padding with some other object, so that we can avoid emitting stores
> into the
> > tail padding if that's the case. We still widen stores into tail padding
> when
> > we can do so.
> >
> > Differential Revision: https://reviews.llvm.org/D45306
> >
> > Added:
> > cfe/trunk/test/CodeGenCXX/tail-padding.cpp
> > Modified:
> > cfe/trunk/lib/CodeGen/CGAtomic.cpp
> > cfe/trunk/lib/CodeGen/CGBlocks.cpp
> > cfe/trunk/lib/CodeGen/CGCall.cpp
> > cfe/trunk/lib/CodeGen/CGClass.cpp
> > cfe/trunk/lib/CodeGen/CGDecl.cpp
> > cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> > cfe/trunk/lib/CodeGen/CGExpr.cpp
> > cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> > cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> > cfe/trunk/lib/CodeGen/CGObjC.cpp
> > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> > cfe/trunk/lib/CodeGen/CGStmt.cpp
> > cfe/trunk/lib/CodeGen/CGValue.h
> > cfe/trunk/lib/CodeGen/CodeGenFunction.h
> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
> > URL: http://llvm.org/viewvc/llvm-
> >
> project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=329342=329341=329342
> > =diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Apr  5 13:52:58 2018
> > @@ -1513,7 +1513,8 @@ void AtomicInfo::emitCopyIntoMemory(RVal
> >  getAtomicType());
> >  bool IsVolatile = rvalue.isVolatileQualified() ||
> >LVal.isVolatileQualified();
> > -CGF.EmitAggregateCopy(Dest, Src, 

[PATCH] D45382: [CodeGen] Avoid destructing a struct type that has already been destructed by a delegated constructor

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Hmm.  I'm not actually sure *why* it's not okay to forward callee-cleanup 
arguments.  Do we just not have the necessary logic to disable the cleanup in 
the caller?


Repository:
  rC Clang

https://reviews.llvm.org/D45382



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


r329445 - Revert "[analyzer] Remove an unused variable"

2018-04-06 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Apr  6 12:14:05 2018
New Revision: 329445

URL: http://llvm.org/viewvc/llvm-project?rev=329445=rev
Log:
Revert "[analyzer] Remove an unused variable"

This reverts commit 2fa3e3edc4ed6547cc4ce46a8c79d1891a5b3b36.

Removed the wrong variable.

Modified:
cfe/trunk/lib/Analysis/LiveVariables.cpp

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=329445=329444=329445=diff
==
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Fri Apr  6 12:14:05 2018
@@ -381,7 +381,7 @@ void TransferFunctions::VisitBlockExpr(B
 void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *DR) {
   const Decl* D = DR->getDecl();
   bool InAssignment = LV.inAssignment[DR];
-  if (isa(D)) {
+  if (const auto *BD = dyn_cast(D)) {
 if (!InAssignment)
   val.liveBindings = LV.BSetFact.add(val.liveBindings, BD);
   } else if (const auto *VD = dyn_cast(D)) {


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


r329444 - [analyzer] Remove an unused variable

2018-04-06 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Apr  6 12:03:43 2018
New Revision: 329444

URL: http://llvm.org/viewvc/llvm-project?rev=329444=rev
Log:
[analyzer] Remove an unused variable

Modified:
cfe/trunk/lib/Analysis/LiveVariables.cpp

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=329444=329443=329444=diff
==
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Fri Apr  6 12:03:43 2018
@@ -381,7 +381,7 @@ void TransferFunctions::VisitBlockExpr(B
 void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *DR) {
   const Decl* D = DR->getDecl();
   bool InAssignment = LV.inAssignment[DR];
-  if (const auto *BD = dyn_cast(D)) {
+  if (isa(D)) {
 if (!InAssignment)
   val.liveBindings = LV.BSetFact.add(val.liveBindings, BD);
   } else if (const auto *VD = dyn_cast(D)) {


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


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, rsmith.

This patch fixes a bug in r328731 that caused structs with `__weak` fields to 
be passed in registers. This happens when a struct doesn't have a `__weak` 
field but one of its subobjects does. To fix this, I added flag 
CXXRecordDecl::CannotPassInRegisters that propagates outwards and tracks 
whether a `__weak` field was seen. I added a new flag instead of reusing the 
CanPassInRegisters flag since in C++ we cannot always determine the value of a 
class' CanPassInRegisters flag by looking at its subobject's CanPassInRegisters 
flag (CanPassInRegisters=true in the subclass doesn't mean 
CanPassInRegisters=true in the derived class in C++).

rdar://problem/39194693


Repository:
  rC Clang

https://reviews.llvm.org/D45384

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Index: test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -8,6 +8,8 @@
 // pointer fields are passed directly.
 
 // CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
+// CHECK: %[[STRUCT_CONTAINSSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
+// CHECK: %[[STRUCT_DERIVEDSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
 // CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
 // CHECK: %[[STRUCT_S:.*]] = type { i8* }
 // CHECK: %[[STRUCT_CONTAINSNONTRIVIAL:.*]] = type { %{{.*}}, i8* }
@@ -21,6 +23,21 @@
   __weak id fweak;
 };
 
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) ContainsStrongWeak {
+#else
+struct ContainsStrongWeak {
+#endif
+  StrongWeak sw;
+};
+
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) DerivedStrongWeak : StrongWeak {
+#else
+struct DerivedStrongWeak : StrongWeak {
+#endif
+};
+
 #ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) Strong {
 #else
@@ -84,6 +101,18 @@
   return *a;
 }
 
+// CHECK: define void @_Z27testParamContainsStrongWeak18ContainsStrongWeak(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_CONTAINSSTRONGWEAK]]* @_ZN18ContainsStrongWeakD1Ev(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A]])
+
+void testParamContainsStrongWeak(ContainsStrongWeak a) {
+}
+
+// CHECK: define void @_Z26testParamDerivedStrongWeak17DerivedStrongWeak(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_DERIVEDSTRONGWEAK]]* @_ZN17DerivedStrongWeakD1Ev(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A]])
+
+void testParamDerivedStrongWeak(DerivedStrongWeak a) {
+}
+
 // CHECK: define void @_Z15testParamStrong6Strong(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONG]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[A]], i32 0, i32 0
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -6024,6 +6024,7 @@
   Record->push_back(Data.HasIrrelevantDestructor);
   Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
   Record->push_back(Data.HasDefaultedDefaultConstructor);
+  Record->push_back(Data.CannotPassInRegisters);
   Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
   Record->push_back(Data.HasConstexprDefaultConstructor);
   Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1592,6 +1592,7 @@
   Data.HasIrrelevantDestructor = Record.readInt();
   Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
   Data.HasDefaultedDefaultConstructor = Record.readInt();
+  Data.CannotPassInRegisters = Record.readInt();
   Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
   Data.HasConstexprDefaultConstructor = Record.readInt();
   Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
@@ -1733,6 +1734,7 @@
   MATCH_FIELD(HasIrrelevantDestructor)
   OR_FIELD(HasConstexprNonCopyMoveConstructor)
   OR_FIELD(HasDefaultedDefaultConstructor)
+  MATCH_FIELD(CannotPassInRegisters)
   MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
   OR_FIELD(HasConstexprDefaultConstructor)
   MATCH_FIELD(HasNonLiteralTypeFieldsOrBases)
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5854,9 +5854,9 @@
   if (RD->isDependentType() || RD->isInvalidDecl())
 return true;
 
-  // The param cannot be passed in registers if CanPassInRegisters is already
-  // set to false.
-  if (!RD->canPassInRegisters())
+  // The param cannot be passed in registers if CannotPassInRegisters 

RE: r329342 - PR36992: do not store beyond the dsize of a class object unless we know

2018-04-06 Thread via cfe-commits
Hi Richard,

I don't know if you are aware, but the test you added in this commit, 
tail-padding.cpp is currently failing on one of the ARM bots. Can you take a 
look?

http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/178

 TEST 'Clang :: CodeGenCXX/tail-padding.cpp' FAILED 

Script:
--
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/clang 
-cc1 -internal-isystem 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/lib/clang/7.0.0/include
 -nostdsysteminc -triple armv7l-unknown-linux-gnueabihf -emit-llvm -o - 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp
 | 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/stage2/bin/FileCheck
 
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp
--
Exit Code: 1

Command Output (stderr):
--
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:8:47:
 warning: static_assert with no message is a C++17 extension
  static_assert(sizeof(C) == sizeof(void*) + 8);
  ^
  , ""
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:25:46:
 warning: static_assert with no message is a C++17 extension
  static_assert(sizeof(C) > sizeof(void*) + 8);
 ^
 , ""
2 warnings generated.
/home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/tools/clang/test/CodeGenCXX/tail-padding.cpp:12:12:
 error: expected string not found in input
 // CHECK: call void @_ZN8Implicit1AC2ERKS0_(
   ^
:78:66: note: scanning from here
define linkonce_odr %"struct.Implicit::C"* 
@_ZN8Implicit1CC1EOS0_(%"struct.Implicit::C"* returned %this, 
%"struct.Implicit::C"* dereferenceable(12)) unnamed_addr #0 comdat align 2 {
 ^
:97:28: note: possible intended match here
 %call = call %"struct.Implicit::A"* 
@_ZN8Implicit1AC2ERKS0_(%"struct.Implicit::A"* %3, %"struct.Implicit::A"* 
dereferenceable(1) %8)
   ^

--



Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Richard Smith via cfe-commits
> Sent: Thursday, April 05, 2018 13:53
> To: cfe-commits@lists.llvm.org
> Subject: r329342 - PR36992: do not store beyond the dsize of a class object
> unless we know
> 
> Author: rsmith
> Date: Thu Apr  5 13:52:58 2018
> New Revision: 329342
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329342=rev
> Log:
> PR36992: do not store beyond the dsize of a class object unless we know the
> tail padding is not reused.
> 
> We track on the AggValueSlot (and through a couple of other initialization
> actions) whether we're dealing with an object that might share its tail
> padding with some other object, so that we can avoid emitting stores into the
> tail padding if that's the case. We still widen stores into tail padding when
> we can do so.
> 
> Differential Revision: https://reviews.llvm.org/D45306
> 
> Added:
> cfe/trunk/test/CodeGenCXX/tail-padding.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGAtomic.cpp
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/CodeGen/CGClass.cpp
> cfe/trunk/lib/CodeGen/CGDecl.cpp
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> cfe/trunk/lib/CodeGen/CGObjC.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGStmt.cpp
> cfe/trunk/lib/CodeGen/CGValue.h
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=329342=329341=329342
> =diff
> ==
> --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Apr  5 13:52:58 2018
> @@ -1513,7 +1513,8 @@ void AtomicInfo::emitCopyIntoMemory(RVal
>  getAtomicType());
>  bool IsVolatile = rvalue.isVolatileQualified() ||
>LVal.isVolatileQualified();
> -CGF.EmitAggregateCopy(Dest, Src, getAtomicType(), IsVolatile);
> +CGF.EmitAggregateCopy(Dest, Src, getAtomicType(),
> +  AggValueSlot::DoesNotOverlap, IsVolatile);
>  return;
>}
> 
> @@ -2008,6 +2009,7 @@ void CodeGenFunction::EmitAtomicInit(Exp
>  AggValueSlot::IsNotDestructed,
>   

[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Rather than adding weird hacks to merging, can we just reject any attempt to 
redeclare a builtin?


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I take it we still have test cases for the arm <-> thumb transition?

"-mthumb" and "-marm" are handled in the driver by rewriting the triple.


Repository:
  rC Clang

https://reviews.llvm.org/D45240



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


[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

2018-04-06 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

Ping @sdardis @compnerd


Repository:
  rUNW libunwind

https://reviews.llvm.org/D41968



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


[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 141393.
efriedma added a comment.

Add a bunch of tests for various arm arches.  Make sure we do something 
reasonable when we can't figure out any arch at all.


Repository:
  rC Clang

https://reviews.llvm.org/D45240

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/arm-long-calls.c
  test/CodeGen/arm-no-movt.c
  test/CodeGen/arm-target-features.c
  test/CodeGen/arm-thumb-mode-target-feature.c

Index: test/CodeGen/arm-thumb-mode-target-feature.c
===
--- test/CodeGen/arm-thumb-mode-target-feature.c
+++ test/CodeGen/arm-thumb-mode-target-feature.c
@@ -17,8 +17,8 @@
 // THUMB: void @t1() [[ThumbAttr:#[0-7]]]
 // THUMB: void @t2() [[NoThumbAttr:#[0-7]]]
 // THUMB: void @t3() [[ThumbAttr:#[0-7]]]
-// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
-// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+armv7-a,+thumb-mode"
+// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="+armv7-a,-thumb-mode"
 //
 // THUMB-CLANG: void @t1() [[ThumbAttr:#[0-7]]]
 // THUMB-CLANG: void @t2() [[NoThumbAttr:#[0-7]]]
@@ -29,5 +29,5 @@
 // ARM: void @t1() [[NoThumbAtr:#[0-7]]]
 // ARM: void @t2() [[NoThumbAttr:#[0-7]]]
 // ARM: void @t3() [[ThumbAttr:#[0-7]]]
-// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
-// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
+// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="+armv7-a,-thumb-mode"
+// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+armv7-a,+thumb-mode"
Index: test/CodeGen/arm-target-features.c
===
--- test/CodeGen/arm-target-features.c
+++ test/CodeGen/arm-target-features.c
@@ -1,22 +1,23 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode
+// CHECK-VFP3: "target-features"="+armv7-a,+dsp,+neon,+thumb-mode,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+dsp,+neon,+thumb-mode,+vfp4"
+// CHECK-VFP4: "target-features"="+armv7-a,+dsp,+neon,+thumb-mode,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
+// RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-2
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4"
+// CHECK-VFP4-DIV: "target-features"="+armv7-a,+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4"
+// CHECK-VFP4-DIV-2: "target-features"="+armv7s,+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4"
 
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
-// CHECK-VFP4-DIV-ARM: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4,-thumb-mode"
+// CHECK-VFP4-DIV-ARM: "target-features"="+armv7-a,+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4,-thumb-mode"
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
@@ -27,37 +28,81 @@
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m2 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m3 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+thumb-mode"
+// CHECK-BASIC-V8: "target-features"="+armv8-a,+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+thumb-mode"
 
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s 

[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: efriedma, eli.friedman, compnerd, rsmith.
erichkeane added a project: clang.

As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033
Any usage of a builtin function that uses a va_list by reference
will cause an assertion when redeclaring it.

Unfortunately, changing the types seems improper, and it breaks
a number of features for it.

Instead, this patch just strips the reference off in this case 
to ensure that the type is properly compared.


Repository:
  rC Clang

https://reviews.llvm.org/D45383

Files:
  lib/AST/ASTContext.cpp
  test/Sema/va_list_builtin_func_redecl.c
  test/Sema/va_list_builtin_func_redecl_errors.c


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8160,6 +8160,19 @@
   if (!rmerge.isNull())
 return rmerge;
 
+  if (!getLangOpts().CPlusPlus) {
+// Builtins that take a reference to a __builtin_va_list in some cases can 
be
+// of the type char*&.  Since this is illegal in C and caught in an assert 
in
+// mergeTypes, remove the reference.  The user cannot 'type' a char*&, so 
this
+// should be a good assumption.
+if (const auto *RefTy = lhs->getAs()) {
+  QualType VaListTy{getBuiltinVaListDecl()->getTypeForDecl(), 0};
+  if (RefTy->getPointeeType().getCanonicalType() ==
+  VaListTy.getCanonicalType())
+lhs = RefTy->getPointeeType();
+}
+  }
+
   return mergeTypes(lhs, rhs, OfBlockPointer, Unqualified);
 }
 
Index: test/Sema/va_list_builtin_func_redecl_errors.c
===
--- test/Sema/va_list_builtin_func_redecl_errors.c
+++ test/Sema/va_list_builtin_func_redecl_errors.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-unknown-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=i386-unknown-pc %s
+
+// expected-error@+2{{conflicting types for '__builtin_va_end'}}
+// expected-note@+1{{'__builtin_va_end' is a builtin with type}}
+void __builtin_va_end(void*);
+
+// expected-error@+2{{conflicting types for '__builtin___vprintf_chk'}}
+// expected-note@+1{{'__builtin___vprintf_chk' is a builtin with type}}
+int __builtin___vprintf_chk(int, const char*, void*);
+
+// expected-warning@+2{{incompatible redeclaration of library function 
'vprintf'}}
+// expected-note@+1{{'vprintf' is a builtin with type}}
+int vprintf(const char*, void*);
Index: test/Sema/va_list_builtin_func_redecl.c
===
--- test/Sema/va_list_builtin_func_redecl.c
+++ test/Sema/va_list_builtin_func_redecl.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-unknown-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=i386-unknown-pc %s
+// expected-no-diagnostics
+
+void __builtin_va_end(__builtin_va_list);
+int vprintf(const char*, __builtin_va_list);
+int __builtin___vprintf_chk(int, const char*, __builtin_va_list);


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8160,6 +8160,19 @@
   if (!rmerge.isNull())
 return rmerge;
 
+  if (!getLangOpts().CPlusPlus) {
+// Builtins that take a reference to a __builtin_va_list in some cases can be
+// of the type char*&.  Since this is illegal in C and caught in an assert in
+// mergeTypes, remove the reference.  The user cannot 'type' a char*&, so this
+// should be a good assumption.
+if (const auto *RefTy = lhs->getAs()) {
+  QualType VaListTy{getBuiltinVaListDecl()->getTypeForDecl(), 0};
+  if (RefTy->getPointeeType().getCanonicalType() ==
+  VaListTy.getCanonicalType())
+lhs = RefTy->getPointeeType();
+}
+  }
+
   return mergeTypes(lhs, rhs, OfBlockPointer, Unqualified);
 }
 
Index: test/Sema/va_list_builtin_func_redecl_errors.c
===
--- test/Sema/va_list_builtin_func_redecl_errors.c
+++ test/Sema/va_list_builtin_func_redecl_errors.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-unknown-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=i386-unknown-pc %s
+
+// expected-error@+2{{conflicting types for '__builtin_va_end'}}
+// expected-note@+1{{'__builtin_va_end' is a builtin with type}}
+void __builtin_va_end(void*);
+
+// expected-error@+2{{conflicting types for '__builtin___vprintf_chk'}}
+// expected-note@+1{{'__builtin___vprintf_chk' is a builtin with type}}
+int __builtin___vprintf_chk(int, const char*, void*);
+
+// expected-warning@+2{{incompatible redeclaration of library function 'vprintf'}}
+// expected-note@+1{{'vprintf' is a builtin with type}}
+int vprintf(const char*, void*);
Index: test/Sema/va_list_builtin_func_redecl.c
===
--- 

r329442 - Generate Libclang invocation reproducers using a new -cc1gen-reproducer

2018-04-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr  6 11:30:14 2018
New Revision: 329442

URL: http://llvm.org/viewvc/llvm-project?rev=329442=rev
Log:
Generate Libclang invocation reproducers using a new -cc1gen-reproducer
driver option

This commit is a follow up to the previous work that recorded Libclang 
invocations
into temporary files: r319702.

It adds a new -cc1 mode to clang: -cc1gen-reproducer. The goal of this mode is 
to generate
Clang reproducer files for Libclang tool invocation. The JSON format in the 
invocation
files is not really intended to be stable, so Libclang and Clang should be of 
the same version
when generating reproducers.
The new mode emits the information about the temporary files and 
Libclang-specific information
to stdout using JSON.

rdar://35322614

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

Added:
cfe/trunk/test/Index/create-libclang-completion-reproducer.c
cfe/trunk/test/Index/create-libclang-parsing-reproducer.c
cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=329442=329441=329442=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Apr  6 11:30:14 2018
@@ -405,11 +405,19 @@ public:
   int ExecuteCompilation(Compilation ,
  SmallVectorImpl< std::pair > );
 
-  /// generateCompilationDiagnostics - Generate diagnostics information 
+  /// Contains the files in the compilation diagnostic report generated by
+  /// generateCompilationDiagnostics.
+  struct CompilationDiagnosticReport {
+llvm::SmallVector TemporaryFiles;
+  };
+
+  /// generateCompilationDiagnostics - Generate diagnostics information
   /// including preprocessed source file(s).
-  /// 
-  void generateCompilationDiagnostics(Compilation ,
-  const Command );
+  ///
+  void generateCompilationDiagnostics(
+  Compilation , const Command ,
+  StringRef AdditionalInformation = "",
+  CompilationDiagnosticReport *GeneratedReport = nullptr);
 
   /// @}
   /// @name Helper Methods

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=329442=329441=329442=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Apr  6 11:30:14 2018
@@ -,8 +,9 @@ bool Driver::getCrashDiagnosticFile(Stri
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
-void Driver::generateCompilationDiagnostics(Compilation ,
-const Command ) {
+void Driver::generateCompilationDiagnostics(
+Compilation , const Command ,
+StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
@@ -1238,6 +1239,8 @@ void Driver::generateCompilationDiagnost
   SmallString<128> ReproCrashFilename;
   for (const char *TempFile : TempFiles) {
 Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
+if (Report)
+  Report->TemporaryFiles.push_back(TempFile);
 if (ReproCrashFilename.empty()) {
   ReproCrashFilename = TempFile;
   llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
@@ -1266,6 +1269,11 @@ void Driver::generateCompilationDiagnost
 ScriptOS << "# Original command: ";
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true, );
+if (!AdditionalInformation.empty())
+  ScriptOS << "\n# Additional information: " << AdditionalInformation
+   << "\n";
+if (Report)
+  Report->TemporaryFiles.push_back(Script);
 Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
   }
 

Added: cfe/trunk/test/Index/create-libclang-completion-reproducer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/create-libclang-completion-reproducer.c?rev=329442=auto
==
--- cfe/trunk/test/Index/create-libclang-completion-reproducer.c (added)
+++ cfe/trunk/test/Index/create-libclang-completion-reproducer.c Fri Apr  6 
11:30:14 2018
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test 
-code-completion-at=%s:10:1 
"-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s
+// RUN: %clang -cc1gen-reproducer 

[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2018-04-06 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329442: Generate Libclang invocation reproducers using a new 
-cc1gen-reproducer (authored by arphaman, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D40983?vs=127935=141391#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40983

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Index/create-libclang-completion-reproducer.c
  cfe/trunk/test/Index/create-libclang-parsing-reproducer.c
  cfe/trunk/tools/driver/CMakeLists.txt
  cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
  cfe/trunk/tools/driver/driver.cpp

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -,8 +,9 @@
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
-void Driver::generateCompilationDiagnostics(Compilation ,
-const Command ) {
+void Driver::generateCompilationDiagnostics(
+Compilation , const Command ,
+StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
@@ -1238,6 +1239,8 @@
   SmallString<128> ReproCrashFilename;
   for (const char *TempFile : TempFiles) {
 Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
+if (Report)
+  Report->TemporaryFiles.push_back(TempFile);
 if (ReproCrashFilename.empty()) {
   ReproCrashFilename = TempFile;
   llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
@@ -1266,6 +1269,11 @@
 ScriptOS << "# Original command: ";
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
 Cmd.Print(ScriptOS, "\n", /*Quote=*/true, );
+if (!AdditionalInformation.empty())
+  ScriptOS << "\n# Additional information: " << AdditionalInformation
+   << "\n";
+if (Report)
+  Report->TemporaryFiles.push_back(Script);
 Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
   }
 
Index: cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
===
--- cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
+++ cfe/trunk/tools/driver/cc1gen_reproducer_main.cpp
@@ -0,0 +1,196 @@
+//===-- cc1gen_reproducer_main.cpp - Clang reproducer generator  --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This is the entry point to the clang -cc1gen-reproducer functionality, which
+// generates reproducers for invocations for clang-based tools.
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+namespace {
+
+struct UnsavedFileHash {
+  std::string Name;
+  std::string MD5;
+};
+
+struct ClangInvocationInfo {
+  std::string Toolchain;
+  std::string LibclangOperation;
+  std::string LibclangOptions;
+  std::vector Arguments;
+  std::vector InvocationArguments;
+  std::vector UnsavedFileHashes;
+  bool Dump = false;
+};
+
+} // end anonymous namespace
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(UnsavedFileHash)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  static void mapping(IO , UnsavedFileHash ) {
+IO.mapRequired("name", Info.Name);
+IO.mapRequired("md5", Info.MD5);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO , ClangInvocationInfo ) {
+IO.mapRequired("toolchain", Info.Toolchain);
+IO.mapOptional("libclang.operation", Info.LibclangOperation);
+IO.mapOptional("libclang.opts", Info.LibclangOptions);
+IO.mapRequired("args", Info.Arguments);
+IO.mapOptional("invocation-args", Info.InvocationArguments);
+IO.mapOptional("unsaved_file_hashes", Info.UnsavedFileHashes);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+static std::string generateReproducerMetaInfo(const ClangInvocationInfo ) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << '{';
+  bool NeedComma = false;
+  auto EmitKey = [&](StringRef Key) {
+if (NeedComma)
+  OS << ", ";
+NeedComma = 

[PATCH] D45382: [CodeGen] Avoid destructing a struct type that has already been destructed by a delegated constructor

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, rsmith.
Herald added a subscriber: kristof.beyls.

This patch fixes a bug where a struct with an ObjC `__weak` field gets 
destructed after it has already been destructed. This bug was introduced in 
r328731, which made changes to the ABI that caused structs with ObjC pointer 
fields to be destructed in the callee in some cases.

This happens in two cases:

1. C++11 inheriting constructors.
2. When EmitConstructorBody does complete->base constructor delegation 
optimization.

I fixed the first case by making changes to canEmitDelegateCallArgs so that it 
returns false when the constructor has a parameter that is destructed in the 
callee.

For the second case, I made changes so that EmitParmDecl doesn't push the 
destructor cleanup for the struct parameter if the function is a constructor 
that is going to delegate to the base constructor. Alternatively, I think it's 
possible to just disable the optimization in EmitConstructorBody if 
canEmitDelegateCallArgs returns false.

rdar://problem/39194693


Repository:
  rC Clang

https://reviews.llvm.org/D45382

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenObjCXX/arc-special-member-functions.mm

Index: test/CodeGenObjCXX/arc-special-member-functions.mm
===
--- test/CodeGenObjCXX/arc-special-member-functions.mm
+++ test/CodeGenObjCXX/arc-special-member-functions.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
 
 struct ObjCMember {
   id member;
@@ -12,6 +12,54 @@
   int (^bp)(int);
 };
 
+// CHECK: %[[STRUCT_CONTAINSWEAK:.*]] = type { %[[STRUCT_WEAK:.*]] }
+// CHECK: %[[STRUCT_WEAK]] = type { i8* }
+
+// The Weak object that is passed is destructed in this constructor.
+
+// CHECK: define void @_ZN12ContainsWeakC2E4Weak(
+// CHECK: call void @_ZN4WeakC1ERKS_(
+// CHECK: call void @_ZN4WeakD1Ev(
+
+// Check that Weak's destructor is not called after the delegate constructor is
+// called.
+
+// CHECK: define void @_ZN12ContainsWeakC1E4Weak(
+// CHECK: call void @_ZN12ContainsWeakC2E4Weak(
+// CHECK-NEXT: ret void
+
+struct Weak {
+  Weak(id);
+  __weak id x;
+};
+
+struct ContainsWeak {
+  ContainsWeak(Weak);
+  Weak w;
+};
+
+ContainsWeak::ContainsWeak(Weak a) : w(a) {}
+
+// Check that the call to the inheriting constructor is inlined.
+
+// CHECK: define internal void @__cxx_global_var_init{{.*}}()
+// CHECK: call void @_ZN4WeakC1EP11objc_object(
+// CHECK-NOT: call
+// CHECK: call void @_ZN4BaseC2E4Weak(
+// CHECK-NEXT: ret void
+
+struct Base {
+  Base(Weak);
+};
+
+Base::Base(Weak a) {}
+
+struct Derived : Base {
+  using Base::Base;
+};
+
+Derived d(Weak(0));
+
 // CHECK-LABEL: define void @_Z42test_ObjCMember_default_construct_destructv(
 void test_ObjCMember_default_construct_destruct() {
   // CHECK: call void @_ZN10ObjCMemberC1Ev
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -380,6 +380,10 @@
   /// should emit cleanups.
   bool CurFuncIsThunk;
 
+  /// In C++, whether we are code generating a constructor that is calling a
+  /// delegating constructor.
+  bool DelegateCXXConstructorCall;
+
   /// In ARC, whether we should autorelease the return value.
   bool AutoreleaseResult;
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -67,7 +67,8 @@
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
   CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
-  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  IsSanitizerScope(false), CurFuncIsThunk(false),
+  DelegateCXXConstructorCall(false), AutoreleaseResult(false),
   SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
   BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
   NormalCleanupDest(Address::invalid()), NextCleanupDestIndex(1),
@@ -1307,6 +1308,13 @@
   if (Body && ShouldEmitLifetimeMarkers)
 Bypasses.Init(Body);
 
+  if (const auto *Ctor = dyn_cast(CurGD.getDecl())) {
+if (CurGD.getCtorType() == Ctor_Complete &&
+IsConstructorDelegationValid(Ctor) &&
+CGM.getTarget().getCXXABI().hasConstructorVariants())
+  DelegateCXXConstructorCall = true;
+  }
+
   // Emit the standard function prologue.
   StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
 
Index: lib/CodeGen/CGDecl.cpp

[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics

2018-04-06 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Headers/waitpkgintrin.h:41
+static __inline__ void __DEFAULT_FN_ATTRS
+_umwait (__SIZE_TYPE__  __CONTROL, __UINT64_TYPE__  __COUNTER)
+{

craig.topper wrote:
> Why does the intrinsic take size_t but then its truncated to 32 bits?
When I replaced umwait32 & umwait64 with a single umwait LLVM intrinsic, I 
choose i32 as the type of the first argument.
The doc says:
bit[0] has a meaning, while bit[31:1] are reserved.
The doc doesn't suggest that the upper 32 bits might ever be used.
But I see, this might need some more discussion.


https://reviews.llvm.org/D45254



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > yaxunl wrote:
> > > > tra wrote:
> > > > > yaxunl wrote:
> > > > > > tra wrote:
> > > > > > > Unless you're planning to guarantee 1:1 match to functionality 
> > > > > > > provided by nvidia's sm_32, it would be prudent to use some other 
> > > > > > > value for the macro so the source code has a way to tell these 
> > > > > > > GPUs apart.
> > > > > > > 
> > > > > > > Another issue with this approach is that typical use pattern for 
> > > > > > > __CUDA_ARCH__ is 
> > > > > > > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be 
> > > > > > > able to maintain order across GPU architectures among NVIDIA and 
> > > > > > > AMD GPUs. Perhaps for HIP compilation it would make more sense to 
> > > > > > > define __CUDA_ARCH__ as 1 (this should serve as a legacy 
> > > > > > > indication of device-side compilation) and define __HIP_ARCH__ to 
> > > > > > > indicate which AMD GPU we're compiling for without accidentally 
> > > > > > > enabling something that was intended for NVIDIA's GPUs only.
> > > > > > I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can 
> > > > > > make that change.
> > > > > > 
> > > > > > On the other hand, I think it may be difficult to define 
> > > > > > `__HIP_ARCH__` which can sort mixed nvptx/amdgcn GPU's by 
> > > > > > capability. I do think a well defined `__HIP_ARCH__` would be 
> > > > > > useful for users. Just need some further discussion how to define 
> > > > > > it.
> > > > > > 
> > > > > > For now, if there are specific codes for nvptx, it can continue use 
> > > > > > `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can 
> > > > > > check predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
> > > > > OK.
> > > > > 
> > > > I asked Ben Sander about whether we can define __HIP_ARCH__, here is 
> > > > his answer:
> > > > 
> > > > HIP targets a broader set of hardware than just a single vendor so 
> > > > additional flexibility in defining feature capability is required.  The 
> > > > HIP_ARCH_ macro provide per-feature-granularity mechanism to query 
> > > > features.  Also the code tends to be more clear as opposed to an "if 
> > > > __CUDA_ARCH>3 ..assume some feature".
> > > > 
> > > > For example
> > > > 
> > > > 
> > > > ```
> > > > // 32-bit Atomics:
> > > > #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (1)
> > > > #define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (1)
> > > > #define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (1)
> > > > #define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (1)
> > > > #define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (1)
> > > > 
> > > > // 64-bit Atomics:
> > > > #define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (1)
> > > > #define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (0)
> > > > 
> > > > // Doubles
> > > > #define __HIP_ARCH_HAS_DOUBLES__ (1)
> > > > 
> > > > // warp cross-lane operations:
> > > > #define __HIP_ARCH_HAS_WARP_VOTE__ (1)
> > > > #define __HIP_ARCH_HAS_WARP_BALLOT__ (1)
> > > > #define __HIP_ARCH_HAS_WARP_SHUFFLE__ (1)
> > > > #define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (0)
> > > > 
> > > > // sync
> > > > #define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (1)
> > > > #define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (0)
> > > > 
> > > > // misc
> > > > #define __HIP_ARCH_HAS_SURFACE_FUNCS__ (0)
> > > > #define __HIP_ARCH_HAS_3DGRID__ (1)
> > > > #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0)
> > > > ```
> > > I assume that will be handled somewhere else -- different patch, 
> > > different place.
> > > Looks like setting `__CUDA_ARCH__` to 1 is all that should be done here.
> > > 
> > > While we're looking a this, is CUDA compatibility one of your goals? I.e. 
> > > do you expect existing CUDA code to be compilable and functional on AMD 
> > > hardware? If not, then, perhaps you don't need `__CUDA_*__` defines at 
> > > all.
> > CUDA code needs to be translated to HIP code since the host API is 
> > different. In most cases the translation can be done by script 
> > automatically. `__CUDA_ARCH__` cannot be automatically translated because 
> > it is not portable to non-nvptx devices, however it is often used to 
> > indicate device compilation. Therefore we still need to define it in HIP to 
> > indicate device compilation. In this way, CUDA programs using 
> > `__CUDA_ARCH__` just for checking device compilation can be automatically 
> > translated. If users want to use features associated with specific 
> > `__CUDA_ARCH__` they can manually modify the translated code to use 
> > `__HIP_ARCH_HAS_*` macros.
> It sounds like this translation is a one-time offline process and  HIP-mode 
> compiler is not going to see any non-HIP code. If that's the case, I'm not 
> quite sure I see the need for defining `__CUDA_ARCH__` in HIP mode -- 
> translation process should've converted the 

[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-06 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.

Thanks for updating it to use the stuff from TargetParser.

LGTM, with tests for the cases @joerg mentiond.




Comment at: lib/Basic/Targets/ARM.cpp:345
   // get default FPU features
+  llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(getTriple().getArchName());
   unsigned FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);

efriedma wrote:
> fhahn wrote:
> > Is there a reason we re-compute the Arch from the triple here, but use the 
> > member variable ArchKind above? Shouldn't they both be the same ?
> ArchKind is based on the triple and the CPU, where "Arch" is just based on 
> the triple, so "Arch" was returning the wrong thing in some cases.
> 
> Actually, looking a bit more, we should probably be calling parseCPUArch here 
> to get the right behavior, rather than depending on the member.  (It doesn't 
> usually matter, but it could make a difference for code using "target" 
> attribute, I guess.  That feature needs a lot more work, though.)
Thanks that makes sense. getDefaultFPU and getDefaultExtensions are only for 
"generic" FPUs.


Repository:
  rC Clang

https://reviews.llvm.org/D45240



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

yaxunl wrote:
> tra wrote:
> > yaxunl wrote:
> > > tra wrote:
> > > > yaxunl wrote:
> > > > > tra wrote:
> > > > > > Unless you're planning to guarantee 1:1 match to functionality 
> > > > > > provided by nvidia's sm_32, it would be prudent to use some other 
> > > > > > value for the macro so the source code has a way to tell these GPUs 
> > > > > > apart.
> > > > > > 
> > > > > > Another issue with this approach is that typical use pattern for 
> > > > > > __CUDA_ARCH__ is 
> > > > > > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be 
> > > > > > able to maintain order across GPU architectures among NVIDIA and 
> > > > > > AMD GPUs. Perhaps for HIP compilation it would make more sense to 
> > > > > > define __CUDA_ARCH__ as 1 (this should serve as a legacy indication 
> > > > > > of device-side compilation) and define __HIP_ARCH__ to indicate 
> > > > > > which AMD GPU we're compiling for without accidentally enabling 
> > > > > > something that was intended for NVIDIA's GPUs only.
> > > > > I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can 
> > > > > make that change.
> > > > > 
> > > > > On the other hand, I think it may be difficult to define 
> > > > > `__HIP_ARCH__` which can sort mixed nvptx/amdgcn GPU's by capability. 
> > > > > I do think a well defined `__HIP_ARCH__` would be useful for users. 
> > > > > Just need some further discussion how to define it.
> > > > > 
> > > > > For now, if there are specific codes for nvptx, it can continue use 
> > > > > `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
> > > > > predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
> > > > OK.
> > > > 
> > > I asked Ben Sander about whether we can define __HIP_ARCH__, here is his 
> > > answer:
> > > 
> > > HIP targets a broader set of hardware than just a single vendor so 
> > > additional flexibility in defining feature capability is required.  The 
> > > HIP_ARCH_ macro provide per-feature-granularity mechanism to query 
> > > features.  Also the code tends to be more clear as opposed to an "if 
> > > __CUDA_ARCH>3 ..assume some feature".
> > > 
> > > For example
> > > 
> > > 
> > > ```
> > > // 32-bit Atomics:
> > > #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (1)
> > > #define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (1)
> > > #define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (1)
> > > #define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (1)
> > > #define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (1)
> > > 
> > > // 64-bit Atomics:
> > > #define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (1)
> > > #define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (0)
> > > 
> > > // Doubles
> > > #define __HIP_ARCH_HAS_DOUBLES__ (1)
> > > 
> > > // warp cross-lane operations:
> > > #define __HIP_ARCH_HAS_WARP_VOTE__ (1)
> > > #define __HIP_ARCH_HAS_WARP_BALLOT__ (1)
> > > #define __HIP_ARCH_HAS_WARP_SHUFFLE__ (1)
> > > #define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (0)
> > > 
> > > // sync
> > > #define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (1)
> > > #define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (0)
> > > 
> > > // misc
> > > #define __HIP_ARCH_HAS_SURFACE_FUNCS__ (0)
> > > #define __HIP_ARCH_HAS_3DGRID__ (1)
> > > #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0)
> > > ```
> > I assume that will be handled somewhere else -- different patch, different 
> > place.
> > Looks like setting `__CUDA_ARCH__` to 1 is all that should be done here.
> > 
> > While we're looking a this, is CUDA compatibility one of your goals? I.e. 
> > do you expect existing CUDA code to be compilable and functional on AMD 
> > hardware? If not, then, perhaps you don't need `__CUDA_*__` defines at all.
> CUDA code needs to be translated to HIP code since the host API is different. 
> In most cases the translation can be done by script automatically. 
> `__CUDA_ARCH__` cannot be automatically translated because it is not portable 
> to non-nvptx devices, however it is often used to indicate device 
> compilation. Therefore we still need to define it in HIP to indicate device 
> compilation. In this way, CUDA programs using `__CUDA_ARCH__` just for 
> checking device compilation can be automatically translated. If users want to 
> use features associated with specific `__CUDA_ARCH__` they can manually 
> modify the translated code to use `__HIP_ARCH_HAS_*` macros.
It sounds like this translation is a one-time offline process and  HIP-mode 
compiler is not going to see any non-HIP code. If that's the case, I'm not 
quite sure I see the need for defining `__CUDA_ARCH__` in HIP mode -- 
translation process should've converted the CUDA-specific macro in the original 
code to it's HIP equivalent or get user to part it to something HIP can deal 
with.

HIP programming guide also says that `__CUDA_ARCH__` is [[ 

[PATCH] D38479: Make -mgeneral-regs-only more like GCC's

2018-04-06 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Hallo! I was wondering what the status of this patch was. :-)


https://reviews.llvm.org/D38479



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


[libunwind] r329340 - [cmake] Remove duplicate command line options from build

2018-04-06 Thread Aaron Smith via cfe-commits
Author: asmith
Date: Thu Apr  5 13:27:50 2018
New Revision: 329340

URL: http://llvm.org/viewvc/llvm-project?rev=329340=rev
Log:
[cmake] Remove duplicate command line options from build

CMAKE_CXX_FLAGS and CMAKE_C_FLAGS are added twice to the command line.
This causes the command line options to be doubled which works until
it doesn't as not all options can be specified twice. 

For example,

clang-cl foo.c /GS- /GS- -mllvm -small-loop-cost=1 -mllvm -small-loop-cost=1
clang (LLVM option parsing): for the -small-loop-cost option: may only occur 
zero or one times!


Modified:
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=329340=329339=329340=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Thu Apr  5 13:27:50 2018
@@ -91,9 +91,9 @@ string(REPLACE ";" " " LIBUNWIND_C_FLAGS
 string(REPLACE ";" " " LIBUNWIND_LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}")
 
 set_property(SOURCE ${LIBUNWIND_CXX_SOURCES}
- APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_CXX_FLAGS} 
${LIBUNWIND_CXX_FLAGS}")
+ APPEND_STRING PROPERTY COMPILE_FLAGS " ${LIBUNWIND_CXX_FLAGS}")
 set_property(SOURCE ${LIBUNWIND_C_SOURCES}
- APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_C_FLAGS} 
${LIBUNWIND_C_FLAGS}")
+ APPEND_STRING PROPERTY COMPILE_FLAGS " ${LIBUNWIND_C_FLAGS}")
 
 # Add a object library that contains the compiled source files.
 add_library(unwind_objects OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})


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


r329223 - Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960

2018-04-06 Thread Max Moroz via cfe-commits
Author: dor1s
Date: Wed Apr  4 12:47:25 2018
New Revision: 329223

URL: http://llvm.org/viewvc/llvm-project?rev=329223=rev
Log:
Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960

Summary:
In https://reviews.llvm.org/D44960, file status check is executed every
time a real file system directory iterator is constructed or
incremented, and emits an error code. This change list fixes the errors
in VirtualFileSystem caused by https://reviews.llvm.org/D44960.

Patch by Yuke Liao (@liaoyuke).

Reviewers: vsk, pcc, zturner, liaoyuke

Reviewed By: vsk

Subscribers: mgrang, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=329223=329222=329223=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Apr  4 12:47:25 2018
@@ -286,24 +286,26 @@ class RealFSDirIter : public clang::vfs:
 
 public:
   RealFSDirIter(const Twine , std::error_code ) : Iter(Path, EC) {
-if (!EC && Iter != llvm::sys::fs::directory_iterator()) {
+if (Iter != llvm::sys::fs::directory_iterator()) {
   llvm::sys::fs::file_status S;
-  EC = llvm::sys::fs::status(Iter->path(), S, true);
+  std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
   CurrentEntry = Status::copyWithNewName(S, Iter->path());
+  if (!EC)
+EC = ErrorCode;
 }
   }
 
   std::error_code increment() override {
 std::error_code EC;
 Iter.increment(EC);
-if (EC) {
-  return EC;
-} else if (Iter == llvm::sys::fs::directory_iterator()) {
+if (Iter == llvm::sys::fs::directory_iterator()) {
   CurrentEntry = Status();
 } else {
   llvm::sys::fs::file_status S;
-  EC = llvm::sys::fs::status(Iter->path(), S, true);
+  std::error_code ErrorCode = llvm::sys::fs::status(Iter->path(), S, true);
   CurrentEntry = Status::copyWithNewName(S, Iter->path());
+  if (!EC)
+EC = ErrorCode;
 }
 return EC;
   }

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=329223=329222=329223=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Wed Apr  4 12:47:25 2018
@@ -442,16 +442,17 @@ TEST(VirtualFileSystemTest, BrokenSymlin
   ScopedDir _dd(TestDirectory + "/d/d");
   ScopedDir _ddd(TestDirectory + "/d/d/d");
   ScopedLink _e("no_such_file", TestDirectory + "/e");
-  std::vector Expected = {_b, _bb, _d, _dd, _ddd};
 
-  std::vector Contents;
+  std::vector ExpectedBrokenSymlinks = {_a, _ba, _bc, _c, _e};
+  std::vector ExpectedNonBrokenSymlinks = {_b, _bb, _d, _dd, _ddd};
+  std::vector VisitedBrokenSymlinks;
+  std::vector VisitedNonBrokenSymlinks;
   std::error_code EC;
   for (vfs::recursive_directory_iterator I(*FS, Twine(TestDirectory), EC), E;
I != E; I.increment(EC)) {
-// Skip broken symlinks.
 auto EC2 = std::make_error_code(std::errc::no_such_file_or_directory);
 if (EC == EC2) {
-  EC.clear();
+  VisitedBrokenSymlinks.push_back(I->getName());
   continue;
 }
 // For bot debugging.
@@ -467,13 +468,20 @@ TEST(VirtualFileSystemTest, BrokenSymlin
  << "EC message: " << EC2.message() << "\n";
 }
 ASSERT_FALSE(EC);
-Contents.push_back(I->getName());
+VisitedNonBrokenSymlinks.push_back(I->getName());
   }
 
-  // Check sorted contents.
-  llvm::sort(Contents.begin(), Contents.end());
-  EXPECT_EQ(Expected.size(), Contents.size());
-  EXPECT_TRUE(std::equal(Contents.begin(), Contents.end(), Expected.begin()));
+  // Check visited file names.
+  std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
+  std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
+  EXPECT_EQ(ExpectedBrokenSymlinks.size(), VisitedBrokenSymlinks.size());
+  EXPECT_TRUE(std::equal(VisitedBrokenSymlinks.begin(),
+ VisitedBrokenSymlinks.end(),
+ ExpectedBrokenSymlinks.begin()));
+  EXPECT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
+  EXPECT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
+ VisitedNonBrokenSymlinks.end(),
+ ExpectedNonBrokenSymlinks.begin()));
 }
 #endif
 


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


r329278 - [PATCH] [RISCV] Extend getTargetDefines for RISCVTargetInfo

2018-04-06 Thread Shiva Chen via cfe-commits
Author: shiva
Date: Thu Apr  5 05:54:00 2018
New Revision: 329278

URL: http://llvm.org/viewvc/llvm-project?rev=329278=rev
Log:
[PATCH] [RISCV] Extend getTargetDefines for RISCVTargetInfo

Summary:
This patch extend getTargetDefines and implement handleTargetFeatures
and hasFeature. and define corresponding marco for those features.

Reviewers: asb, apazos, eli.friedman

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

Patch by Kito Cheng.

Added:
cfe/trunk/test/Preprocessor/riscv-target-features.c
Modified:
cfe/trunk/lib/Basic/Targets/RISCV.cpp
cfe/trunk/lib/Basic/Targets/RISCV.h
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/target-features.m

Modified: cfe/trunk/lib/Basic/Targets/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.cpp?rev=329278=329277=329278=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp Thu Apr  5 05:54:00 2018
@@ -49,4 +49,56 @@ void RISCVTargetInfo::getTargetDefines(c
   // TODO: modify when more code models and ABIs are supported.
   Builder.defineMacro("__riscv_cmodel_medlow");
   Builder.defineMacro("__riscv_float_abi_soft");
+
+  if (HasM) {
+Builder.defineMacro("__riscv_mul");
+Builder.defineMacro("__riscv_div");
+Builder.defineMacro("__riscv_muldiv");
+  }
+
+  if (HasA)
+Builder.defineMacro("__riscv_atomic");
+
+  if (HasF || HasD) {
+Builder.defineMacro("__riscv_flen", HasD ? "64" : "32");
+Builder.defineMacro("__riscv_fdiv");
+Builder.defineMacro("__riscv_fsqrt");
+  }
+
+  if (HasC)
+Builder.defineMacro("__riscv_compressed");
+}
+
+/// Return true if has this feature, need to sync with handleTargetFeatures.
+bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
+  bool Is64Bit = getTriple().getArch() == llvm::Triple::riscv64;
+  return llvm::StringSwitch(Feature)
+  .Case("riscv", true)
+  .Case("riscv32", !Is64Bit)
+  .Case("riscv64", Is64Bit)
+  .Case("m", HasM)
+  .Case("a", HasA)
+  .Case("f", HasF)
+  .Case("d", HasD)
+  .Case("c", HasC)
+  .Default(false);
+}
+
+/// Perform initialization based on the user configured set of features.
+bool RISCVTargetInfo::handleTargetFeatures(std::vector ,
+   DiagnosticsEngine ) {
+  for (const auto  : Features) {
+if (Feature == "+m")
+  HasM = true;
+else if (Feature == "+a")
+  HasA = true;
+else if (Feature == "+f")
+  HasF = true;
+else if (Feature == "+d")
+  HasD = true;
+else if (Feature == "+c")
+  HasC = true;
+  }
+
+  return true;
 }

Modified: cfe/trunk/lib/Basic/Targets/RISCV.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.h?rev=329278=329277=329278=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.h (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.h Thu Apr  5 05:54:00 2018
@@ -26,10 +26,16 @@ namespace targets {
 class RISCVTargetInfo : public TargetInfo {
 protected:
   std::string ABI;
+  bool HasM;
+  bool HasA;
+  bool HasF;
+  bool HasD;
+  bool HasC;
 
 public:
   RISCVTargetInfo(const llvm::Triple , const TargetOptions &)
-  : TargetInfo(Triple) {
+  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
+HasD(false), HasC(false) {
 TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
@@ -59,6 +65,11 @@ public:
  TargetInfo::ConstraintInfo ) const override {
 return false;
   }
+
+  bool hasFeature(StringRef Feature) const override;
+
+  bool handleTargetFeatures(std::vector ,
+DiagnosticsEngine ) override;
 };
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=329278=329277=329278=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Thu Apr  5 05:54:00 2018
@@ -380,6 +380,11 @@ module TargetFeatures {
 module x86_32 { requires x86_32 }
 module x86_64 { requires x86_64 }
   }
+  module riscv {
+requires riscv
+module riscv32 { requires riscv32 }
+module riscv64 { requires riscv64 }
+  }
 }
 
 module DebugSubmodules {

Modified: cfe/trunk/test/Modules/target-features.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/target-features.m?rev=329278=329277=329278=diff
==
--- cfe/trunk/test/Modules/target-features.m (original)
+++ cfe/trunk/test/Modules/target-features.m Thu Apr  5 05:54:00 2018
@@ -1,6 +1,7 @@
 // REQUIRES: 

Re: [PATCH] D41316: [libcxx] Allow random_device to be built optionally

2018-04-06 Thread Jon Roelofs via cfe-commits
>  the targets where you would want to use this can't run the libcxx
testsuite anyway (because they don't have an operating system to run the
test programs under).

I used to run libcxx tests for an arm baremetal toolchain I was building
via semihosted QEMU. It was awkward and slow (especially for some of the
std::*_distribution tests), but it worked.


Jon

On Thu, Apr 5, 2018 at 7:55 PM, Eli Friedman via Phabricator <
revi...@reviews.llvm.org> wrote:

> efriedma updated this revision to Diff 141255.
> efriedma added a comment.
>
> Get rid of the test changes.
>
> They were broken in multiple ways, and weren't really useful anyway
> because the targets where you would want to use this can't run the libcxx
> testsuite anyway (because they don't have an operating system to run the
> test programs under).
>
>
> Repository:
>   rCXX libc++
>
> https://reviews.llvm.org/D41316
>
> Files:
>   CMakeLists.txt
>   include/__config_site.in
>   include/random
>   src/random.cpp
>
>
> Index: src/random.cpp
> ===
> --- src/random.cpp
> +++ src/random.cpp
> @@ -8,6 +8,7 @@
>  //===---
> ---===//
>
>  #include <__config>
> +#ifndef _LIBCPP_HAS_NO_RANDOM_DEVICE
>
>  #if defined(_LIBCPP_USING_WIN32_RANDOM)
>  // Must be defined before including stdlib.h to enable rand_s().
> @@ -177,3 +178,4 @@
>  }
>
>  _LIBCPP_END_NAMESPACE_STD
> +#endif // _LIBCPP_HAS_NO_RANDOM_DEVICE
> Index: include/random
> ===
> --- include/random
> +++ include/random
> @@ -3476,6 +3476,7 @@
>
>  typedef shuffle_order_engine
>  knuth_b;
>
> +#ifndef _LIBCPP_HAS_NO_RANDOM_DEVICE
>  // random_device
>
>  class _LIBCPP_TYPE_VIS random_device
> @@ -3511,6 +3512,7 @@
>  random_device(const random_device&); // = delete;
>  random_device& operator=(const random_device&); // = delete;
>  };
> +#endif // _LIBCPP_HAS_NO_RANDOM_DEVICE
>
>  // seed_seq
>
> Index: include/__config_site.in
> ===
> --- include/__config_site.in
> +++ include/__config_site.in
> @@ -20,6 +20,7 @@
>  #cmakedefine _LIBCPP_HAS_NO_THREADS
>  #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
>  #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
> +#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
>  #cmakedefine _LIBCPP_HAS_MUSL_LIBC
>  #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
>  #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
> Index: CMakeLists.txt
> ===
> --- CMakeLists.txt
> +++ CMakeLists.txt
> @@ -71,6 +71,7 @@
>  option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of
> libc++experimental.a"
>  ${ENABLE_FILESYSTEM_DEFAULT})
>  option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests."
> ${LLVM_INCLUDE_TESTS})
> +option(LIBCXX_ENABLE_RANDOM_DEVICE "Build random_device class" ON)
>
>  # Benchmark options --
> -
>  option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their
> dependancies" ON)
> @@ -632,6 +633,7 @@
>  config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
>  config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK
> _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
>  config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS
> _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
> +config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE
> _LIBCPP_HAS_NO_RANDOM_DEVICE)
>
>  config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
>  config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_
> EXTERNAL)
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > yaxunl wrote:
> > > > tra wrote:
> > > > > Unless you're planning to guarantee 1:1 match to functionality 
> > > > > provided by nvidia's sm_32, it would be prudent to use some other 
> > > > > value for the macro so the source code has a way to tell these GPUs 
> > > > > apart.
> > > > > 
> > > > > Another issue with this approach is that typical use pattern for 
> > > > > __CUDA_ARCH__ is 
> > > > > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able 
> > > > > to maintain order across GPU architectures among NVIDIA and AMD GPUs. 
> > > > > Perhaps for HIP compilation it would make more sense to define 
> > > > > __CUDA_ARCH__ as 1 (this should serve as a legacy indication of 
> > > > > device-side compilation) and define __HIP_ARCH__ to indicate which 
> > > > > AMD GPU we're compiling for without accidentally enabling something 
> > > > > that was intended for NVIDIA's GPUs only.
> > > > I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can make 
> > > > that change.
> > > > 
> > > > On the other hand, I think it may be difficult to define `__HIP_ARCH__` 
> > > > which can sort mixed nvptx/amdgcn GPU's by capability. I do think a 
> > > > well defined `__HIP_ARCH__` would be useful for users. Just need some 
> > > > further discussion how to define it.
> > > > 
> > > > For now, if there are specific codes for nvptx, it can continue use 
> > > > `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
> > > > predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
> > > OK.
> > > 
> > I asked Ben Sander about whether we can define __HIP_ARCH__, here is his 
> > answer:
> > 
> > HIP targets a broader set of hardware than just a single vendor so 
> > additional flexibility in defining feature capability is required.  The 
> > HIP_ARCH_ macro provide per-feature-granularity mechanism to query 
> > features.  Also the code tends to be more clear as opposed to an "if 
> > __CUDA_ARCH>3 ..assume some feature".
> > 
> > For example
> > 
> > 
> > ```
> > // 32-bit Atomics:
> > #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (1)
> > #define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (1)
> > #define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (1)
> > #define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (1)
> > #define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (1)
> > 
> > // 64-bit Atomics:
> > #define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (1)
> > #define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (0)
> > 
> > // Doubles
> > #define __HIP_ARCH_HAS_DOUBLES__ (1)
> > 
> > // warp cross-lane operations:
> > #define __HIP_ARCH_HAS_WARP_VOTE__ (1)
> > #define __HIP_ARCH_HAS_WARP_BALLOT__ (1)
> > #define __HIP_ARCH_HAS_WARP_SHUFFLE__ (1)
> > #define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (0)
> > 
> > // sync
> > #define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (1)
> > #define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (0)
> > 
> > // misc
> > #define __HIP_ARCH_HAS_SURFACE_FUNCS__ (0)
> > #define __HIP_ARCH_HAS_3DGRID__ (1)
> > #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0)
> > ```
> I assume that will be handled somewhere else -- different patch, different 
> place.
> Looks like setting `__CUDA_ARCH__` to 1 is all that should be done here.
> 
> While we're looking a this, is CUDA compatibility one of your goals? I.e. do 
> you expect existing CUDA code to be compilable and functional on AMD 
> hardware? If not, then, perhaps you don't need `__CUDA_*__` defines at all.
CUDA code needs to be translated to HIP code since the host API is different. 
In most cases the translation can be done by script automatically. 
`__CUDA_ARCH__` cannot be automatically translated because it is not portable 
to non-nvptx devices, however it is often used to indicate device compilation. 
Therefore we still need to define it in HIP to indicate device compilation. In 
this way, CUDA programs using `__CUDA_ARCH__` just for checking device 
compilation can be automatically translated. If users want to use features 
associated with specific `__CUDA_ARCH__` they can manually modify the 
translated code to use `__HIP_ARCH_HAS_*` macros.


Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


[libclc] r329433 - fmod: Port from amd_builtins

2018-04-06 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Apr  6 10:43:08 2018
New Revision: 329433

URL: http://llvm.org/viewvc/llvm-project?rev=329433=rev
Log:
fmod: Port from amd_builtins

Uses only denormal path for fp32.
Passes CTS on carrizo and turks.

v2: whitespace fix

Signed-off-by: Jan Vesely 
Reviewer: Aaron Watry 

Added:
libclc/trunk/generic/include/math/clc_fmod.h
libclc/trunk/generic/lib/math/clc_fmod.cl
Removed:
libclc/trunk/generic/include/clc/math/fmod.inc
Modified:
libclc/trunk/generic/include/clc/math/fmod.h
libclc/trunk/generic/lib/SOURCES
libclc/trunk/generic/lib/math/fmod.cl

Modified: libclc/trunk/generic/include/clc/math/fmod.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fmod.h?rev=329433=329432=329433=diff
==
--- libclc/trunk/generic/include/clc/math/fmod.h (original)
+++ libclc/trunk/generic/include/clc/math/fmod.h Fri Apr  6 10:43:08 2018
@@ -1,2 +1,4 @@
-#define __CLC_BODY 
+#define __CLC_FUNCTION fmod
+#define __CLC_BODY 
 #include 
+#undef __CLC_FUNCTION

Removed: libclc/trunk/generic/include/clc/math/fmod.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fmod.inc?rev=329432=auto
==
--- libclc/trunk/generic/include/clc/math/fmod.inc (original)
+++ libclc/trunk/generic/include/clc/math/fmod.inc (removed)
@@ -1 +0,0 @@
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fmod(__CLC_GENTYPE a, __CLC_GENTYPE b);

Added: libclc/trunk/generic/include/math/clc_fmod.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_fmod.h?rev=329433=auto
==
--- libclc/trunk/generic/include/math/clc_fmod.h (added)
+++ libclc/trunk/generic/include/math/clc_fmod.h Fri Apr  6 10:43:08 2018
@@ -0,0 +1,4 @@
+#define __CLC_FUNCTION __clc_fmod
+#define __CLC_BODY 
+#include 
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=329433=329432=329433=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Apr  6 10:43:08 2018
@@ -102,6 +102,7 @@ math/exp10.cl
 math/fdim.cl
 math/fmax.cl
 math/fmin.cl
+math/clc_fmod.cl
 math/fmod.cl
 math/fract.cl
 math/frexp.cl

Added: libclc/trunk/generic/lib/math/clc_fmod.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/clc_fmod.cl?rev=329433=auto
==
--- libclc/trunk/generic/lib/math/clc_fmod.cl (added)
+++ libclc/trunk/generic/lib/math/clc_fmod.cl Fri Apr  6 10:43:08 2018
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+
+#include 
+#include "../clcmacro.h"
+#include "config.h"
+#include "math.h"
+
+_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y)
+{
+int ux = as_int(x);
+int ax = ux & EXSIGNBIT_SP32;
+float xa = as_float(ax);
+int sx = ux ^ ax;
+int ex = ax >> EXPSHIFTBITS_SP32;
+
+int uy = as_int(y);
+int ay = uy & EXSIGNBIT_SP32;
+float ya = as_float(ay);
+int ey = ay >> EXPSHIFTBITS_SP32;
+
+float xr = as_float(0x3f80 | (ax & 0x007f));
+float yr = as_float(0x3f80 | (ay & 0x007f));
+int c;
+int k = ex - ey;
+
+while (k > 0) {
+c = xr >= yr;
+xr -= c ? yr : 0.0f;
+xr += xr;
+--k;
+}
+
+c = xr >= yr;
+xr -= c ? yr : 0.0f;
+
+int lt = ex < ey;
+
+xr = lt ? xa : xr;
+yr = lt ? ya : yr;
+
+
+float s = as_float(ey << EXPSHIFTBITS_SP32);
+xr *= lt ? 1.0f : s;
+
+c 

[PATCH] D45310: Warn about memcpy'ing non-trivial C structs

2018-04-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/NonTrivialCStructTypeVisitor.h:30
+if (asDerived().getContext().getAsArrayType(FT))
+  return asDerived().visitArray(DK, FT, std::forward(Args)...);
+

ahatanak wrote:
> rjmccall wrote:
> > Should you have this pass the array type down?  And is it really important 
> > to do this in the generic visitor?  It seems like something you could do in 
> > an IRGen subclass.
> The subclasses in CGNonTrivialStruct.cpp need the size and the element type 
> of the array to be passed to visitArray, so I think we have to pass the array 
> type to visitArray. I guess it's possible to move this to the subclasses, but 
> then the visit methods in the subclasses have to check whether the type is an 
> array or not. I think we had a discussion on how arrays should be handled in 
> this review: https://reviews.llvm.org/D41228.
> 
> But perhaps you have a better idea in mind?
Well, you could "override" the visit method in the subclass, e.g.:

  template 
  class CGDestructedTypeVisitor : public DestructedTypeVisitor {
using super = DestructedTypeVisitor;

  public:
using super::asDerived;
using super::visit;

template 
RetTy visit(QualType::DestructionKind DK, QualType FT, Ts &&... Args) {
  if (asDerived().getContext().getAsArrayType(FT))
return asDerived().visitArray(DK, FT, std::forward(Args)...);

  return super::visit(DK, FT, std::forward(Args)...);
}
  };

It's a bit more boilerplate, but I really feel like the array logic doesn't 
belong in the generic visitor.

About the array type: I wasn't trying to suggest that you should pass the 
element type to visitArray, I was suggesting you could just pass the array type 
as an `ArrayType*`, since that's what `visitArray` actually wants.


Repository:
  rC Clang

https://reviews.llvm.org/D45310



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


[clang-tools-extra] r329428 - [clang-tidy] Sort includes; NFC

2018-04-06 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Apr  6 10:22:36 2018
New Revision: 329428

URL: http://llvm.org/viewvc/llvm-project?rev=329428=rev
Log:
[clang-tidy] Sort includes; NFC

Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=329428=329427=329428=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Fri Apr  6 
10:22:36 2018
@@ -13,9 +13,9 @@
 #include "CloexecAccept4Check.h"
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
+#include "CloexecDupCheck.h"
 #include "CloexecEpollCreate1Check.h"
 #include "CloexecEpollCreateCheck.h"
-#include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
 #include "CloexecInotifyInit1Check.h"
 #include "CloexecInotifyInitCheck.h"


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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

yaxunl wrote:
> tra wrote:
> > yaxunl wrote:
> > > tra wrote:
> > > > Unless you're planning to guarantee 1:1 match to functionality provided 
> > > > by nvidia's sm_32, it would be prudent to use some other value for the 
> > > > macro so the source code has a way to tell these GPUs apart.
> > > > 
> > > > Another issue with this approach is that typical use pattern for 
> > > > __CUDA_ARCH__ is 
> > > > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able to 
> > > > maintain order across GPU architectures among NVIDIA and AMD GPUs. 
> > > > Perhaps for HIP compilation it would make more sense to define 
> > > > __CUDA_ARCH__ as 1 (this should serve as a legacy indication of 
> > > > device-side compilation) and define __HIP_ARCH__ to indicate which AMD 
> > > > GPU we're compiling for without accidentally enabling something that 
> > > > was intended for NVIDIA's GPUs only.
> > > I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can make 
> > > that change.
> > > 
> > > On the other hand, I think it may be difficult to define `__HIP_ARCH__` 
> > > which can sort mixed nvptx/amdgcn GPU's by capability. I do think a well 
> > > defined `__HIP_ARCH__` would be useful for users. Just need some further 
> > > discussion how to define it.
> > > 
> > > For now, if there are specific codes for nvptx, it can continue use 
> > > `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
> > > predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
> > OK.
> > 
> I asked Ben Sander about whether we can define __HIP_ARCH__, here is his 
> answer:
> 
> HIP targets a broader set of hardware than just a single vendor so additional 
> flexibility in defining feature capability is required.  The HIP_ARCH_ macro 
> provide per-feature-granularity mechanism to query features.  Also the code 
> tends to be more clear as opposed to an "if __CUDA_ARCH>3 ..assume some 
> feature".
> 
> For example
> 
> 
> ```
> // 32-bit Atomics:
> #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (1)
> #define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (1)
> #define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (1)
> #define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (1)
> #define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (1)
> 
> // 64-bit Atomics:
> #define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (1)
> #define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (0)
> 
> // Doubles
> #define __HIP_ARCH_HAS_DOUBLES__ (1)
> 
> // warp cross-lane operations:
> #define __HIP_ARCH_HAS_WARP_VOTE__ (1)
> #define __HIP_ARCH_HAS_WARP_BALLOT__ (1)
> #define __HIP_ARCH_HAS_WARP_SHUFFLE__ (1)
> #define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (0)
> 
> // sync
> #define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (1)
> #define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (0)
> 
> // misc
> #define __HIP_ARCH_HAS_SURFACE_FUNCS__ (0)
> #define __HIP_ARCH_HAS_3DGRID__ (1)
> #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0)
> ```
I assume that will be handled somewhere else -- different patch, different 
place.
Looks like setting `__CUDA_ARCH__` to 1 is all that should be done here.

While we're looking a this, is CUDA compatibility one of your goals? I.e. do 
you expect existing CUDA code to be compilable and functional on AMD hardware? 
If not, then, perhaps you don't need `__CUDA_*__` defines at all.


Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


r329420 - [HIP] define __CUDA_ARCH_=1 for amdgcn targets

2018-04-06 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Apr  6 09:43:42 2018
New Revision: 329420

URL: http://llvm.org/viewvc/llvm-project?rev=329420=rev
Log:
[HIP] define __CUDA_ARCH_=1 for amdgcn targets

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

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=329420=329419=329420=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Apr  6 09:43:42 2018
@@ -158,7 +158,7 @@ void defineCudaArchMacro(CudaArch GPU, c
 case CudaArch::GFX810:
 case CudaArch::GFX900:
 case CudaArch::GFX902:
-  return "320";
+  return "1";
 case CudaArch::UNKNOWN:
   llvm_unreachable("unhandled Cuda/HIP Arch");
 }


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


[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics

2018-04-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.

LGTM




Comment at: lib/Headers/waitpkgintrin.h:41
+static __inline__ void __DEFAULT_FN_ATTRS
+_umwait (__SIZE_TYPE__  __CONTROL, __UINT64_TYPE__  __COUNTER)
+{

Why does the intrinsic take size_t but then its truncated to 32 bits?


https://reviews.llvm.org/D45254



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


r329411 - [OPENMP, NVPTX] Fix codegen for the teams reduction.

2018-04-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr  6 09:03:36 2018
New Revision: 329411

URL: http://llvm.org/viewvc/llvm-project?rev=329411=rev
Log:
[OPENMP, NVPTX] Fix codegen for the teams reduction.

Added NUW flags for all the add|mul|sub operations + replaced sdiv by udiv
as we operate on unsigned values only (addresses, converted to integers)

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=329411=329410=329411=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Apr  6 09:03:36 2018
@@ -529,8 +529,8 @@ static llvm::Value *getThreadLimit(CodeG
   CGBuilderTy  = CGF.Builder;
   return IsInSpmdExecutionMode
  ? getNVPTXNumThreads(CGF)
- : Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
- "thread_limit");
+ : Bld.CreateNUWSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
+"thread_limit");
 }
 
 /// Get the thread id of the OMP master thread.
@@ -545,9 +545,9 @@ static llvm::Value *getMasterThreadID(Co
   llvm::Value *NumThreads = getNVPTXNumThreads(CGF);
 
   // We assume that the warp size is a power of 2.
-  llvm::Value *Mask = Bld.CreateSub(getNVPTXWarpSize(CGF), Bld.getInt32(1));
+  llvm::Value *Mask = Bld.CreateNUWSub(getNVPTXWarpSize(CGF), Bld.getInt32(1));
 
-  return Bld.CreateAnd(Bld.CreateSub(NumThreads, Bld.getInt32(1)),
+  return Bld.CreateAnd(Bld.CreateNUWSub(NumThreads, Bld.getInt32(1)),
Bld.CreateNot(Mask), "master_tid");
 }
 
@@ -1714,13 +1714,11 @@ static void emitReductionListCopy(
 
   // Step 1.2: Get the address for dest element:
   // address = base + index * ElementSizeInChars.
-  unsigned ElementSizeInChars =
-  C.getTypeSizeInChars(Private->getType()).getQuantity();
+  llvm::Value *ElementSizeInChars = CGF.getTypeSize(Private->getType());
   auto *CurrentOffset =
-  Bld.CreateMul(llvm::ConstantInt::get(CGM.SizeTy, ElementSizeInChars),
-ScratchpadIndex);
+  Bld.CreateNUWMul(ElementSizeInChars, ScratchpadIndex);
   auto *ScratchPadElemAbsolutePtrVal =
-  Bld.CreateAdd(DestBase.getPointer(), CurrentOffset);
+  Bld.CreateNUWAdd(DestBase.getPointer(), CurrentOffset);
   ScratchPadElemAbsolutePtrVal =
   Bld.CreateIntToPtr(ScratchPadElemAbsolutePtrVal, CGF.VoidPtrTy);
   DestElementAddr = Address(ScratchPadElemAbsolutePtrVal,
@@ -1731,13 +1729,11 @@ static void emitReductionListCopy(
 case ScratchpadToThread: {
   // Step 1.1: Get the address for the src element in the scratchpad.
   // address = base + index * ElementSizeInChars.
-  unsigned ElementSizeInChars =
-  C.getTypeSizeInChars(Private->getType()).getQuantity();
+  llvm::Value *ElementSizeInChars = CGF.getTypeSize(Private->getType());
   auto *CurrentOffset =
-  Bld.CreateMul(llvm::ConstantInt::get(CGM.SizeTy, ElementSizeInChars),
-ScratchpadIndex);
+  Bld.CreateNUWMul(ElementSizeInChars, ScratchpadIndex);
   auto *ScratchPadElemAbsolutePtrVal =
-  Bld.CreateAdd(SrcBase.getPointer(), CurrentOffset);
+  Bld.CreateNUWAdd(SrcBase.getPointer(), CurrentOffset);
   ScratchPadElemAbsolutePtrVal =
   Bld.CreateIntToPtr(ScratchPadElemAbsolutePtrVal, CGF.VoidPtrTy);
   SrcElementAddr = Address(ScratchPadElemAbsolutePtrVal,
@@ -1796,22 +1792,20 @@ static void emitReductionListCopy(
 if ((IncrScratchpadDest || IncrScratchpadSrc) && (Idx + 1 < Size)) {
   llvm::Value *ScratchpadBasePtr =
   IncrScratchpadDest ? DestBase.getPointer() : SrcBase.getPointer();
-  unsigned ElementSizeInChars =
-  C.getTypeSizeInChars(Private->getType()).getQuantity();
-  ScratchpadBasePtr = Bld.CreateAdd(
+  llvm::Value *ElementSizeInChars = CGF.getTypeSize(Private->getType());
+  ScratchpadBasePtr = Bld.CreateNUWAdd(
   ScratchpadBasePtr,
-  Bld.CreateMul(ScratchpadWidth, llvm::ConstantInt::get(
- CGM.SizeTy, ElementSizeInChars)));
+  Bld.CreateNUWMul(ScratchpadWidth, ElementSizeInChars));
 
   // Take care of global memory alignment for performance
-  ScratchpadBasePtr = Bld.CreateSub(ScratchpadBasePtr,
-llvm::ConstantInt::get(CGM.SizeTy, 1));
-  ScratchpadBasePtr = Bld.CreateSDiv(
+  

[PATCH] D45373: [clang-format] Don't remove empty lines before namespace endings

2018-04-06 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: djasper.
Herald added subscribers: cfe-commits, klimek.

This implements an alternative to r327861, namely preserving empty lines before 
namespace endings.


Repository:
  rC Clang

https://reviews.llvm.org/D45373

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/NamespaceEndCommentsFixer.h
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineFormatter.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -278,19 +278,41 @@
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
+  // Don't remove empty lines before namespace endings.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
 "int i;\n"
+"\n"
 "}",
 format("namespace {\n"
"int i;\n"
"\n"
"}", LLVMWithNoNamespaceFix));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
 "}",
+format("namespace {\n"
+   "int i;\n"
+   "}", LLVMWithNoNamespaceFix));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};", LLVMWithNoNamespaceFix));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "};", LLVMWithNoNamespaceFix));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"\n"
+"}",
 format("namespace {\n"
"int i;\n"
"\n"
Index: lib/Format/UnwrappedLineFormatter.h
===
--- lib/Format/UnwrappedLineFormatter.h
+++ lib/Format/UnwrappedLineFormatter.h
@@ -49,8 +49,9 @@
   /// \brief Add a new line and the required indent before the first Token
   /// of the \c UnwrappedLine if there was no structural parsing error.
   void formatFirstToken(const AnnotatedLine ,
-const AnnotatedLine *PreviousLine, unsigned Indent,
-unsigned NewlineIndent);
+const AnnotatedLine *PreviousLine,
+const SmallVectorImpl ,
+unsigned Indent, unsigned NewlineIndent);
 
   /// \brief Returns the column limit for a line, taking into account whether we
   /// need an escaped newline due to a continued preprocessor directive.
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "NamespaceEndCommentsFixer.h"
 #include "UnwrappedLineFormatter.h"
 #include "WhitespaceManager.h"
 #include "llvm/Support/Debug.h"
@@ -1050,8 +1051,7 @@
 if (ShouldFormat && TheLine.Type != LT_Invalid) {
   if (!DryRun) {
 bool LastLine = Line->First->is(tok::eof);
-formatFirstToken(TheLine, PreviousLine,
- Indent,
+formatFirstToken(TheLine, PreviousLine, Lines, Indent,
  LastLine ? LastStartColumn : NextStartColumn + Indent);
   }
 
@@ -1095,7 +1095,7 @@
   TheLine.LeadingEmptyLinesAffected);
 // Format the first token.
 if (ReformatLeadingWhitespace)
-  formatFirstToken(TheLine, PreviousLine,
+  formatFirstToken(TheLine, PreviousLine, Lines,
TheLine.First->OriginalColumn,
TheLine.First->OriginalColumn);
 else
@@ -1117,10 +1117,10 @@
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(const AnnotatedLine ,
-  const AnnotatedLine *PreviousLine,
-  unsigned Indent,
-  unsigned NewlineIndent) {
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine , const AnnotatedLine *PreviousLine,
+const SmallVectorImpl , unsigned Indent,
+unsigned NewlineIndent) {
   FormatToken  = *Line.First;
   if (RootToken.is(tok::eof)) {
 unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
@@ -1134,7 +1134,9 @@
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::semi) && 

[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-06 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: include/clang/Frontend/LangStandards.def:167
+LANGSTANDARD_ALIAS_DEPR(opencl22, "CL2.2")
+LANGSTANDARD_ALIAS_DEPR(opencl22, "clc++")
+LANGSTANDARD_ALIAS_DEPR(opencl22, "CLC++")

OpenCL C++ 1.0 specification defines only 'c++' value for -cl-std option.
Assuming that OpenCL C++ 1.0 might be supported by multiple OpenCL version, 
wouldn't 'CL2.2' confuse people?
As we have separate kernel language specification with independent version 
numbering, I think we should avoid using OpenCL API numbering for language 
version.

What is the naming scheme for next versions of OpenCL C++ specification? 
'clc++N.M'?



Comment at: lib/Frontend/InitPreprocessor.cpp:428
   // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
-  if (LangOpts.OpenCL) {
+  if (LangOpts.OpenCL && !LangOpts.CPlusPlus) {
 // OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the

I think we should not skip this section for OpenCL C++, but define 
OPENCL_CPP_VERSION macro.


https://reviews.llvm.org/D45363



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


Re: r329300 - Disable -fmerge-all-constants as default.

2018-04-06 Thread Manoj Gupta via cfe-commits
Sure, will update.

Thanks,
Manoj

On Fri, Apr 6, 2018 at 4:56 AM Nico Weber  wrote:

> This should probably get a release notes entry. Can you write one?
>
> On Thu, Apr 5, 2018 at 11:29 AM, Manoj Gupta via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: manojgupta
>> Date: Thu Apr  5 08:29:52 2018
>> New Revision: 329300
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=329300=rev
>> Log:
>> Disable -fmerge-all-constants as default.
>>
>> Summary:
>> "-fmerge-all-constants" is a non-conforming optimization and should not
>> be the default. It is also causing miscompiles when building Linux
>> Kernel (https://lkml.org/lkml/2018/3/20/872).
>>
>> Fixes PR18538.
>>
>> Reviewers: rjmccall, rsmith, chandlerc
>>
>> Reviewed By: rsmith, chandlerc
>>
>> Subscribers: srhines, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D45289
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/test/CodeGen/array-init.c
>> cfe/trunk/test/CodeGen/decl.c
>> cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
>> cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
>> cfe/trunk/test/Driver/clang_f_opts.c
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329300=329299=329300=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
>> @@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
>>HelpText<"Perform ThinLTO importing using provided function summary
>> index">;
>>  def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
>>  Group, Flags<[DriverOption,
>> CoreOption]>;
>> -def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
>> Group;
>> +def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
>> Group,
>> +  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
>>  def fmessage_length_EQ : Joined<["-"], "fmessage-length=">,
>> Group;
>>  def fms_extensions : Flag<["-"], "fms-extensions">, Group,
>> Flags<[CC1Option, CoreOption]>,
>>HelpText<"Accept some non-standard constructs supported by the
>> Microsoft compiler">;
>> @@ -1282,7 +1283,7 @@ def fveclib : Joined<["-"], "fveclib=">,
>>  def fno_lax_vector_conversions : Flag<["-"],
>> "fno-lax-vector-conversions">, Group,
>>HelpText<"Disallow implicit conversions between vectors with a
>> different number of elements or different element types">,
>> Flags<[CC1Option]>;
>>  def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">,
>> Group,
>> -Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
>> +  HelpText<"Disallow merging of constants">;
>>  def fno_modules : Flag <["-"], "fno-modules">, Group,
>>Flags<[DriverOption]>;
>>  def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">,
>> Group,
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=329300=329299=329300=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr  5 08:29:52 2018
>> @@ -8596,9 +8596,6 @@ bool IntExprEvaluator::VisitBinaryOperat
>>  (LHSValue.Base && isZeroSized(RHSValue)))
>>return Error(E);
>>  // Pointers with different bases cannot represent the same
>> object.
>> -// (Note that clang defaults to -fmerge-all-constants, which can
>> -// lead to inconsistent results for comparisons involving the
>> address
>> -// of a constant; this generally doesn't matter in practice.)
>>  return Success(E->getOpcode() == BO_NE, E);
>>}
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=329300=329299=329300=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Apr  5 08:29:52 2018
>> @@ -3361,9 +3361,9 @@ void Clang::ConstructJob(Compilation ,
>>
>>Args.AddLastArg(CmdArgs, options::OPT_fveclib);
>>
>> -  if (!Args.hasFlag(options::OPT_fmerge_all_constants,
>> -options::OPT_fno_merge_all_constants))
>> -CmdArgs.push_back("-fno-merge-all-constants");
>> +  if 

[PATCH] D44188: Misc typos

2018-04-06 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Feel free to send the rest of the fixes as a separate patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D44188



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


[PATCH] D44295: [clang-tidy] Detect and fix calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-04-06 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Alexander, thanks for your patience and comments :-)


https://reviews.llvm.org/D44295



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


[PATCH] D44295: [clang-tidy] Detect and fix calls to grand-...parent virtual methods instead of calls to parent's virtual methods

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

LG


https://reviews.llvm.org/D44295



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > Unless you're planning to guarantee 1:1 match to functionality provided 
> > > by nvidia's sm_32, it would be prudent to use some other value for the 
> > > macro so the source code has a way to tell these GPUs apart.
> > > 
> > > Another issue with this approach is that typical use pattern for 
> > > __CUDA_ARCH__ is 
> > > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able to 
> > > maintain order across GPU architectures among NVIDIA and AMD GPUs. 
> > > Perhaps for HIP compilation it would make more sense to define 
> > > __CUDA_ARCH__ as 1 (this should serve as a legacy indication of 
> > > device-side compilation) and define __HIP_ARCH__ to indicate which AMD 
> > > GPU we're compiling for without accidentally enabling something that was 
> > > intended for NVIDIA's GPUs only.
> > I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can make that 
> > change.
> > 
> > On the other hand, I think it may be difficult to define `__HIP_ARCH__` 
> > which can sort mixed nvptx/amdgcn GPU's by capability. I do think a well 
> > defined `__HIP_ARCH__` would be useful for users. Just need some further 
> > discussion how to define it.
> > 
> > For now, if there are specific codes for nvptx, it can continue use 
> > `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
> > predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
> OK.
> 
I asked Ben Sander about whether we can define __HIP_ARCH__, here is his answer:

HIP targets a broader set of hardware than just a single vendor so additional 
flexibility in defining feature capability is required.  The HIP_ARCH_ macro 
provide per-feature-granularity mechanism to query features.  Also the code 
tends to be more clear as opposed to an "if __CUDA_ARCH>3 ..assume some 
feature".

For example


```
// 32-bit Atomics:
#define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (1)
#define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (1)
#define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (1)
#define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (1)
#define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (1)

// 64-bit Atomics:
#define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (1)
#define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (0)

// Doubles
#define __HIP_ARCH_HAS_DOUBLES__ (1)

// warp cross-lane operations:
#define __HIP_ARCH_HAS_WARP_VOTE__ (1)
#define __HIP_ARCH_HAS_WARP_BALLOT__ (1)
#define __HIP_ARCH_HAS_WARP_SHUFFLE__ (1)
#define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (0)

// sync
#define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (1)
#define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (0)

// misc
#define __HIP_ARCH_HAS_SURFACE_FUNCS__ (0)
#define __HIP_ARCH_HAS_3DGRID__ (1)
#define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0)
```


Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. Thank!


https://reviews.llvm.org/D45363



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


[PATCH] D44188: Misc typos

2018-04-06 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

Thanks!
I've looked through all the fixes. Most of them look reasonable. I've reverted 
a few files where I found something suspicious or outright wrong and will 
commit the rest of the patch after I ensure the tests pass.

These files couldn't be patched:

  include/clang/Basic/AttrDocs.td
  lib/Basic/VirtualFileSystem.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/Driver/ToolChains/Hexagon.cpp
  lib/Sema/Sema.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  test/CodeGenCXX/ms-integer-static-data-members.cpp

The list of the files I reverted:

  lib/ARCMigrate/FileRemapper.cpp
  lib/AST/ExprConstant.cpp
  lib/Frontend/CacheTokens.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/htmintrin.h
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLookup.cpp
  test/CodeGen/builtins-arm-exclusive.c
  test/CodeGen/vectorcall.c
  test/Modules/odr_hash.cpp
  test/Sema/warn-documentation-fixits.cpp
  test/Sema/warn-documentation-unknown-command.cpp


Repository:
  rC Clang

https://reviews.llvm.org/D44188



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


r329394 - [Hexagon] Remove default values from lambda parameters

2018-04-06 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Apr  6 06:51:48 2018
New Revision: 329394

URL: http://llvm.org/viewvc/llvm-project?rev=329394=rev
Log:
[Hexagon] Remove default values from lambda parameters

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=329394=329393=329394=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Apr  6 06:51:48 2018
@@ -10774,7 +10774,7 @@ Value *CodeGenFunction::EmitHexagonBuilt
   SmallVector Ops;
   Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
-  auto MakeCircLd = [&](unsigned IntID, bool HasImm = true) {
+  auto MakeCircLd = [&](unsigned IntID, bool HasImm) {
 // The base pointer is passed by address, so it needs to be loaded.
 Address BP = EmitPointerWithAlignment(E->getArg(0));
 BP = Address(Builder.CreateBitCast(BP.getPointer(), Int8PtrPtrTy),
@@ -10799,7 +10799,7 @@ Value *CodeGenFunction::EmitHexagonBuilt
 return Builder.CreateExtractValue(Result, 0);
   };
 
-  auto MakeCircSt = [&](unsigned IntID, bool HasImm = true) {
+  auto MakeCircSt = [&](unsigned IntID, bool HasImm) {
 // The base pointer is passed by address, so it needs to be loaded.
 Address BP = EmitPointerWithAlignment(E->getArg(0));
 BP = Address(Builder.CreateBitCast(BP.getPointer(), Int8PtrPtrTy),
@@ -10907,49 +10907,49 @@ Value *CodeGenFunction::EmitHexagonBuilt
 return Builder.CreateExtractValue(Result, 0);
   }
   case Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrub_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrub_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrb_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrb_pci,  /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadruh_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadruh_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrh_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrh_pci,  /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadri_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadri_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadri_pci,  /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrd_pci);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrd_pci,  /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrub_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrub_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrub_pcr, /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrb_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrb_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrb_pcr,  /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_L2_loadruh_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadruh_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadruh_pcr, /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrh_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrh_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrh_pcr,  /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_L2_loadri_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadri_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadri_pcr,  /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_L2_loadrd_pcr:
-return MakeCircLd(Intrinsic::hexagon_L2_loadrd_pcr, /*HasImm=*/false);
+return MakeCircLd(Intrinsic::hexagon_L2_loadrd_pcr,  /*HasImm*/false);
   case Hexagon::BI__builtin_HEXAGON_S2_storerb_pci:
-return MakeCircSt(Intrinsic::hexagon_S2_storerb_pci);
+return MakeCircSt(Intrinsic::hexagon_S2_storerb_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_S2_storerh_pci:
-return MakeCircSt(Intrinsic::hexagon_S2_storerh_pci);
+return MakeCircSt(Intrinsic::hexagon_S2_storerh_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_S2_storerf_pci:
-return MakeCircSt(Intrinsic::hexagon_S2_storerf_pci);
+return MakeCircSt(Intrinsic::hexagon_S2_storerf_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_S2_storeri_pci:
-return MakeCircSt(Intrinsic::hexagon_S2_storeri_pci);
+return MakeCircSt(Intrinsic::hexagon_S2_storeri_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_S2_storerd_pci:
-return MakeCircSt(Intrinsic::hexagon_S2_storerd_pci);
+return MakeCircSt(Intrinsic::hexagon_S2_storerd_pci, /*HasImm*/true);
   case Hexagon::BI__builtin_HEXAGON_S2_storerb_pcr:
-return 

[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

2018-04-06 Thread Francois JEAN via Phabricator via cfe-commits
Wawha added a comment.

I'm not working on a public project with a public style guide, so not sure it 
will fit all the requirement inside. But perhaps the request of Rian for 
bareflank (https://bugs.llvm.org//show_bug.cgi?id=32151#c4) could help to fit 
the needs.

The current patch do not exactly do what he ask, but like you say, it's not 
easy to find all options or one options to match lambda formatting.

In my case, the main requirement is to be able **avoid** a lambda in one line. 
It's not easy to manage, when you put a breakpoint on a such line. It could 
break when the function taking the lambda in arg is call, or when the lambda 
body is executed. Which very annoying for debugging.
As example:

  return something([] ()  { somethingelse(); }); // Breakpoint one this line 
will break when calling something() AND somethingelse()

For the moment, there is no way to format is code in another way. We could have 
this possibilities:

  return something(
   [] ()
   {
 somethingelse();
   });

or

  return something([] ()  {
 somethingelse();
   });

or

  return something(
   [] ()  {
 somethingelse();
   });

The current patch are able to manage the first case, and I'm agree it make 
sense in allman option. So I'm ok to have it by default for allman.


Repository:
  rC Clang

https://reviews.llvm.org/D44609



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


[PATCH] D41316: [libcxx] Allow random_device to be built optionally

2018-04-06 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a subscriber: efriedma.
jroelofs added a comment.

>   the targets where you would want to use this can't run the libcxx

testsuite anyway (because they don't have an operating system to run the
test programs under).

I used to run libcxx tests for an arm baremetal toolchain I was building
via semihosted QEMU. It was awkward and slow (especially for some of the
std::*_distribution tests), but it worked.

Jon


Repository:
  rCXX libc++

https://reviews.llvm.org/D41316



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


[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-06 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329391: Allow the creation of human-friendly ASTDumper to 
arbitrary output stream (authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45096?vs=141309=141326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45096

Files:
  cfe/trunk/docs/HowToSetupToolingForLLVM.rst
  cfe/trunk/include/clang/Frontend/ASTConsumers.h
  cfe/trunk/lib/Frontend/ASTConsumers.cpp
  cfe/trunk/lib/Frontend/FrontendActions.cpp
  cfe/trunk/tools/clang-check/ClangCheck.cpp
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp


Index: cfe/trunk/docs/HowToSetupToolingForLLVM.rst
===
--- cfe/trunk/docs/HowToSetupToolingForLLVM.rst
+++ cfe/trunk/docs/HowToSetupToolingForLLVM.rst
@@ -133,7 +133,8 @@
   if (this->ASTList.operator _Bool())
   return clang::CreateASTDeclNodeLister();
   if (this->ASTDump.operator _Bool())
-  return clang::CreateASTDumper(this->ASTDumpFilter);
+  return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
+this->ASTDumpFilter);
   if (this->ASTPrint.operator _Bool())
   return clang::CreateASTPrinter(::outs(), this->ASTDumpFilter);
   return new clang::ASTConsumer();
Index: cfe/trunk/include/clang/Frontend/ASTConsumers.h
===
--- cfe/trunk/include/clang/Frontend/ASTConsumers.h
+++ cfe/trunk/include/clang/Frontend/ASTConsumers.h
@@ -34,9 +34,10 @@
 std::unique_ptr CreateASTPrinter(std::unique_ptr OS,
   StringRef FilterString);
 
-// AST dumper: dumps the raw AST in human-readable form to stderr; this is
-// intended for debugging.
-std::unique_ptr CreateASTDumper(StringRef FilterString,
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream, or stdout if OS is nullptr.
+std::unique_ptr CreateASTDumper(std::unique_ptr OS,
+ StringRef FilterString,
  bool DumpDecls, bool Deserialize,
  bool DumpLookups);
 
Index: cfe/trunk/lib/Frontend/FrontendActions.cpp
===
--- cfe/trunk/lib/Frontend/FrontendActions.cpp
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp
@@ -74,7 +74,8 @@
 
 std::unique_ptr
 ASTDumpAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
-  return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
+  return CreateASTDumper(nullptr /*Dump to stdout.*/,
+ CI.getFrontendOpts().ASTDumpFilter,
  CI.getFrontendOpts().ASTDumpDecls,
  CI.getFrontendOpts().ASTDumpAll,
  CI.getFrontendOpts().ASTDumpLookups);
Index: cfe/trunk/lib/Frontend/ASTConsumers.cpp
===
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp
@@ -138,12 +138,14 @@
FilterString);
 }
 
-std::unique_ptr clang::CreateASTDumper(StringRef FilterString,
-bool DumpDecls,
-bool Deserialize,
-bool DumpLookups) {
+std::unique_ptr
+clang::CreateASTDumper(std::unique_ptr Out,
+   StringRef FilterString,
+   bool DumpDecls,
+   bool Deserialize,
+   bool DumpLookups) {
   assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
-  return llvm::make_unique(nullptr,
+  return llvm::make_unique(std::move(Out),
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :
ASTPrinter::None,
Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -313,7 +313,8 @@
   auto  = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
-ASTConsumers.push_back(CreateASTDumper("", true, false, false));
+ASTConsumers.push_back(CreateASTDumper(nullptr /*Dump to stdout.*/,
+   "", true, false, false));
 
   CI.getDiagnosticClient().BeginSourceFile(
   CI.getCompilerInstance().getLangOpts(),
Index: cfe/trunk/tools/clang-check/ClangCheck.cpp
===
--- 

r329391 - Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-06 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Apr  6 06:01:12 2018
New Revision: 329391

URL: http://llvm.org/viewvc/llvm-project?rev=329391=rev
Log:
Allow the creation of human-friendly ASTDumper to arbitrary output stream

Summary:
`ASTPrinter` allows setting the ouput to any O-Stream, but that printer creates 
source-code-like syntax (and is also marked with a `FIXME`). The nice, 
colourful, mostly human-readable `ASTDumper` only works on the standard output, 
which is not feasible in case a user wants to see the AST of a file through a 
code navigation/comprehension tool.

This small addition of an overload solves generating a nice colourful AST block 
for the users of a tool I'm working on, [[ 
http://github.com/Ericsson/CodeCompass | CodeCompass ]], as opposed to having 
to duplicate the behaviour of definitions that only exist in the anonymous 
namespace of implementation TUs related to this module.

Reviewers: alexfh, klimek, rsmith

Reviewed By: alexfh

Subscribers: rnkovacs, dkrupp, gsd, xazax.hun, cfe-commits, #clang

Tags: #clang

Patch by Whisperity!

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

Modified:
cfe/trunk/docs/HowToSetupToolingForLLVM.rst
cfe/trunk/include/clang/Frontend/ASTConsumers.h
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/tools/clang-check/ClangCheck.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/docs/HowToSetupToolingForLLVM.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HowToSetupToolingForLLVM.rst?rev=329391=329390=329391=diff
==
--- cfe/trunk/docs/HowToSetupToolingForLLVM.rst (original)
+++ cfe/trunk/docs/HowToSetupToolingForLLVM.rst Fri Apr  6 06:01:12 2018
@@ -133,7 +133,8 @@ Examples:
   if (this->ASTList.operator _Bool())
   return clang::CreateASTDeclNodeLister();
   if (this->ASTDump.operator _Bool())
-  return clang::CreateASTDumper(this->ASTDumpFilter);
+  return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
+this->ASTDumpFilter);
   if (this->ASTPrint.operator _Bool())
   return clang::CreateASTPrinter(::outs(), this->ASTDumpFilter);
   return new clang::ASTConsumer();

Modified: cfe/trunk/include/clang/Frontend/ASTConsumers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTConsumers.h?rev=329391=329390=329391=diff
==
--- cfe/trunk/include/clang/Frontend/ASTConsumers.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTConsumers.h Fri Apr  6 06:01:12 2018
@@ -34,9 +34,10 @@ class TargetOptions;
 std::unique_ptr CreateASTPrinter(std::unique_ptr OS,
   StringRef FilterString);
 
-// AST dumper: dumps the raw AST in human-readable form to stderr; this is
-// intended for debugging.
-std::unique_ptr CreateASTDumper(StringRef FilterString,
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream, or stdout if OS is nullptr.
+std::unique_ptr CreateASTDumper(std::unique_ptr OS,
+ StringRef FilterString,
  bool DumpDecls, bool Deserialize,
  bool DumpLookups);
 

Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=329391=329390=329391=diff
==
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Fri Apr  6 06:01:12 2018
@@ -138,12 +138,14 @@ clang::CreateASTPrinter(std::unique_ptr<
FilterString);
 }
 
-std::unique_ptr clang::CreateASTDumper(StringRef FilterString,
-bool DumpDecls,
-bool Deserialize,
-bool DumpLookups) {
+std::unique_ptr
+clang::CreateASTDumper(std::unique_ptr Out,
+   StringRef FilterString,
+   bool DumpDecls,
+   bool Deserialize,
+   bool DumpLookups) {
   assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
-  return llvm::make_unique(nullptr,
+  return llvm::make_unique(std::move(Out),
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :
ASTPrinter::None,

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=329391=329390=329391=diff

[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

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

LG. I'll commit the patch for you.


Repository:
  rC Clang

https://reviews.llvm.org/D45096



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


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-04-06 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 141322.
szepet marked 4 inline comments as done.
szepet added a comment.

Addressed comments and readded the lost fixes.


https://reviews.llvm.org/D40937

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tidy/bugprone/InfiniteLoopCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-infinite-loop.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-infinite-loop.cpp

Index: test/clang-tidy/bugprone-infinite-loop.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-infinite-loop.cpp
@@ -0,0 +1,121 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t
+
+void simple_infinite_loop1() {
+  int i = 0;
+  int j = 0;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body
+j++;
+  } while (i < 10);
+
+  for (i = 0; i < 10; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body
+  }
+}
+
+void simple_infinite_loop2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+j++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+  }
+}
+
+void simple_not_infinite() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) { // Not an error since 'Limit' is updated
+Limit--;
+  }
+  do {
+Limit--;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; Limit--) {
+  }
+}
+
+void escape_before1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = 
+  while (i < Limit) { // Not an error, since p is alias of i.
+*++p;
+  }
+
+  do {
+*++p;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; *++p) {
+;
+  }
+}
+
+void escape_before2() {
+  int i = 0;
+  int Limit = 100;
+  int *p = 
+  while (i < Limit) { // We do not warn since the var 'i' is escaped but it is
+  // an actual error, since the pointer 'p' is increased.
+*(p++);
+  }
+}
+
+void escape_after() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+  }
+  int *p = 
+}
+
+int glob;
+void glob_var(int ) {
+  int i = 0, Limit = 100;
+  while (x < Limit) { // Not an error since 'x' can be an alias of glob.
+glob++;
+  }
+}
+
+void glob_var2() {
+  int i = 0, Limit = 100;
+  while (glob < Limit) { // Since 'glob' is declared out of the function we do not warn.
+i++;
+  }
+}
+
+struct X {
+  void memberExpr_test(int i) {
+while (i < m) { // False negative: No warning, since skipping the case where
+// a memberExpr can be found in the condition.
+  ;
+}
+  }
+
+  void memberExpr_test2(int i) {
+while (i < m) {
+  --m;
+}
+  }
+  int m;
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -28,6 +28,7 @@
bugprone-forwarding-reference-overload
bugprone-inaccurate-erase
bugprone-incorrect-roundings
+   bugprone-infinite-loop
bugprone-integer-division
bugprone-lambda-function-name
bugprone-macro-parentheses
Index: docs/clang-tidy/checks/bugprone-infinite-loop.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-infinite-loop.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - bugprone-infinite-loop
+
+bugprone-infinite-loop
+==
+
+Finds loops where none of the condition variables are updated in the body. This
+performs a very conservative check in order to avoid false positives and work
+only on integer types at the moment.
+
+Examples:
+
+.. code-block:: c++
+
+  void simple_infinite_loop() {
+int i = 0;
+int j = 0;
+int Limit = 10;
+while (i < Limit) { // Error, since none of the variables are updated.
+  j++;
+}
+  }
+
+  void escape_before() {
+int i = 0;
+int Limit = 100;
+int *p = 
+while (i < Limit) { // Not an error, since p is alias of i.
+  *++p;
+}
+  }
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 

[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-06 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Can you make sure that we handle the older ARM versions correctly as well, i.e. 
v4, v5 and v6? I take it we still have test cases for the arm <-> thumb 
transition? That's the one part of the triple logic that is really non-trivial.


Repository:
  rC Clang

https://reviews.llvm.org/D45240



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


[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics

2018-04-06 Thread Gabor Buella via Phabricator via cfe-commits
GBuella updated this revision to Diff 141319.
GBuella added a comment.

Using the modified LLVM intrinsics from https://reviews.llvm.org/D45253.


https://reviews.llvm.org/D45254

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/waitpkgintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/waitpkg.c
  test/Driver/x86-target-features.c

Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -139,3 +139,8 @@
 // RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s
 // RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk"
 // NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk"
+
+// RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s
+// RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s
+// WAITPKG: "-target-feature" "+waitpkg"
+// NO-WAITPKG: "-target-feature" "-waitpkg"
Index: test/CodeGen/waitpkg.c
===
--- /dev/null
+++ test/CodeGen/waitpkg.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple i386-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s
+
+#include 
+
+#include 
+#include 
+
+void test_umonitor(void *address) {
+  //CHECK-LABEL: @test_umonitor
+  //CHECK: call void @llvm.x86.umonitor(i8* %{{.*}})
+  return _umonitor(address);
+}
+
+void test_umwait(size_t control, uint64_t counter) {
+  //CHECK-LABEL: @test_umwait
+  //CHECK: call void @llvm.x86.umwait(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
+  return _umwait(control, counter);
+}
+
+void test_tpause(size_t control, uint64_t counter) {
+  //CHECK-LABEL: @test_tpause
+  //CHECK: call void @llvm.x86.tpause(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
+  return _tpause(control, counter);
+}
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -88,4 +88,8 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__)
+#include 
+#endif
+
 #endif /* __X86INTRIN_H */
Index: lib/Headers/waitpkgintrin.h
===
--- /dev/null
+++ lib/Headers/waitpkgintrin.h
@@ -0,0 +1,56 @@
+/*===--- waitpkgintrin.h - WAITPKG ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __X86INTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef _WAITPKGINTRIN_H
+#define _WAITPKGINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __nodebug__,  __target__("waitpkg")))
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_umonitor (void * __ADDRESS)
+{
+  __builtin_ia32_umonitor (__ADDRESS);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_umwait (__SIZE_TYPE__  __CONTROL, __UINT64_TYPE__  __COUNTER)
+{
+  __builtin_ia32_umwait ((unsigned int)__CONTROL,
+  (unsigned int)(__COUNTER >> 32), (unsigned int)__COUNTER);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_tpause (__SIZE_TYPE__  __CONTROL, __UINT64_TYPE__  __COUNTER)
+{
+  __builtin_ia32_tpause ((unsigned int)__CONTROL,
+  (unsigned int)(__COUNTER >> 32), (unsigned int)__COUNTER);
+}
+

  1   2   >