[PATCH] D54557: [analyzer] MoveChecker Pt.2: Restrict the warning to STL objects and locals.

2018-11-17 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D54557#1300654, @NoQ wrote:

> In https://reviews.llvm.org/D54557#1299736, @xazax.hun wrote:
>
> > It would be great to have a way to extend the list of (possibly non-stl) 
> > types to check. But I do understand that the analyzer does not have a great 
> > way to set such configuration options right now.
>
>
> Do you envision room for another attribute here? I.e., a class attribute that 
> says "this object is always unsafe to use after move, unless a method 
> annotated with `reinitializes` is called"?


Exactly :) My only concern is that I doubt users will end up passing such 
options using command line options. Having file base configuration options 
would be more convenient. They can be easily checked in the repository and 
evolve together with the product (like the .clang-tidy files in the LLVM repos).


https://reviews.llvm.org/D54557



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


r347136 - [AST][NFC] Pack CXXThrowExpr

2018-11-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sat Nov 17 04:53:56 2018
New Revision: 347136

URL: http://llvm.org/viewvc/llvm-project?rev=347136&view=rev
Log:
[AST][NFC] Pack CXXThrowExpr

Use the newly available space in the bit-fields of Stmt.
This saves 8 bytes per CXXThrowExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347136&r1=347135&r2=347136&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Nov 17 04:53:56 2018
@@ -1003,42 +1003,43 @@ public:
 class CXXThrowExpr : public Expr {
   friend class ASTStmtReader;
 
-  Stmt *Op;
-  SourceLocation ThrowLoc;
-
-  /// Whether the thrown variable (if any) is in scope.
-  unsigned IsThrownVariableInScope : 1;
+  /// The optional expression in the throw statement.
+  Stmt *Operand;
 
 public:
   // \p Ty is the void type which is used as the result type of the
-  // expression.  The \p l is the location of the throw keyword.  \p expr
-  // can by null, if the optional expression to throw isn't present.
-  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l,
+  // expression. The \p Loc is the location of the throw keyword.
+  // \p Operand is the expression in the throw statement, and can be
+  // null if not present.
+  CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc,
bool IsThrownVariableInScope)
   : Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
- expr && expr->isInstantiationDependent(),
- expr && expr->containsUnexpandedParameterPack()),
-Op(expr), ThrowLoc(l),
-IsThrownVariableInScope(IsThrownVariableInScope) {}
+ Operand && Operand->isInstantiationDependent(),
+ Operand && Operand->containsUnexpandedParameterPack()),
+Operand(Operand) {
+CXXThrowExprBits.ThrowLoc = Loc;
+CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
+  }
   CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
 
-  const Expr *getSubExpr() const { return cast_or_null(Op); }
-  Expr *getSubExpr() { return cast_or_null(Op); }
+  const Expr *getSubExpr() const { return cast_or_null(Operand); }
+  Expr *getSubExpr() { return cast_or_null(Operand); }
 
-  SourceLocation getThrowLoc() const { return ThrowLoc; }
+  SourceLocation getThrowLoc() const { return CXXThrowExprBits.ThrowLoc; }
 
   /// Determines whether the variable thrown by this expression (if any!)
   /// is within the innermost try block.
   ///
   /// This information is required to determine whether the NRVO can apply to
   /// this variable.
-  bool isThrownVariableInScope() const { return IsThrownVariableInScope; }
-
-  SourceLocation getBeginLoc() const LLVM_READONLY { return ThrowLoc; }
+  bool isThrownVariableInScope() const {
+return CXXThrowExprBits.IsThrownVariableInScope;
+  }
 
+  SourceLocation getBeginLoc() const { return getThrowLoc(); }
   SourceLocation getEndLoc() const LLVM_READONLY {
 if (!getSubExpr())
-  return ThrowLoc;
+  return getThrowLoc();
 return getSubExpr()->getEndLoc();
   }
 
@@ -1048,7 +1049,7 @@ public:
 
   // Iterators
   child_range children() {
-return child_range(&Op, Op ? &Op+1 : &Op);
+return child_range(&Operand, Operand ? &Operand + 1 : &Operand);
   }
 };
 

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347136&r1=347135&r2=347136&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sat Nov 17 04:53:56 2018
@@ -535,6 +535,19 @@ protected:
 SourceLocation Loc;
   };
 
+  class CXXThrowExprBitfields {
+friend class ASTStmtReader;
+friend class CXXThrowExpr;
+
+unsigned : NumExprBits;
+
+/// Whether the thrown variable (if any) is in scope.
+unsigned IsThrownVariableInScope : 1;
+
+/// The location of the "throw".
+SourceLocation ThrowLoc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -636,6 +649,7 @@ protected:
 CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
 CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
 CXXThisExprBitfields CXXThisExprBits;
+CXXThrowExprBitfields CXXThrowExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=347136&r1=347135&r2=347136&view=diff

r347137 - [AST][NFC] Pack CXXDefaultArgExpr

2018-11-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sat Nov 17 04:56:30 2018
New Revision: 347137

URL: http://llvm.org/viewvc/llvm-project?rev=347137&view=rev
Log:
[AST][NFC] Pack CXXDefaultArgExpr

Use the newly available space in the bit-fields of Stmt.
This saves one pointer per CXXDefaultArgExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347137&r1=347136&r2=347137&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Nov 17 04:56:30 2018
@@ -1059,26 +1059,24 @@ public:
 /// corresponding parameter's default argument, when the call did not
 /// explicitly supply arguments for all of the parameters.
 class CXXDefaultArgExpr final : public Expr {
+  friend class ASTStmtReader;
+
   /// The parameter whose default is being used.
   ParmVarDecl *Param;
 
-  /// The location where the default argument expression was used.
-  SourceLocation Loc;
-
-  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
+  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param)
   : Expr(SC,
- param->hasUnparsedDefaultArg()
-   ? param->getType().getNonReferenceType()
-   : param->getDefaultArg()->getType(),
- param->getDefaultArg()->getValueKind(),
- param->getDefaultArg()->getObjectKind(), false, false, false,
+ Param->hasUnparsedDefaultArg()
+ ? Param->getType().getNonReferenceType()
+ : Param->getDefaultArg()->getType(),
+ Param->getDefaultArg()->getValueKind(),
+ Param->getDefaultArg()->getObjectKind(), false, false, false,
  false),
-Param(param), Loc(Loc) {}
+Param(Param) {
+CXXDefaultArgExprBits.Loc = Loc;
+  }
 
 public:
-  friend class ASTStmtReader;
-  friend class ASTStmtWriter;
-
   CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
 
   // \p Param is the parameter whose default argument is used by this
@@ -1093,23 +1091,18 @@ public:
   ParmVarDecl *getParam() { return Param; }
 
   // Retrieve the actual argument to the function call.
-  const Expr *getExpr() const {
-return getParam()->getDefaultArg();
-  }
-  Expr *getExpr() {
-return getParam()->getDefaultArg();
-  }
+  const Expr *getExpr() const { return getParam()->getDefaultArg(); }
+  Expr *getExpr() { return getParam()->getDefaultArg(); }
 
-  /// Retrieve the location where this default argument was actually
-  /// used.
-  SourceLocation getUsedLocation() const { return Loc; }
+  /// Retrieve the location where this default argument was actually used.
+  SourceLocation getUsedLocation() const { return CXXDefaultArgExprBits.Loc; }
 
   /// Default argument expressions have no representation in the
   /// source, so they have an empty source range.
-  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
-  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
+  SourceLocation getBeginLoc() const { return SourceLocation(); }
+  SourceLocation getEndLoc() const { return SourceLocation(); }
 
-  SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
+  SourceLocation getExprLoc() const { return getUsedLocation(); }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDefaultArgExprClass;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347137&r1=347136&r2=347137&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sat Nov 17 04:56:30 2018
@@ -548,6 +548,16 @@ protected:
 SourceLocation ThrowLoc;
   };
 
