Re: [PATCH] D22384: [OpenMP] add check for both simdlen and safelen clauses specified

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275529: [OpenMP] add check for both simdlen and safelen 
clauses specified (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D22384?vs=64048=64087#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22384

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
  cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
  cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c

Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -5426,26 +5426,44 @@
   return nullptr;
 }
 
-static bool checkSimdlenSafelenValues(Sema , const Expr *Simdlen,
-  const Expr *Safelen) {
-  llvm::APSInt SimdlenRes, SafelenRes;
-  if (Simdlen->isValueDependent() || Simdlen->isTypeDependent() ||
-  Simdlen->isInstantiationDependent() ||
-  Simdlen->containsUnexpandedParameterPack())
-return false;
-  if (Safelen->isValueDependent() || Safelen->isTypeDependent() ||
-  Safelen->isInstantiationDependent() ||
-  Safelen->containsUnexpandedParameterPack())
-return false;
-  Simdlen->EvaluateAsInt(SimdlenRes, S.Context);
-  Safelen->EvaluateAsInt(SafelenRes, S.Context);
-  // OpenMP 4.1 [2.8.1, simd Construct, Restrictions]
-  // If both simdlen and safelen clauses are specified, the value of the simdlen
-  // parameter must be less than or equal to the value of the safelen parameter.
-  if (SimdlenRes > SafelenRes) {
-S.Diag(Simdlen->getExprLoc(), diag::err_omp_wrong_simdlen_safelen_values)
-<< Simdlen->getSourceRange() << Safelen->getSourceRange();
-return true;
+static bool checkSimdlenSafelenSpecified(Sema ,
+ const ArrayRef Clauses) {
+  OMPSafelenClause *Safelen = nullptr;
+  OMPSimdlenClause *Simdlen = nullptr;
+
+  for (auto *Clause : Clauses) {
+if (Clause->getClauseKind() == OMPC_safelen)
+  Safelen = cast(Clause);
+else if (Clause->getClauseKind() == OMPC_simdlen)
+  Simdlen = cast(Clause);
+if (Safelen && Simdlen)
+  break;
+  }
+
+  if (Simdlen && Safelen) {
+llvm::APSInt SimdlenRes, SafelenRes;
+auto SimdlenLength = Simdlen->getSimdlen();
+auto SafelenLength = Safelen->getSafelen();
+if (SimdlenLength->isValueDependent() || SimdlenLength->isTypeDependent() ||
+SimdlenLength->isInstantiationDependent() ||
+SimdlenLength->containsUnexpandedParameterPack())
+  return false;
+if (SafelenLength->isValueDependent() || SafelenLength->isTypeDependent() ||
+SafelenLength->isInstantiationDependent() ||
+SafelenLength->containsUnexpandedParameterPack())
+  return false;
+SimdlenLength->EvaluateAsInt(SimdlenRes, S.Context);
+SafelenLength->EvaluateAsInt(SafelenRes, S.Context);
+// OpenMP 4.5 [2.8.1, simd Construct, Restrictions]
+// If both simdlen and safelen clauses are specified, the value of the
+// simdlen parameter must be less than or equal to the value of the safelen
+// parameter.
+if (SimdlenRes > SafelenRes) {
+  S.Diag(SimdlenLength->getExprLoc(),
+ diag::err_omp_wrong_simdlen_safelen_values)
+  << SimdlenLength->getSourceRange() << SafelenLength->getSourceRange();
+  return true;
+}
   }
   return false;
 }
@@ -5481,22 +5499,7 @@
 }
   }
 
-  // OpenMP 4.1 [2.8.1, simd Construct, Restrictions]
-  // If both simdlen and safelen clauses are specified, the value of the simdlen
-  // parameter must be less than or equal to the value of the safelen parameter.
-  OMPSafelenClause *Safelen = nullptr;
-  OMPSimdlenClause *Simdlen = nullptr;
-  for (auto *Clause : Clauses) {
-if (Clause->getClauseKind() == OMPC_safelen)
-  Safelen = cast(Clause);
-else if (Clause->getClauseKind() == OMPC_simdlen)
-  Simdlen = cast(Clause);
-if (Safelen && Simdlen)
-  break;
-  }
-  if (Simdlen && Safelen &&
-  checkSimdlenSafelenValues(*this, Simdlen->getSimdlen(),
-Safelen->getSafelen()))
+  if (checkSimdlenSafelenSpecified(*this, Clauses))
 return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
@@ -5572,22 +5575,7 @@
 }
   }
 
-  // OpenMP 4.1 [2.8.1, simd Construct, Restrictions]
-  // If both simdlen and safelen clauses are specified, the value of the simdlen
-  // parameter must be less than or equal to the value of the safelen parameter.
-  OMPSafelenClause *Safelen = nullptr;
-  OMPSimdlenClause *Simdlen = nullptr;
-  for (auto *Clause : Clauses) {
-if (Clause->getClauseKind() == OMPC_safelen)
-  Safelen = cast(Clause);
-else if (Clause->getClauseKind() == OMPC_simdlen)
-  Simdlen = cast(Clause);
-if (Safelen && Simdlen)
-  break;
-  }
-  if (Simdlen && Safelen &&
-   

Re: [PATCH] D22248: [Sema] Create a separate group for incompatible function pointer warning

2016-07-14 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D22248



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


Re: [PATCH] D18639: Use __builtin_isnan/isinf/isfinite in complex

2016-07-14 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

Ping.


https://reviews.llvm.org/D18639



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


Re: [PATCH] D22392: [Sema] Fix an invalid nullability warning for binary conditional operators

2016-07-14 Thread Doug Gregor via cfe-commits
doug.gregor added a comment.

A bunch of comments above. This needs much more extensive testing, because 
there are numerous paths through the ternary operator code and the results need 
to be symmetric.



Comment at: lib/Sema/SemaExpr.cpp:7007
@@ +7006,3 @@
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext ) {

This name could be improved. You're not really 'modifying' nullability here; in 
the general case, you're computing the appropriate nullability given the LHS, 
RHS, and applying that to the result type.


Comment at: lib/Sema/SemaExpr.cpp:7024
@@ +7023,3 @@
+
+  NullabilityKind NewKind = GetNullability(RHSExpr->getType());
+

I'm fairly certain that more extensive testing will show that you need to have 
the LHSExpr as well, to look at the nullability of both.


Comment at: lib/Sema/SemaExpr.cpp:7030
@@ +7029,3 @@
+  // Create a new AttributedType with the new nullability kind.
+  QualType NewTy = ResTy.getDesugaredType(Ctx);
+  auto NewAttr = AttributedType::getNullabilityAttrKind(NewKind);

 It would be better to only unwrap sugar until we hit the 
nullability-attributed type, then replace it.


Comment at: test/Sema/nullability.c:137
@@ +136,3 @@
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}

You really need much more testing coverage here, e.g., for ternary operators 
where the types on the second and third arguments are different types (say, 
superclass/subclass pointer), the nullability is on either argument, etc. The 
ternary operator, especially in C++, has a ton of different cases that you need 
to look at.


https://reviews.llvm.org/D22392



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


Re: [PATCH] D21954: [PM] Add some internal options for testing out the new PM.

2016-07-14 Thread Chandler Carruth via cfe-commits
chandlerc added a comment.

I'd like someone more active on the Clang side to comment about this, but here 
is my 2 cents...

It seems like it'd be nice to not populate or run or otherwise build up the 
legacy pass managers when using this option. I guess I would expect something 
to more split early between the two pipelines, and then merge back before doing 
codegen.

I'm also somewhat hesitant with the '-middle-end-...' naming, but not sure what 
would work better. We don't have anything even comparable with the legacy PM, 
so maybe just "-llvm-custom-passes" or something similar?


https://reviews.llvm.org/D21954



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


Re: [PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-14 Thread Doug Gregor via cfe-commits
doug.gregor added a comment.

I think this check should go into SemaChecking.cpp


https://reviews.llvm.org/D22391



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


Re: [PATCH] D22096: [OpenMP] Sema and parsing for 'target parallel for simd' pragma

2016-07-14 Thread Alexey Bataev via cfe-commits
Hi Paul,
Could you provide a little bit more info about diagnostic you see? Maybe 
the tests just need to be fixed

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

15.07.2016 2:09, Paul Robinson пишет:
> probinson added a subscriber: probinson.
> probinson added a comment.
>
> I'm seeing a different set of diagnostics in two of these tests, because we 
> default to C+11, which makes them fail for us.  Ideally you'd conditionalize 
> the tests on the value of `__cplusplus` (like Charles Li has been doing for a 
> whole lot of the Clang tests).  If that's inconvenient for you right now, 
> would you mind if I added `-std=c++03` to the following tests?  It's just 
> these two that need it:
>
> target_parallel_for_simd_collapse_messages.cpp
> target_parallel_for_simd_ordered_messages.cpp
>
>
> Repository:
>rL LLVM
>
> https://reviews.llvm.org/D22096
>
>
>

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


Re: [PATCH] D22384: [OpenMP] add check for both simdlen and safelen clauses specified

2016-07-14 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22384



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


Re: [PATCH] D22392: [Sema] Fix an invalid nullability warning for binary conditional operators

2016-07-14 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 64077.
ahatanak added a comment.

Remove unused variable.


https://reviews.llvm.org/D22392

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/nullability.c

Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -128,3 +128,11 @@
 
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nonnull'}}
 }
+
+// Check nullability of binary conditional expressions.
+void modify_nullability(int c) {
+  int * _Nullable p0;
+  int * _Nonnull p1;
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7002,6 +7002,36 @@
 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
 }
 
+/// Modify the nullability kind of the result type of a binary conditional
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext ) {
+  if (!ResTy->isPointerType())
+return ResTy;
+
+  auto GetNullability = [](QualType Ty) {
+Optional Kind = Ty->getNullability(Ctx);
+if (Kind)
+  return *Kind;
+return NullabilityKind::Unspecified;
+  };
+
+  // Change the result type only if the conditional expression is nullable and
+  // the RHS is nonnull.
+  if (GetNullability(ResTy) != NullabilityKind::Nullable)
+return ResTy;
+
+  NullabilityKind NewKind = GetNullability(RHSExpr->getType());
+
+  if (NewKind != NullabilityKind::NonNull)
+return ResTy;
+
+  // Create a new AttributedType with the new nullability kind.
+  QualType NewTy = ResTy.getDesugaredType(Ctx);
+  auto NewAttr = AttributedType::getNullabilityAttrKind(NewKind);
+  return Ctx.getAttributedType(NewAttr, NewTy, NewTy);
+}
+
 /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
 ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
@@ -7088,6 +7118,7 @@
 ConditionalOperator(Cond.get(), QuestionLoc, LHS.get(), ColonLoc,
 RHS.get(), result, VK, OK);
 
+  result = modifyNullability(result, RHSExpr, Context);
   return new (Context) BinaryConditionalOperator(
   commonExpr, opaqueValue, Cond.get(), LHS.get(), RHS.get(), QuestionLoc,
   ColonLoc, result, VK, OK);


Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -128,3 +128,11 @@
 
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
 }
+
+// Check nullability of binary conditional expressions.
+void modify_nullability(int c) {
+  int * _Nullable p0;
+  int * _Nonnull p1;
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7002,6 +7002,36 @@
 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
 }
 
+/// Modify the nullability kind of the result type of a binary conditional
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext ) {
+  if (!ResTy->isPointerType())
+return ResTy;
+
+  auto GetNullability = [](QualType Ty) {
+Optional Kind = Ty->getNullability(Ctx);
+if (Kind)
+  return *Kind;
+return NullabilityKind::Unspecified;
+  };
+
+  // Change the result type only if the conditional expression is nullable and
+  // the RHS is nonnull.
+  if (GetNullability(ResTy) != NullabilityKind::Nullable)
+return ResTy;
+
+  NullabilityKind NewKind = GetNullability(RHSExpr->getType());
+
+  if (NewKind != NullabilityKind::NonNull)
+return ResTy;
+
+  // Create a new AttributedType with the new nullability kind.
+  QualType NewTy = ResTy.getDesugaredType(Ctx);
+  auto NewAttr = AttributedType::getNullabilityAttrKind(NewKind);
+  return Ctx.getAttributedType(NewAttr, NewTy, NewTy);
+}
+
 /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
 ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
@@ -7088,6 +7118,7 @@
 ConditionalOperator(Cond.get(), QuestionLoc, LHS.get(), ColonLoc,
 RHS.get(), result, VK, OK);
 
+  result = modifyNullability(result, RHSExpr, Context);
   return new (Context) BinaryConditionalOperator(
   commonExpr, opaqueValue, Cond.get(), LHS.get(), RHS.get(), QuestionLoc,
   ColonLoc, result, VK, OK);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D21954: [PM] Add some internal options for testing out the new PM.

2016-07-14 Thread Sean Silva via cfe-commits
silvas added a comment.

Ping.


https://reviews.llvm.org/D21954



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


[PATCH] D22392: [Sema] Fix an invalid nullability warning for binary conditional operators

2016-07-14 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: doug.gregor.
ahatanak added a subscriber: cfe-commits.

Currently clang issues a warning when the following code using a shorthand form 
of the conditional operator is compiled:

$ cat test1.c
```
void foo() {
  int * _Nullable p0;
  int * _Nonnull p1;
  int * _Nonnull p2 = p0 ?: p1;
}
```
test.c:4:23: warning: implicit conversion from nullable pointer 'int * 
_Nullable' to non-nullable pointer
  type 'int * _Nonnull' [-Wnullable-to-nonnull-conversion]
  int * _Nonnull p2 = p0 ?: p1; 

This happens because sema uses the type of the first operand (p0's type, which 
is "int * _Nullable") for the type of the binary condition expression and then 
complains because a nullable pointer is being assigned to a nonnull pointer. 
The warning is not valid since the expression "p0 ?: p1" cannot be null if p1 
is nonnull.

This patch fixes the bug by propagating the nullability of the last operand to 
the binary conditional expression.

https://reviews.llvm.org/D22392

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/nullability.c

Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -128,3 +128,11 @@
 
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nonnull'}}
 }
+
+// Check nullability of binary conditional expressions.
+void modify_nullability(int c) {
+  int * _Nullable p0;
+  int * _Nonnull p1;
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7002,6 +7002,38 @@
 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
 }
 
+/// Modify the nullability kind of the result type of a binary conditional
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext ) {
+  if (!ResTy->isPointerType())
+return ResTy;
+
+  auto GetNullability = [](QualType Ty) {
+Optional Kind = Ty->getNullability(Ctx);
+if (Kind)
+  return *Kind;
+return NullabilityKind::Unspecified;
+  };
+
+  // Change the result type only if the conditional expression is nullable and
+  // the RHS is nonnull.
+  NullabilityKind ResKind = GetNullability(ResTy);
+
+  if (GetNullability(ResTy) != NullabilityKind::Nullable)
+return ResTy;
+
+  NullabilityKind NewKind = GetNullability(RHSExpr->getType());
+
+  if (NewKind != NullabilityKind::NonNull)
+return ResTy;
+
+  // Create a new AttributedType with the new nullability kind.
+  QualType NewTy = ResTy.getDesugaredType(Ctx);
+  auto NewAttr = AttributedType::getNullabilityAttrKind(NewKind);
+  return Ctx.getAttributedType(NewAttr, NewTy, NewTy);
+}
+
 /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
 ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
@@ -7088,6 +7120,7 @@
 ConditionalOperator(Cond.get(), QuestionLoc, LHS.get(), ColonLoc,
 RHS.get(), result, VK, OK);
 
+  result = modifyNullability(result, RHSExpr, Context);
   return new (Context) BinaryConditionalOperator(
   commonExpr, opaqueValue, Cond.get(), LHS.get(), RHS.get(), QuestionLoc,
   ColonLoc, result, VK, OK);


Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -128,3 +128,11 @@
 
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
 }
+
+// Check nullability of binary conditional expressions.
+void modify_nullability(int c) {
+  int * _Nullable p0;
+  int * _Nonnull p1;
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7002,6 +7002,38 @@
 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
 }
 
