[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

To be honest, I don't really know. But since we're not installing it straight 
to `/usr`, I suppose that's not a problem we need to solve right now.

However, they do work with clang installed in `/usr/lib/llvm/*/bin`, and this 
patch must not regress that. So if your `/usr` hack solves that, I don't see a 
problem with it.


Repository:
  rC Clang

https://reviews.llvm.org/D45233



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


[PATCH] D45356: [clangd] Adapt index interfaces to D45014, and fix the old bugs.

2018-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, MaskRay, ioeric, jkorous-apple, 
ilya-biryukov, klimek.

- don't count occurrences of decls where we don't spell the name


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45356

Files:
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -250,14 +250,16 @@
 class Y;
 class Z {}; // not used anywhere
 Y* y = nullptr;  // used in header doesn't count
+#define GLOBAL_Z(name) Z name;
   )";
   const std::string Main = R"(
 W* w = nullptr;
 W* w2 = nullptr; // only one usage counts
 X x();
 class V;
 V* v = nullptr; // Used, but not eligible for indexing.
 class Y{}; // definition doesn't count as a reference
+GLOBAL_Z(z); // Not a reference to Z, we don't spell the type.
   )";
   CollectorOpts.CountReferences = true;
   runSymbolCollector(Header, Main);
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -59,8 +59,8 @@
 
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-  ArrayRef Relations, FileID FID,
-  unsigned Offset,
+  ArrayRef Relations,
+  SourceLocation Loc,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override;
 
   SymbolSlab takeSymbols() { return std::move(Symbols).build(); }
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -225,7 +225,7 @@
 // Always return true to continue indexing.
 bool SymbolCollector::handleDeclOccurence(
 const Decl *D, index::SymbolRoleSet Roles,
-ArrayRef Relations, FileID FID, unsigned Offset,
+ArrayRef Relations, SourceLocation Loc,
 index::IndexDataConsumer::ASTNodeInfo ASTNode) {
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
@@ -235,9 +235,10 @@
 
   // Mark D as referenced if this is a reference coming from the main file.
   // D may not be an interesting symbol, but it's cheaper to check at the end.
+  auto &SM = ASTCtx->getSourceManager();
   if (Opts.CountReferences &&
   (Roles & static_cast(index::SymbolRole::Reference)) &&
-  ASTCtx->getSourceManager().getMainFileID() == FID)
+  SM.getFileID(SM.getSpellingLoc(Loc)) == SM.getMainFileID())
 ReferencedDecls.insert(ND);
 
   // Don't continue indexing if this is a mere reference.
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -79,10 +79,10 @@
 
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-  ArrayRef Relations, FileID FID,
-  unsigned Offset,
+  ArrayRef Relations,
+  SourceLocation Loc,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset)) {
+if (AST.getSourceManager().getSpellingLoc(Loc) == SearchedLocation) {
   // Find and add definition declarations (for GoToDefinition).
   // We don't use parameter `D`, as Parameter `D` is the canonical
   // declaration, which is the first declaration of a redeclarable
@@ -98,12 +98,6 @@
   }
 
 private:
-  bool isSearchedLocation(FileID FID, unsigned Offset) const {
-const SourceManager &SourceMgr = AST.getSourceManager();
-return SourceMgr.getFileOffset(SearchedLocation) == Offset &&
-   SourceMgr.getFileID(SearchedLocation) == FID;
-  }
-
   void finish() override {
 // Also handle possible macro at the searched location.
 Token Result;
@@ -125,19 +119,8 @@
 MacroDefinition MacroDef =
 PP.getMacroDefinitionAtLoc(IdentifierInfo, BeforeSearchedLocation);
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
-if (MacroInf) {
+if (MacroInf)
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
-  // Clear all collected delcarations if this is a macro search.
-  //
-  // In theory, there should be no declarataions being collected when we
-  // search a source location that refers to a macro.
-  // The occurrence location returned by `handleDeclOccurence` is
-  // limited (FID, Offset are from expansion location), we will collect
-  // all declarations inside the macro.
-  //
-  // FIXME: Avoid adding decls from inside macros

[clang-tools-extra] r329380 - [clangd] move comment to the right place. NFC

2018-04-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Apr  6 00:48:21 2018
New Revision: 329380

URL: http://llvm.org/viewvc/llvm-project?rev=329380&view=rev
Log:
[clangd] move comment to the right place. NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=329380&r1=329379&r2=329380&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Fri Apr  6 00:48:21 2018
@@ -219,6 +219,8 @@ namespace {
 
 SourceLocation getMacroArgExpandedLocation(const SourceManager &Mgr,
const FileEntry *FE, Position Pos) {
+  // The language server protocol uses zero-based line and column numbers.
+  // Clang uses one-based numbers.
   SourceLocation InputLoc =
   Mgr.translateFileLineCol(FE, Pos.line + 1, Pos.character + 1);
   return Mgr.getMacroArgExpandedLocation(InputLoc);
@@ -469,9 +471,6 @@ CppFile::rebuildPreamble(CompilerInvocat
 SourceLocation clangd::getBeginningOfIdentifier(ParsedAST &Unit,
 const Position &Pos,
 const FileEntry *FE) {
-  // The language server protocol uses zero-based line and column numbers.
-  // Clang uses one-based numbers.
-
   const ASTContext &AST = Unit.getASTContext();
   const SourceManager &SourceMgr = AST.getSourceManager();
 


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


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

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 141291.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D45310

Files:
  include/clang/AST/NonTrivialTypeVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/Sema/SemaChecking.cpp
  test/SemaObjC/warn-nontrivial-struct-memaccess.m

Index: test/SemaObjC/warn-nontrivial-struct-memaccess.m
===
--- /dev/null
+++ test/SemaObjC/warn-nontrivial-struct-memaccess.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime-has-weak -x objective-c -fobjc-arc -verify %s
+
+void *memset(void *, int, __SIZE_TYPE__);
+void bzero(void *, __SIZE_TYPE__);
+void *memcpy(void *, const void *, __SIZE_TYPE__);
+void *memmove(void *, const void *, __SIZE_TYPE__);
+
+struct Trivial {
+  int f0;
+  volatile int f1;
+};
+
+struct NonTrivial0 {
+  int f0;
+  __weak id f1; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
+  volatile int f2;
+  id f3[10]; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
+};
+
+struct NonTrivial1 {
+  id f0; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
+  int f1;
+  struct NonTrivial0 f2;
+};
+
+void testTrivial(struct Trivial *d, struct Trivial *s) {
+  memset(d, 0, sizeof(struct Trivial));
+  bzero(d, sizeof(struct Trivial));
+  memcpy(d, s, sizeof(struct Trivial));
+  memmove(d, s, sizeof(struct Trivial));
+}
+
+void testNonTrivial1(struct NonTrivial1 *d, struct NonTrivial1 *s) {
+  memset(d, 0, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-default-initialize}} expected-note {{explicitly cast the pointer to silence}}
+  memset((void *)d, 0, sizeof(struct NonTrivial1));
+  bzero(d, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-default-initialize}} expected-note {{explicitly cast the pointer to silence}}
+  memcpy(d, s, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-copy}} expected-note {{explicitly cast the pointer to silence}}
+  memmove(d, s, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-copy}} expected-note {{explicitly cast the pointer to silence}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -28,6 +28,7 @@
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/NSAPI.h"
+#include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
@@ -7321,6 +7322,78 @@
   return QualType();
 }
 
+namespace {
+
+struct SearchNonTrivialToInitializeField : DefaultInitializedTypeVisitor {
+  SearchNonTrivialToInitializeField(const Expr *E, Sema &S) : E(E), S(S) {}
+  void visitARCStrong(QualType FT, SourceLocation SL) {
+S.DiagRuntimeBehavior(SL, E,
+  S.PDiag(diag::note_nontrivial_field) << 1);
+  }
+  void visitARCWeak(QualType FT, SourceLocation SL) {
+S.DiagRuntimeBehavior(SL, E,
+  S.PDiag(diag::note_nontrivial_field) << 1);
+  }
+  void visitStruct(QualType FT, SourceLocation SL) {
+for (const FieldDecl *FD : FT->castAs()->getDecl()->fields())
+  visit(FD->getType(), FD->getLocation());
+  }
+  void visitArray(QualType::PrimitiveDefaultInitializeKind PDIK, QualType FT,
+  SourceLocation SL) {
+const auto *AT = getContext().getAsArrayType(FT);
+visit(PDIK, getContext().getBaseElementType(AT), SL);
+  }
+  void visitTrivial(QualType FT, SourceLocation SL) {}
+
+  static void diag(QualType RT, const Expr *E, Sema &S) {
+SearchNonTrivialToInitializeField(E, S).visitStruct(RT, SourceLocation());
+  }
+
+  ASTContext &getContext() {
+return S.getASTContext();
+  }
+
+  const Expr *E;
+  Sema &S;
+};
+
+struct SearchNonTrivialToCopyField : CopiedTypeVisitor {
+  SearchNonTrivialToCopyField(const Expr *E, Sema &S) : E(E), S(S) {}
+  void visitARCStrong(QualType FT, SourceLocation SL) {
+S.DiagRuntimeBehavior(SL, E,
+  S.PDiag(diag::note_nontrivial_field) << 0);
+  }
+  void visitARCWeak(QualType FT, SourceLocation SL) {
+S.DiagRuntimeBehavior(SL, E,
+  S.PDiag(diag::note_nontrivial_field) << 0);
+  }
+  void visitStruct(QualType FT, SourceLocation SL) {
+for (const FieldDecl *FD : FT->castAs()->getDecl()->fields())
+  visit(FD->getType(), FD->getLocation());
+  }
+  void visitArray(QualType::PrimitiveCopyKind PCK, QualType FT,
+  SourceLocation SL) {
+const auto *AT = getContext().getAsArrayType(FT);
+visit(PCK, getContext().getBaseElement

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

2018-04-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



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

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?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:619
+  "%select{primitive-default-initialize|primitive-copy}3">,
+  InGroup>;
+def note_nontrivial_field : Note<

rjmccall wrote:
> I think this warning group should be -Wnontrivial-memaccess, and maybe 
> -Wclass-memaccess should just be a subgroup of it.
Yes, we can create different DiagGroups when support for -Wclass-memaccess 
(warning for C++ classes) is added.


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


[PATCH] D45131: [AST] Refactor UnaryTransformType into TransformTraitType supporting non-unary transforms

2018-04-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 141293.
EricWF marked 2 inline comments as done.
EricWF added a comment.

Address all inline comments.

- Dynamically allocate `TransformTraitType`s list of argument types; making the 
node trivially destructible.
- Detect and handle parameter packs when building TransformTraitType.
- Factor out trait arity diagnostics between the parser and sema.
- Rename `TransformTypeSourceListAndExpandPacks` as suggested.
- Add a terminator character to the mangling to prevent ambiguity.


https://reviews.llvm.org/D45131

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/CanonicalType.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/AST/TypePrinter.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenCXX/mangle.cpp
  test/SemaCXX/underlying_type.cpp

Index: test/SemaCXX/underlying_type.cpp
===
--- test/SemaCXX/underlying_type.cpp
+++ test/SemaCXX/underlying_type.cpp
@@ -10,7 +10,10 @@
 struct is_same_type {
   static const bool value = true;
 };
-
+// expected-error@+1 {{C++ requires a type}}
+__underlying_type() x; // expected-error {{type trait requires 1 argument; have 0 arguments}}
+// expected-error@+1 {{C++ requires a type}}
+__underlying_type(int, int) y; // expected-error {{type trait requires 1 argument; have 2 arguments}}
 __underlying_type(int) a; // expected-error {{only enumeration types}}
 __underlying_type(struct b) c; // expected-error {{only enumeration types}}
 
@@ -26,6 +29,31 @@
 static_assert(is_same_type::value,
   "h has the wrong type");
 
+template  struct TypeList {};
+
+template 
+struct TestParse;
+
+template  struct MyTest {};
+
+template 
+struct TestParse> {
+  using type = __underlying_type(Args...);
+};
+
+template 
+struct TestParse, TypeList> {
+  // expected-error@+2 2 {{type trait requires 1 argument; have 2 arguments}}
+  // expected-error@+1 {{type trait requires 1 argument; have 0 arguments}}
+  using type = __underlying_type(Args1..., Args2...);
+};
+static_assert(is_same_type>::type, char>::value, "wrong type");
+static_assert(is_same_type, TypeList<>>::type, char>::value, "wrong type");
+template struct TestParse, TypeList<>>; // expected-note {{requested here}}
+template struct TestParse, TypeList<>>; // expected-note {{requested here}}
+template struct TestParse, TypeList>; // expected-note {{requested here}}
+
+
 template 
 struct underlying_type {
   typedef __underlying_type(T) type; // expected-error {{only enumeration types}}
@@ -38,7 +66,7 @@
 
 using uint = unsigned;
 enum class foo : uint { bar };
- 
+
 static_assert(is_same_type::type, unsigned>::value,
   "foo has the wrong underlying type");
 
Index: test/CodeGenCXX/mangle.cpp
===
--- test/CodeGenCXX/mangle.cpp
+++ test/CodeGenCXX/mangle.cpp
@@ -1110,9 +1110,13 @@
 void fn(T, __underlying_type(T)) {}
 
 template void fn(E, __underlying_type(E));
-// CHECK-LABEL: @_ZN6test552fnINS_1vT_U3eutS2_
+// CHECK-LABEL: @_ZN6test552fnINS_1vT_U3eutS2_E
+
+void fn2(E, __underlying_type(E)) {}
+// CHECK-LABEL: @_ZN6test553fn2ENS_1EEj
 }
 
+
 namespace test56 {
   struct A { A *operator->(); int n; } a;
   template void f(decltype(a->n + N)) {}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -358,11 +358,14 @@
   Code = TYPE_DECLTYPE;
 }
 
-void ASTTypeWriter::VisitUnaryTransformType(const UnaryTransformType *T) {
-  Record.AddTypeRef(T->getBaseType());
-  Record.AddTypeRef(T->getUnderlyingType());
-  Record.push_back(T->getUTTKind());
-  Code = TYPE_UNARY_TRANSFORM;
+void ASTTypeWriter::VisitTransformTraitType(const TransformTraitType *T) {
+  auto ArgTys = T->getArgs();
+  Record.push_back(ArgTys.size());
+  for (auto Ty : ArgTys)
+Record.AddTypeRef(Ty);
+  Record.AddTypeRef(T-

[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 141295.
manojgupta edited the summary of this revision.
manojgupta added a comment.

Can solve crossdev issue by passing -gcc-toolchain=/usr
so just detect gcc libs as an offset to sysroot for now.


Repository:
  rC Clang

https://reviews.llvm.org/D45233

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release
  test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -343,6 +343,59 @@
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for parsing Gentoo's gcc-config -- clang should parse the
+// /etc/env.d/gcc/config-x86_64-pc-linux-gnu file to find CURRENT gcc used.
+// Then should pick the multilibs from version 4.9.x specified in
+// /etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X %s
+//
+// CHECK-GENTOO-4-9-X: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnux32 -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-X32 %s
+// CHECK-GENTOO-4-9-X-X32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X-X32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu/x32"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-32 %s
+// CHECK-GENTOO-4-9-X-32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-

[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Michał, can you give the latest change a try? Hopefully it should not break any 
tests.


Repository:
  rC Clang

https://reviews.llvm.org/D45233



___
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 Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.
dberris added reviewers: echristo, vlad.tsyrklevich, eugenis.

This change consolidates the always/never lists that may be provided to
clang to externally control which functions should be XRay instrumented
by imbuing attributes. The files follow the same format as defined in
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the
sanitizer blacklist.

We also deprecate the existing `-fxray-instrument-always=` and
`-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`.

This fixes http://llvm.org/PR34721.


https://reviews.llvm.org/D45357

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/XRayLists.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/XRayLists.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-always-instrument.cpp
  clang/test/CodeGen/xray-attr-list.cpp
  clang/test/CodeGen/xray-imbue-arg1.cpp
  clang/test/CodeGen/xray-never-instrument.cpp
  llvm/docs/XRay.rst
  llvm/docs/XRayExample.rst

Index: llvm/docs/XRayExample.rst
===
--- llvm/docs/XRayExample.rst
+++ llvm/docs/XRayExample.rst
@@ -178,22 +178,22 @@
 To use this feature, you can define one file for the functions to always
 instrument, and another for functions to never instrument. The format of these
 files are exactly the same as the SanitizerLists files that control similar
-things for the sanitizer implementations. For example, we can have two
-different files like below:
+things for the sanitizer implementations. For example:
 
 ::
 
-  # always-instrument.txt
+  # xray-attr-list.txt
   # always instrument functions that match the following filters:
+  [always]
   fun:main
 
-  # never-instrument.txt
   # never instrument functions that match the following filters:
+  [never]
   fun:__cxx_*
 
-Given the above two files we can re-build by providing those two files as
-arguments to clang as ``-fxray-always-instrument=always-instrument.txt`` or
-``-fxray-never-instrument=never-instrument.txt``.
+Given the file above we can re-build by providing it to the
+``-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.
 
 The XRay stack tool
 ---
Index: llvm/docs/XRay.rst
===
--- llvm/docs/XRay.rst
+++ llvm/docs/XRay.rst
@@ -117,6 +117,27 @@
   ; ...
 }
 
+Special Case File
+-
+
+Attributes can be imbued through the use of special case files instead of
+adding them to the original source files. You can use this to mark certain
+functions and classes to be never, always, or instrumented with first-argument
+logging from a file. The file's format is described below:
+
+.. code-block:: bash
+
+# Comments are supported
+[always]
+fun:always_instrument
+fun:log_arg1=arg1 # Log the first argument for the function
+
+[never]
+fun:never_instrument
+
+These files can be provided through the ``-fxray-attr-list=`` flag to clang.
+You may have multiple files loaded through multiple instances of the flag.
+
 XRay Runtime Library
 
 
Index: clang/test/CodeGen/xray-never-instrument.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-never-instrument.cpp
@@ -0,0 +1,24 @@
+// RUN: echo "fun:*foo*" > %t.never-instrument
+// RUN: echo "src:*xray-never-instrument.cpp" >> %t.never-instrument
+// RUN: echo "[never]" > %t.xray-attrlist
+// RUN: echo "fun:*foo*" >> %t.xray-attrlist
+// RUN: echo "src:*xray-never-instrument.cpp" >> %t.xray-attrlist
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-never-instrument=%t.never-instrument -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 \
+// RUN: -fxray-attr-list=%t.xray-attrlist -emit-llvm -o - %s \
+// RUN: -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+void foo() {}
+
+[[clang::xray_always_instrument]] void bar() {}
+
+void baz() {}
+
+// CHECK: define void @_Z3foov() #[[NEVERATTR:[0-9]+]] {
+// CHECK: define void @_Z3barv() #[[ALWAYSATTR:[0-9]+]] {
+// CHECK: define void @_Z3bazv() #[[NEVERATTR:[0-9]+]] {
+// CHECK: attributes #[[NEVERATTR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
+// CHECK: attributes #[[ALWAYSATTR]] = {{.*}} "function-instrument"="xray-always" {{.*}}
+
Index: clang/test/CodeGen/xray-imbue-arg1.cpp
===
--- clang/test/CodeGen/xray-imbue-arg1.cpp
+++ clang/test/CodeGen/xray-imbue-arg1.cpp
@@ -1,5 +1,12 @@
 // RUN: echo "fun:*arg1*=arg1" >> %t.always-instrument
-// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -fxray

[PATCH] D45014: [Index] Return SourceLocation to consumers, not FileID/Offset pair.

2018-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Ping...

@akyrtzi @arphaman I'm confident there's no functional change in this patch so 
I'm happy to land it with just a review from clangd folks, but would be great 
to know if you're happy with the interface change.


Repository:
  rC Clang

https://reviews.llvm.org/D45014



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


[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Well, it's better:

  Failing Tests (1):
  Clang :: Driver/linux-header-search.cpp

It is apparently the new test failing:

  + 
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/clang
 -no-canonical-prefixes 
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/linux-header-search.cpp
 -### -fsyntax-only -target i386-unknown-linux-gnu -stdlib=libstdc++ 
--sysroot=/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree
 --gcc-toolchain=
  + 
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/clang
 -no-canonical-prefixes 
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/linux-header-search.cpp
 -### -fsyntax-only -target x86_64-unknown-linux-gnu -stdlib=libstdc++ 
--sysroot=/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree
 --gcc-toolchain=
  + /usr/lib64/llvm/6/bin/FileCheck --check-prefix=CHECK-GENTOO-4-9-X 
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/linux-header-search.cpp
  
/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/linux-header-search.cpp:359:24:
 error: expected string not found in input
  // CHECK-GENTOO-4-9-X: "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
 ^
  :5:752: note: scanning from here
   
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/clang"
 "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-fsyntax-only" "-disable-free" 
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" 
"linux-header-search.cpp" "-mrelocation-model" "static" "-mthread-model" 
"posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" 
"-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" 
"x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/../../../../lib/clang/6.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/local/include"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/../../../../lib/clang/6.0.0/include"
 "-internal-externc-isystem" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/include"
 "-internal-externc-isystem" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include"
 "-fdeprecated-macro" "-fdebug-compilation-dir" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" 
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-x" "c++" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/linux-header-search.cpp"









 ^
  :5:752: note: with variable "SYSROOT" equal to 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree"
   
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/clang"
 "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-fsyntax-only" "-disable-free" 
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" 
"linux-header-search.cpp" "-mrelocation-model" "static" "-mthread-model" 
"posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" 
"-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" 
"x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src-abi_x86_32.x86/bin/../../../../lib/clang/6.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-6.0.0-r1/work/x/y/cfe-6.0.0.src/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree"
 "-internal-isystem" 

[PATCH] D45356: [clangd] Adapt index interfaces to D45014, and fix the old bugs.

2018-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 141300.
sammccall edited the summary of this revision.
sammccall added a comment.

Also fix source/expansion location confusion in XRefs (findDefinition et al)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45356

Files:
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -222,6 +222,18 @@
}
   )cpp",
 
+  R"cpp(// Macro argument
+   int [[i]];
+   #define ADDRESSOF(X) &X;
+   int *j = ADDRESSOF(^i);
+  )cpp",
+
+  R"cpp(// Symbol concatenated inside macro (not supported)
+   int *pi;
+   #define POINTER(X) p # X;
+   int i = *POINTER(^i);
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};
@@ -249,8 +261,11 @@
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = build(T.code());
+std::vector> ExpectedLocations;
+for (const auto &R : T.ranges())
+  ExpectedLocations.push_back(RangeIs(R));
 EXPECT_THAT(findDefinitions(AST, T.point()),
-ElementsAre(RangeIs(T.range(
+ElementsAreArray(ExpectedLocations))
 << Test;
   }
 }
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -250,14 +250,16 @@
 class Y;
 class Z {}; // not used anywhere
 Y* y = nullptr;  // used in header doesn't count
+#define GLOBAL_Z(name) Z name;
   )";
   const std::string Main = R"(
 W* w = nullptr;
 W* w2 = nullptr; // only one usage counts
 X x();
 class V;
 V* v = nullptr; // Used, but not eligible for indexing.
 class Y{}; // definition doesn't count as a reference
+GLOBAL_Z(z); // Not a reference to Z, we don't spell the type.
   )";
   CollectorOpts.CountReferences = true;
   runSymbolCollector(Header, Main);
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -59,8 +59,8 @@
 
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-  ArrayRef Relations, FileID FID,
-  unsigned Offset,
+  ArrayRef Relations,
+  SourceLocation Loc,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override;
 
   SymbolSlab takeSymbols() { return std::move(Symbols).build(); }
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -225,7 +225,7 @@
 // Always return true to continue indexing.
 bool SymbolCollector::handleDeclOccurence(
 const Decl *D, index::SymbolRoleSet Roles,
-ArrayRef Relations, FileID FID, unsigned Offset,
+ArrayRef Relations, SourceLocation Loc,
 index::IndexDataConsumer::ASTNodeInfo ASTNode) {
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
   assert(CompletionAllocator && CompletionTUInfo);
@@ -235,9 +235,10 @@
 
   // Mark D as referenced if this is a reference coming from the main file.
   // D may not be an interesting symbol, but it's cheaper to check at the end.
+  auto &SM = ASTCtx->getSourceManager();
   if (Opts.CountReferences &&
   (Roles & static_cast(index::SymbolRole::Reference)) &&
-  ASTCtx->getSourceManager().getMainFileID() == FID)
+  SM.getFileID(SM.getSpellingLoc(Loc)) == SM.getMainFileID())
 ReferencedDecls.insert(ND);
 
   // Don't continue indexing if this is a mere reference.
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -79,10 +79,10 @@
 
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-  ArrayRef Relations, FileID FID,
-  unsigned Offset,
+  ArrayRef Relations,
+  SourceLocation Loc,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset)) {
+if (Loc == SearchedLocation) {
   // Find and add definition declarations (for GoToDefinition).
   // We don't use parameter `D`, as Parameter `D` is the canonical
   // declaration, which is the first declaration of a redeclarable
@@ -98,18 +98,12 @@
   }
 
 private:
-  bool isSearchedLocation(FileID FID, unsigned Offset) const {
-const SourceManager &SourceMgr = AST.getSourceManager();
-return SourceMgr.getFileOffset(Searched

[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-06 Thread Simon Dardis via Phabricator via cfe-commits
sdardis requested changes to this revision.
sdardis added a comment.
This revision now requires changes to proceed.

You should also update the description of the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



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


[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I can't reproduce this using the trunk llvm. Does it pass for you if %clang is 
replaced by %clang++ in the test case?


Repository:
  rC Clang

https://reviews.llvm.org/D45233



___
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 Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Looks fine to me.


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] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

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

Another couple of nits.




Comment at: docs/HowToSetupToolingForLLVM.rst:136
   if (this->ASTDump.operator _Bool())
-  return clang::CreateASTDumper(this->ASTDumpFilter);
+  return clang::CreateASTDumper(nullptr, this->ASTDumpFilter);
   if (this->ASTPrint.operator _Bool())

Please add an argument comment for nullptr, e.g.

  return clang::CreateASTDumper(/*OS=*/nullptr, ...);

or maybe

  return clang::CreateASTDumper(nullptr /*dump to stderr*/, ...);

Same in the actual callers below.



Comment at: include/clang/Frontend/ASTConsumers.h:38
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream.
+std::unique_ptr CreateASTDumper(std::unique_ptr OS,

Add "When OS is nullptr, dumps AST to stderr."


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] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-06 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 141309.
whisperity added a comment.

Added comments on what `nullptr` means at call sites.


Repository:
  rC Clang

https://reviews.llvm.org/D45096

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


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -313,7 +313,8 @@
   auto &CG = *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: tools/clang-check/ClangCheck.cpp
===
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -138,7 +138,9 @@
 if (ASTList)
   return clang::CreateASTDeclNodeLister();
 if (ASTDump)
-  return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
+  return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
+ASTDumpFilter,
+/*DumpDecls=*/true,
 /*Deserialize=*/false,
 /*DumpLookups=*/false);
 if (ASTPrint)
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -74,7 +74,8 @@
 
 std::unique_ptr
 ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, 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: lib/Frontend/ASTConsumers.cpp
===
--- lib/Frontend/ASTConsumers.cpp
+++ 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: include/clang/Frontend/ASTConsumers.h
===
--- include/clang/Frontend/ASTConsumers.h
+++ 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: docs/HowToSetupToolingForLLVM.rst
===
--- docs/HowToSetupToolingForLLVM.rst
+++ 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())
  

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

2018-04-06 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 2 inline comments as done.
whisperity added a comment.

It is also std-out (`llvm::outs()`) in case of `nullptr` and not std-err.


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] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, bader, yaxunl.

Added std option for OpenCL C++, see cfe-dev thread for more details:
http://lists.llvm.org/pipermail/cfe-dev/2018-April/057535.html

Examples:
`clang -std=CL2.2 test.cl`
`clang -std=cl2.2 test.cl`
`clang -std=CLC++ test.cl`
`clang -std=clc++ test.cl`

I am not sure if we need a separate language mode. Right now I am reusing 
OpenCL. We can discuss.


https://reviews.llvm.org/D45363

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Driver/unknown-std.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c

Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -4,10 +4,14 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl2.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL2.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 // CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
Index: test/Frontend/opencl.cl
===
--- test/Frontend/opencl.cl
+++ test/Frontend/opencl.cl
@@ -1,24 +1,33 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.2 -DSYNTAX -DCXX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only -DSYNTAX
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
+#ifdef SYNTAX
+class test{
+int member;
+};
+#ifndef CXX
+//expected-error@-4{{unknown type name 'class'}}
+//expected-error@-5{{expected ';' after top level declarator}}
+#endif
+#endif
+
 void f(void (^g)(void)) {
-#ifdef __OPENCL_C_VERSION__
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(BLOCKS)
-  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0 or above}}
-#else
-  // expected-no-diagnostics
+#if defined(__OPENCL_C_VERSION__) || defined(CXX)
+#if !defined(BLOCKS) && (defined(CXX)  || __OPENCL_C_VERSION__ != CL_VERSION_2_0)
+  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0}}
 #endif
 #else
-  // expected-error@-8{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
+  // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 }
 
Index: test/Driver/unknown-std.cl
===
--- test/Driver/unknown-std.cl
+++ test/Driver/unknown-std.cl
@@ -10,6 +10,7 @@
 // CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard
 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
+// CHECK-NEXT: note: use 'cl2.2' for 'OpenCL 2.2 (aka OpenCL C++)' standard
 
 // Make sure that no other o

[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-06 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Ok, you know the ObjC community much better than I do. If you think that adding 
the indentation for ObjC irrespective of the option works for most people, I am 
happy to go with it.


Repository:
  rC Clang

https://reviews.llvm.org/D45004



___
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 Nico Weber via cfe-commits
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&view=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&r1=329299&r2=329300&view=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&r1=329299&r2=329300&view=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&r1=329299&r2=329300&view=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 &C,
>
>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 (Args.hasFlag(options::OPT_fmerge_all_constants,
> +   options::OPT_fno_merge_all_constants, false))
> +CmdArgs.push_back("-fmerge-all-constants");
>
>// LLVM Code Generator Optio

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

2018-04-06 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a subscriber: joerg.
rengolin added a comment.

LTO is something I never considered before in the context of the target parser, 
but I understand the issues are similar to what the build attributes were 
trying to solve, so adding more info shouldn't make it worse.

However, this will probably break obscure cases that normally only @compnerd 
and @joerg pick up. I, personally, don't have any opinion on how much this 
makes sense or not. :/

I'm with @fhahn that we should make ARM and AArch64 as common as possible, not 
only in code for the target parser but also in behaviour for the front-end, 
mostly because ARMv8 spans both and we want to avoid surprises.


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);
+}
+
+#un

[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] 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 = &i;
+  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 = &i;
+  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 = &i;
+}
+
+int glob;
+void glob_var(int &x) {
+  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 = &i;
+while (i < Limit) { // Not an error, since p is alias of i.
+  *++p;
+}
+  }
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rs

[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


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&view=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&r1=329390&r2=329391&view=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(&llvm::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&r1=329390&r2=329391&view=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&r1=329390&r2=329391&view=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&

[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&id=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(&llvm::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 &CI, 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 &CG = *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
===
--- cfe/trunk/tools/clang-check/

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


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&view=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&r1=329393&r2=329394&view=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 MakeCircSt(Intrinsic::hexago

[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


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


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&view=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&r1=329299&r2=329300&view=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&r1=329299&r2=329300&view=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&r1=329299&r2=329300&view=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 &C,
>>
>>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 (Ar

[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


[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 &Line,
-const AnnotatedLine *PreviousLine, unsigned Indent,
-unsigned NewlineIndent);
+const AnnotatedLine *PreviousLine,
+const SmallVectorImpl &Lines,
+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 &Line,
-  const AnnotatedLine *PreviousLine,
-  unsigned Indent,
-  unsigned NewlineIndent) {
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
   FormatToken &RootToken = *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.Nex

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&view=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&r1=329410&r2=329411&view=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 &Bld = 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] 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


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&view=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&r1=329419&r2=329420&view=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] 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


[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&view=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&r1=329427&r2=329428&view=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] 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


[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&view=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&r1=329432&r2=329433&view=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&view=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&view=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&r1=329432&r2=329433&view=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&view=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] 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


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&view=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&r1=329277&r2=329278&view=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 &Features,
+   DiagnosticsEngine &Diags) {
+  for (const auto &Feature : 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&r1=329277&r2=329278&view=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 &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 &Info) const override {
 return false;
   }
+
+  bool hasFeature(StringRef Feature) const override;
+
+  bool handleTargetFeatures(std::vector &Features,
+DiagnosticsEngine &Diags) 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&r1=329277&r2=329278&view=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&r1=329277&r2=329278&view=diff
==
--- cfe/trunk/test/Modules/target-features.m (original)
+++ cfe/trunk/te

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&view=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&r1=329222&r2=329223&view=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 &Path, std::error_code &EC) : 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&r1=329222&r2=329223&view=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


[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&view=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&r1=329339&r2=329340&view=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


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


[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 [[ 
https://github.com/ROCm-Developer-Tools/HIP/blob/ma

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

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

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&view=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&r1=329441&r2=329442&view=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 &C,
  SmallVectorImpl< std::pair > &FailingCommands);
 
-  /// 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 &C,
-  const Command &FailingCommand);
+  ///
+  void generateCompilationDiagnostics(
+  Compilation &C, const Command &FailingCommand,
+  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&r1=329441&r2=329442&view=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 &C,
-const Command &FailingCommand) {
+void Driver::generateCompilationDiagnostics(
+Compilation &C, const Command &FailingCommand,
+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, &CrashInfo);
+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&view=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-fil

[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&id=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 &C,
-const Command &FailingCommand) {
+void Driver::generateCompilationDiagnostics(
+Compilation &C, const Command &FailingCommand,
+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, &CrashInfo);
+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 &IO, UnsavedFileHash &Info) {
+IO.mapRequired("name", Info.Name);
+IO.mapRequired("md5", Info.MD5);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO &IO, ClangInvocationInfo &Info) {
+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 &Info) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << '{';
+  bool NeedComma = false;
+  auto EmitKey = [&](StringRef

[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
===
--- test/Sema/va_list_buil

[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 --check-prefix=CHECK

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


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&view=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&r1=329341&r2=329342&view
> =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::IsNotDest

[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 

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&view=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&r1=329443&r2=329444&view=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


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&view=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&r1=329444&r2=329445&view=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


[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


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&view=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&r1=329341&r2=329342&view
> > =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(), IsVola

[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


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&view=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&r1=329446&r2=329447&view=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 &C,
  SmallVectorImpl< std::pair > &FailingCommands);
 
-  /// 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 &C, const Command &FailingCommand,
-  StringRef AdditionalInformation = "",
-  CompilationDiagnosticReport *GeneratedReport = nullptr);
+  /// 
+  void generateCompilationDiagnostics(Compilation &C,
+  const Command &FailingCommand);
 
   /// @}
   /// @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&r1=329446&r2=329447&view=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 &C, const Command &FailingCommand,
-StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
+void Driver::generateCompilationDiagnostics(Compilation &C,
+const Command &FailingCommand) {
   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, &CrashInfo);
-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&view=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: 
http

[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 &Builder) 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 &TT) {
 return TT.getArch() == llvm::Triple::amdgcn;
   }
-  CudaArch GCN_Subarch;
 
 public:
   AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
@@ -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 &Opts,
clan

[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 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] 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-..parent's 
virtual method was called instead of… (authored by zinovy.nis, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44295?vs=141199&id=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: :[[@LINE-1

[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&view=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&r1=329447&r2=329448&view=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&r1=329447&r2=329448&view=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&view=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 &Parent,
+   const CXXRecordDecl &ThisClass) {
+  if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
+return true;
+  const auto ClassIter = llvm::find_if(ThisClass.bases(), [=](auto &Base) {
+auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+assert(BaseDecl);
+return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
+  });
+  return ClassIter != ThisClass.bases_end();
+}
+
+static BasesVector getParentsByGrandParent(const CXXRecordDecl &GrandParent,
+   const CXXRecordDecl &ThisClass,
+

[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


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&view=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&r1=329448&r2=329449&view=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] 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


[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


[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&view=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&r1=329451&r2=329452&view=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 &ThisClass) {
   if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
 return true;
-  const auto ClassIter = llvm::find_if(ThisClass.bases(), [=](auto &Base) {
-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 &Base) {
+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 &E,
clang::ASTContext &AC) {
   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


[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&view=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&r1=329453&r2=329454&view=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 &E,
clang::ASTContext &AC) {
   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


[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


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


[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&view=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&r1=329459&r2=329460&view=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&r1=329459&r2=329460&view=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&view=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 alg

[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


[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
===
--- test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackf

[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&view=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&r1=329461&r2=329462&view=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] 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, "");
+static_assert(!is_simd_mask>::value, "");
+static_assert(!is_simd_mask::value, "");
+
+#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
+!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mas

[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] 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 ${fi

[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] 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 &Result) 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 @@
+//===--- Iv

[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 &Result) 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 - clang-tid

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


  1   2   >