+  class CXXDefaultArgExprBitfields {
+friend class ASTStmtReader;
+friend class CXXDefaultArgExpr;
+
+unsigned : NumExprBits;
+
+/// The location where the default argument expression was used.
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -650,6 +660,7 @@ protected:
 CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
 CXXThisExprBitfields CXXThisExprBits;
 CXXThrowExprBitfields CXXThrowExprBits;
+CXXDefaultArgExprBitfields CXXDefaultArgExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=347137&r1=347136&r2=347137&view=diff
=

r347138 - [AST][NFC] Pack CXXDefaultInitExpr

2018-11-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sat Nov 17 05:02:47 2018
New Revision: 347138

URL: http://llvm.org/viewvc/llvm-project?rev=347138&view=rev
Log:
[AST][NFC] Pack CXXDefaultInitExpr

Use the newly available space in the bit-fields of Stmt.
This saves one pointer per CXXDefaultInitExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347138&r1=347137&r2=347138&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Nov 17 05:02:47 2018
@@ -1123,26 +1123,23 @@ public:
 /// (C++11 [class.base.init]p8) or in aggregate initialization
 /// (C++1y [dcl.init.aggr]p7).
 class CXXDefaultInitExpr : public Expr {
+  friend class ASTReader;
+  friend class ASTStmtReader;
+
   /// The field whose default is being used.
   FieldDecl *Field;
 
-  /// The location where the default initializer expression was used.
-  SourceLocation Loc;
-
-  CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc, FieldDecl *Field,
- QualType T);
+  CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
+ FieldDecl *Field, QualType Ty);
 
   CXXDefaultInitExpr(EmptyShell Empty) : Expr(CXXDefaultInitExprClass, Empty) 
{}
 
 public:
-  friend class ASTReader;
-  friend class ASTStmtReader;
-
   /// \p Field is the non-static data member whose default initializer is used
   /// by this expression.
-  static CXXDefaultInitExpr *Create(const ASTContext &C, SourceLocation Loc,
+  static CXXDefaultInitExpr *Create(const ASTContext &Ctx, SourceLocation Loc,
 FieldDecl *Field) {
-return new (C) CXXDefaultInitExpr(C, Loc, Field, Field->getType());
+return new (Ctx) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType());
   }
 
   /// Get the field whose initializer will be used.
@@ -1159,8 +1156,8 @@ public:
 return Field->getInClassInitializer();
   }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
-  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+  SourceLocation getBeginLoc() const { return CXXDefaultInitExprBits.Loc; }
+  SourceLocation getEndLoc() const { return CXXDefaultInitExprBits.Loc; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXDefaultInitExprClass;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347138&r1=347137&r2=347138&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sat Nov 17 05:02:47 2018
@@ -558,6 +558,16 @@ protected:
 SourceLocation Loc;
   };
 
+  class CXXDefaultInitExprBitfields {
+friend class ASTStmtReader;
+friend class CXXDefaultInitExpr;
+
+unsigned : NumExprBits;
+
+/// The location where the default initializer expression was used.
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -661,6 +671,7 @@ protected:
 CXXThisExprBitfields CXXThisExprBits;
 CXXThrowExprBitfields CXXThrowExprBits;
 CXXDefaultArgExprBitfields CXXDefaultArgExprBits;
+CXXDefaultInitExprBitfields CXXDefaultInitExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=347138&r1=347137&r2=347138&view=diff
==
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sat Nov 17 05:02:47 2018
@@ -749,14 +749,15 @@ const IdentifierInfo *UserDefinedLiteral
   return cast(getCalleeDecl())->getLiteralIdentifier();
 }
 
-CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc,
-   FieldDecl *Field, QualType T)
-: Expr(CXXDefaultInitExprClass, T.getNonLValueExprType(C),
-   T->isLValueReferenceType() ? VK_LValue : T->isRValueReferenceType()
+CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation 
Loc,
+   FieldDecl *Field, QualType Ty)
+: Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
+   Ty->isLValueReferenceType() ? VK_LValue : 
Ty->isRValueReferenceType()
 ? VK_XValue
 : VK_RValue,
/*FIXME*/ OK_Ordinary, false, false, false, false),
-  Field(Field), 

[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-11-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 174505.
xbolva00 added a comment.

Addressed comments, fixed tests


https://reviews.llvm.org/D52835

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
  test/Sema/ext_vector_casts.c
  test/Sema/impcast-integer-float.c

Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -Wfloat-precision -triple x86_64-linux -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483647 to 2.1474836E+9}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}}
+double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775807 to 9.223372036854775E+18}} 
+
+long double c1 = ((__int128)1 << 127) + 1; // expected-warning {{implicit conversion from '__int128' to 'long double' changes value from -170141183460469231731687303715884105727 to -1.7014118346046923173E+38}}
+long double c2 = (__int128)1 << 127;
+
+float d = (__uint128_t)-1; // expected-warning {{implicit conversion from '__uint128_t' (aka 'unsigned __int128') to 'float' changes value from 340282366920938463463374607431768211455 to +Inf}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4.2949673E+9}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
   vd = l + vd;