+/// Modify the nullability kind of the result type of a binary conditional
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext ) {
+  if (!ResTy->isPointerType())
+return ResTy;
+
+  auto GetNullability = [](QualType Ty) {
+Optional Kind = Ty->getNullability(Ctx);
+if (Kind)
+  return *Kind;
+return NullabilityKind::Unspecified;
+  };
+
+  // Change the result type only if the conditional expression is nullable and
+  // the RHS is nonnull.
+  NullabilityKind ResKind = GetNullability(ResTy);
+
+  if (GetNullability(ResTy) != NullabilityKind::Nullable)
+return ResTy;
+
+  NullabilityKind NewKind = 

Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-14 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D19544#484439, @spatel wrote:

> Hi Matt -
>
> This looks like the right first step in the path that Hal suggested, except I 
> think we need a test case for each function that you want to enable. Please 
> see test/Transforms/LoopVectorize/X86/veclib-calls.ll as a reference for how 
> to do that.


Agreed. Once this has regression tests it should be good to go. Thanks for 
continuing to work on this!


https://reviews.llvm.org/D19544



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


Re: [PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

2016-07-14 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275507: Frontend: Simplify ownership model for clang's 
output streams. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D21537?vs=61317=64071#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21537

Files:
  cfe/trunk/include/clang/CodeGen/BackendUtil.h
  cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
  cfe/trunk/include/clang/Frontend/ASTConsumers.h
  cfe/trunk/include/clang/Frontend/CompilerInstance.h
  cfe/trunk/include/clang/Frontend/FrontendActions.h
  cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
  cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  cfe/trunk/lib/Frontend/ASTConsumers.cpp
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Frontend/CompilerInstance.cpp
  cfe/trunk/lib/Frontend/FrontendActions.cpp
  cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
  cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
  cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/tools/clang-check/ClangCheck.cpp

Index: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -71,7 +71,7 @@
 Stmt *CurrentBody;
 ParentMap *PropParentMap; // created lazily.
 std::string InFileName;
-raw_ostream* OutFile;
+std::unique_ptr OutFile;
 std::string Preamble;
 
 TypeDecl *ProtocolTypeDecl;
@@ -190,7 +190,7 @@
 
 void HandleTopLevelSingleDecl(Decl *D);
 void HandleDeclInMainFile(Decl *D);
-RewriteObjC(std::string inFile, raw_ostream *OS,
+RewriteObjC(std::string inFile, std::unique_ptr OS,
 DiagnosticsEngine , const LangOptions ,
 bool silenceMacroWarn);
 
@@ -506,11 +506,10 @@
   
   class RewriteObjCFragileABI : public RewriteObjC {
   public:
-RewriteObjCFragileABI(std::string inFile, raw_ostream *OS,
-DiagnosticsEngine , const LangOptions ,
-bool silenceMacroWarn) : RewriteObjC(inFile, OS,
- D, LOpts,
- silenceMacroWarn) {}
+RewriteObjCFragileABI(std::string inFile, std::unique_ptr OS,
+  DiagnosticsEngine , const LangOptions ,
+  bool silenceMacroWarn)
+: RewriteObjC(inFile, std::move(OS), D, LOpts, silenceMacroWarn) {}
 
 ~RewriteObjCFragileABI() override {}
 void Initialize(ASTContext ) override;
@@ -575,11 +574,11 @@
   return Ext == "h" || Ext == "hh" || Ext == "H";
 }
 
-RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS,
+RewriteObjC::RewriteObjC(std::string inFile, std::unique_ptr OS,
  DiagnosticsEngine , const LangOptions ,
  bool silenceMacroWarn)
-  : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
-SilenceRewriteMacroWarning(silenceMacroWarn) {
+: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)),
+  SilenceRewriteMacroWarning(silenceMacroWarn) {
   IsHeader = IsHeaderFile(inFile);
   RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting sub-expression within a macro (may not be correct)");
@@ -590,11 +589,12 @@
 }
 
 std::unique_ptr
-clang::CreateObjCRewriter(const std::string , raw_ostream *OS,
+clang::CreateObjCRewriter(const std::string ,
+  std::unique_ptr OS,
   DiagnosticsEngine , const LangOptions ,
   bool SilenceRewriteMacroWarning) {
-  return llvm::make_unique(InFile, OS, Diags, LOpts,
-  SilenceRewriteMacroWarning);
+  return llvm::make_unique(
+  InFile, std::move(OS), Diags, LOpts, SilenceRewriteMacroWarning);
 }
 
 void RewriteObjC::InitializeCommon(ASTContext ) {
Index: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -72,7 +72,7 @@
 Stmt *CurrentBody;
 ParentMap *PropParentMap; // created lazily.
 std::string InFileName;
-raw_ostream* OutFile;
+std::unique_ptr OutFile;
 std::string Preamble;
 
 TypeDecl *ProtocolTypeDecl;
@@ -239,9 +239,9 @@
 
 void HandleTopLevelSingleDecl(Decl *D);
 void HandleDeclInMainFile(Decl *D);
-RewriteModernObjC(std::string inFile, raw_ostream *OS,
-DiagnosticsEngine , const LangOptions ,
-

r275507 - Frontend: Simplify ownership model for clang's output streams.

2016-07-14 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Jul 14 19:55:40 2016
New Revision: 275507

URL: http://llvm.org/viewvc/llvm-project?rev=275507=rev
Log:
Frontend: Simplify ownership model for clang's output streams.

This changes the CompilerInstance::createOutputFile function to return
a std::unique_ptr, rather than an llvm::raw_ostream
implicitly owned by the CompilerInstance. This in most cases required that
I move ownership of the output stream to the relevant ASTConsumer.

The motivation for this change is to allow BackendConsumer to be a client
of interfaces such as D20268 which take ownership of the output stream.

Differential Revision: http://reviews.llvm.org/D21537

Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
cfe/trunk/include/clang/Frontend/ASTConsumers.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/tools/clang-check/ClangCheck.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=275507=275506=275507=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jul 14 19:55:40 2016
@@ -37,7 +37,8 @@ namespace clang {
   void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions 
,
  const TargetOptions , const LangOptions ,
  const llvm::DataLayout , llvm::Module *M,
- BackendAction Action, raw_pwrite_stream *OS);
+ BackendAction Action,
+ std::unique_ptr OS);
 
   void EmbedBitcode(llvm::Module *M, const CodeGenOptions ,
 llvm::MemoryBufferRef Buf);

Modified: cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h?rev=275507=275506=275507=diff
==
--- cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h 
(original)
+++ cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h Thu Jul 
14 19:55:40 2016
@@ -22,10 +22,12 @@ class ObjectFilePCHContainerWriter : pub
   /// Return an ASTConsumer that can be chained with a
   /// PCHGenerator that produces a wrapper file format
   /// that also contains full debug info for the module.
-  std::unique_ptr CreatePCHContainerGenerator(
-  CompilerInstance , const std::string ,
-  const std::string , llvm::raw_pwrite_stream *OS,
-  std::shared_ptr Buffer) const override;
+  std::unique_ptr
+  CreatePCHContainerGenerator(CompilerInstance ,
+  const std::string ,
+  const std::string ,
+  std::unique_ptr OS,
+  std::shared_ptr Buffer) const 
override;
 };
 
 /// A PCHContainerReader implementation that uses LLVM to

Modified: cfe/trunk/include/clang/Frontend/ASTConsumers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTConsumers.h?rev=275507=275506=275507=diff
==
--- cfe/trunk/include/clang/Frontend/ASTConsumers.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTConsumers.h Thu Jul 14 19:55:40 2016
@@ -31,7 +31,7 @@ class TargetOptions;
 // original C code.  The output is intended to be in a format such that
 // clang could re-parse the output back into the same AST, but the
 // implementation is still incomplete.
-std::unique_ptr CreateASTPrinter(raw_ostream *OS,
+std::unique_ptr CreateASTPrinter(std::unique_ptr OS,
   StringRef FilterString);
 
 // AST dumper: dumps the raw AST in human-readable form to stderr; this is

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=275507=275506=275507=diff

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-14 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: doug.gregor.
ahatanak added a subscriber: cfe-commits.

This patch makes clang issue a warning when a null constant is used in a 
context where a non null expression is expected. For example:

```
int * _Nonnull p0 = 0; // warning expected here
int * _Nonnull p1;
int * _Nonnull p2 = c ? p1 : 0; // warning expected here
```

A new function Sema::diagnoseNullPtrToNonnullCast is defined, which checks 
whether a null pointer constant is being cast to a _Nonnull pointer type, and 
called before ImplicitCastExprs are created.

rdar://problem/24724255
rdar://problem/22074116



https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/nullability.c
  test/SemaCXX/nullability.cpp

Index: test/SemaCXX/nullability.cpp
===
--- test/SemaCXX/nullability.cpp
+++ test/SemaCXX/nullability.cpp
@@ -54,16 +54,16 @@
 void (_nonnull_5)(_Nonnull int *ptr) = accepts_nonnull_4;
 
 void test_accepts_nonnull_null_pointer_literal(X *x) {
-  accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  (x->*accepts_nonnull_3)(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  accepts_nonnull_4(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  accepts_nonnull_5(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
+  accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  (x->*accepts_nonnull_3)(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  accepts_nonnull_4(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  accepts_nonnull_5(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
 }
 
 template 
 void test_accepts_nonnull_null_pointer_literal_template() {
-  FP(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
+  FP(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
 }
 
 template void test_accepts_nonnull_null_pointer_literal_template<_nonnull_4>(); // expected-note{{instantiation of function template specialization}}
Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -106,15 +106,15 @@
 void (^accepts_nonnull_3)(_Nonnull int *ptr);
 
 void test_accepts_nonnull_null_pointer_literal() {
-  accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
-  accepts_nonnull_3(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
+  accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull}}
+  accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull}}
+  accepts_nonnull_3(0); // expected-warning{{null passed to a callee that requires a non-null argument}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull}}
 }
 
 // Check returning nil from a _Nonnull-returning function.
 _Nonnull int *returns_int_ptr(int x) {
   if (x) {
-return 0; // expected-warning{{null returned from function that requires a non-null return value}}
+return 0; // expected-warning{{null returned from function that requires a non-null return value}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull}}
   }
 
   return (_Nonnull int *)0;
@@ -128,3 +128,9 @@
 
   accepts_nonnull_1(ptr); // 

[libcxxabi] r275505 - libc++abi: add a top level option for using CompilerRT

2016-07-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jul 14 19:49:42 2016
New Revision: 275505

URL: http://llvm.org/viewvc/llvm-project?rev=275505=rev
Log:
libc++abi: add a top level option for using CompilerRT

Add an option to opt into compiler-rt instead of libgcc.  This option defaults
to OFF to avoid a behaviour change.  It is not possible to mix and match
different runtime libraries.  Disabling this requires that libc++ is built
accordingly.  This knob is particularly useful for targets that are GCC by
default (i.e. Linux).

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/cmake/config-ix.cmake

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=275505=275504=275505=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Jul 14 19:49:42 2016
@@ -113,6 +113,7 @@ option(LIBCXXABI_ENABLE_ASSERTIONS "Enab
 option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
+option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
 option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS})
@@ -243,6 +244,9 @@ if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
   string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 endif()
 
+if (LIBCXXABI_USE_COMPILER_RT)
+  list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt")
+endif ()
 
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WERROR_FLAG 
-Werror=return-type)
 

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=275505=275504=275505=diff
==
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Thu Jul 14 19:49:42 2016
@@ -42,6 +42,8 @@ check_cxx_compiler_flag(/GR-
 check_library_exists(c fopen "" LIBCXXABI_HAS_C_LIB)
 check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB)
 check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
+if (NOT LIBCXXABI_USE_COMPILER_RT)
+  check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
+endif ()
 check_library_exists(c __cxa_thread_atexit_impl ""
   LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)


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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Richard Smith via cfe-commits
OK, actually, GCC is doing something a lot more clever here.

Here's what seems to really be going on:

Packed members are modeled somewhat like bitfield members: a packed member
lvalue is a different kind of lvalue to which a reference cannot be bound
(like a bitfield). An attempt to bind a const / rvalue reference to such a
member will create a temporary, copy the packed / bitfield member to the
temporary, and then bind the reference to the temporary.

If we want to follow GCC here (and I think we do -- this seems like a very
sensible model), we should handle this case as an ObjectKind and generally
apply the same semantic rules that we use for bitfields.

On Thu, Jul 14, 2016 at 5:18 PM, Richard Smith 
wrote:

> It appears that GCC accepts that case. More generally, it looks like GCC
> suppresses the warning when the reference is a function parameter (any
> function, not just a copy constructor or similar). I'm not sure if that's
> an intentional feature or a bug, but it should be pretty easy for us to be
> compatible with, at least...
>
> On Thu, Jul 14, 2016 at 5:03 PM, Reid Kleckner  wrote:
>
>> I wonder if GCC accepts this:
>>
>> In file included from ../../net/tools/quic/quic_epoll_clock_test.cc:7:
>> In file included from
>> ../../net/tools/quic/test_tools/mock_epoll_server.h:16:
>> In file included from ../../net/tools/epoll_server/epoll_server.h:41:
>> ../../build/linux/debian_wheezy_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/epoll.h:89:8:
>> error: binding reference to packed member 'data' of class or structure
>> 'epoll_event'
>> struct epoll_event
>>^~~
>> ../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stl_pair.h:267:14:
>> note: in instantiation of function template specialization 'std::pair> epoll_event>::pair' requested here
>>   return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
>>  ^
>> ../../net/tools/quic/test_tools/mock_epoll_server.h:69:30: note: in
>> instantiation of function template specialization 'std::make_pair> const epoll_event &>' requested here
>> event_queue_.insert(std::make_pair(time_in_usec, ee));
>>
>> On Thu, Jul 14, 2016 at 4:54 PM, Richard Smith 
>> wrote:
>>
>>> On Thu, Jul 14, 2016 at 3:52 PM, Reid Kleckner via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Why did we upgrade the unaligned reference binding from a warning to an
 error? That will make it hard to roll this change out across many 
 codebases.

>>>
>>> GCC has given an error on this since version 4.7. If there are cases
>>> that GCC accepts and we reject, that sounds like a bug.
>>>
>>>
 On Thu, Jul 14, 2016 at 7:10 AM, Roger Ferrer Ibanez via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: rogfer01
> Date: Thu Jul 14 09:10:43 2016
> New Revision: 275417
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
> Log:
> Diagnose taking address and reference binding of packed members
>
> This patch implements PR#22821.
>
> Taking the address of a packed member is dangerous since the reduced
> alignment of the pointee is lost. This can lead to memory alignment
> faults in some architectures if the pointer value is dereferenced.
>
> This change adds a new warning to clang emitted when taking the address
> of a packed member. A packed member is either a field/data member
> declared as attribute((packed)) or belonging to a struct/class
> declared as such. The associated flag is -Waddress-of-packed-member.
> Conversions (either implicit or via a valid casting) to pointer types
> with lower or equal alignment requirements (e.g. void* or char*)
> silence the warning.
>
> This change also adds a new error diagnostic when the user attempts to
> bind a reference to a packed member, regardless of the alignment.
>
> Differential Revision: https://reviews.llvm.org/D20561
>
>
>
> Added:
> cfe/trunk/test/Sema/address-packed-member-memops.c
> cfe/trunk/test/Sema/address-packed.c
> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
> cfe/trunk/test/SemaCXX/address-packed.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>
> ==
> --- 

Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Richard Smith via cfe-commits
It appears that GCC accepts that case. More generally, it looks like GCC
suppresses the warning when the reference is a function parameter (any
function, not just a copy constructor or similar). I'm not sure if that's
an intentional feature or a bug, but it should be pretty easy for us to be
compatible with, at least...

On Thu, Jul 14, 2016 at 5:03 PM, Reid Kleckner  wrote:

> I wonder if GCC accepts this:
>
> In file included from ../../net/tools/quic/quic_epoll_clock_test.cc:7:
> In file included from
> ../../net/tools/quic/test_tools/mock_epoll_server.h:16:
> In file included from ../../net/tools/epoll_server/epoll_server.h:41:
> ../../build/linux/debian_wheezy_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/epoll.h:89:8:
> error: binding reference to packed member 'data' of class or structure
> 'epoll_event'
> struct epoll_event
>^~~
> ../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stl_pair.h:267:14:
> note: in instantiation of function template specialization 'std::pair epoll_event>::pair' requested here
>   return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
>  ^
> ../../net/tools/quic/test_tools/mock_epoll_server.h:69:30: note: in
> instantiation of function template specialization 'std::make_pair const epoll_event &>' requested here
> event_queue_.insert(std::make_pair(time_in_usec, ee));
>
> On Thu, Jul 14, 2016 at 4:54 PM, Richard Smith 
> wrote:
>
>> On Thu, Jul 14, 2016 at 3:52 PM, Reid Kleckner via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Why did we upgrade the unaligned reference binding from a warning to an
>>> error? That will make it hard to roll this change out across many codebases.
>>>
>>
>> GCC has given an error on this since version 4.7. If there are cases that
>> GCC accepts and we reject, that sounds like a bug.
>>
>>
>>> On Thu, Jul 14, 2016 at 7:10 AM, Roger Ferrer Ibanez via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rogfer01
 Date: Thu Jul 14 09:10:43 2016
 New Revision: 275417

 URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
 Log:
 Diagnose taking address and reference binding of packed members

 This patch implements PR#22821.

 Taking the address of a packed member is dangerous since the reduced
 alignment of the pointee is lost. This can lead to memory alignment
 faults in some architectures if the pointer value is dereferenced.

 This change adds a new warning to clang emitted when taking the address
 of a packed member. A packed member is either a field/data member
 declared as attribute((packed)) or belonging to a struct/class
 declared as such. The associated flag is -Waddress-of-packed-member.
 Conversions (either implicit or via a valid casting) to pointer types
 with lower or equal alignment requirements (e.g. void* or char*)
 silence the warning.

 This change also adds a new error diagnostic when the user attempts to
 bind a reference to a packed member, regardless of the alignment.

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



 Added:
 cfe/trunk/test/Sema/address-packed-member-memops.c
 cfe/trunk/test/Sema/address-packed.c
 cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
 cfe/trunk/test/SemaCXX/address-packed.cpp
 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/Sema/SemaCast.cpp
 cfe/trunk/lib/Sema/SemaChecking.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaInit.cpp

 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
 09:10:43 2016
 @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
"dereference of type %1 that was reinterpret_cast from type %0 has
 undefined "
"behavior">,
InGroup, DefaultIgnore;
 +def warn_taking_address_of_packed_member : Warning<
 +  "taking address of packed member %0 of class or structure %q1 may
 result in an unaligned pointer value">,
 +  InGroup>;
 +def err_binding_reference_to_packed_member : Error<
 +  "binding reference to packed member %0 of class or structure %q1">;

  def err_objc_object_assignment : Error<
"cannot assign to class object (%0 invalid)">;

 Modified: 

Re: [PATCH] D18510: [cxx1z-constexpr-lambda] Make conversion function constexpr

2016-07-14 Thread Richard Smith via cfe-commits
rsmith added a comment.

I don't see how this approach can work; the fact that we happened to ask the 
expression evaluator to evaluate an expression is not sufficient reason for us 
to issue this warning. For instance:

  auto a = []{};
  void (*p)() = a;

... will ask the evaluator to evaluate the initializer of `p`, which it appears 
will now generate a bogus extension warning in C++11 and C++14 mode.

If you want to carry on down this path, I think you will need to do something 
similar to what we discussed at Oulu, but I expect getting a correct warning to 
be complex and difficult, so I think the best approach would be to give up on 
this compat warning / extension, and instead only turn on the `constexpr` flag 
in C++17 mode. We could burn a lot of time getting this compatibility warning / 
extwarn to work, and it seems better to make progress on the rest of the 
constexpr lambdas feature instead :)


https://reviews.llvm.org/D18510



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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Reid Kleckner via cfe-commits
I wonder if GCC accepts this:

In file included from ../../net/tools/quic/quic_epoll_clock_test.cc:7:
In file included from
../../net/tools/quic/test_tools/mock_epoll_server.h:16:
In file included from ../../net/tools/epoll_server/epoll_server.h:41:
../../build/linux/debian_wheezy_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/epoll.h:89:8:
error: binding reference to packed member 'data' of class or structure
'epoll_event'
struct epoll_event
   ^~~
../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stl_pair.h:267:14:
note: in instantiation of function template specialization 'std::pair::pair' requested here
  return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
 ^
../../net/tools/quic/test_tools/mock_epoll_server.h:69:30: note: in
instantiation of function template specialization 'std::make_pair' requested here
event_queue_.insert(std::make_pair(time_in_usec, ee));

On Thu, Jul 14, 2016 at 4:54 PM, Richard Smith 
wrote:

> On Thu, Jul 14, 2016 at 3:52 PM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Why did we upgrade the unaligned reference binding from a warning to an
>> error? That will make it hard to roll this change out across many codebases.
>>
>
> GCC has given an error on this since version 4.7. If there are cases that
> GCC accepts and we reject, that sounds like a bug.
>
>
>> On Thu, Jul 14, 2016 at 7:10 AM, Roger Ferrer Ibanez via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rogfer01
>>> Date: Thu Jul 14 09:10:43 2016
>>> New Revision: 275417
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
>>> Log:
>>> Diagnose taking address and reference binding of packed members
>>>
>>> This patch implements PR#22821.
>>>
>>> Taking the address of a packed member is dangerous since the reduced
>>> alignment of the pointee is lost. This can lead to memory alignment
>>> faults in some architectures if the pointer value is dereferenced.
>>>
>>> This change adds a new warning to clang emitted when taking the address
>>> of a packed member. A packed member is either a field/data member
>>> declared as attribute((packed)) or belonging to a struct/class
>>> declared as such. The associated flag is -Waddress-of-packed-member.
>>> Conversions (either implicit or via a valid casting) to pointer types
>>> with lower or equal alignment requirements (e.g. void* or char*)
>>> silence the warning.
>>>
>>> This change also adds a new error diagnostic when the user attempts to
>>> bind a reference to a packed member, regardless of the alignment.
>>>
>>> Differential Revision: https://reviews.llvm.org/D20561
>>>
>>>
>>>
>>> Added:
>>> cfe/trunk/test/Sema/address-packed-member-memops.c
>>> cfe/trunk/test/Sema/address-packed.c
>>> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
>>> cfe/trunk/test/SemaCXX/address-packed.cpp
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Sema/SemaCast.cpp
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaInit.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
>>> 09:10:43 2016
>>> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>>>"dereference of type %1 that was reinterpret_cast from type %0 has
>>> undefined "
>>>"behavior">,
>>>InGroup, DefaultIgnore;
>>> +def warn_taking_address_of_packed_member : Warning<
>>> +  "taking address of packed member %0 of class or structure %q1 may
>>> result in an unaligned pointer value">,
>>> +  InGroup>;
>>> +def err_binding_reference_to_packed_member : Error<
>>> +  "binding reference to packed member %0 of class or structure %q1">;
>>>
>>>  def err_objc_object_assignment : Error<
>>>"cannot assign to class object (%0 invalid)">;
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417=275416=275417=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
>>> @@ -9518,6 +9518,10 @@ private:
>>>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>>>  const Expr * const *ExprArgs);
>>>
>>> +  /// 

Re: [PATCH] D21753: Comprehensive Static Instrumentation (2/2): Clang flag

2016-07-14 Thread Derek Bruening via cfe-commits
bruening added inline comments.


Comment at: docs/CSI.rst:30
@@ +29,3 @@
+To create a CSI tool, add ``#include `` at the top of the tool source
+and implement function bodies for the hooks relevant to the tool.
+

Are there any constraints on what libraries the tool library is allowed to use? 
 Generally there are, for tool code that runs in the same process as the 
application.  The tool library will be operating at arbitrary points during 
application execution.  This means that it should avoid using the same 
resources as the instrumented application, because the application's routines 
are not all re-entrant and they use global state, and to minimize perturbation 
of the application's behavior (such as heap layout patterns) from how it 
behaves with no tool present.  A tool using standard libraries becomes more 
likely to cause issues when libc routines are being intercepted by the tool 
(see related comment below) or libc itself is instrumented. The existing LLVM 
instrumentation runtime libraries, for the sanitizer tools, avoid calling libc 
routines and are not able to use the STL: they use their own custom 
implementations of all data structures and algorithms that they need, but this 
is a small set.  Dynamic tool platforms like Pin and DynamoRIO go to great 
lengths to isolate tool libraries by loading separate copies of libc.  Has any 
thought been put into isolating the tool library and its imports from the 
application?  I realize that some of these may seem more long-term topics, but 
if the idea is to create a framework for use with a wide range of tools it is 
good to consider all issues up front.



Comment at: docs/CSI.rst:230
@@ +229,3 @@
+
+CSI provides the following hooks for memory operations:
+

For observing loads and stores, typically compiler-based tools intercept libc's 
memcpy, memset, etc. (or in some cases libc is built and instrumented along 
with the application), to avoid missing many memory references.  The existing 
LLVM sanitizer tools all intercept a large number of libc routines to ensure 
they see more than just events happening in application code proper.  Has there 
been any thought about this for CSI?



Repository:
  rL LLVM

https://reviews.llvm.org/D21753



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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Richard Smith via cfe-commits
On Thu, Jul 14, 2016 at 3:52 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Why did we upgrade the unaligned reference binding from a warning to an
> error? That will make it hard to roll this change out across many codebases.
>

GCC has given an error on this since version 4.7. If there are cases that
GCC accepts and we reject, that sounds like a bug.


> On Thu, Jul 14, 2016 at 7:10 AM, Roger Ferrer Ibanez via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rogfer01
>> Date: Thu Jul 14 09:10:43 2016
>> New Revision: 275417
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
>> Log:
>> Diagnose taking address and reference binding of packed members
>>
>> This patch implements PR#22821.
>>
>> Taking the address of a packed member is dangerous since the reduced
>> alignment of the pointee is lost. This can lead to memory alignment
>> faults in some architectures if the pointer value is dereferenced.
>>
>> This change adds a new warning to clang emitted when taking the address
>> of a packed member. A packed member is either a field/data member
>> declared as attribute((packed)) or belonging to a struct/class
>> declared as such. The associated flag is -Waddress-of-packed-member.
>> Conversions (either implicit or via a valid casting) to pointer types
>> with lower or equal alignment requirements (e.g. void* or char*)
>> silence the warning.
>>
>> This change also adds a new error diagnostic when the user attempts to
>> bind a reference to a packed member, regardless of the alignment.
>>
>> Differential Revision: https://reviews.llvm.org/D20561
>>
>>
>>
>> Added:
>> cfe/trunk/test/Sema/address-packed-member-memops.c
>> cfe/trunk/test/Sema/address-packed.c
>> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
>> cfe/trunk/test/SemaCXX/address-packed.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaCast.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaInit.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
>> 09:10:43 2016
>> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>>"dereference of type %1 that was reinterpret_cast from type %0 has
>> undefined "
>>"behavior">,
>>InGroup, DefaultIgnore;
>> +def warn_taking_address_of_packed_member : Warning<
>> +  "taking address of packed member %0 of class or structure %q1 may
>> result in an unaligned pointer value">,
>> +  InGroup>;
>> +def err_binding_reference_to_packed_member : Error<
>> +  "binding reference to packed member %0 of class or structure %q1">;
>>
>>  def err_objc_object_assignment : Error<
>>"cannot assign to class object (%0 invalid)">;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417=275416=275417=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
>> @@ -9518,6 +9518,10 @@ private:
>>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>>  const Expr * const *ExprArgs);
>>
>> +  /// \brief Check if we are taking the address of a packed field
>> +  /// as this may be a problem if the pointer value is dereferenced.
>> +  void CheckAddressOfPackedMember(Expr *rhs);
>> +
>>/// \brief The parser's current scope.
>>///
>>/// The parser maintains this state here.
>> @@ -9596,6 +9600,51 @@ public:
>>// Emitting members of dllexported classes is delayed until the class
>>// (including field initializers) is fully parsed.
>>SmallVector DelayedDllExportClasses;
>> +
>> +private:
>> +  /// \brief Helper class that collects misaligned member designations
>> and
>> +  /// their location info for delayed diagnostics.
>> +  struct MisalignedMember {
>> +Expr *E;
>> +RecordDecl *RD;
>> +ValueDecl *MD;
>> +CharUnits Alignment;
>> +
>> +MisalignedMember() : E(), RD(), MD(), Alignment() {}
>> +MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
>> + CharUnits Alignment)
>> +: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
>> +explicit MisalignedMember(Expr *E)
>> +: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
>> +
>> +bool operator==(const MisalignedMember ) { 

Re: r275464 - Attempt to workaround Windows bots after my previous commit

2016-07-14 Thread Vitaly Buka via cfe-commits
Thank you.

On Thu, Jul 14, 2016 at 4:00 PM Ben Langmuir  wrote:

> Thanks! it was actually my earlier commit that broke it, it just didn’t
> turn up until a second build happened.
>
> Fixed in r275496
>
>
>
> On Jul 14, 2016, at 2:55 PM, Vitaly Buka  wrote:
>
> The patch breaks this test:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14659/steps/check-clang%20msan/logs/stdio
>
> On Thu, Jul 14, 2016 at 1:16 PM Ben Langmuir via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: benlangmuir
>> Date: Thu Jul 14 15:08:43 2016
>> New Revision: 275464
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=275464=rev
>> Log:
>> Attempt to workaround Windows bots after my previous commit
>>
>> For some reason it seems the second invocation is getting DMOD_OTHER_H
>> set to a path with/forward/slashes, but one of the use sites
>> has\back\slashes. There should be no difference with what was already
>> there, but for now try to avoid checking those paths.
>>
>> Modified:
>> cfe/trunk/test/Index/index-module.m
>>
>> Modified: cfe/trunk/test/Index/index-module.m
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275464=275463=275464=diff
>>
>> ==
>> --- cfe/trunk/test/Index/index-module.m (original)
>> +++ cfe/trunk/test/Index/index-module.m Thu Jul 14 15:08:43 2016
>> @@ -20,7 +20,7 @@ int glob;
>>  // CHECK-NOT: [indexDeclaration]
>>
>>  // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck
>> %s -check-prefix=CHECK-DMOD
>> -// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm |
>> FileCheck %s -check-prefix=CHECK-DMOD
>> +// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm |
>> FileCheck %s -check-prefix=CHECK-DMOD-AST
>>
>>  // CHECK-DMOD:  [startedTranslationUnit]
>>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
>> [[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
>> | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
>> @@ -31,7 +31,6 @@ int glob;
>>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
>> [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
>> | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0
>> | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
>>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
>> [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
>> | {{.*}} | hash loc:  | {{.*}} | module:
>> DependsOnModule.Private.DependsOnModule
>>  // CHECK-DMOD-NEXT: [importedASTFile]:
>> {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name:
>> "Module" | isImplicit: 1
>> -//
>>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
>> depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
>>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template
>> | {{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12
>>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
>> sub_framework | {{.*}} | loc: [[DMOD_SUB_H]]:2:8
>> @@ -39,6 +38,8 @@ int glob;
>>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
>> depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
>>  // CHECK-DMOD-NOT: [indexDeclaration]
>>
>> +// CHECK-DMOD-AST: [importedASTFile]:
>> {{.*}}.cache.sys{{[/\\]}}Module.pcm | loc: {{.*}}DependsOnModule.h:1:1 |
>> name: "Module" | isImplicit: 1
>> +
>>  // RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s
>> -check-prefix=CHECK-TMOD
>>
>>  // CHECK-TMOD:  [startedTranslationUnit]
>>
>>
>> ___
>> 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: r275464 - Attempt to workaround Windows bots after my previous commit

2016-07-14 Thread Ben Langmuir via cfe-commits
Thanks! it was actually my earlier commit that broke it, it just didn’t turn up 
until a second build happened.

Fixed in r275496


> On Jul 14, 2016, at 2:55 PM, Vitaly Buka  wrote:
> 
> The patch breaks this test: 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14659/steps/check-clang%20msan/logs/stdio
>  
> 
> On Thu, Jul 14, 2016 at 1:16 PM Ben Langmuir via cfe-commits 
> > wrote:
> Author: benlangmuir
> Date: Thu Jul 14 15:08:43 2016
> New Revision: 275464
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=275464=rev 
> 
> Log:
> Attempt to workaround Windows bots after my previous commit
> 
> For some reason it seems the second invocation is getting DMOD_OTHER_H
> set to a path with/forward/slashes, but one of the use sites
> has\back\slashes. There should be no difference with what was already
> there, but for now try to avoid checking those paths.
> 
> Modified:
> cfe/trunk/test/Index/index-module.m
> 
> Modified: cfe/trunk/test/Index/index-module.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275464=275463=275464=diff
>  
> 
> ==
> --- cfe/trunk/test/Index/index-module.m (original)
> +++ cfe/trunk/test/Index/index-module.m Thu Jul 14 15:08:43 2016
> @@ -20,7 +20,7 @@ int glob;
>  // CHECK-NOT: [indexDeclaration]
> 
>  // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s 
> -check-prefix=CHECK-DMOD
> -// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck 
> %s -check-prefix=CHECK-DMOD
> +// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck 
> %s -check-prefix=CHECK-DMOD-AST
> 
>  // CHECK-DMOD:  [startedTranslationUnit]
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
> @@ -31,7 +31,6 @@ int glob;
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
>  | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 
> | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: 
> DependsOnModule.Private.DependsOnModule
>  // CHECK-DMOD-NEXT: [importedASTFile]: 
> {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: 
> "Module" | isImplicit: 1
> -//
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
> depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template | 
> {{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework 
> | {{.*}} | loc: [[DMOD_SUB_H]]:2:8
> @@ -39,6 +38,8 @@ int glob;
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
> depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
>  // CHECK-DMOD-NOT: [indexDeclaration]
> 
> +// CHECK-DMOD-AST: [importedASTFile]: {{.*}}.cache.sys{{[/\\]}}Module.pcm | 
> loc: {{.*}}DependsOnModule.h:1:1 | name: "Module" | isImplicit: 1
> +
>  // RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s 
> -check-prefix=CHECK-TMOD
> 
>  // CHECK-TMOD:  [startedTranslationUnit]
> 
> 
> ___
> 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


r275496 - Remove the new module cache from the index-module test

2016-07-14 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Jul 14 17:53:23 2016
New Revision: 275496

URL: http://llvm.org/viewvc/llvm-project?rev=275496=rev
Log:
Remove the new module cache from the index-module test

Forgot to add the new cache to the `rm -rf` line. This broke some bots
when trying to load a module built with an older compiler.

Modified:
cfe/trunk/test/Index/index-module.m

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275496=275495=275496=diff
==
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Thu Jul 14 17:53:23 2016
@@ -3,7 +3,7 @@
 @import DependsOnModule;
 int glob;
 
-// RUN: rm -rf %t.cache
+// RUN: rm -rf %t.cache %t.cache.sys
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F 
%S/../Modules/Inputs \
 // RUN:  -Xclang -fdisable-module-hash | FileCheck %s
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache.sys 
-fmodules -iframework %S/../Modules/Inputs \


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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Reid Kleckner via cfe-commits
Why did we upgrade the unaligned reference binding from a warning to an
error? That will make it hard to roll this change out across many codebases.

On Thu, Jul 14, 2016 at 7:10 AM, Roger Ferrer Ibanez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rogfer01
> Date: Thu Jul 14 09:10:43 2016
> New Revision: 275417
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
> Log:
> Diagnose taking address and reference binding of packed members
>
> This patch implements PR#22821.
>
> Taking the address of a packed member is dangerous since the reduced
> alignment of the pointee is lost. This can lead to memory alignment
> faults in some architectures if the pointer value is dereferenced.
>
> This change adds a new warning to clang emitted when taking the address
> of a packed member. A packed member is either a field/data member
> declared as attribute((packed)) or belonging to a struct/class
> declared as such. The associated flag is -Waddress-of-packed-member.
> Conversions (either implicit or via a valid casting) to pointer types
> with lower or equal alignment requirements (e.g. void* or char*)
> silence the warning.
>
> This change also adds a new error diagnostic when the user attempts to
> bind a reference to a packed member, regardless of the alignment.
>
> Differential Revision: https://reviews.llvm.org/D20561
>
>
>
> Added:
> cfe/trunk/test/Sema/address-packed-member-memops.c
> cfe/trunk/test/Sema/address-packed.c
> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
> cfe/trunk/test/SemaCXX/address-packed.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
> 09:10:43 2016
> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>"dereference of type %1 that was reinterpret_cast from type %0 has
> undefined "
>"behavior">,
>InGroup, DefaultIgnore;
> +def warn_taking_address_of_packed_member : Warning<
> +  "taking address of packed member %0 of class or structure %q1 may
> result in an unaligned pointer value">,
> +  InGroup>;
> +def err_binding_reference_to_packed_member : Error<
> +  "binding reference to packed member %0 of class or structure %q1">;
>
>  def err_objc_object_assignment : Error<
>"cannot assign to class object (%0 invalid)">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417=275416=275417=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
> @@ -9518,6 +9518,10 @@ private:
>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>  const Expr * const *ExprArgs);
>
> +  /// \brief Check if we are taking the address of a packed field
> +  /// as this may be a problem if the pointer value is dereferenced.
> +  void CheckAddressOfPackedMember(Expr *rhs);
> +
>/// \brief The parser's current scope.
>///
>/// The parser maintains this state here.
> @@ -9596,6 +9600,51 @@ public:
>// Emitting members of dllexported classes is delayed until the class
>// (including field initializers) is fully parsed.
>SmallVector DelayedDllExportClasses;
> +
> +private:
> +  /// \brief Helper class that collects misaligned member designations and
> +  /// their location info for delayed diagnostics.
> +  struct MisalignedMember {
> +Expr *E;
> +RecordDecl *RD;
> +ValueDecl *MD;
> +CharUnits Alignment;
> +
> +MisalignedMember() : E(), RD(), MD(), Alignment() {}
> +MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
> + CharUnits Alignment)
> +: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
> +explicit MisalignedMember(Expr *E)
> +: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
> +
> +bool operator==(const MisalignedMember ) { return this->E == m.E; }
> +  };
> +  /// \brief Small set of gathered accesses to potentially misaligned
> members
> +  /// due to the packed attribute.
> +  SmallVector MisalignedMembers;
> +
> +  /// \brief Adds an expression to the set of gathered misaligned members.
> +  void AddPotentialMisalignedMembers(Expr *E, 

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-14 Thread Jake VanAdrighem via cfe-commits
jakev added inline comments.


Comment at: test/Profile/gcc-flag-compatibility.c:10
@@ -9,3 +9,3 @@
 
-// Check that -fprofile-generate uses the runtime default profile file.
+// Check that -fprofile-generate overrides the default profraw.
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck 
-check-prefix=PROFILE-GEN %s

davidxl wrote:
> Please add a FIXME here. I noticed that there is a bug in IR PGO 
> implementation that -fprofile-generate still invokes overrider api in 
> instrumentation which is unnecessary.
I actually have a patch that fixes this behavior. I can post it once this patch 
has landed.


Repository:
  rL LLVM

https://reviews.llvm.org/D21823



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


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-14 Thread Jake VanAdrighem via cfe-commits
jakev updated this revision to Diff 64056.
jakev marked 3 inline comments as done.
jakev added a comment.

Add a couple notes to the docs and a fixme to a test. We can more thoroughly 
fix up the docs in a separate patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D21823

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/clang_f_opts.c
  test/Profile/gcc-flag-compatibility.c

Index: test/Profile/gcc-flag-compatibility.c
===
--- test/Profile/gcc-flag-compatibility.c
+++ test/Profile/gcc-flag-compatibility.c
@@ -7,10 +7,11 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
-// Check that -fprofile-generate uses the runtime default profile file.
+// FIXME: IRPGO shouldn't use the override API when no profraw name is given.
+// Check that -fprofile-generate overrides the default profraw.
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s
-// PROFILE-GEN-NOT: call void @__llvm_profile_override_default_filename
-// PROFILE-GEN-NOT: declare void @__llvm_profile_override_default_filename(i8*)
+// PROFILE-GEN: call void @__llvm_profile_override_default_filename
+// PROFILE-GEN: declare void @__llvm_profile_override_default_filename(i8*)
 
 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -66,7 +66,7 @@
 // CHECK-PROFILE-ARCS: "-femit-coverage-data"
 // CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
 
-// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
+// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
 // RUN: %clang -### -S -fprofile-instr-generate=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
@@ -87,20 +87,22 @@
 // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
-// RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
+// RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s
+// RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=dir -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
-// RUN: %clang -### -S -fprofile-generate=dir -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
 // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
 // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|}}default.profraw"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
+// CHECK-NO-MIX-GENERATE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang"
 // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use"
 // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with 

Re: [PATCH] D22190: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-14 Thread Richard Smith via cfe-commits
rsmith added a comment.

It's not meaningful to ask whether a value-dependent expression is an integral 
constant expression. The answer is not knowable, so the function asserting 
doesn't seem unreasonable. Any value we returned from that function would be a 
lie.


Repository:
  rL LLVM

https://reviews.llvm.org/D22190



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Paul Robinson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275493: C does not have inline variables. (authored by 
probinson).

Changed prior to commit:
  https://reviews.llvm.org/D22113?vs=64053=64057#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22113

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/inline.c
  cfe/trunk/test/SemaCXX/inline.cpp

Index: cfe/trunk/test/SemaCXX/inline.cpp
===
--- cfe/trunk/test/SemaCXX/inline.cpp
+++ cfe/trunk/test/SemaCXX/inline.cpp
@@ -1,5 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s 
-Wc++98-c++11-c++14-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
 struct c {inline int a;}; // expected-error{{'inline' can only appear on 
functions}}
+
+void localVar() {
+  inline int a; // expected-error{{inline declaration of 'a' not allowed in 
block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ 
standards before C++1z}}
+#endif
Index: cfe/trunk/test/Sema/inline.c
===
--- cfe/trunk/test/Sema/inline.c
+++ cfe/trunk/test/Sema/inline.c
@@ -49,7 +49,7 @@
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on 
functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6178,7 +6178,10 @@
   }
 
   if (D.getDeclSpec().isInlineSpecified()) {
-if (CurContext->isFunctionOrMethod()) {
+if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
+} else if (CurContext->isFunctionOrMethod()) {
   // 'inline' is not allowed on block scope variable declaration.
   Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name


Index: cfe/trunk/test/SemaCXX/inline.cpp
===
--- cfe/trunk/test/SemaCXX/inline.cpp
+++ cfe/trunk/test/SemaCXX/inline.cpp
@@ -1,5 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s -Wc++98-c++11-c++14-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
 struct c {inline int a;}; // expected-error{{'inline' can only appear on functions}}
+
+void localVar() {
+  inline int a; // expected-error{{inline declaration of 'a' not allowed in block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ standards before C++1z}}
+#endif
Index: cfe/trunk/test/Sema/inline.c
===
--- cfe/trunk/test/Sema/inline.c
+++ cfe/trunk/test/Sema/inline.c
@@ -49,7 +49,7 @@
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6178,7 +6178,10 @@
   }
 
   if (D.getDeclSpec().isInlineSpecified()) {
-if (CurContext->isFunctionOrMethod()) {
+if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
+} else if (CurContext->isFunctionOrMethod()) {
   // 'inline' is not allowed on block scope variable declaration.
   Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275493 - C does not have inline variables.

2016-07-14 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Jul 14 17:22:58 2016
New Revision: 275493

URL: http://llvm.org/viewvc/llvm-project?rev=275493=rev
Log:
C does not have inline variables.
Add a few missing tests for related C++ diagnostics.

Differential Revision: http://reviews.llvm.org/D22113

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/inline.c
cfe/trunk/test/SemaCXX/inline.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=275493=275492=275493=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 14 17:22:58 2016
@@ -6178,7 +6178,10 @@ Sema::ActOnVariableDeclarator(Scope *S,
   }
 
   if (D.getDeclSpec().isInlineSpecified()) {
-if (CurContext->isFunctionOrMethod()) {
+if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
+} else if (CurContext->isFunctionOrMethod()) {
   // 'inline' is not allowed on block scope variable declaration.
   Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name

Modified: cfe/trunk/test/Sema/inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline.c?rev=275493=275492=275493=diff
==
--- cfe/trunk/test/Sema/inline.c (original)
+++ cfe/trunk/test/Sema/inline.c Thu Jul 14 17:22:58 2016
@@ -49,7 +49,7 @@ inline int useConst () {
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on 
functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 

Modified: cfe/trunk/test/SemaCXX/inline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/inline.cpp?rev=275493=275492=275493=diff
==
--- cfe/trunk/test/SemaCXX/inline.cpp (original)
+++ cfe/trunk/test/SemaCXX/inline.cpp Thu Jul 14 17:22:58 2016
@@ -1,5 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s 
-Wc++98-c++11-c++14-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
 struct c {inline int a;}; // expected-error{{'inline' can only appear on 
functions}}
+
+void localVar() {
+  inline int a; // expected-error{{inline declaration of 'a' not allowed in 
block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ 
standards before C++1z}}
+#endif


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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Thanks!


https://reviews.llvm.org/D22113



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


Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-14 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Other than adding expected notes for the path notes to the test, this looks 
good to me. Thanks Ádám!



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1698
@@ +1697,3 @@
+PathDiagnosticPiece *
+CXXSelfAssignmentBRVisitor::VisitNode(const ExplodedNode *Succ,
+  const ExplodedNode *Pred,

This is great.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:452
@@ -444,5 +451,3 @@
   // inlining when reanalyzing an already inlined function.
-  if (Visited.count(D)) {
-assert(isa(D) &&
-   "We are only reanalyzing ObjCMethods.");
+  if (Visited.count(D) && isa(D)) {
 const ObjCMethodDecl *ObjCM = cast(D);

baloghadamsoftware wrote:
> I made a quick measurement on our build server using clang as target code. 
> Real/user/system times were 75/575/18 for minimal and 76/587/18 for regular. 
> This does not seem too much. However, since the semantics of a copy 
> assignment operator is often composed of the semantics of a destructor and 
> the semantics of a copy constructor implementations often put these two 
> functionalities into separate functions and call them from the destructor, 
> copy constructor and copy assignment operator. Such implementations requires 
> regular inlining to be checked.
Ok, makes sense to me.


Comment at: test/Analysis/self-assign.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -std=c++11 -analyze 
-analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify
+

I think it would be good to add -analyzer-output=text to this test line and 
check the expected output of that path notes.


https://reviews.llvm.org/D19311



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


r275490 - Add test inputs missed by r275481.

2016-07-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jul 14 17:15:06 2016
New Revision: 275490

URL: http://llvm.org/viewvc/llvm-project?rev=275490=rev
Log:
Add test inputs missed by r275481.

Added:
cfe/trunk/test/Modules/Inputs/unused-global-init/
cfe/trunk/test/Modules/Inputs/unused-global-init/init.h
cfe/trunk/test/Modules/Inputs/unused-global-init/module.modulemap
cfe/trunk/test/Modules/Inputs/unused-global-init/other.h
cfe/trunk/test/Modules/Inputs/unused-global-init/unused.h
cfe/trunk/test/Modules/Inputs/unused-global-init/used.h

Added: cfe/trunk/test/Modules/Inputs/unused-global-init/init.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unused-global-init/init.h?rev=275490=auto
==
--- cfe/trunk/test/Modules/Inputs/unused-global-init/init.h (added)
+++ cfe/trunk/test/Modules/Inputs/unused-global-init/init.h Thu Jul 14 17:15:06 
2016
@@ -0,0 +1 @@
+struct Init { Init(); ~Init(); } init;

Added: cfe/trunk/test/Modules/Inputs/unused-global-init/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unused-global-init/module.modulemap?rev=275490=auto
==
--- cfe/trunk/test/Modules/Inputs/unused-global-init/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/unused-global-init/module.modulemap Thu Jul 
14 17:15:06 2016
@@ -0,0 +1,3 @@
+module used { header "used.h" }
+module unused { header "unused.h" }
+module init { module a { header "init.h" } module b { header "other.h" } }

Added: cfe/trunk/test/Modules/Inputs/unused-global-init/other.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unused-global-init/other.h?rev=275490=auto
==
--- cfe/trunk/test/Modules/Inputs/unused-global-init/other.h (added)
+++ cfe/trunk/test/Modules/Inputs/unused-global-init/other.h Thu Jul 14 
17:15:06 2016
@@ -0,0 +1 @@
+// other.h

Added: cfe/trunk/test/Modules/Inputs/unused-global-init/unused.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unused-global-init/unused.h?rev=275490=auto
==
--- cfe/trunk/test/Modules/Inputs/unused-global-init/unused.h (added)
+++ cfe/trunk/test/Modules/Inputs/unused-global-init/unused.h Thu Jul 14 
17:15:06 2016
@@ -0,0 +1 @@
+// unused.h

Added: cfe/trunk/test/Modules/Inputs/unused-global-init/used.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/unused-global-init/used.h?rev=275490=auto
==
--- cfe/trunk/test/Modules/Inputs/unused-global-init/used.h (added)
+++ cfe/trunk/test/Modules/Inputs/unused-global-init/used.h Thu Jul 14 17:15:06 
2016
@@ -0,0 +1,2 @@
+// used.h
+#include "other.h"


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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Paul Robinson via cfe-commits
probinson updated this revision to Diff 64053.
probinson marked an inline comment as done.
probinson added a comment.

Reorder the checks.  I didn't see any tests for the adjacent (C++) diagnostics 
so I added some.


https://reviews.llvm.org/D22113

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/inline.c
  test/SemaCXX/inline.cpp

Index: test/SemaCXX/inline.cpp
===
--- test/SemaCXX/inline.cpp
+++ test/SemaCXX/inline.cpp
@@ -1,5 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s 
-Wc++98-c++11-c++14-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
 struct c {inline int a;}; // expected-error{{'inline' can only appear on 
functions}}
+
+void localVar() {
+  inline int a; // expected-error{{inline declaration of 'a' not allowed in 
block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ 
standards before C++1z}}
+#endif
Index: test/Sema/inline.c
===
--- test/Sema/inline.c
+++ test/Sema/inline.c
@@ -49,7 +49,7 @@
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on 
functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6178,7 +6178,10 @@
   }
 
   if (D.getDeclSpec().isInlineSpecified()) {
-if (CurContext->isFunctionOrMethod()) {
+if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
+} else if (CurContext->isFunctionOrMethod()) {
   // 'inline' is not allowed on block scope variable declaration.
   Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name


Index: test/SemaCXX/inline.cpp
===
--- test/SemaCXX/inline.cpp
+++ test/SemaCXX/inline.cpp
@@ -1,5 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s -Wc++98-c++11-c++14-compat
 
 // Check that we don't allow illegal uses of inline
 // (checking C++-only constructs here)
 struct c {inline int a;}; // expected-error{{'inline' can only appear on functions}}
+
+void localVar() {
+  inline int a; // expected-error{{inline declaration of 'a' not allowed in block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ standards before C++1z}}
+#endif
Index: test/Sema/inline.c
===
--- test/Sema/inline.c
+++ test/Sema/inline.c
@@ -49,7 +49,7 @@
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6178,7 +6178,10 @@
   }
 
   if (D.getDeclSpec().isInlineSpecified()) {
-if (CurContext->isFunctionOrMethod()) {
+if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
+} else if (CurContext->isFunctionOrMethod()) {
   // 'inline' is not allowed on block scope variable declaration.
   Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Paul Robinson via cfe-commits
probinson marked an inline comment as done.


Comment at: lib/Sema/SemaDecl.cpp:6189-6191
@@ -6188,2 +6188,5 @@
 << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+} else if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
 } else {

majnemer wrote:
> I'd suggest sorting this condition higher.  It doesn't make much sense to 
> mention block scopes when inline variables are prohibited in all contexts in 
> C.
Right... for some reason the word 'block' in the comment made me think it was 
an Objective-C thing.  The C-language check is first now.


https://reviews.llvm.org/D22113



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


r275481 - [modules] Don't pass interesting decls to the consumer for a module file that's

2016-07-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jul 14 16:50:09 2016
New Revision: 275481

URL: http://llvm.org/viewvc/llvm-project?rev=275481=rev
Log:
[modules] Don't pass interesting decls to the consumer for a module file that's
passed on the command line but never actually used. We consider a (top-level)
module to be used if any part of it is imported, either by the current
translation unit, or by any part of a top-level module that is itself used.

(Put another way, a module is used if an implicit modules build would have
loaded its .pcm file.)

Added:
cfe/trunk/test/Modules/unused-global-init.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=275481=275480=275481=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 14 16:50:09 2016
@@ -613,7 +613,7 @@ private:
   /// \brief A mapping from each of the hidden submodules to the deserialized
   /// declarations in that submodule that could be made visible.
   HiddenNamesMapType HiddenNamesMap;
-  
+
   
   /// \brief A module import, export, or conflict that hasn't yet been 
resolved.
   struct UnresolvedModuleRef {
@@ -947,6 +947,24 @@ private:
   /// Objective-C protocols.
   std::deque InterestingDecls;
 
+  /// \brief Contains imported interesting declarations from modules that have
+  /// not yet themselves been imported, even indirectly.
+  typedef llvm::SmallVector ModuleInterestingDecls;
+
+  /// Map from top-level modules to their list of interesting declarations.
+  /// Each map entry may be in one of three states: no entry means we've never
+  /// seen this module and never transitively imported it. A null pointer means
+  /// we're not tracking interesting decls: they should be handed straight to
+  /// the consumer because we've transitively imported this module already.
+  /// Otherwise, a list of pending interesting decls.
+  ///
+  /// As an added twist, declarations that are re-exported are listed against
+  /// the owning module and the re-exporting one, but the owning module's list
+  /// is definitive: the decl is there if and only if it has not been handed to
+  /// the consumer already.
+  llvm::DenseMap
+  UnimportedModuleInterestingDecls;
+
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed, and the local offset to the corresponding list
   /// of redeclarations.
@@ -1249,6 +1267,9 @@ private:
   llvm::iterator_range
   getModuleFileLevelDecls(ModuleFile );
 
+  void addInterestingDecl(Decl *D,
+  llvm::Optional OwnerOverride = llvm::None);
+
   void PassInterestingDeclsToConsumer();
   void PassInterestingDeclToConsumer(Decl *D);
 
@@ -1386,6 +1407,11 @@ public:
   /// \brief Make the names within this set of hidden names visible.
   void makeNamesVisible(const HiddenNames , Module *Owner);
 
+  /// \brief Mark a module as "used". This implies that any global initializers
+  /// of declarations contained transitively within it should be run as part of
+  /// the current compilation.
+  void markModuleUsed(Module *M);
+
   /// \brief Take the AST callbacks listener.
   std::unique_ptr takeListener() {
 return std::move(Listener);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=275481=275480=275481=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 14 16:50:09 2016
@@ -2691,6 +2691,8 @@ ASTReader::ReadASTBlock(ModuleFile , u
 case EAGERLY_DESERIALIZED_DECLS:
   // FIXME: Skip reading this record if our ASTConsumer doesn't care
   // about "interesting" decls (for instance, if we're building a module).
+  // FIXME: Store this somewhere per-module and defer until
+  // markModuleReferenced is called.
   for (unsigned I = 0, N = Record.size(); I != N; ++I)
 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
   break;
@@ -3361,6 +3363,9 @@ void ASTReader::makeNamesVisible(const H
 void ASTReader::makeModuleVisible(Module *Mod,
   Module::NameVisibilityKind NameVisibility,
   SourceLocation ImportLoc) {
+  // If we import anything from the module in any way, then it is used.
+  markModuleUsed(Mod);
+
   llvm::SmallPtrSet Visited;
   SmallVector Stack;
   Stack.push_back(Mod);
@@ -6727,10 +6732,95 @@ void ASTReader::PassInterestingDeclsToCo
 Decl *D = 

Re: [PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

2016-07-14 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Yeah, I think this makes sense on balance, even though it does create a weird 
situation for the `ASTPrinter` case, where we don't really want to transfer 
ownership of the stream.



Comment at: lib/CodeGen/CodeGenAction.cpp:705
@@ -703,3 +704,3 @@
   case Backend_EmitNothing:
-return nullptr;
+return {};
   case Backend_EmitMCNull:

I think `return nullptr;` would be clearer here.


Comment at: lib/Frontend/CompilerInstance.cpp:599
@@ -606,3 +598,3 @@
 << 
EC.message();
-return nullptr;
+return {};
   }

Likewise.


https://reviews.llvm.org/D21537



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


Re: r275464 - Attempt to workaround Windows bots after my previous commit

2016-07-14 Thread Vitaly Buka via cfe-commits
The patch breaks this test:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14659/steps/check-clang%20msan/logs/stdio

On Thu, Jul 14, 2016 at 1:16 PM Ben Langmuir via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: benlangmuir
> Date: Thu Jul 14 15:08:43 2016
> New Revision: 275464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275464=rev
> Log:
> Attempt to workaround Windows bots after my previous commit
>
> For some reason it seems the second invocation is getting DMOD_OTHER_H
> set to a path with/forward/slashes, but one of the use sites
> has\back\slashes. There should be no difference with what was already
> there, but for now try to avoid checking those paths.
>
> Modified:
> cfe/trunk/test/Index/index-module.m
>
> Modified: cfe/trunk/test/Index/index-module.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275464=275463=275464=diff
>
> ==
> --- cfe/trunk/test/Index/index-module.m (original)
> +++ cfe/trunk/test/Index/index-module.m Thu Jul 14 15:08:43 2016
> @@ -20,7 +20,7 @@ int glob;
>  // CHECK-NOT: [indexDeclaration]
>
>  // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck
> %s -check-prefix=CHECK-DMOD
> -// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm |
> FileCheck %s -check-prefix=CHECK-DMOD
> +// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm |
> FileCheck %s -check-prefix=CHECK-DMOD-AST
>
>  // CHECK-DMOD:  [startedTranslationUnit]
>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
> [[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
> | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
> @@ -31,7 +31,6 @@ int glob;
>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
> [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
> | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0
> | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
>  // CHECK-DMOD-NEXT: [ppIncludedFile]:
> [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
> | {{.*}} | hash loc:  | {{.*}} | module:
> DependsOnModule.Private.DependsOnModule
>  // CHECK-DMOD-NEXT: [importedASTFile]:
> {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name:
> "Module" | isImplicit: 1
> -//
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
> depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template |
> {{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
> sub_framework | {{.*}} | loc: [[DMOD_SUB_H]]:2:8
> @@ -39,6 +38,8 @@ int glob;
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name:
> depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
>  // CHECK-DMOD-NOT: [indexDeclaration]
>
> +// CHECK-DMOD-AST: [importedASTFile]: {{.*}}.cache.sys{{[/\\]}}Module.pcm
> | loc: {{.*}}DependsOnModule.h:1:1 | name: "Module" | isImplicit: 1
> +
>  // RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s
> -check-prefix=CHECK-TMOD
>
>  // CHECK-TMOD:  [startedTranslationUnit]
>
>
> ___
> 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] D22384: [OpenMP] add check for both simdlen and safelen clauses specified

2016-07-14 Thread Kelvin Li via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, sfantao, carlo.bertolli, arpith-jacob, hfinkel.
kkwli0 added a subscriber: cfe-commits.

This patch adds the check for specifying both simdlen and safelen clauses on 
the 'distribute simd' or 'distribute parallel for simd' constructs.

https://reviews.llvm.org/D22384

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/distribute_parallel_for_simd_misc_messages.c
  test/OpenMP/distribute_simd_misc_messages.c
  test/OpenMP/target_parallel_for_simd_misc_messages.c

Index: test/OpenMP/target_parallel_for_simd_misc_messages.c
===
--- test/OpenMP/target_parallel_for_simd_misc_messages.c
+++ test/OpenMP/target_parallel_for_simd_misc_messages.c
@@ -312,3 +312,184 @@
   }
 }
 
+void test_safelen() {
+  int i;
+// expected-error@+1 {{expected '('}}
+#pragma omp target parallel for simd safelen
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}}
+#pragma omp target parallel for simd safelen()
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(,
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(, )
+  for (i = 0; i < 16; ++i)
+;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp target parallel for simd safelen 4)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4,
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4, )
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target parallel for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4 4)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4, , 4)
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target parallel for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd safelen(4, 8)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp target parallel for simd safelen(2.5)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp target parallel for simd safelen(foo())
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp target parallel for simd safelen(-5)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp target parallel for simd safelen(0)
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp target parallel for simd safelen(5 - 5)
+  for (i = 0; i < 16; ++i)
+;
+}
+
+void test_simdlen() {
+  int i;
+// expected-error@+1 {{expected '('}}
+#pragma omp target parallel for simd simdlen
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd simdlen(
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}}
+#pragma omp target parallel for simd simdlen()
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd simdlen(,
+  for (i = 0; i < 16; ++i)
+;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp target parallel for simd simdlen(, )
+  for (i = 0; i < 16; ++i)
+;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp target parallel for simd' are ignored}}
+// expected-error@+1 

Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Nico Weber via cfe-commits
I mean clang's diagnostic could say this too. For example, it could have a
note pointing at the attribute(packed) saying "struct alignment set to 1
here" or some such.

On Thu, Jul 14, 2016 at 5:25 PM, Roger Ferrer Ibanez <
roger.ferreriba...@arm.com> wrote:

> Hi Nico,
>
>
> yes, it should be clearly stated in the documentation. I will try to find
> some time to contribute a change in the docs.
>
>
> I forgot that fact in my first answer to your original question. So, I
> think that the warning should fire in this case. Actually, I analysed
> precisely this case in phabricator and there was some consensus in that the
> warning was sensible.
>
>
> Kind regards,
>
> Roger
>
>
> --
> *From:* tha...@google.com  on behalf of Nico Weber <
> tha...@chromium.org>
> *Sent:* 14 July 2016 22:14:10
> *To:* Richard Smith
> *Cc:* Roger Ferrer Ibanez; cfe-commits
> *Subject:* Re: r275417 - Diagnose taking address and reference binding of
> packed members
>
> On Thu, Jul 14, 2016 at 5:07 PM, Richard Smith 
> wrote:
>
>> On Thu, Jul 14, 2016 at 10:15 AM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hi,
>>>
>>> this fires on (at least) usrsctplib [1]:
>>>
>>> FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
>>> ../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15:
>>> error: taking address of packed member 'time_entered' of class or structure
>>> 'sctp_state_cookie' may result in an unaligned pointer value
>>> [-Werror,-Waddress-of-packed-member]
>>>
>>> >time_entered,
>>>
>>>  ^~~~
>>> ../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10:
>>> error: taking address of packed member 'time_entered' of class or structure
>>> 'sctp_state_cookie' may result in an unaligned pointer value
>>> [-Werror,-Waddress-of-packed-member]
>>>   >time_entered,
>>> sctp_align_unsafe_makecopy,
>>>^~~~
>>> 2 errors generated.
>>>
>>> The struct looks like so [2]:
>>>
>>> struct sctp_state_cookie { /* this is our definition... */
>>> uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
>>> struct timeval time_entered; /* the time I built cookie */
>>>   ...
>>>
>>> The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field
>>> should be aligned as well, right? And while the struct is packed, its
>>> alignment isn't overwritten (unless the packed attribute does that too, but
>>> the docs at least don't mention that).
>>>
>>
>> The packed attribute does that too.
>>
>> struct __attribute__((packed)) X {
>>   unsigned long long a;
>> };
>> static_assert(alignof(X) == 1, ""); // does not fire
>>
>> What __attribute__((packed)) really means is that the minimum alignment
>> is reduced to 1.
>>
>
> Wow, that's pretty surprising! Maybe the warning text could be more
> explicit about this.
>
>
>>
>>
>>> Should the warning really fire here?
>>>
>>> 1:
>>> https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
>>> 2:
>>> https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium=C=1468495044=190
>>>
>>> On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rogfer01
 Date: Thu Jul 14 09:10:43 2016
 New Revision: 275417

 URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
 Log:
 Diagnose taking address and reference binding of packed members

 This patch implements PR#22821.

 Taking the address of a packed member is dangerous since the reduced
 alignment of the pointee is lost. This can lead to memory alignment
 faults in some architectures if the pointer value is dereferenced.

 This change adds a new warning to clang emitted when taking the address
 of a packed member. A packed member is either a field/data member
 declared as attribute((packed)) or belonging to a struct/class
 declared as such. The associated flag is -Waddress-of-packed-member.
 Conversions (either implicit or via a valid casting) to pointer types
 with lower or equal alignment requirements (e.g. void* or char*)
 silence the warning.

 This change also adds a new error diagnostic when the user attempts to
 bind a reference to a packed member, regardless of the alignment.

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



 Added:
 cfe/trunk/test/Sema/address-packed-member-memops.c
 cfe/trunk/test/Sema/address-packed.c
 cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
 cfe/trunk/test/SemaCXX/address-packed.cpp
 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 cfe/trunk/include/clang/Sema/Sema.h

Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-07-14 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/AST/ASTImporter.cpp:2253-2254
@@ +2252,4 @@
+  return nullptr;
+  }
+  else {
+ToRequiresClause = nullptr;

`else` on same line as `}` please.


https://reviews.llvm.org/D19322



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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Hi Nico,


yes, it should be clearly stated in the documentation. I will try to find some 
time to contribute a change in the docs.


I forgot that fact in my first answer to your original question. So, I think 
that the warning should fire in this case. Actually, I analysed precisely this 
case in phabricator and there was some consensus in that the warning was 
sensible.


Kind regards,

Roger



From: tha...@google.com  on behalf of Nico Weber 

Sent: 14 July 2016 22:14:10
To: Richard Smith
Cc: Roger Ferrer Ibanez; cfe-commits
Subject: Re: r275417 - Diagnose taking address and reference binding of packed 
members

On Thu, Jul 14, 2016 at 5:07 PM, Richard Smith 
> wrote:
On Thu, Jul 14, 2016 at 10:15 AM, Nico Weber via cfe-commits 
> wrote:
Hi,

this fires on (at least) usrsctplib [1]:

FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  
>time_entered,
   
^~~~
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  >time_entered, 
sctp_align_unsafe_makecopy,
   ^~~~
2 errors generated.

The struct looks like so [2]:

struct sctp_state_cookie { /* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered; /* the time I built cookie */
  ...

The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field should 
be aligned as well, right? And while the struct is packed, its alignment isn't 
overwritten (unless the packed attribute does that too, but the docs at least 
don't mention that).

The packed attribute does that too.

struct __attribute__((packed)) X {
  unsigned long long a;
};
static_assert(alignof(X) == 1, ""); // does not fire

What __attribute__((packed)) really means is that the minimum alignment is 
reduced to 1.

Wow, that's pretty surprising! Maybe the warning text could be more explicit 
about this.


Should the warning really fire here?

1: 
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
2: 
https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium=C=1468495044=190

On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits 
> wrote:
Author: rogfer01
Date: Thu Jul 14 09:10:43 2016
New Revision: 275417

URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
Log:
Diagnose taking address and reference binding of packed members

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
silence the warning.

This change also adds a new error diagnostic when the user attempts to
bind a reference to a packed member, regardless of the alignment.

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



Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td 

Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.

(I didn't mark it as accepted because Teresa did, but in case you're waiting 
for me, don't)


https://reviews.llvm.org/D21545



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


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Peter Collingbourne via cfe-commits
pcc marked an inline comment as done.
pcc added a comment.

https://reviews.llvm.org/D21545



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


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 64043.
pcc added a comment.

- Add a FIXME


https://reviews.llvm.org/D21545

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CMakeLists.txt

Index: lib/CodeGen/CMakeLists.txt
===
--- lib/CodeGen/CMakeLists.txt
+++ lib/CodeGen/CMakeLists.txt
@@ -8,6 +8,7 @@
   IRReader
   InstCombine
   Instrumentation
+  LTO
   Linker
   MC
   ObjCARCOpts
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -29,9 +29,11 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/Timer.h"
@@ -74,8 +76,7 @@
   /// Set LLVM command line options passed through -backend-option.
   void setCommandLineOpts();
 
-  void CreatePasses(legacy::PassManager , legacy::FunctionPassManager ,
-ModuleSummaryIndex *ModuleSummary);
+  void CreatePasses(legacy::PassManager , legacy::FunctionPassManager );
 
   /// Generates the TargetMachine.
   /// Leaves TM unchanged if it is unable to create the target machine.
@@ -281,8 +282,7 @@
 }
 
 void EmitAssemblyHelper::CreatePasses(legacy::PassManager ,
-  legacy::FunctionPassManager ,
-  ModuleSummaryIndex *ModuleSummary) {
+  legacy::FunctionPassManager ) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -333,14 +333,6 @@
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
-  // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory module summary index.
-  if (ModuleSummary) {
-PMBuilder.ModuleSummary = ModuleSummary;
-PMBuilder.populateThinLTOPassManager(MPM);
-return;
-  }
-
   // Add target-specific passes that need to run as early as possible.
   if (TM)
 PMBuilder.addExtension(
@@ -659,35 +651,15 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  // If we are performing a ThinLTO importing compile, load the function
-  // index into memory and pass it into CreatePasses, which will add it
-  // to the PassManagerBuilder and invoke LTO passes.
-  std::unique_ptr ModuleSummary;
-  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
-ErrorOr IndexOrErr =
-llvm::getModuleSummaryIndexForFile(
-CodeGenOpts.ThinLTOIndexFile, [&](const DiagnosticInfo ) {
-  TheModule->getContext().diagnose(DI);
-});
-if (std::error_code EC = IndexOrErr.getError()) {
-  std::string Error = EC.message();
-  errs() << "Error loading index file '" << CodeGenOpts.ThinLTOIndexFile
- << "': " << Error << "\n";
-  return;
-}
-ModuleSummary = std::move(IndexOrErr.get());
-assert(ModuleSummary && "Expected non-empty module summary index");
-  }
-
   legacy::PassManager PerModulePasses;
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
   legacy::FunctionPassManager PerFunctionPasses(TheModule);
   PerFunctionPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
-  CreatePasses(PerModulePasses, PerFunctionPasses, ModuleSummary.get());
+  CreatePasses(PerModulePasses, PerFunctionPasses);
 
   legacy::PassManager CodeGenPasses;
   CodeGenPasses.add(
@@ -740,12 +712,71 @@
   }
 }
 
+static void runThinLTOBackend(const CodeGenOptions , Module *M,
+  std::unique_ptr OS) {
+  // If we are performing a ThinLTO importing compile, load the function index
+  // into memory and pass it into thinBackend, which will run the function
+  // importer and invoke LTO passes.
+  ErrorOr IndexOrErr =
+  llvm::getModuleSummaryIndexForFile(
+  CGOpts.ThinLTOIndexFile,
+  [&](const DiagnosticInfo ) { M->getContext().diagnose(DI); });
+  if (std::error_code EC = IndexOrErr.getError()) {
+std::string Error = EC.message();
+errs() << "Error loading index file '" << CGOpts.ThinLTOIndexFile
+   << "': " << Error << "\n";
+return;
+  }
+  std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+
+  auto AddStream = [&](size_t Task) { return std::move(OS); };
+
+  StringMap>
+  ModuleToDefinedGVSummaries;
+  CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
+
+  // FIXME: We could simply import the modules mentioned in the combined index
+  // here.
+  

Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Richard Smith via cfe-commits
On Thu, Jul 14, 2016 at 10:15 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi,
>
> this fires on (at least) usrsctplib [1]:
>
> FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
> ../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15:
> error: taking address of packed member 'time_entered' of class or structure
> 'sctp_state_cookie' may result in an unaligned pointer value
> [-Werror,-Waddress-of-packed-member]
>
> >time_entered,
>
>  ^~~~
> ../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10:
> error: taking address of packed member 'time_entered' of class or structure
> 'sctp_state_cookie' may result in an unaligned pointer value
> [-Werror,-Waddress-of-packed-member]
>   >time_entered,
> sctp_align_unsafe_makecopy,
>^~~~
> 2 errors generated.
>
> The struct looks like so [2]:
>
> struct sctp_state_cookie { /* this is our definition... */
> uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
> struct timeval time_entered; /* the time I built cookie */
>   ...
>
> The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field
> should be aligned as well, right? And while the struct is packed, its
> alignment isn't overwritten (unless the packed attribute does that too, but
> the docs at least don't mention that).
>

The packed attribute does that too.

struct __attribute__((packed)) X {
  unsigned long long a;
};
static_assert(alignof(X) == 1, ""); // does not fire

What __attribute__((packed)) really means is that the minimum alignment is
reduced to 1.


> Should the warning really fire here?
>
> 1:
> https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
> 2:
> https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium=C=1468495044=190
>
> On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rogfer01
>> Date: Thu Jul 14 09:10:43 2016
>> New Revision: 275417
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
>> Log:
>> Diagnose taking address and reference binding of packed members
>>
>> This patch implements PR#22821.
>>
>> Taking the address of a packed member is dangerous since the reduced
>> alignment of the pointee is lost. This can lead to memory alignment
>> faults in some architectures if the pointer value is dereferenced.
>>
>> This change adds a new warning to clang emitted when taking the address
>> of a packed member. A packed member is either a field/data member
>> declared as attribute((packed)) or belonging to a struct/class
>> declared as such. The associated flag is -Waddress-of-packed-member.
>> Conversions (either implicit or via a valid casting) to pointer types
>> with lower or equal alignment requirements (e.g. void* or char*)
>> silence the warning.
>>
>> This change also adds a new error diagnostic when the user attempts to
>> bind a reference to a packed member, regardless of the alignment.
>>
>> Differential Revision: https://reviews.llvm.org/D20561
>>
>>
>>
>> Added:
>> cfe/trunk/test/Sema/address-packed-member-memops.c
>> cfe/trunk/test/Sema/address-packed.c
>> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
>> cfe/trunk/test/SemaCXX/address-packed.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaCast.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaInit.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
>> 09:10:43 2016
>> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>>"dereference of type %1 that was reinterpret_cast from type %0 has
>> undefined "
>>"behavior">,
>>InGroup, DefaultIgnore;
>> +def warn_taking_address_of_packed_member : Warning<
>> +  "taking address of packed member %0 of class or structure %q1 may
>> result in an unaligned pointer value">,
>> +  InGroup>;
>> +def err_binding_reference_to_packed_member : Error<
>> +  "binding reference to packed member %0 of class or structure %q1">;
>>
>>  def err_objc_object_assignment : Error<
>>"cannot assign to class object (%0 invalid)">;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> 

Re: [PATCH] D22069: clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

2016-07-14 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

I additionally have run the check on blender and ITK and the assert did not 
fire.


https://reviews.llvm.org/D22069



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


[PATCH] D22381: cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor

2016-07-14 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, aaron.ballman.
mgehre added a subscriber: cfe-commits.
Herald added subscribers: nemanjai, aemerson.

The code

  struct A {
int x[3];
  };

gets an compiler-generated copy constructor that uses ArraySubscriptExpr (see 
below).
Previously, the check would generate a warning on that copy constructor.
This commit disables the warning on implicitly generated code.
AST:

  |-CXXConstructorDecl 0x337b3c8  col:8 implicit used constexpr A 'void 
(const struct A &) noexcept' inline
  | |-ParmVarDecl 0x337b510  col:8 used 'const struct A &'
  | |-CXXCtorInitializer Field 0x3379238 'x' 'int [3]'
  | | `-ImplicitCastExpr 0x337e158  'int' 
  | |   `-ArraySubscriptExpr 0x337e130  'const int' lvalue
  | | |-ImplicitCastExpr 0x337e118  'const int *' 

  | | | `-MemberExpr 0x337dfc8  'int const[3]' lvalue .x 0x3379238
  | | |   `-DeclRefExpr 0x337dfa0  'const struct A' lvalue ParmVar 
0x337b510 '' 'const struct A &'
  | | `-ImplicitCastExpr 0x337e098  'unsigned long' 
  | |   `-DeclRefExpr 0x337e070  'unsigned long' lvalue Var 
0x337e010 '__i0' 'unsigned long'

https://reviews.llvm.org/D22381

Files:
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
@@ -74,3 +74,14 @@
   int i = 0;
   s[i] = 3; // OK, custom operator
 }
+
+struct A {
+  // The compiler-generated copy constructor uses an ArraySubscriptExpr. Don't 
warn.
+  int x[3];
+};
+
+void use_A() {
+  // Force the compiler to generate a copy constructor.
+  A a;
+  A a2(a);
+}
Index: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -45,9 +45,12 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
+  // Note: if a struct contains an array member, the compiler-generated
+  // constructor has an arraySubscriptExpr.
   Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
 
constantArrayType().bind("type",
-hasIndex(expr().bind("index")))
+hasIndex(expr().bind("index")),
+unless(hasAncestor(isImplicit(
  .bind("expr"),
  this);
 


Index: test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
@@ -74,3 +74,14 @@
   int i = 0;
   s[i] = 3; // OK, custom operator
 }
+
+struct A {
+  // The compiler-generated copy constructor uses an ArraySubscriptExpr. Don't warn.
+  int x[3];
+};
+
+void use_A() {
+  // Force the compiler to generate a copy constructor.
+  A a;
+  A a2(a);
+}
Index: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -45,9 +45,12 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
+  // Note: if a struct contains an array member, the compiler-generated
+  // constructor has an arraySubscriptExpr.
   Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
 constantArrayType().bind("type",
-hasIndex(expr().bind("index")))
+hasIndex(expr().bind("index")),
+unless(hasAncestor(isImplicit(
  .bind("expr"),
  this);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275466 - [arcmt/objcmt] Fix ParentMap crash with invalid code.

2016-07-14 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Jul 14 15:21:16 2016
New Revision: 275466

URL: http://llvm.org/viewvc/llvm-project?rev=275466=rev
Log:
[arcmt/objcmt] Fix ParentMap crash with invalid code.

rdar://22489560

Added:
cfe/trunk/test/ARCMT/objcmt-invalid-code.mm
cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result
Modified:
cfe/trunk/lib/AST/ParentMap.cpp

Modified: cfe/trunk/lib/AST/ParentMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ParentMap.cpp?rev=275466=275465=275466=diff
==
--- cfe/trunk/lib/AST/ParentMap.cpp (original)
+++ cfe/trunk/lib/AST/ParentMap.cpp Thu Jul 14 15:21:16 2016
@@ -28,6 +28,8 @@ enum OpaqueValueMode {
 
 static void BuildParentMap(MapTy& M, Stmt* S,
OpaqueValueMode OVMode = OV_Transparent) {
+  if (!S)
+return;
 
   switch (S->getStmtClass()) {
   case Stmt::PseudoObjectExprClass: {

Added: cfe/trunk/test/ARCMT/objcmt-invalid-code.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-invalid-code.mm?rev=275466=auto
==
--- cfe/trunk/test/ARCMT/objcmt-invalid-code.mm (added)
+++ cfe/trunk/test/ARCMT/objcmt-invalid-code.mm Thu Jul 14 15:21:16 2016
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals 
-objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
-verify-transformed-files %s.result
+
+// Make sure there is no crash.
+
+@interface NSObject @end
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+void foo(int x = undeclared) { // expected-error {{undeclared}}
+  NSNumber *n = [NSNumber numberWithInt:1];
+}

Added: cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result?rev=275466=auto
==
--- cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result (added)
+++ cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result Thu Jul 14 15:21:16 2016
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals 
-objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
-verify-transformed-files %s.result
+
+// Make sure there is no crash.
+
+@interface NSObject @end
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+void foo(int x = undeclared) { // expected-error {{undeclared}}
+  NSNumber *n = @1;
+}


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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Hi Nico,


it seems it may be necessary to take into account the actual offset of the 
field in such cases to avoid these kind of false positives.


I reverted the change until I get a better solution.


Thanks,

Roger


From: tha...@google.com  on behalf of Nico Weber 

Sent: 14 July 2016 18:15:42
To: Roger Ferrer Ibanez
Cc: cfe-commits
Subject: Re: r275417 - Diagnose taking address and reference binding of packed 
members

Hi,

this fires on (at least) usrsctplib [1]:

FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  
>time_entered,
   
^~~~
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  >time_entered, 
sctp_align_unsafe_makecopy,
   ^~~~
2 errors generated.

The struct looks like so [2]:

struct sctp_state_cookie { /* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered; /* the time I built cookie */
  ...

The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field should 
be aligned as well, right? And while the struct is packed, its alignment isn't 
overwritten (unless the packed attribute does that too, but the docs at least 
don't mention that). Should the warning really fire here?

1: 
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
2: 
https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium=C=1468495044=190

On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits 
> wrote:
Author: rogfer01
Date: Thu Jul 14 09:10:43 2016
New Revision: 275417

URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
Log:
Diagnose taking address and reference binding of packed members

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
silence the warning.

This change also adds a new error diagnostic when the user attempts to
bind a reference to a packed member, regardless of the alignment.

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



Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 09:10:43 
2016
@@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;
+def err_binding_reference_to_packed_member : Error<
+  "binding reference to packed member %0 of class or structure %q1">;

 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

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

r275464 - Attempt to workaround Windows bots after my previous commit

2016-07-14 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Jul 14 15:08:43 2016
New Revision: 275464

URL: http://llvm.org/viewvc/llvm-project?rev=275464=rev
Log:
Attempt to workaround Windows bots after my previous commit

For some reason it seems the second invocation is getting DMOD_OTHER_H
set to a path with/forward/slashes, but one of the use sites
has\back\slashes. There should be no difference with what was already
there, but for now try to avoid checking those paths.

Modified:
cfe/trunk/test/Index/index-module.m

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275464=275463=275464=diff
==
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Thu Jul 14 15:08:43 2016
@@ -20,7 +20,7 @@ int glob;
 // CHECK-NOT: [indexDeclaration]
 
 // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
-// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
+// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD-AST
 
 // CHECK-DMOD:  [startedTranslationUnit]
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
@@ -31,7 +31,6 @@ int glob;
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
 | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | 
isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: 
DependsOnModule.Private.DependsOnModule
 // CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm 
| loc: [[DMOD_MODULE_H]]:1:1 | name: "Module" | isImplicit: 1
-//
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template | 
{{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework | 
{{.*}} | loc: [[DMOD_SUB_H]]:2:8
@@ -39,6 +38,8 @@ int glob;
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
 // CHECK-DMOD-NOT: [indexDeclaration]
 
+// CHECK-DMOD-AST: [importedASTFile]: {{.*}}.cache.sys{{[/\\]}}Module.pcm | 
loc: {{.*}}DependsOnModule.h:1:1 | name: "Module" | isImplicit: 1
+
 // RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s 
-check-prefix=CHECK-TMOD
 
 // CHECK-TMOD:  [startedTranslationUnit]


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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Reverted.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


r275462 - Reverting 275417

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Jul 14 15:05:30 2016
New Revision: 275462

URL: http://llvm.org/viewvc/llvm-project?rev=275462=rev
Log:
Reverting 275417

This change has triggered unexpected failures.


Removed:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275462=275461=275462=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 15:05:30 
2016
@@ -5425,11 +5425,6 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
-def warn_taking_address_of_packed_member : Warning<
-  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
-  InGroup>;
-def err_binding_reference_to_packed_member : Error<
-  "binding reference to packed member %0 of class or structure %q1">;
 
 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275462=275461=275462=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 15:05:30 2016
@@ -9518,10 +9518,6 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);
 
-  /// \brief Check if we are taking the address of a packed field
-  /// as this may be a problem if the pointer value is dereferenced.
-  void CheckAddressOfPackedMember(Expr *rhs);
-
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9600,51 +9596,6 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
-
-private:
-  /// \brief Helper class that collects misaligned member designations and
-  /// their location info for delayed diagnostics.
-  struct MisalignedMember {
-Expr *E;
-RecordDecl *RD;
-ValueDecl *MD;
-CharUnits Alignment;
-
-MisalignedMember() : E(), RD(), MD(), Alignment() {}
-MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
- CharUnits Alignment)
-: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
-explicit MisalignedMember(Expr *E)
-: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
-
-bool operator==(const MisalignedMember ) { return this->E == m.E; }
-  };
-  /// \brief Small set of gathered accesses to potentially misaligned members
-  /// due to the packed attribute.
-  SmallVector MisalignedMembers;
-
-  /// \brief Adds an expression to the set of gathered misaligned members.
-  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
- CharUnits Alignment);
-
-public:
-  /// \brief Diagnoses the current set of gathered accesses. This typically
-  /// happens at full expression level. The set is cleared after emitting the
-  /// diagnostics.
-  void DiagnoseMisalignedMembers();
-
-  /// \brief This function checks if the expression is in the sef of 
potentially
-  /// misaligned members and it is converted to some pointer type T with lower
-  /// or equal alignment requirements.  If so it removes it. This is used when
-  /// we do not want to diagnose such misaligned access (e.g. in conversions 
to void*).
-  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
-
-  /// \brief This function calls Action when it determines that E designates a
-  /// misaligned member due to the packed attribute. This is used to emit
-  /// local diagnostics like in reference binding.
-  void RefersToMemberWithReducedAlignment(
-  Expr *E,
-  std::function 
Action);
 };
 
 /// \brief RAII object that enters a new expression evaluation context.

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=275462=275461=275462=diff

Re: [PATCH] D22190: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-14 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275461: cppcoreguidelines-pro-bounds-constant-array-index: 
crash for value dependent… (authored by mgehre).

Changed prior to commit:
  https://reviews.llvm.org/D22190?vs=63795=64030#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22190

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp

Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -65,6 +65,10 @@
 const MatchFinder::MatchResult ) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s 
-checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | 
count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -65,6 +65,10 @@
 const MatchFinder::MatchResult ) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s -checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r275461 - cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-14 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Thu Jul 14 15:00:48 2016
New Revision: 275461

URL: http://llvm.org/viewvc/llvm-project?rev=275461=rev
Log:
cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent 
index in c++03 mode

Summary:
When the expression is value dependent,
isIntegerConstantExpr() crashes in C++03 mode with
 ../tools/clang/lib/AST/ExprConstant.cpp:9330: (anonymous namespace)::ICEDiag 
CheckICE(const clang::Expr *, const clang::ASTContext &):
  Assertion `!E->isValueDependent() && "Should not see value dependent exprs!"' 
failed.
In C++11 mode, that assert does not trigger.

This commit works around this in the check. We don't check
value-dependent indices and instead check their specialization.

Reviewers: alexfh, aaron.ballman

Subscribers: nemanjai, cfe-commits

Differential Revision: http://reviews.llvm.org/D22190

Added:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=275461=275460=275461=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 Thu Jul 14 15:00:48 2016
@@ -65,6 +65,10 @@ void ProBoundsConstantArrayIndexCheck::c
 const MatchFinder::MatchResult ) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {

Added: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c%2B%2B03.cpp?rev=275461=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
 Thu Jul 14 15:00:48 2016
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s 
-checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | 
count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};


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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Yes I will revert this ASAP.


Sorry for the fuss.


From: Aaron Ballman 
Sent: 14 July 2016 19:30:58
To: reviews+d20561+public+af1fea8a731d8...@reviews.llvm.org
Cc: Roger Ferrer Ibanez; Richard Smith; James Y Knight; Evgenii Stepanov; 
cfe-commits
Subject: Re: [PATCH] D20561: Warn when taking address of packed member

Roger, can you please revert? This seems to have caused some pain for
our users, and it would be good to unblock them while deciding what to
do about the issues.

~Aaron

On Thu, Jul 14, 2016 at 2:19 PM, James Y Knight  wrote:
> jyknight added a comment.
>
> Regardless, I think this should not have added a new un-disableable error, 
> but instead only a default-on warning.
>
> The ""binding reference to packed member" error is firing on some of our 
> code, and even if it's not a false-positive, it should be possible to disable 
> it until the code is modified.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D20561
>
>
>

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275460 - When importing classes and structs with anonymous structs, it is critical that

2016-07-14 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Thu Jul 14 14:53:44 2016
New Revision: 275460

URL: http://llvm.org/viewvc/llvm-project?rev=275460=rev
Log:
When importing classes and structs with anonymous structs, it is critical that
distinct anonymous structs remain distinct despite having similar layout.

This is already ensured by distinguishing based on their placement in the parent
struct, using the function `findAnonymousStructOrUnionIndex`.

The problem is that this function only handles anonymous structs, like
```
class Foo { struct { int a; } }
```
and not untagged structs like
```
class Foo { struct { int a; } var; }
```
Both need to be handled, and this patch fixes that.  The test case ensures that 
this functionality doesn't regress.

Thanks to Manman Ren for review.

https://reviews.llvm.org/D22270

Added:
cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp
cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp
cfe/trunk/test/ASTMerge/anonymous-fields.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=275460=275459=275460=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Jul 14 14:53:44 2016
@@ -1029,7 +1029,7 @@ static bool IsStructurallyEquivalent(Str
 /// including the next assigned index (if none of them match). Returns an
 /// empty option if the context is not a record, i.e.. if the anonymous
 /// struct/union is at namespace or block scope.
-static Optional findAnonymousStructOrUnionIndex(RecordDecl *Anon) {
+static Optional findUntaggedStructOrUnionIndex(RecordDecl *Anon) {
   ASTContext  = Anon->getASTContext();
   QualType AnonTy = Context.getRecordType(Anon);
 
@@ -1040,13 +1040,29 @@ static Optional findAnonymousS
   unsigned Index = 0;
   for (const auto *D : Owner->noload_decls()) {
 const auto *F = dyn_cast(D);
-if (!F || !F->isAnonymousStructOrUnion())
+if (!F)
   continue;
 
-if (Context.hasSameType(F->getType(), AnonTy))
-  break;
+if (F->isAnonymousStructOrUnion()) {
+  if (Context.hasSameType(F->getType(), AnonTy))
+break;
+  ++Index;
+  continue;
+}
 
-++Index;
+// If the field looks like this:
+// struct { ... } A;
+QualType FieldType = F->getType();
+if (const auto *RecType = dyn_cast(FieldType)) {
+  const RecordDecl *RecDecl = RecType->getDecl();
+  if (RecDecl->getDeclContext() == Owner &&
+  !RecDecl->getIdentifier()) {
+if (Context.hasSameType(FieldType, AnonTy))
+  break;
+++Index;
+continue;
+  }
+}
   }
 
   return Index;
@@ -1068,8 +1084,8 @@ static bool IsStructurallyEquivalent(Str
   if (D1->isAnonymousStructOrUnion() && D2->isAnonymousStructOrUnion()) {
 // If both anonymous structs/unions are in a record context, make sure
 // they occur in the same location in the context records.
-if (Optional Index1 = findAnonymousStructOrUnionIndex(D1)) {
-  if (Optional Index2 = findAnonymousStructOrUnionIndex(D2)) {
+if (Optional Index1 = findUntaggedStructOrUnionIndex(D1)) {
+  if (Optional Index2 = findUntaggedStructOrUnionIndex(D2)) {
 if (*Index1 != *Index2)
   return false;
   }
@@ -2749,9 +2765,9 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   // If both anonymous structs/unions are in a record context, make 
sure
   // they occur in the same location in the context records.
   if (Optional Index1
-  = findAnonymousStructOrUnionIndex(D)) {
+  = findUntaggedStructOrUnionIndex(D)) {
 if (Optional Index2 =
-findAnonymousStructOrUnionIndex(FoundRecord)) {
+findUntaggedStructOrUnionIndex(FoundRecord)) {
   if (*Index1 != *Index2)
 continue;
 }

Added: cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp?rev=275460=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp (added)
+++ cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp Thu Jul 14 14:53:44 
2016
@@ -0,0 +1,5 @@
+class A {
+public:
+  struct { int foo; } f;
+  struct { int foo; } g;
+};

Added: cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp?rev=275460=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp (added)
+++ cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp Thu Jul 14 14:53:44 
2016
@@ -0,0 +1,9 @@
+class A {
+public:
+  struct { int foo; } f;
+  struct { int foo; } g;
+};
+
+inline int useA(A ) {

Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Teresa Johnson via cfe-commits
tejohnson added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:740
@@ +739,3 @@
+  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
+ImportList);
+

mehdi_amini wrote:
> This should go away at some point right?
> Just to double check if my memory is correct: the linker plugin will emit the 
> import decision and the backend will take it as an input instead of 
> recomputing anything?
The way they are passed down is via the individual combined index. So it simply 
computes via what is in the index, which will only include summaries for what 
should be imported. I suppose we could make the logic even simpler tho and just 
blindly import what is in the index. 

Peter, can you add a fixme? 


https://reviews.llvm.org/D21545



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


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64027.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Forgot to add asserts for main() in the testcase.


https://reviews.llvm.org/D22237



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


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64025.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:740
@@ +739,3 @@
+  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
+ImportList);
+

This should go away at some point right?
Just to double check if my memory is correct: the linker plugin will emit the 
import decision and the backend will take it as an input instead of recomputing 
anything?


https://reviews.llvm.org/D21545



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


Re: [PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

2016-07-14 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

Ping.


https://reviews.llvm.org/D21537



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


Re: [PATCH] D22290: [PATCH 2/2] [Driver] Compute effective target triples once per job (NFCI)

2016-07-14 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 64023.
vsk added a comment.

- Addressed Paul's comment: added a release note about this.
- Rebased onto master to pick up an Xray change.


https://reviews.llvm.org/D22290

Files:
  docs/ReleaseNotes.rst
  include/clang/Driver/Driver.h
  include/clang/Driver/SanitizerArgs.h
  include/clang/Driver/Tool.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h

Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -60,7 +60,8 @@
const InputInfoList ,
const ToolChain *AuxToolChain) const;
 
-  void AddAArch64TargetArgs(const llvm::opt::ArgList ,
+  void AddAArch64TargetArgs(const llvm::Triple ,
+const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
   void AddARMTargetArgs(const llvm::Triple ,
 const llvm::opt::ArgList ,
@@ -115,6 +116,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -132,6 +134,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -159,6 +162,7 @@
   bool hasIntegratedAssembler() const override { return true; }
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 
@@ -218,6 +222,7 @@
llvm::opt::ArgStringList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -233,6 +238,7 @@
llvm::opt::ArgStringList ) const;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -247,6 +253,7 @@
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -262,6 +269,7 @@
   bool hasIntegratedCPP() const override;
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -323,6 +331,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -362,6 +371,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -382,6 +392,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -394,6 +405,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -408,6 +420,7 @@
 
   void ConstructJob(Compilation , const JobAction ,
 const InputInfo , const InputInfoList ,
+const llvm::Triple ,
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
@@ -421,6 +434,7 @@

r275454 - [index] Index system ImportDecls even when there is a DeclarationsOnly filter

2016-07-14 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Jul 14 13:51:55 2016
New Revision: 275454

URL: http://llvm.org/viewvc/llvm-project?rev=275454=rev
Log:
[index] Index system ImportDecls even when there is a DeclarationsOnly filter

Whether we call an ImportDecl a decl or a reference symbol role is
somewhat academic, but in practice it's more like a declaration because
it is interesting even to consumers who wouldn't care about references.
Most importantly, we want to report the module dependencies of system
modules even when we have declaration-only filtering.

rdar://problem/27134855

Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-with-module.m
cfe/trunk/test/Index/index-module.m

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=275454=275453=275454=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Thu Jul 14 13:51:55 2016
@@ -83,14 +83,14 @@ bool IndexingContext::importedModule(con
   if (SEntry.getFile().getFileCharacteristic() != SrcMgr::C_User) {
 switch (IndexOpts.SystemSymbolFilter) {
 case IndexingOptions::SystemSymbolFilterKind::None:
-case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly:
   return true;
+case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly:
 case IndexingOptions::SystemSymbolFilterKind::All:
   break;
 }
   }
 
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
+  SymbolRoleSet Roles = (unsigned)SymbolRole::Declaration;
   if (ImportD->isImplicit())
 Roles |= (unsigned)SymbolRole::Implicit;
 

Modified: cfe/trunk/test/Index/Core/index-with-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-with-module.m?rev=275454=275453=275454=diff
==
--- cfe/trunk/test/Index/Core/index-with-module.m (original)
+++ cfe/trunk/test/Index/Core/index-with-module.m Thu Jul 14 13:51:55 2016
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t.mcp
 // RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module 
-fmodules -fmodules-cache-path=%t.mcp | FileCheck %s
 
-// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref |
+// CHECK: [[@LINE+1]]:9 | module/C | ModA | Decl |
 @import ModA;
-// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl |
+// CHECK: [[@LINE+1]]:1 | module/C | ModA | Decl,Impl |
 #include "ModA.h"
 
 void foo() {
   // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | 
Ref,Call,RelCall | rel: 1
   ModA_func();
-}
\ No newline at end of file
+}

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275454=275453=275454=diff
==
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Thu Jul 14 13:51:55 2016
@@ -6,6 +6,8 @@ int glob;
 // RUN: rm -rf %t.cache
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F 
%S/../Modules/Inputs \
 // RUN:  -Xclang -fdisable-module-hash | FileCheck %s
+// RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache.sys 
-fmodules -iframework %S/../Modules/Inputs \
+// RUN:  -Xclang -fdisable-module-hash | FileCheck %s
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules 
-gmodules -F %S/../Modules/Inputs \
 // RUN:  -Xclang -fdisable-module-hash | FileCheck %s
 
@@ -18,6 +20,7 @@ int glob;
 // CHECK-NOT: [indexDeclaration]
 
 // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
+// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
 
 // CHECK-DMOD:  [startedTranslationUnit]
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
@@ -27,7 +30,8 @@ int glob;
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule.SubFramework
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
 | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | 
isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: 
DependsOnModule.Private.DependsOnModule
-// 

Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread Aaron Ballman via cfe-commits
Roger, can you please revert? This seems to have caused some pain for
our users, and it would be good to unblock them while deciding what to
do about the issues.

~Aaron

On Thu, Jul 14, 2016 at 2:19 PM, James Y Knight  wrote:
> jyknight added a comment.
>
> Regardless, I think this should not have added a new un-disableable error, 
> but instead only a default-on warning.
>
> The ""binding reference to packed member" error is firing on some of our 
> code, and even if it's not a false-positive, it should be possible to disable 
> it until the code is modified.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D20561
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21749: Changes related to new implementation of tooling::Replacements as class.

2016-07-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 64015.
ioeric added a comment.

- merged with origin/master
- Addressed reviewer's comments in the corresponding patch.


https://reviews.llvm.org/D21749

Files:
  
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  include-fixer/IncludeFixer.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  tool-template/ToolTemplate.cpp
  unittests/clang-tidy/ClangTidyTest.h
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -89,18 +89,28 @@
   runOnCode(, Code, FakeFileName, ExtraArgs);
   if (FixerContext.getHeaderInfos().empty())
 return Code;
-  auto Replaces = clang::include_fixer::createInsertHeaderReplacements(
+  auto ReplacesOrError = clang::include_fixer::createInsertHeaderReplacements(
   Code, FakeFileName, FixerContext.getHeaderInfos().front().Header);
-  EXPECT_TRUE(static_cast(Replaces))
-  << llvm::toString(Replaces.takeError()) << "\n";
-  if (!Replaces)
+  EXPECT_TRUE(static_cast(ReplacesOrError))
+  << llvm::toString(ReplacesOrError.takeError()) << "\n";
+  if (!ReplacesOrError)
 return "";
+  auto Replaces = std::move(*ReplacesOrError);
+  auto R = tooling::Replacement(
+  FakeFileName, FixerContext.getSymbolRange().getOffset(),
+  FixerContext.getSymbolRange().getLength(),
+  FixerContext.getHeaderInfos().front().QualifiedName);
+  auto Err = Replaces.add(R);
+  if (Err) {
+llvm::consumeError(std::move(Err));
+R = tooling::Replacement(R.getFilePath(),
+ Replaces.getShiftedCodePosition(R.getOffset()),
+ R.getLength(), R.getReplacementText());
+Replaces = Replaces.merge(tooling::Replacements(R));
+  }
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
-  Replaces->insert({FakeFileName, FixerContext.getSymbolRange().getOffset(),
-FixerContext.getSymbolRange().getLength(),
-FixerContext.getHeaderInfos().front().QualifiedName});
-  clang::tooling::applyAllReplacements(*Replaces, Context.Rewrite);
+  EXPECT_TRUE(clang::tooling::applyAllReplacements(Replaces, Context.Rewrite));
   return Context.getRewrittenText(ID);
 }
 
Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -119,7 +119,14 @@
   DiagConsumer.finish();
   tooling::Replacements Fixes;
   for (const ClangTidyError  : Context.getErrors())
-Fixes.insert(Error.Fix.begin(), Error.Fix.end());
+for (const auto  : Error.Fix) {
+  auto Err = Fixes.add(Fix);
+  // FIXME: better error handling.
+  if (Err) {
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+return "";
+  }
+}
   if (Errors)
 *Errors = Context.getErrors();
   auto Result = tooling::applyAllReplacements(Code, Fixes);
Index: tool-template/ToolTemplate.cpp
===
--- tool-template/ToolTemplate.cpp
+++ tool-template/ToolTemplate.cpp
@@ -53,18 +53,20 @@
 
 namespace {
 class ToolTemplateCallback : public MatchFinder::MatchCallback {
- public:
-  ToolTemplateCallback(Replacements *Replace) : Replace(Replace) {}
+public:
+  ToolTemplateCallback(std::map *Replace)
+  : Replace(Replace) {}
 
   void run(const MatchFinder::MatchResult ) override {
-// TODO: This routine will get called for each thing that the matchers find.
+// TODO: This routine will get called for each thing that the matchers
+// find.
 // At this point, you can examine the match, and do whatever you want,
 // including replacing the matched text with other text
 (void)Replace; // This to prevent an "unused member variable" warning;
   }
 
- private:
-  Replacements *Replace;
+private:
+  std::map *Replace;
 };
 } // end anonymous namespace
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -262,12 +262,14 @@
   return 1;
 }
 
-auto Replacements = clang::include_fixer::createInsertHeaderReplacements(
+// FIXME: pull code for generating header insertion and namespace insertion
+// replacements into a function since similar stuff is performed below.
+auto 

Re: r275040 - [CodeGen] Treat imported static local variables as declarations

2016-07-14 Thread David Blaikie via cfe-commits
On Tue, Jul 12, 2016 at 3:51 PM David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Jul 12, 2016 at 2:55 PM, Robinson, Paul 
> wrote:
>
>> A declaration that gets used within the CU generally does get a
>> debug-info description.
>>
>
> It does except if it is a static data member:
> $ cat t.cpp
> struct S {
>   static int i;
> };
> int  = ::i;
> $ ~/llvm/Debug+Asserts/bin/clang t.cpp -target x86_64-gnu-linux -g -S
> -emit-llvm -o -
> ; ModuleID = 't.cpp'
> source_filename = "t.cpp"
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64--linux-gnu"
>
> @_ZN1S1iE = external global i32, align 4
> @gv = global i32* @_ZN1S1iE, align 8
>
> !llvm.dbg.cu = !{!0}
> !llvm.module.flags = !{!7, !8}
> !llvm.ident = !{!9}
>
> !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
> producer: "clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)",
> isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2,
> globals: !3)
> !1 = !DIFile(filename: "t.cpp", directory:
> "/usr/local/google/home/majnemer")
> !2 = !{}
> !3 = !{!4}
> !4 = distinct !DIGlobalVariable(name: "gv", scope: !0, file: !1, line: 4,
> type: !5, isLocal: false, isDefinition: true, variable: i32** @gv)
> !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64,
> align: 64)
> !6 = !DIBasicType(name: "int", size: 32, align: 32, encoding:
> DW_ATE_signed)
> !7 = !{i32 2, !"Dwarf Version", i32 4}
> !8 = !{i32 2, !"Debug Info Version", i32 3}
> !9 = !{!"clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)"}
>
> Note that there is no DIGlobalVariable for S::i.  I agree that this is not
> great behavior.  I merely changed a dllimport'd template instantiation of a
> static data member to behave the same way, poor, way a declaration is
> treated.
>

Yep, in theory (if anyone's interested) we could add such types to the
retained types list (that's what it's there for - when a type not
referenced from the debug info graph (variables, parameters, etc) is still
used).

I'm not too fussed by this. Mostly it's going to hit traits classes (that
don't have other members) that are careful to have no odr uses, so they
don't have a real definition anywhere. (or uses of -fstandalone-debug,
where the TU containing the definition is compiled without debug info, etc)

- Dave


>
>
>> I think no DWARF-using target has dllimport (yet) so you are actually
>> handling a new situation here.  Being unable to find the entity in the
>> dllimport-using CU is not a friendly debugging experience.
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Tuesday, July 12, 2016 2:07 PM
>>
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Jul 12, 2016 at 2:02 PM, Robinson, Paul 
>> wrote:
>>
>> I was asking for the debug info to describe the entity as a declaration,
>> rather than a definition.
>>
>> Instead you eliminated the debug-info description entirely.  These are
>> pretty different things.
>>
>>
>>
>> I treated the dllimported entity the same way we currently treat
>> declarations: ignore them.
>>
>> I don't have the bandwidth to generically improve debug info beyond what
>> we can do for DWARF/GDB targets.
>>
>>
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Monday, July 11, 2016 12:27 PM
>>
>>
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Jul 11, 2016 at 11:45 AM, Robinson, Paul 
>> wrote:
>>
>> It was not particularly obvious that by "static local variables" you
>> actually meant "template static data members."
>>
>> Now I can tell that this is not addressing what I was asking about in the
>> comment on r274986.
>>
>>
>>
>> I'm not sure I understand.  How is this not addressing what you are
>> asking for?  We will no longer emit a DIGlobalVariable for the imported
>> static data member.
>>
>>
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Monday, July 11, 2016 9:53 AM
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Jul 11, 2016 at 9:48 AM, Robinson, Paul 
>> wrote:
>>
>> This changes the IR but not the debug-info metadata?
>> --paulr
>>
>>
>>
>> The net effect is that the debug-info metadata is not generated for such
>> static members.
>>
>>
>>
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf Of
>> > David Majnemer via cfe-commits
>> > 

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 64016.
ioeric marked 6 inline comments as done.
ioeric added a comment.

- Merge branch 'master' of http://llvm.org/git/clang into replace
- Addressed reviewer's comments.


https://reviews.llvm.org/D21748

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/TokenAnalyzer.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  lib/Tooling/RefactoringCallbacks.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp
  unittests/Tooling/RewriterTest.cpp

Index: unittests/Tooling/RewriterTest.cpp
===
--- unittests/Tooling/RewriterTest.cpp
+++ unittests/Tooling/RewriterTest.cpp
@@ -39,8 +39,11 @@
 
 TEST(Rewriter, AdjacentInsertAndDelete) {
   Replacements Replaces;
-  Replaces.insert(Replacement("", 6, 6, ""));
-  Replaces.insert(Replacement("", 6, 0, "replaced\n"));
+  auto Err = Replaces.add(Replacement("", 6, 6, ""));
+  EXPECT_TRUE(!Err);
+  Replaces =
+  Replaces.merge(Replacements(Replacement("", 6, 0, "replaced\n")));
+
   auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces);
   EXPECT_TRUE(static_cast(Rewritten));
   EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten);
Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -109,62 +109,72 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+static Replacements toReplacements(const std::set ) {
+  Replacements Result;
+  for (const auto  : Replaces) {
+auto Err = Result.add(R);
+EXPECT_TRUE(!Err);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return Replacements();
+}
+  }
+  return Result;
+}
+
+TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),
-  5, "other"));
-  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
+  auto Err = Replaces.add(Replacement("x.cc", 0, 10, "3"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
 }
 
-// FIXME: Remove this test case when Replacements is implemented as std::vector
-// instead of std::set. The other ReplacementTest tests will need to be updated
-// at that point as well.
-TEST_F(ReplacementTest, VectorCanApplyReplacements) {
+TEST_F(ReplacementTest, CanApplyReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  std::vector Replaces;
-  Replaces.push_back(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
- 5, "replaced"));
-  Replaces.push_back(
-  Replacement(Context.Sources, Context.getLocation(ID, 3, 1), 5, "other"));
+  Replacements Replaces =
+  toReplacements({Replacement(Context.Sources,
+  Context.getLocation(ID, 2, 1), 5, "replaced"),
+  Replacement(Context.Sources,
+  Context.getLocation(ID, 3, 1), 5, "other")});
   EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
   EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, SkipsDuplicateReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
+  auto Replaces = toReplacements({Replacement(
+  Context.Sources, 

Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread James Y Knight via cfe-commits
jyknight added a comment.

Regardless, I think this should not have added a new un-disableable error, but 
instead only a default-on warning.

The ""binding reference to packed member" error is firing on some of our code, 
and even if it's not a false-positive, it should be possible to disable it 
until the code is modified.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-14 Thread Sanjay Patel via cfe-commits
spatel added a comment.

Hi Matt -

This looks like the right first step in the path that Hal suggested, except I 
think we need a test case for each function that you want to enable. Please see 
test/Transforms/LoopVectorize/X86/veclib-calls.ll as a reference for how to do 
that.


https://reviews.llvm.org/D19544



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread James Y Knight via cfe-commits
jyknight added a subscriber: jyknight.
jyknight added a comment.

This seems to trigger even for the implicitly generated copier of a packed 
struct. E.g.

  #include 
  
  void copyit(epoll_event, const epoll_event ) {
out = in;
  }

Is that as intended?


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-14 Thread Matt via cfe-commits
mmasten added a comment.

Hello all,

Just wanted to see if you guys have some time to review.

Thanks,

Matt


https://reviews.llvm.org/D19544



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein added a comment.

+Daniel who suggests this feature ;)


https://reviews.llvm.org/D22351



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


Re: [PATCH] D22248: [Sema] Create a separate group for incompatible function pointer warning

2016-07-14 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D22248



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


r275440 - Despite there being an option, it seems that Sphinx has decided that "=123" is part of the option directive name, and so having "=0" in the option tag is problematic. Since the option tag is

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 12:15:06 2016
New Revision: 275440

URL: http://llvm.org/viewvc/llvm-project?rev=275440=rev
Log:
Despite there being an option, it seems that Sphinx has decided that "=123" is 
part of the option directive name, and so having "=0" in the option tag is 
problematic. Since the option tag is part of the option directive definition, 
it's superfluous, and so I've removed it.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=275440=275439=275440=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Jul 14 12:15:06 2016
@@ -133,13 +133,13 @@ Options to Control Error and Warning Mes
 .. option:: -ferror-limit=123
 
   Stop emitting diagnostics after 123 errors have been produced. The default is
-  20, and the error limit can be disabled with :option:`-ferror-limit=0`.
+  20, and the error limit can be disabled with `-ferror-limit=0`.
 
 .. option:: -ftemplate-backtrace-limit=123
 
   Only emit up to 123 template instantiation notes within the template
   instantiation backtrace for a single warning or error. The default is 10, and
-  the limit can be disabled with :option:`-ftemplate-backtrace-limit=0`.
+  the limit can be disabled with `-ftemplate-backtrace-limit=0`.
 
 .. _cl_diag_formatting:
 


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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 64004.
hokein added a comment.

Add an option to make move-cursor configurable.


https://reviews.llvm.org/D22351

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

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,13 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 
+if jump_to_include:
+  # Set cursor to the #include line.
+  include_header = "#include " + header["HeaderInfos"][0]["Header"]
+  line_num = lines.index(include_header) + 1
+  vim.current.window.cursor = (line_num, 0)
+
 
 def main():
   parser = argparse.ArgumentParser(
@@ -128,22 +140,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print "Couldn't find a header for {0}.\n".format(symbol)
-return
-
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
+print "Couldn't find a header for {0}.".format(symbol)
 return
 
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print "Added #include {0} for {1}.".format(unique_headers[0], symbol)
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +165,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": selected_header_infos}, text)
-print "Added #include {0} for {1}.\n".format(selected, symbol)
+print "Added #include {0} for {1}.".format(selected, symbol)
   except Exception as error:
 print >> sys.stderr, error.message
   return


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,13 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 
+if jump_to_include:
+  # Set cursor to the #include line.
+  include_header = "#include " + header["HeaderInfos"][0]["Header"]
+  line_num = lines.index(include_header) + 1
+  vim.current.window.cursor = (line_num, 0)
+
 
 def main():
   parser = argparse.ArgumentParser(
@@ -128,22 +140,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print 

Re: [PATCH] D22290: [PATCH 2/2] [Driver] Compute effective target triples once per job (NFCI)

2016-07-14 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

On the thread you suggested it would affect out-of-tree targets, so this 
probably deserves a release note?


https://reviews.llvm.org/D22290



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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Nico Weber via cfe-commits
Hi,

this fires on (at least) usrsctplib [1]:

FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15:
error: taking address of packed member 'time_entered' of class or structure
'sctp_state_cookie' may result in an unaligned pointer value
[-Werror,-Waddress-of-packed-member]

>time_entered,

 ^~~~
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10:
error: taking address of packed member 'time_entered' of class or structure
'sctp_state_cookie' may result in an unaligned pointer value
[-Werror,-Waddress-of-packed-member]
  >time_entered,
sctp_align_unsafe_makecopy,
   ^~~~
2 errors generated.

The struct looks like so [2]:

struct sctp_state_cookie { /* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered; /* the time I built cookie */
  ...

The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field
should be aligned as well, right? And while the struct is packed, its
alignment isn't overwritten (unless the packed attribute does that too, but
the docs at least don't mention that). Should the warning really fire here?

1:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
2:
https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium=C=1468495044=190

On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rogfer01
> Date: Thu Jul 14 09:10:43 2016
> New Revision: 275417
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
> Log:
> Diagnose taking address and reference binding of packed members
>
> This patch implements PR#22821.
>
> Taking the address of a packed member is dangerous since the reduced
> alignment of the pointee is lost. This can lead to memory alignment
> faults in some architectures if the pointer value is dereferenced.
>
> This change adds a new warning to clang emitted when taking the address
> of a packed member. A packed member is either a field/data member
> declared as attribute((packed)) or belonging to a struct/class
> declared as such. The associated flag is -Waddress-of-packed-member.
> Conversions (either implicit or via a valid casting) to pointer types
> with lower or equal alignment requirements (e.g. void* or char*)
> silence the warning.
>
> This change also adds a new error diagnostic when the user attempts to
> bind a reference to a packed member, regardless of the alignment.
>
> Differential Revision: https://reviews.llvm.org/D20561
>
>
>
> Added:
> cfe/trunk/test/Sema/address-packed-member-memops.c
> cfe/trunk/test/Sema/address-packed.c
> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
> cfe/trunk/test/SemaCXX/address-packed.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
> 09:10:43 2016
> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>"dereference of type %1 that was reinterpret_cast from type %0 has
> undefined "
>"behavior">,
>InGroup, DefaultIgnore;
> +def warn_taking_address_of_packed_member : Warning<
> +  "taking address of packed member %0 of class or structure %q1 may
> result in an unaligned pointer value">,
> +  InGroup>;
> +def err_binding_reference_to_packed_member : Error<
> +  "binding reference to packed member %0 of class or structure %q1">;
>
>  def err_objc_object_assignment : Error<
>"cannot assign to class object (%0 invalid)">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417=275416=275417=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
> @@ -9518,6 +9518,10 @@ private:
>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>  const Expr * const *ExprArgs);
>
> +  /// \brief Check if we are taking the address of a packed field
> +  /// as 

Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Sema/SemaDecl.cpp:6189-6191
@@ -6188,2 +6188,5 @@
 << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+} else if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
 } else {

I'd suggest sorting this condition higher.  It doesn't make much sense to 
mention block scopes when inline variables are prohibited in all contexts in C.


https://reviews.llvm.org/D22113



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! I don't think we intended this to be an extension for C.


https://reviews.llvm.org/D22113



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Paul Robinson via cfe-commits
probinson added a comment.

Ping.


https://reviews.llvm.org/D22113



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


Re: [PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
This revision is now accepted and ready to land.


Comment at: include-fixer/IncludeFixerContext.cpp:54
@@ -49,2 +53,3 @@
 
-  return FullyQualifiedName;
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);

Add a comment that you're trying to find the minimal scope qualifier here.


https://reviews.llvm.org/D22367



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


[PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D22367

Files:
  include-fixer/IncludeFixerContext.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo ) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers;
-  RawSymbolName.split(SymbolQualifiers, "::");
+  auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
@@ -43,11 +50,27 @@
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
 
-  // Skips symbol scoped qualifiers prefix.
-  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
-return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
 
-  return FullyQualifiedName;
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);
+  auto FullySymbolQualifiersIter = FullySymbolQualifiers.begin();
+  auto SymbolScopedQualifiersIter = ScopedQualifiers.begin();
+  // Find and skip the common prefix qualifiers.
+  while (FullySymbolQualifiersIter != FullySymbolQualifiers.end() &&
+ SymbolScopedQualifiersIter != ScopedQualifiers.end()) {
+if (*FullySymbolQualifiersIter != *SymbolScopedQualifiersIter)
+  break;
+++FullySymbolQualifiersIter;
+++SymbolScopedQualifiersIter;
+  }
+  std::string Result;
+  for (; FullySymbolQualifiersIter != FullySymbolQualifiers.end();
+   ++FullySymbolQualifiersIter) {
+if (!Result.empty())
+  Result += "::";
+Result += *FullySymbolQualifiersIter;
+  }
+  return Result;
 }
 
 } // anonymous namespace


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  

Re: [PATCH] D22270: [ASTImporter] Properly report the locations of anonymous structs declared as part of named fields

2016-07-14 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks,
Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D22270



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


Re: [PATCH] D22292: [libunwind] Fix unw_getcontext for ARMv6-m

2016-07-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Update: Almost there, should be able to put it up for review tomorrow.

Cheers,

/ Asiri


https://reviews.llvm.org/D22292



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Manuel Klimek via cfe-commits
klimek added a subscriber: klimek.
klimek added a comment.

+1 to not throwing users around by default. Can we make it configurable if 
folks want it?


https://reviews.llvm.org/D22351



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I'm not entirely sure if jumping cursors are a good user interface. It will 
completely throw the user out of context, which is exactly what we want to 
avoid with include-fixer.


https://reviews.llvm.org/D22351



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


Re: [PATCH] D22359: [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275428: [OpenCL] In test/Driver/opencl.cl, don't require 
name of Clang binary to… (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D22359?vs=63976=63981#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22359

Files:
  cfe/trunk/test/Driver/opencl.cl

Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: 

r275428 - [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 10:06:57 2016
New Revision: 275428

URL: http://llvm.org/viewvc/llvm-project?rev=275428=rev
Log:
[OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to 
contain "clang"

The test currently fails if the name of the Clang binary doesn't contain 
"clang".

This patch removes that requirement, as some environments may choose to run the 
test with a differently named binary. This shouldn't make the test any less 
strict -- the only place where the flags we're searching for can really occur 
is the Clang command line.

Patch by Martin Böhme!

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

Modified:
cfe/trunk/test/Driver/opencl.cl

Modified: cfe/trunk/test/Driver/opencl.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opencl.cl?rev=275428=275427=275428=diff
==
--- cfe/trunk/test/Driver/opencl.cl (original)
+++ cfe/trunk/test/Driver/opencl.cl Thu Jul 14 10:06:57 2016
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


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


[PATCH] D22359: [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: bkramer.
mboehme added a subscriber: cfe-commits.

The test currently fails if the name of the Clang binary doesn't contain 
"clang".

This patch removes that requirement, as some environments may choose to run the 
test with a differently named binary. This shouldn't make the test any less 
strict -- the only place where the flags we're searching for can really occur 
is the Clang command line.

https://reviews.llvm.org/D22359

Files:
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} 

Re: [PATCH] D22310: Make the test for fno-pch-timestamp compatible with read-only checkouts.

2016-07-14 Thread pierre gousseau via cfe-commits
pgousseau closed this revision.
pgousseau added a comment.

Committed in https://reviews.llvm.org/rL275415


https://reviews.llvm.org/D22310



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


r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Jul 14 09:10:43 2016
New Revision: 275417

URL: http://llvm.org/viewvc/llvm-project?rev=275417=rev
Log:
Diagnose taking address and reference binding of packed members

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
silence the warning.

This change also adds a new error diagnostic when the user attempts to
bind a reference to a packed member, regardless of the alignment.

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



Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417=275416=275417=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 09:10:43 
2016
@@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;
+def err_binding_reference_to_packed_member : Error<
+  "binding reference to packed member %0 of class or structure %q1">;
 
 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417=275416=275417=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
@@ -9518,6 +9518,10 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);
 
+  /// \brief Check if we are taking the address of a packed field
+  /// as this may be a problem if the pointer value is dereferenced.
+  void CheckAddressOfPackedMember(Expr *rhs);
+
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9596,6 +9600,51 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
+
+private:
+  /// \brief Helper class that collects misaligned member designations and
+  /// their location info for delayed diagnostics.
+  struct MisalignedMember {
+Expr *E;
+RecordDecl *RD;
+ValueDecl *MD;
+CharUnits Alignment;
+
+MisalignedMember() : E(), RD(), MD(), Alignment() {}
+MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment)
+: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
+explicit MisalignedMember(Expr *E)
+: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
+
+bool operator==(const MisalignedMember ) { return this->E == m.E; }
+  };
+  /// \brief Small set of gathered accesses to potentially misaligned members
+  /// due to the packed attribute.
+  SmallVector MisalignedMembers;
+
+  /// \brief Adds an expression to the set of gathered misaligned members.
+  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment);
+
+public:
+  /// \brief Diagnoses the current set of gathered accesses. This typically
+  /// happens at full expression level. The set is cleared after emitting the
+  /// diagnostics.
+  void DiagnoseMisalignedMembers();
+
+  /// \brief This function checks if the expression is in the sef of 
potentially
+  /// misaligned members and it is converted to some pointer type T 

Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275417: Diagnose taking address and reference binding of 
packed members (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D20561?vs=61089=63970#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20561

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/Sema/address-packed-member-memops.c
  cfe/trunk/test/Sema/address-packed.c
  cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
  cfe/trunk/test/SemaCXX/address-packed.cpp

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -6001,7 +6001,9 @@
   CheckTollFreeBridgeCast(castType, CastExpr);
   
   CheckObjCBridgeRelatedCast(castType, CastExpr);
-  
+
+  DiscardMisalignedMemberAddress(castType.getTypePtr(), CastExpr);
+
   return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
 }
 
@@ -10534,6 +10536,8 @@
   if (op->getType()->isObjCObjectType())
 return Context.getObjCObjectPointerType(op->getType());
 
+  CheckAddressOfPackedMember(op);
+
   return Context.getPointerType(op->getType());
 }
 
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8302,6 +8302,8 @@
 
   DiagnoseNullConversion(S, E, T, CC);
 
+  S.DiscardMisalignedMemberAddress(Target, E);
+
   if (!Source->isIntegerType() || !Target->isIntegerType())
 return;
 
@@ -9371,6 +9373,7 @@
   CheckUnsequencedOperations(E);
   if (!IsConstexpr && !E->isValueDependent())
 CheckForIntOverflow(E);
+  DiagnoseMisalignedMembers();
 }
 
 void Sema::CheckBitFieldInitialization(SourceLocation InitLoc,
@@ -10916,3 +10919,67 @@
 << ArgumentExpr->getSourceRange()
 << TypeTagExpr->getSourceRange();
 }
+
+void Sema::AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment) {
+  MisalignedMembers.emplace_back(E, RD, MD, Alignment);
+}
+
+void Sema::DiagnoseMisalignedMembers() {
+  for (MisalignedMember  : MisalignedMembers) {
+Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
+<< m.MD << m.RD << m.E->getSourceRange();
+  }
+  MisalignedMembers.clear();
+}
+
+void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
+  if (!T->isPointerType())
+return;
+  if (isa(E) &&
+  cast(E)->getOpcode() == UO_AddrOf) {
+auto *Op = cast(E)->getSubExpr()->IgnoreParens();
+if (isa(Op)) {
+  auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
+  MisalignedMember(Op));
+  if (MA != MisalignedMembers.end() &&
+  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+MisalignedMembers.erase(MA);
+}
+  }
+}
+
+void Sema::RefersToMemberWithReducedAlignment(
+Expr *E,
+std::function Action) {
+  const auto *ME = dyn_cast(E);
+  while (ME && isa(ME->getMemberDecl())) {
+QualType BaseType = ME->getBase()->getType();
+if (ME->isArrow())
+  BaseType = BaseType->getPointeeType();
+RecordDecl *RD = BaseType->getAs()->getDecl();
+
+ValueDecl *MD = ME->getMemberDecl();
+bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
+if (ByteAligned) // Attribute packed does not have any effect.
+  break;
+
+if (!ByteAligned &&
+(RD->hasAttr() || (MD->hasAttr( {
+  CharUnits Alignment = std::min(Context.getTypeAlignInChars(MD->getType()),
+ Context.getTypeAlignInChars(BaseType));
+  // Notify that this expression designates a member with reduced alignment
+  Action(E, RD, MD, Alignment);
+  break;
+}
+ME = dyn_cast(ME->getBase());
+  }
+}
+
+void Sema::CheckAddressOfPackedMember(Expr *rhs) {
+  using namespace std::placeholders;
+  RefersToMemberWithReducedAlignment(
+  rhs, std::bind(::AddPotentialMisalignedMembers, std::ref(*this), _1,
+ _2, _3, _4));
+}
+
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -6457,6 +6457,15 @@
   ExtendingEntity->getDecl());
 
   CheckForNullPointerDereference(S, CurInit.get());
+
+  S.RefersToMemberWithReducedAlignment(CurInit.get(), [&](Expr *E,
+  RecordDecl *RD,
+  ValueDecl 

r275416 - Removing more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/1

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 09:07:37 2016
New Revision: 275416

URL: http://llvm.org/viewvc/llvm-project?rev=275416=rev
Log:
Removing more :option: tags that we do not have corresponding .. option 
directives for; these are causing the sphinx bot to fail 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15195/steps/docs-clang-html/logs/stdio).

Modified:
cfe/trunk/docs/ClangPlugins.rst

Modified: cfe/trunk/docs/ClangPlugins.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangPlugins.rst?rev=275416=275415=275416=diff
==
--- cfe/trunk/docs/ClangPlugins.rst (original)
+++ cfe/trunk/docs/ClangPlugins.rst Thu Jul 14 09:07:37 2016
@@ -79,20 +79,20 @@ Using the cc1 command line
 --
 
 To run a plugin, the dynamic library containing the plugin registry must be
-loaded via the :option:`-load` command line option. This will load all plugins
+loaded via the `-load` command line option. This will load all plugins
 that are registered, and you can select the plugins to run by specifying the
-:option:`-plugin` option. Additional parameters for the plugins can be passed 
with
-:option:`-plugin-arg-`.
+`-plugin` option. Additional parameters for the plugins can be passed with
+`-plugin-arg-`.
 
 Note that those options must reach clang's cc1 process. There are two
 ways to do so:
 
-* Directly call the parsing process by using the :option:`-cc1` option; this
+* Directly call the parsing process by using the `-cc1` option; this
   has the downside of not configuring the default header search paths, so
   you'll need to specify the full system path configuration on the command
   line.
 * Use clang as usual, but prefix all arguments to the cc1 process with
-  :option:`-Xclang`.
+  `-Xclang`.
 
 For example, to run the ``print-function-names`` plugin over a source file in
 clang, first build the plugin, and then call clang with the plugin from the
@@ -116,11 +116,11 @@ Also see the print-function-name plugin
 Using the clang command line
 
 
-Using :option:`-fplugin=plugin` on the clang command line passes the plugin
-through as an argument to :option:`-load` on the cc1 command line. If the 
plugin
+Using `-fplugin=plugin` on the clang command line passes the plugin
+through as an argument to `-load` on the cc1 command line. If the plugin
 class implements the ``getActionType`` method then the plugin is run
 automatically. For example, to run the plugin automatically after the main AST
-action (i.e. the same as using :option:`-add-plugin`):
+action (i.e. the same as using `-add-plugin`):
 
 .. code-block:: c++
 


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


Re: [PATCH] D22310: Make the test for fno-pch-timestamp compatible with read-only checkouts.

2016-07-14 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In https://reviews.llvm.org/D22310#484017, @bkramer wrote:

> lg


Thanks for the review!


https://reviews.llvm.org/D22310



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


r275415 - The test added in r275267 does not work on read-only checkouts because of the use of touch -m -t.

2016-07-14 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Thu Jul 14 08:58:27 2016
New Revision: 275415

URL: http://llvm.org/viewvc/llvm-project?rev=275415=rev
Log:
The test added in r275267 does not work on read-only checkouts because of the 
use of touch -m -t.
Following Tom Rybka suggestion, the test files are now copied to a temporary 
directory first.

Modified:
cfe/trunk/test/PCH/include-timestamp.cpp

Modified: cfe/trunk/test/PCH/include-timestamp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/include-timestamp.cpp?rev=275415=275414=275415=diff
==
--- cfe/trunk/test/PCH/include-timestamp.cpp (original)
+++ cfe/trunk/test/PCH/include-timestamp.cpp Thu Jul 14 08:58:27 2016
@@ -1,23 +1,28 @@
 // Test that the timestamp is not included in the produced pch file with
 // -fno-pch-timestamp.
 
+// Copying files allow for read-only checkouts to run this test.
+// RUN: cp %S/Inputs/pragma-once2-pch.h %T
+// RUN: cp %S/Inputs/pragma-once2.h %T
+// RUN: cp %s %t1.cpp
+
 // Check timestamp is included by default.
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h
-// RUN: touch -m -a -t 201008011501 %S/Inputs/pragma-once2.h
-// RUN: not %clang_cc1 -include-pch %t %s 2>&1 | FileCheck 
-check-prefix=CHECK-TIMESTAMP %s
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h
+// RUN: touch -m -a -t 201008011501 %T/pragma-once2.h
+// RUN: not %clang_cc1 -include-pch %t %t1.cpp 2>&1 | FileCheck 
-check-prefix=CHECK-TIMESTAMP %s
 
 // Check bitcode output as well.
 // RUN: llvm-bcanalyzer -dump %t | FileCheck 
-check-prefix=CHECK-BITCODE-TIMESTAMP-ON %s
 
 // Check timestamp inclusion is disabled by -fno-pch-timestamp.
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h 
-fno-pch-timestamp
-// RUN: touch -m -a -t 201008011502 %S/Inputs/pragma-once2.h
-// RUN: %clang_cc1 -include-pch %t %s 2>&1
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h 
-fno-pch-timestamp
+// RUN: touch -m -a -t 201008011502 %T/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t %t1.cpp 2>&1
 
 // Check bitcode output as well.
 // RUN: llvm-bcanalyzer -dump %t | FileCheck 
-check-prefix=CHECK-BITCODE-TIMESTAMP-OFF %s
 
-#include "Inputs/pragma-once2.h"
+#include "pragma-once2.h"
 
 void g() { f(); }
 


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


Re: r275368 - Add C++ dependencies to xray runtime

2016-07-14 Thread Mikael Holmén via cfe-commits



On 07/14/2016 02:10 PM, Dean Michael Berris wrote:

Thanks Mikael -- this has been fixed in r275377
(http://reviews.llvm.org/rL275377).


Yes, now it compiled. Thank you!
/Mikael



On Thu, Jul 14, 2016 at 7:30 PM Mikael Holmén
> wrote:

Hi,

Your commit

  Add C++ dependencies to xray runtime

Doesn't compile with gcc. At least 5.3 and 4.8.4 complains about this
change:

+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A =
Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+
options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+

../tools/clang/lib/Driver/Tools.cpp:4613:57: error: converting to
'llvm::opt::OptSpecifier' from initializer list would use explicit
constructor 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
 options::OPT_fnoxray_instrument, false)) {
   ^
In file included from ../include/llvm/Option/OptTable.h:15:0,
   from ../include/llvm/Option/Option.h:15,
   from ../tools/clang/lib/Driver/Tools.h:19,
   from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error:
'llvm::opt::OptSpecifier::OptSpecifier(bool)' is private
   explicit OptSpecifier(bool) = delete;
^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: within this context
 options::OPT_fnoxray_instrument, false)) {
   ^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: use of deleted
function 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
In file included from ../include/llvm/Option/OptTable.h:15:0,
   from ../include/llvm/Option/Option.h:15,
   from ../tools/clang/lib/Driver/Tools.h:19,
   from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error: declared here
   explicit OptSpecifier(bool) = delete;
^
In file included from
../tools/clang/include/clang/Driver/SanitizerArgs.h:15:0,
   from ../tools/clang/lib/Driver/Tools.cpp:24:
../include/llvm/Option/ArgList.h:191:8: error:   initializing argument 3
of 'bool llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,
llvm::opt::OptSpecifier, llvm::opt::OptSpecifier) const'
 bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2)
const {
  ^
ninja: build stopped: subcommand failed.
system(/proj/flexasic/app/ninja/1.4/SLED11-64/bin/ninja -j1 -C
build-all-gcc53 llc llvm-stress opt clang all) failed: child exited with
value 1



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


[PATCH] D22351: [include-fixer] Move curosr to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

A small improvement: for only one suggested header, user don't have to
type ENTER manually after running the python script.

https://reviews.llvm.org/D22351

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

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -84,12 +84,18 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+# Set cursor to the #include line.
+include_header = "#include " + header["HeaderInfos"][0]["Header"]
+line_num = lines.index(include_header) + 1
+vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -135,15 +141,16 @@
 print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
-return
-
+  message = "Added #include for {0}".format(symbol)
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print message
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +160,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": selected_header_infos}, text)
-print "Added #include {0} for {1}.\n".format(selected, symbol)
+print message
   except Exception as error:
 print >> sys.stderr, error.message
   return


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -84,12 +84,18 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+# Set cursor to the #include line.
+include_header = "#include " + header["HeaderInfos"][0]["Header"]
+line_num = lines.index(include_header) + 1
+vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -135,15 +141,16 @@
 print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
-return
-
+  message = "Added #include for {0}".format(symbol)
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print message
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +160,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": 

  1   2   >