Index: test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
===
--- test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
+++ test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
@@ -121,8 +121,10 @@
 
   // Constants.
   Agg f4 = {12345678};  // OK (exactly fits in a float)
+  // expected-warning@+1 {{implicit conversion from 'int' to 'float' changes value from 123456789 to 1.2345679E+8}}
   Agg f5 = {123456789};  // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
 
+  // expected-warning@+1 {{implicit conversion from 'int' to 'float' changes value from 123456789 to 1.2345679E+8}}
   Agg ce1 = { Convert(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}}
   Agg ce2 = { ConvertVar() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}}
 }
Index: test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
===
--- test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
+++ test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -133,8 +133,10 @@
   // Constants.
   Agg f7 = {12345678};  // OK (exactly fits in a float)
   Agg f8 = {EnumVal};  // OK
+  // expected-warning@+1 {{implicit conversion from 'int' to 'float' changes value from 123456789 to 1.2345679E+8}}
   Agg f9 = {123456789};  // expected-error {{ cannot be narrowed }} expected-note {{silence}}
-
+  
+  // expected-warning@+1 {{implicit conversion from 'int' to 'float' changes value from 123456789 to 1.2345679E+8}}
   Agg ce1 = { Convert(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}}
   Agg ce2 = { ConvertVar() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}}
 }
In

[PATCH] D54657: [clang] Add -MJJ for appending to compilation databases.

2018-11-17 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I don't understand the point here. Why would you want to include 
pre-processing-only commands in the compilation database?


Repository:
  rC Clang

https://reviews.llvm.org/D54657



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D54246#1301940, @hwright wrote:

> @aaron.ballman I don't actually have the commit bit, can you commit this, or 
> are we waiting for further review?


No further review required. I'm happy to commit for you. I'll do it later today 
or tomorrow, unless someone else gets to it first.


https://reviews.llvm.org/D54246



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-11-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:3811
   case ParsedAttr::AT_CXX11NoReturn:
+  case ParsedAttr::AT_TriviallyRelocatable:
 return true;

erichkeane wrote:
> A note for future reviewers, after the C++11 spelling is removed, this likely 
> needs to go as well.
With this line:
```
struct [[clang::trivially_relocatable()]] A {};
// expected-error@-1 {{attribute 'trivially_relocatable' cannot have an 
argument list}}
struct [[clang::trivially_relocatable(42)]] B {};
// expected-error@-1 {{attribute 'trivially_relocatable' cannot have an 
argument list}}
```
Without this line:
```
struct [[clang::trivially_relocatable()]] A {};
struct [[clang::trivially_relocatable(42)]] B {};
// expected-error@-1 {{'trivially_relocatable' attribute takes no arguments}}
```
IMO the former behavior (with this line) is //much// preferable to the latter 
behavior. I think I wish this switch statement included //all// attributes!


Repository:
  rC Clang

https://reviews.llvm.org/D50119



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


r347141 - Sink BuryPointer from Clang into LLVM for reuse there

2018-11-17 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Sat Nov 17 10:04:13 2018
New Revision: 347141

URL: http://llvm.org/viewvc/llvm-project?rev=347141&view=rev
Log:
Sink BuryPointer from Clang into LLVM for reuse there

Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/tools/driver/cc1_main.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=347141&r1=347140&r2=347141&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Sat Nov 17 10:04:13 2018
@@ -22,6 +22,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/BuryPointer.h"
 #include 
 #include 
 #include 
@@ -411,7 +412,7 @@ public:
   }
 
   void resetAndLeakFileManager() {
-BuryPointer(FileMgr.get());
+llvm::BuryPointer(FileMgr.get());
 FileMgr.resetWithoutRelease();
   }
 
@@ -431,7 +432,7 @@ public:
   }
 
   void resetAndLeakSourceManager() {
-BuryPointer(SourceMgr.get());
+llvm::BuryPointer(SourceMgr.get());
 SourceMgr.resetWithoutRelease();
   }
 
@@ -453,7 +454,7 @@ public:
   std::shared_ptr getPreprocessorPtr() { return PP; }
 
   void resetAndLeakPreprocessor() {
-BuryPointer(new std::shared_ptr(PP));
+llvm::BuryPointer(new std::shared_ptr(PP));
   }
 
   /// Replace the current preprocessor.
@@ -471,7 +472,7 @@ public:
   }
 
   void resetAndLeakASTContext() {
-BuryPointer(Context.get());
+llvm::BuryPointer(Context.get());
 Context.resetWithoutRelease();
   }
 

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=347141&r1=347140&r2=347141&view=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Sat Nov 17 10:04:13 2018
@@ -226,14 +226,6 @@ inline uint64_t getLastArgUInt64Value(co
   return getLastArgUInt64Value(Args, Id, Default, &Diags);
 }
 
-// When Clang->getFrontendOpts().DisableFree is set we don't delete some of the
-// global objects, but we don't want LeakDetectors to complain, so we bury them
-// in a globally visible array.
-void BuryPointer(const void *Ptr);
-template  void BuryPointer(std::unique_ptr Ptr) {
-  BuryPointer(Ptr.release());
-}
-
 // Frontend timing utils
 
 /// If the user specifies the -ftime-report argument on an Clang command line

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=347141&r1=347140&r2=347141&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Nov 17 10:04:13 2018
@@ -37,6 +37,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=347141&r1=347140&r2=347141&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sat Nov 17 10:04:13 2018
@@ -38,6 +38,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
@@ -2132,7 +2133,7 @@ CompilerInstance::lookupMissingImports(S
 
   return false;
 }
-void CompilerInstance::resetAndLeakSema() { BuryPointer(takeSema()); }
+void CompilerInstance::resetAndLeakSema() { llvm::BuryPointer(takeSema()); }
 
 void CompilerInstance::setExternalSemaSource(
 IntrusiveRefCntPtr ESS) {

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=347141&r1=347140&r2=347141&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/Compi

[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-17 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul marked 9 inline comments as done.
sthibaul added inline comments.



Comment at: lib/Basic/Targets/OSTargets.h:283
+Builder.defineMacro("__GLIBC__");
+Builder.defineMacro("__ELF__");
+if (Opts.POSIXThreads)

kristina wrote:
> `__MACH__` and `__HURD__` seem appropriate? Apple Mach (Darwin/XNU) uses 
> `__MACH__` with `__APPLE__`, Hurd should probably follow a similar 
> convention, I don't think there are many places aside from XNU build where 
> `__MACH__` is used on its own.
There is actually no `__HURD__` macro, it's the `__GNU__` macro which has that 
role. `__MACH__` should however  be there too indeed, as well as `__gnu_hurd__` 
similarly to Linux' `__gnu_linux__`.



Comment at: lib/Driver/ToolChains/Hurd.cpp:78
+
+  return std::string();
+}

kristina wrote:
> I'm not quite sure I like this. Also early return should be for the "bad" 
> case, not for the good case, at least IMO, this is not a huge issue but I'll 
> see what others say. I think this may just be subjective.
Well, this is inspired from clang/lib/Driver/ToolChains/Linux.cpp, which 
additionally has some gcc tests, which I'll include in a later patch. That 
argues for using this way of doing the test since that is how it will be in the 
end.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-17 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul added a comment.

> In general when structuring your code, the performance penalty for other 
> targets when the conditions that can be easily tested are not met should 
> pretty much be close to nonexistent. I would suggest keeping that in mind 
> when submitting revisions.

I know, as discussed on IRC I just hadn't managed to find a way to achieve it 
in this case :)

But thanks to the IRC discussion I'll be able to do it.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54600: [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov (after revert https://reviews.llvm.org/rL346659)

2018-11-17 Thread calixte via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347144: [Clang] Add options -fprofile-filter-files and 
-fprofile-exclude-files to… (authored by calixte, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54600?vs=174281&id=174512#toc

Repository:
  rC Clang

https://reviews.llvm.org/D54600

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/code-coverage-filter1.h
  test/CodeGen/Inputs/code-coverage-filter2.h
  test/CodeGen/code-coverage-filter.c

Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -129,6 +129,12 @@
   /// The filename with path we use for coverage notes files.
   std::string CoverageNotesFile;
 
+  /// Regexes separated by a semi-colon to filter the files to instrument.
+  std::string ProfileFilterFiles;
+
+  /// Regexes separated by a semi-colon to filter the files to not instrument.
+  std::string ProfileExcludeFiles;
+
   /// The version string to put into coverage files.
   char CoverageVersion[4];
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -768,6 +768,12 @@
 HelpText<"Disable using instrumentation data for profile-guided optimization">;
 def fno_profile_use : Flag<["-"], "fno-profile-use">,
 Alias;
+def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
+Group, Flags<[CC1Option, CoreOption]>,
+HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">;
+def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
+Group, Flags<[CC1Option, CoreOption]>,
+HelpText<"Instrument only functions from files where names don't match all the regexes separated by a semi-colon">;
 
 def faddrsig : Flag<["-"], "faddrsig">, Group, Flags<[CoreOption, CC1Option]>,
   HelpText<"Emit an address-significance table">;
Index: test/CodeGen/Inputs/code-coverage-filter2.h
===
--- test/CodeGen/Inputs/code-coverage-filter2.h
+++ test/CodeGen/Inputs/code-coverage-filter2.h
@@ -0,0 +1 @@
+void test2() {}
Index: test/CodeGen/Inputs/code-coverage-filter1.h
===
--- test/CodeGen/Inputs/code-coverage-filter1.h
+++ test/CodeGen/Inputs/code-coverage-filter1.h
@@ -0,0 +1 @@
+void test1() {}
Index: test/CodeGen/code-coverage-filter.c
===
--- test/CodeGen/code-coverage-filter.c
+++ test/CodeGen/code-coverage-filter.c
@@ -0,0 +1,84 @@
+// RUN: %clang -S -emit-llvm --coverage %s -o %t
+// RUN: FileCheck -check-prefix=ALL < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-exclude-files=".*\.h$" %s -o %t
+// RUN: FileCheck -check-prefix=NO-HEADER < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-filter-files=".*\.c$" %s -o %t
+// RUN: FileCheck -check-prefix=NO-HEADER < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-filter-files=".*\.c$;.*1\.h$" %s -o %t
+// RUN: FileCheck -check-prefix=NO-HEADER2 < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-exclude-files=".*2\.h$;.*1\.h$" %s -o %t
+// RUN: FileCheck -check-prefix=JUST-C < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-exclude-files=".*code\-coverage\-filter\.c$" %s -o %t
+// RUN: FileCheck -check-prefix=HEADER < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.c$" %s -o %t
+// RUN: FileCheck -check-prefix=NONE < %t %s
+// RUN: %clang -S -emit-llvm --coverage -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.h$" %s -o %t
+// RUN: FileCheck -check-prefix=JUST-C < %t %s
+
+#include "Inputs/code-coverage-filter1.h"
+#include "Inputs/code-coverage-filter2.h"
+
+void test() {
+  test1();
+  test2();
+}
+
+// ALL: void @test1() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: void @test2() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: void @test() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+
+// NO-HEADER: void @test1() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: void @test2() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: void @test() #0 {{.*}}
+// NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+
+// NO-HEADER2: void @test1() #0 {{.*}}
+// NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+// NO-HEADER2: void @test2() #0 {

r347144 - [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov (after revert https://reviews.llvm.org/rL346659)

2018-11-17 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Sat Nov 17 11:41:39 2018
New Revision: 347144

URL: http://llvm.org/viewvc/llvm-project?rev=347144&view=rev
Log:
[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to 
filter the files to instrument with gcov (after revert 
https://reviews.llvm.org/rL346659)

Summary:
the previous patch (https://reviews.llvm.org/rC346642) has been reverted 
because of test failure under windows.
So this patch fix the test cfe/trunk/test/CodeGen/code-coverage-filter.c.

Reviewers: marco-c

Reviewed By: marco-c

Subscribers: cfe-commits, sylvestre.ledru

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

Added:
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter1.h
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter2.h
cfe/trunk/test/CodeGen/code-coverage-filter.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=347144&r1=347143&r2=347144&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sat Nov 17 11:41:39 2018
@@ -64,6 +64,12 @@ Non-comprehensive list of changes in thi
 New Compiler Flags
 --
 
+- ``-fprofile-filter-files=[regexes]`` and 
``-fprofile-exclude-files=[regexes]``.
+
+  Clang has now options to filter or exclude some files when
+  instrumenting for gcov-based profiling.
+  See the :doc:`UsersManual` for details.
+
 - ...
 
 Deprecated Compiler Flags

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=347144&r1=347143&r2=347144&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Sat Nov 17 11:41:39 2018
@@ -1871,6 +1871,55 @@ using the ``llvm-cxxmap`` and ``llvm-pro
   following the Itanium C++ ABI mangling scheme. This covers all C++ targets
   supported by Clang other than Windows.
 
+GCOV-based Profiling
+
+
+GCOV is a test coverage program, it helps to know how often a line of code
+is executed. When instrumenting the code with ``--coverage`` option, some
+counters are added for each edge linking basic blocks.
+
+At compile time, gcno files are generated containing information about
+blocks and edges between them. At runtime the counters are incremented and at
+exit the counters are dumped in gcda files.
+
+The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate
+a report ``.c.gcov``.
+
+.. option:: -fprofile-filter-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name matches any of the regexes then the file is instrumented.
+
+   .. code-block:: console
+
+ $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c
+
+  For example, this will only instrument files finishing with ``.c``, skipping 
``.h`` files.
+
+.. option:: -fprofile-exclude-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name doesn't match all the regexes then the file is instrumented.
+
+  .. code-block:: console
+
+ $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c
+
+  For example, this will instrument all the files except the ones in 
``/usr/include``.
+
+If both options are used then a file is instrumented if its name matches any
+of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes
+from ``-fprofile-exclude-list``.
+
+.. code-block:: console
+
+   $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \
+   -fprofile-filter-files="^/usr/.*$"
+  
+In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter 
regex and
+doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it 
matches
+the exclude regex.
+
 Controlling Debug Information
 -
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=347144&r1=347143&r2=347144&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sat Nov 17 11:41:39 2018
@@ -768,6 +768,12 @@ def fno_profile_instr_use : Flag<["-"],
 HelpText<"Disable using instrumentation data for profile-guided 
optimization">;
 def fno_profile_use : Flag<["-"], "fno-profile-use">,
 Alias;
+def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
+Group, Flags<[CC1Opti

[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-11-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 174513.
Quuxplusone added a comment.

Implement `[[clang::maybe_trivially_relocatable]]` along the lines suggested by 
@rjmccall. The idea is that there are two levels of "opt-in-ness."

The first level, `[[clang::maybe_trivially_relocatable]]`, means "I warrant 
that even though I may have user-provided, non-defaulted, special member 
functions, I have designed them so that my relocation operation will not do 
anything substantially different from memberwise relocation." So if all of my 
member+base subobjects are trivially relocatable (and not mutable and not 
volatile), then I myself will be trivially relocatable.

The second level, `[[clang::trivially_relocatable]]`, means "I warrant that 
even though I may have user-provided, non-defaulted, special member functions, 
and even though I may have non-trivially relocatable (or mutable or volatile) 
subobjects, I have designed them so that my relocation operation will not do 
anything substantially different from memcpy." So I myself will be trivially 
relocatable //no matter// what my subobjects claim about themselves. 
Significantly, this means that I can write a class that //overrules// a 
decision made by one of its members.

- I can make a `TriviallyRelocatableWidget` that encloses a heap and a bunch of 
offset_ptrs into that heap, even though a single offset_ptr in isolation is not 
trivially relocatable.
- I can make a `TriviallyRelocatableWidget` that encloses a 
`boost::shared_ptr`, even though the maintainer of `boost::shared_ptr` may 
not have marked `boost::shared_ptr` as trivially relocatable.
- (Of dubious usefulness) I can make a `BaseClass` that is not marked trivially 
relocatable, and then make a `TriviallyRelocatableDerivedClass` that 
//strengthens// the guarantees of its `BaseClass` while remaining 
Liskov-substitutable for it.

Now that `[[clang::maybe_trivially_relocatable]]` is implemented, we can see if 
it does actually simplify the libc++ patch. I will try to get to that tonight. 
The current libc++ patch is here:
https://github.com/Quuxplusone/libcxx/tree/trivially-relocatable


Repository:
  rC Clang

https://reviews.llvm.org/D50119

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Features.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/maybe-trivially-relocatable.cpp
  test/SemaCXX/trivially-relocatable.cpp

Index: test/SemaCXX/trivially-relocatable.cpp
===
--- /dev/null
+++ test/SemaCXX/trivially-relocatable.cpp
@@ -0,0 +1,645 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-diagnostics
+
+static_assert(__has_extension(trivially_relocatable), "");
+
+// It shall appear at most once in each attribute-list
+// and no attribute-argument-clause shall be present.
+
+struct [[clang::trivially_relocatable, clang::trivially_relocatable]] B1 {}; // should really be an error
+
+struct [[clang::trivially_relocatable]] [[clang::trivially_relocatable]] B2 {}; // should really be an error
+
+struct [[clang::trivially_relocatable(42)]] B3 {};
+// expected-error@-1{{'trivially_relocatable' attribute takes no arguments}}
+
+
+//   The first declaration of a type shall specify the
+//   trivially_relocatable attribute if any declaration of that
+//   type specifies the trivially_relocatable attribute.
+
+struct [[clang::trivially_relocatable]] A1 {};  // ok
+struct [[clang::trivially_relocatable]] A1;
+
+struct [[clang::trivially_relocatable]] A2;  // ok
+struct [[clang::trivially_relocatable]] A2 {};
+
+struct [[clang::trivially_relocatable]] A3 {};  // ok
+struct A3;
+
+struct [[clang::trivially_relocatable]] A4;  // ok
+struct A4 {};
+
+struct A5 {};
+struct [[clang::trivially_relocatable]] A5;
+// expected-error@-1{{type A5 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+// expected-warning@-3{{attribute declaration must precede definition}}
+// expected-note@-5{{previous definition is here}}
+
+struct A6;
+struct [[clang::trivially_relocatable]] A6 {};
+// expected-error@-1{{type A6 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+
+
+// If a type T is declared with the trivially_relocatable attribute, and T is
+// either not move-constructible or not destructible

[PATCH] D54097: Save memory in ASTReader by using DenseMap instead of vector

2018-11-17 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Ping...


https://reviews.llvm.org/D54097



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-17 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally added a comment.

In https://reviews.llvm.org/D53157#1301992, @hfinkel wrote:

> > Just because FENV_ACCESS can be toggled on that granularity doesn't mean we 
> > have to represent it that way. We've previously agreed (I think) that if 
> > FENV_ACCESS is enabled anywhere in a function we will want to use the 
> > constrained intrinsics for all FP operations in the function, not just the 
> > ones in the scope where it was specified.
>
> Yes, this is also my understanding. We can't soundly mix the two in the same 
> function because we can't prevent the code motion within the function.


Ugh, I don't know. The C Standard's language is so vague.

In https://reviews.llvm.org/D53157#1301994, @hfinkel wrote:

> The rounding mode does need to be reset to its default setting when passing 
> from FENV_ACCESS "on" to FENV_ACCESS "off", but that seems to be the user's 
> responsibility. Are you saying that the implementation should reset it on 
> that transition?


Yes, that's how I was interpreting the Standard (today). The implementation 
should reset the control modes. The verbiage is murky at best though.

We touched on this in https://reviews.llvm.org/D43142 and I do realize that my 
opinion has flip-flopped since then. I previously believed that reseting the 
control modes was up to the user, but now I'm not so sure. I suppose that 
either way, as long as a fesetround(default_mode_constant) is seen with a 
FENV_ACCESS=OFF, we could use that as a barrier to prevent the problematic code 
motion.

Thinking aloud, maybe we should be working on redefining FENV_ACCESS in the C 
Standard? It's pretty clear that this section could use some work.

All that said, my understanding of $7.6.1 in the Standard is cloudy at best. If 
I'm the only one that feels this way, I'll drop my objections...


https://reviews.llvm.org/D53157



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


[PATCH] D54672: clang-include-fixer.el: support remote files

2018-11-17 Thread Philipp via Phabricator via cfe-commits
phst created this revision.
phst added a reviewer: klimek.
Herald added a subscriber: cfe-commits.

Support remote files (e.g., Tramp) in the Emacs integration for 
clang-include-fixer


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54672

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; 
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,15 +129,15 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
 arguments.  Return the new process object."
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-include-fixer output*"))
  (process-connection-type nil)
- (process (apply #'start-process "clang-include-fixer" stdout
+ (process (apply #'start-file-process "clang-include-fixer" stdout
  (clang-include-fixer--command args
 (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
 (set-process-query-on-exit-flag process nil)
@@ -156,7 +160,7 @@
 ,(format "-input=%s" clang-include-fixer-init-string)
 "-stdin"
 ,@args
-,(buffer-file-name)))
+,(clang-include-fixer--file-local-name buffer-file-name)))
 
 (defun clang-include-fixer--sentinel (stdin stdout stderr callback)
   "Return a process sentinel for clang-include-fixer processes.
@@ -446,5 +450,11 @@
 (defalias 'clang-include-fixer--format-message
   (if (fboundp 'format-message) 'format-message 'format))
 
+;; ‘file-local-name’ is new in Emacs 26.1.  Provide a fallback for older
+;; versions.
+(defalias 'clang-include-fixer--file-local-name
+  (if (fboundp 'file-local-name) #'file-local-name
+(lambda (file) (or (file-remote-p file 'localname) file
+
 (provide 'clang-include-fixer)
 ;;; clang-include-fixer.el ends here


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,15 +129,15 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
 arguments.  Return the new process object."
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-include-fixer output*"))
  (process-connection-type nil)
- (process (apply #'star

Re: r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

2018-11-17 Thread Shoaib Meenai via cfe-commits
Could we merge this into 7.0.1? It's a trivial typo fix, and the error message 
could otherwise be confusing to users (someone brought this up in IRC a few 
hours ago).

From: cfe-commits  on behalf of Alex Lorenz 
via cfe-commits 
Reply-To: Alex Lorenz 
Date: Friday, September 7, 2018 at 12:01 PM
To: "cfe-commits@lists.llvm.org" 
Subject: r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead 
of '-std'

Author: arphaman
Date: Fri Sep  7 11:59:45 2018
New Revision: 341697

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D341697-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=MYePhuYEkBYd5aK7fqamBrBRJJGtvC-BPPojLInHah8&e=
Log:
warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

Addresses first post-commit feedback for r335081 from Nico

Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_DiagnosticFrontendKinds.td-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=ZQcIenU2yQH3SmDrAhdXm2VKI10aP3_5IoBH-72HxYA&e=
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep  7 
11:59:45 2018
@@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa
   "OpenCL version %0 does not support the option '%1'">, InGroup;
def warn_stdlibcxx_not_found : Warning<
-  "include path for stdlibc++ headers not found; pass '-std=libc++' on the "
+  "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the "
   "command line to use the libc++ standard library instead">,
   InGroup>;
}

Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Frontend_warning-2Dstdlibcxx-2Ddarwin.cpp-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=YR_ENMKZ9M1ESvYMVXN6PlRtSZ8bXMsfvYf8QaBm5X4&e=
==
--- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
+++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep  7 11:59:45 
2018
@@ -1,5 +1,5 @@
// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 
2>&1 | FileCheck %s
// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist 
-stdlib=libc++ %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-std=libc++' on 
the command line to use the libc++ standard library instead
+// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' 
on the command line to use the libc++ standard library instead
// expected-no-diagnostics


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=Q8IVygsR4GuCJTOTCl7xRLj0JSxkuoS-q2HhesuNe4U&e=

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


Re: r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

2018-11-17 Thread Richard Smith via cfe-commits
Good idea, this LG for a patch release.

On Sat, 17 Nov 2018, 18:48 Shoaib Meenai via cfe-commits <
cfe-commits@lists.llvm.org wrote:

> Could we merge this into 7.0.1? It's a trivial typo fix, and the error
> message could otherwise be confusing to users (someone brought this up in
> IRC a few hours ago).
>
>
>
> *From: *cfe-commits  on behalf of
> Alex Lorenz via cfe-commits 
> *Reply-To: *Alex Lorenz 
> *Date: *Friday, September 7, 2018 at 12:01 PM
> *To: *"cfe-commits@lists.llvm.org" 
> *Subject: *r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++'
> instead of '-std'
>
>
>
> Author: arphaman
>
> Date: Fri Sep  7 11:59:45 2018
>
> New Revision: 341697
>
>
>
> URL:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D341697-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=MYePhuYEkBYd5aK7fqamBrBRJJGtvC-BPPojLInHah8&e=
>
> Log:
>
> warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'
>
>
>
> Addresses first post-commit feedback for r335081 from Nico
>
>
>
> Modified:
>
> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>
> cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>
>
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>
> URL:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_DiagnosticFrontendKinds.td-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=ZQcIenU2yQH3SmDrAhdXm2VKI10aP3_5IoBH-72HxYA&e=
>
>
> ==
>
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
>
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep  7
> 11:59:45 2018
>
> @@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa
>
>"OpenCL version %0 does not support the option '%1'">,
> InGroup;
>
> def warn_stdlibcxx_not_found : Warning<
>
> -  "include path for stdlibc++ headers not found; pass '-std=libc++' on
> the "
>
> +  "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on
> the "
>
>"command line to use the libc++ standard library instead">,
>
>InGroup>;
>
> }
>
>
>
> Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>
> URL:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Frontend_warning-2Dstdlibcxx-2Ddarwin.cpp-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=YR_ENMKZ9M1ESvYMVXN6PlRtSZ8bXMsfvYf8QaBm5X4&e=
>
>
> ==
>
> --- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
>
> +++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep  7
> 11:59:45 2018
>
> @@ -1,5 +1,5 @@
>
> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist
> %s 2>&1 | FileCheck %s
>
> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist
> -stdlib=libc++ %s -verify
>
> -// CHECK: include path for stdlibc++ headers not found; pass
> '-std=libc++' on the command line to use the libc++ standard library instead
>
> +// CHECK: include path for stdlibc++ headers not found; pass
> '-stdlib=libc++' on the command line to use the libc++ standard library
> instead
>
> // expected-no-diagnostics
>
>
>
>
>
> ___
>
> cfe-commits mailing list
>
> cfe-commits@lists.llvm.org
>
>
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=Q8IVygsR4GuCJTOTCl7xRLj0JSxkuoS-q2HhesuNe4U&e=
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

2018-11-17 Thread Arthur O'Dwyer via cfe-commits
Peanut gallery says: I think the one remaining instance of `-std=libc++` in
the tests should be fixed at the same time.

–Arthur

On Sat, Nov 17, 2018 at 9:52 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Good idea, this LG for a patch release.
>
> On Sat, 17 Nov 2018, 18:48 Shoaib Meenai via cfe-commits <
> cfe-commits@lists.llvm.org wrote:
>
>> Could we merge this into 7.0.1? It's a trivial typo fix, and the error
>> message could otherwise be confusing to users (someone brought this up in
>> IRC a few hours ago).
>>
>>
>>
>> *From: *cfe-commits  on behalf of
>> Alex Lorenz via cfe-commits 
>> *Reply-To: *Alex Lorenz 
>> *Date: *Friday, September 7, 2018 at 12:01 PM
>> *To: *"cfe-commits@lists.llvm.org" 
>> *Subject: *r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++'
>> instead of '-std'
>>
>>
>>
>> Author: arphaman
>>
>> Date: Fri Sep  7 11:59:45 2018
>>
>> New Revision: 341697
>>
>>
>>
>> URL:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D341697-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=MYePhuYEkBYd5aK7fqamBrBRJJGtvC-BPPojLInHah8&e=
>>
>> Log:
>>
>> warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'
>>
>>
>>
>> Addresses first post-commit feedback for r335081 from Nico
>>
>>
>>
>> Modified:
>>
>> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>>
>> cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>>
>>
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>>
>> URL:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_DiagnosticFrontendKinds.td-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=ZQcIenU2yQH3SmDrAhdXm2VKI10aP3_5IoBH-72HxYA&e=
>>
>>
>> ==
>>
>> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
>>
>> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep  7
>> 11:59:45 2018
>>
>> @@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa
>>
>>"OpenCL version %0 does not support the option '%1'">,
>> InGroup;
>>
>> def warn_stdlibcxx_not_found : Warning<
>>
>> -  "include path for stdlibc++ headers not found; pass '-std=libc++' on
>> the "
>>
>> +  "include path for stdlibc++ headers not found; pass '-stdlib=libc++'
>> on the "
>>
>>"command line to use the libc++ standard library instead">,
>>
>>InGroup>;
>>
>> }
>>
>>
>>
>> Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>>
>> URL:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Frontend_warning-2Dstdlibcxx-2Ddarwin.cpp-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=YR_ENMKZ9M1ESvYMVXN6PlRtSZ8bXMsfvYf8QaBm5X4&e=
>>
>>
>> ==
>>
>> --- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
>>
>> +++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep  7
>> 11:59:45 2018
>>
>> @@ -1,5 +1,5 @@
>>
>> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot
>> %S/doesnotexist %s 2>&1 | FileCheck %s
>>
>> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot
>> %S/doesnotexist -stdlib=libc++ %s -verify
>>
>> -// CHECK: include path for stdlibc++ headers not found; pass
>> '-std=libc++' on the command line to use the libc++ standard library instead
>>
>> +// CHECK: include path for stdlibc++ headers not found; pass
>> '-stdlib=libc++' on the command line to use the libc++ standard library
>> instead
>>
>> // expected-no-diagnostics
>>
>>
>>
>>
>>
>> ___
>>
>> cfe-commits mailing list
>>
>> cfe-commits@lists.llvm.org
>>
>>
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=Q8IVygsR4GuCJTOTCl7xRLj0JSxkuoS-q2HhesuNe4U&e=
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-17 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul updated this revision to Diff 174526.
sthibaul edited the summary of this revision.

Repository:
  rC Clang

https://reviews.llvm.org/D54379

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Hurd.cpp
  lib/Driver/ToolChains/Hurd.h
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/Inputs/basic_hurd_tree/include/.keep
  test/Driver/Inputs/basic_hurd_tree/lib/i386-gnu/.keep
  test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/.keep
  test/Driver/Inputs/basic_hurd_tree/usr/lib/.keep
  test/Driver/hurd.c

Index: test/Driver/hurd.c
===
--- test/Driver/hurd.c
+++ test/Driver/hurd.c
@@ -0,0 +1,16 @@
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i386-pc-gnu \
+// RUN: --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning:
+// CHECK: "{{.*}}clang{{(.exe)?}}"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/i386-gnu"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "crtbegin.o"
+// CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "-L[[SYSROOT]]/usr/lib"
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -260,6 +260,7 @@
 
   switch (os) {
   case llvm::Triple::Linux:
+  case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
 llvm_unreachable("Include management is handled in the driver.");
 
@@ -412,6 +413,7 @@
 
   switch (os) {
   case llvm::Triple::Linux:
+  case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
 llvm_unreachable("Include management is handled in the driver.");
 break;
@@ -460,6 +462,7 @@
 break; // Everything else continues to use this routine's logic.
 
   case llvm::Triple::Linux:
+  case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
 return;
 
Index: lib/Driver/ToolChains/Hurd.h
===
--- lib/Driver/ToolChains/Hurd.h
+++ lib/Driver/ToolChains/Hurd.h
@@ -0,0 +1,46 @@
+//===--- Hurd.h - Hurd ToolChain Implementations --*- 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_LIB_DRIVER_TOOLCHAINS_Hurd_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H
+
+#include "Gnu.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF {
+public:
+  Hurd(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+
+  bool HasNativeLLVMSupport() const override;
+
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+
+  virtual std::string computeSysRoot() const;
+
+  virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const;
+
+  std::vector ExtraOpts;
+
+protected:
+  Tool *buildAssembler() const override;
+  Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H
Index: lib/Driver/ToolChains/Hurd.cpp
===
--- lib/Driver/ToolChains/Hurd.cpp
+++ lib/Driver/ToolChains/Hurd.cpp
@@ -0,0 +1,172 @@
+//===--- Hurd.cpp - Hurd ToolChain Implementations *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Hurd.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang;
+using namespace llvm::opt;
+
+using tools::addPathIfExists;
+
+/// Get our best guess at the multiarch triple for a target.
+///
+/// Debian-based systems are starting to use a multiarch setup where they use
+/// a target-triple direc

[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-17 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul marked 5 inline comments as done.
sthibaul added a comment.

I believe this version handles all the comments.
I could run this with check-all on a linux-amd64 box.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


Re: r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

2018-11-17 Thread Richard Smith via cfe-commits
Procedurally, we shouldn't be making other changes at the same time as a
backport, but I'd sure like to see "stdlibc++" replaced with the correct
"libstdc++" (on trunk and branch).

On Sat, 17 Nov 2018, 19:00 Arthur O'Dwyer via cfe-commits <
cfe-commits@lists.llvm.org wrote:

> Peanut gallery says: I think the one remaining instance of `-std=libc++`
> in the tests should be fixed at the same time.
>
> –Arthur
>
> On Sat, Nov 17, 2018 at 9:52 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Good idea, this LG for a patch release.
>>
>> On Sat, 17 Nov 2018, 18:48 Shoaib Meenai via cfe-commits <
>> cfe-commits@lists.llvm.org wrote:
>>
>>> Could we merge this into 7.0.1? It's a trivial typo fix, and the error
>>> message could otherwise be confusing to users (someone brought this up in
>>> IRC a few hours ago).
>>>
>>>
>>>
>>> *From: *cfe-commits  on behalf of
>>> Alex Lorenz via cfe-commits 
>>> *Reply-To: *Alex Lorenz 
>>> *Date: *Friday, September 7, 2018 at 12:01 PM
>>> *To: *"cfe-commits@lists.llvm.org" 
>>> *Subject: *r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++'
>>> instead of '-std'
>>>
>>>
>>>
>>> Author: arphaman
>>>
>>> Date: Fri Sep  7 11:59:45 2018
>>>
>>> New Revision: 341697
>>>
>>>
>>>
>>> URL:
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D341697-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=MYePhuYEkBYd5aK7fqamBrBRJJGtvC-BPPojLInHah8&e=
>>>
>>> Log:
>>>
>>> warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'
>>>
>>>
>>>
>>> Addresses first post-commit feedback for r335081 from Nico
>>>
>>>
>>>
>>> Modified:
>>>
>>> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>>>
>>> cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>>>
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
>>>
>>> URL:
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_DiagnosticFrontendKinds.td-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=ZQcIenU2yQH3SmDrAhdXm2VKI10aP3_5IoBH-72HxYA&e=
>>>
>>>
>>> ==
>>>
>>> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
>>>
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep  7
>>> 11:59:45 2018
>>>
>>> @@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa
>>>
>>>"OpenCL version %0 does not support the option '%1'">,
>>> InGroup;
>>>
>>> def warn_stdlibcxx_not_found : Warning<
>>>
>>> -  "include path for stdlibc++ headers not found; pass '-std=libc++' on
>>> the "
>>>
>>> +  "include path for stdlibc++ headers not found; pass '-stdlib=libc++'
>>> on the "
>>>
>>>"command line to use the libc++ standard library instead">,
>>>
>>>InGroup>;
>>>
>>> }
>>>
>>>
>>>
>>> Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
>>>
>>> URL:
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_Frontend_warning-2Dstdlibcxx-2Ddarwin.cpp-3Frev-3D341697-26r1-3D341696-26r2-3D341697-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=YR_ENMKZ9M1ESvYMVXN6PlRtSZ8bXMsfvYf8QaBm5X4&e=
>>>
>>>
>>> ==
>>>
>>> --- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
>>>
>>> +++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep  7
>>> 11:59:45 2018
>>>
>>> @@ -1,5 +1,5 @@
>>>
>>> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot
>>> %S/doesnotexist %s 2>&1 | FileCheck %s
>>>
>>> // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot
>>> %S/doesnotexist -stdlib=libc++ %s -verify
>>>
>>> -// CHECK: include path for stdlibc++ headers not found; pass
>>> '-std=libc++' on the command line to use the libc++ standard library instead
>>>
>>> +// CHECK: include path for stdlibc++ headers not found; pass
>>> '-stdlib=libc++' on the command line to use the libc++ standard library
>>> instead
>>>
>>> // expected-no-diagnostics
>>>
>>>
>>>
>>>
>>>
>>> ___
>>>
>>> cfe-commits mailing list
>>>
>>> cfe-commits@lists.llvm.org
>>>
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=IqJdIRn5MxFdIr2LEpZYhRLQTay50tZijNg6klhhdRA&s=Q8IVygsR4GuCJTOTCl7xRLj0JSxkuoS-q2HhesuNe4U&e=
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>