[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:117
 
+TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
+  auto AST = tooling::buildASTFromCode(

I think you could add another test with `X x` (if you don't have it already 
and I overlooked them)



Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:309
 
+TEST(ExprMutationAnalyzerTest, CallUnresolved) {
+  auto AST =

I think we are missing tests for non-type template paramters (`template `). They should behave the same. But the following case would not be a 
mutation:

```
void non_mutating(const char* Array, int size) { /* Foo */ }
template 
struct ArrayLike {
  char* data[N]; // Initialized to something
  void SomeFunction() {
non_mutating(data, N);
  }
};
```

The difference between the 'normal' and non-type templates would be, that `N` 
is not mutatable at all and the semantics is clear (builtin integer-like type).

If the current implementation would not figure that out, you can just add a 
test for it and assume a mutation. Handling non-type templates later is 
absolutly ok.



Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:410
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y"));
+}

Out of curiosity: Why is the result with `y` different from the result for `x`? 
Both time `x` is mutated and `g()` mutates them.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-15 Thread David Chisnall via Phabricator via cfe-commits
theraven added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:1886
   case BuiltinType::ObjCId:
-mangleArtificalTagType(TTK_Struct, "objc_object");
+mangleArtificalTagType(TTK_Struct, ".objc_object");
 break;

compnerd wrote:
> DHowett-MSFT wrote:
> > I'm interested in @smeenai's take on this, as well.
> Hmm, doesn't this break ObjC/ObjC++ interoperability?  I don't think that we 
> should be changing the decoration here for the MS ABI case.
No, this fixes ObjC++ interop.  Throwing an exception from a `@throw` and 
catching it with `catch` now works and we avoid the problem that a C++ 
compilation unit declares a `struct` that happens to have the same name as an 
Objective-C class (which is very common for wrapper code) may catch things of 
the wrong type.


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


Re: r339603 - [OPENMP] Fix emission of the loop doacross constructs.

2018-08-15 Thread Jonas Hahnfeld via cfe-commits

Alexey, Hans,

does it make sense to backport for 7.0 as it fixes PR37580?

Thanks,
Jonas

On 2018-08-13 21:04, Alexey Bataev via cfe-commits wrote:

Author: abataev
Date: Mon Aug 13 12:04:24 2018
New Revision: 339603

URL: http://llvm.org/viewvc/llvm-project?rev=339603&view=rev
Log:
[OPENMP] Fix emission of the loop doacross constructs.

The number of loops associated with the OpenMP loop constructs should
not be considered as the number loops to collapse.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/ordered_doacross_codegen.c
cfe/trunk/test/OpenMP/ordered_doacross_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=339603&r1=339602&r2=339603&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Aug 13 12:04:24 2018
@@ -930,8 +930,11 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp for' has 'ordered' clause 
with

 /// parameter 2.
-class OMPOrderedClause : public OMPClause {
+class OMPOrderedClause final
+: public OMPClause,
+  private llvm::TrailingObjects {
   friend class OMPClauseReader;
+  friend TrailingObjects;

   /// Location of '('.
   SourceLocation LParenLoc;
@@ -939,6 +942,26 @@ class OMPOrderedClause : public OMPClaus
   /// Number of for-loops.
   Stmt *NumForLoops = nullptr;

+  /// Real number of loops.
+  unsigned NumberOfLoops = 0;
+
+  /// Build 'ordered' clause.
+  ///
+  /// \param Num Expression, possibly associated with this clause.
+  /// \param NumLoops Number of loops, associated with this clause.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation 
StartLoc,

+   SourceLocation LParenLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_ordered, StartLoc, EndLoc), 
LParenLoc(LParenLoc),

+NumForLoops(Num), NumberOfLoops(NumLoops) {}
+
+  /// Build an empty clause.
+  explicit OMPOrderedClause(unsigned NumLoops)
+  : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()),
+NumberOfLoops(NumLoops) {}
+
   /// Set the number of associated for-loops.
   void setNumForLoops(Expr *Num) { NumForLoops = Num; }

@@ -946,17 +969,17 @@ public:
   /// Build 'ordered' clause.
   ///
   /// \param Num Expression, possibly associated with this clause.
+  /// \param NumLoops Number of loops, associated with this clause.
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  OMPOrderedClause(Expr *Num, SourceLocation StartLoc,
-SourceLocation LParenLoc, SourceLocation EndLoc)
-  : OMPClause(OMPC_ordered, StartLoc, EndLoc), 
LParenLoc(LParenLoc),

-NumForLoops(Num) {}
+  static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
+  unsigned NumLoops, SourceLocation 
StartLoc,

+  SourceLocation LParenLoc,
+  SourceLocation EndLoc);

   /// Build an empty clause.
-  explicit OMPOrderedClause()
-  : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()) {}
+  static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned 
NumLoops);


   /// Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
@@ -967,6 +990,17 @@ public:
   /// Return the number of associated for-loops.
   Expr *getNumForLoops() const { return 
cast_or_null(NumForLoops); }


+  /// Set number of iterations for the specified loop.
+  void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
+  /// Get number of iterations for all the loops.
+  ArrayRef getLoopNumIterations() const;
+
+  /// Set loop counter for the specified loop.
+  void setLoopCounter(unsigned NumLoop, Expr *Counter);
+  /// Get loops counter for the specified loop.
+  Expr *getLoopCunter(unsigned NumLoop);
+  const Expr *getLoopCunter(unsigned NumLoop) const;
+
   child_range children() { return child_range(&NumForLoops,
&NumForLoops + 1); }

   static bool classof(const OMPClause *T) {
@@ -3095,24 +3129,32 @@ class OMPDependClause final
   /// Colon location.
   SourceLocation ColonLoc;

+  /// Number of loops, associated with the depend clause.
+  unsigned NumLoops = 0;
+
   /// Build clause with number of v

[PATCH] D50246: [RISCV] Add support for computing sysroot for riscv32-unknown-elf

2018-08-15 Thread Simon Cook via Phabricator via cfe-commits
simoncook accepted this revision.
simoncook added a comment.
This revision is now accepted and ready to land.

My tests now look better, there are a couple of failures, but this seems to be 
a bug in newlib, rather than with clang/this patch (the bug was masked before 
as we would have been pulling in system headers). So this patch looks good to 
me.

@asb  Does this look good to you/are you able to commit this?


Repository:
  rC Clang

https://reviews.llvm.org/D50246



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


r339759 - Fix ASTMatchersTraversalTest testcase compile on older compilers

2018-08-15 Thread David Green via cfe-commits
Author: dmgreen
Date: Wed Aug 15 03:39:43 2018
New Revision: 339759

URL: http://llvm.org/viewvc/llvm-project?rev=339759&view=rev
Log:
Fix ASTMatchersTraversalTest testcase compile on older compilers

Some versions of gcc, especially when invoked through ccache (-E), can have
trouble with raw string literals inside macros. This moves the string out of
the macro.

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=339759&r1=339758&r2=339759&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Wed Aug 15 
03:39:43 2018
@@ -1322,7 +1322,7 @@ TEST(IgnoringImplicit, MatchesImplicit)
 }
 
 TEST(IgnoringImplicit, MatchesNestedImplicit) {
-  EXPECT_TRUE(matches(R"(
+  StringRef Code = R"(
 
 struct OtherType;
 
@@ -1348,8 +1348,8 @@ int main()
 {
 SomeType i = something();
 }
-)"
-  , varDecl(
+)";
+  EXPECT_TRUE(matches(Code, varDecl(
   hasName("i"),
   hasInitializer(exprWithCleanups(has(
 cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(


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


[PATCH] D50763: [Parser] Refactor and fix bugs in late-parsing

2018-08-15 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.
hamzasood added reviewers: erichkeane, v.g.vassilev, malcolm.parsons, rsmith.
Herald added a reviewer: javed.absar.
Herald added subscribers: cfe-commits, kristof.beyls, eraman.

This patch extracts the eof/stop token pattern used in late-parsing to a 
re-usable RAII class. This simplifies a lot of the late-parsing code.

A few related bugs were fixed in the process:

- Late-parsing a method with default arguments but without an exception 
specification would result in an invalid union access. It was mostly harmless 
but it's technically undefined behaviour.
- When an inherited late-parsed parameter is encountered, the associated 
declaration is force-casted to FunctionDecl. This caused a crash when the 
declaration is a template.


Repository:
  rC Clang

https://reviews.llvm.org/D50763

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp

Index: test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
===
--- test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
+++ test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -61,15 +61,24 @@
 struct A {
   struct B {
 static void Foo (int = 0);
+
+template
+static void TFoo (T = 0);
   };
   
   // should not hide default args
   friend void B::Foo (int);
+
+  // Same as above, but with templates!
+  // Should not crash the compiler.
+  template
+  friend void B::TFoo (T);
 };
 
 void Test ()
 {
   A::B::Foo ();
+  A::B::TFoo ();
 }
 
 } // namespace
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1116,10 +1116,10 @@
   this->Enabled = true;
 }
 
-
-Sema::CXXThisScopeRAII::~CXXThisScopeRAII() {
+void Sema::CXXThisScopeRAII::Exit() {
   if (Enabled) {
 S.CXXThisTypeOverride = OldCXXThisTypeOverride;
+Enabled = false;
   }
 }
 
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2097,43 +2097,42 @@
 /// delayed, e.g., default arguments or an exception-specification, create a
 /// late-parsed method declaration record to handle the parsing at the end of
 /// the class definition.
-void Parser::HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
+void Parser::HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
 Decl *ThisDecl) {
-  DeclaratorChunk::FunctionTypeInfo &FTI
-= DeclaratorInfo.getFunctionTypeInfo();
-  // If there was a late-parsed exception-specification, we'll need a
-  // late parse
-  bool NeedLateParse = FTI.getExceptionSpecType() == EST_Unparsed;
-
-  if (!NeedLateParse) {
-// Look ahead to see if there are any default args
-for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) {
-  auto Param = cast(FTI.Params[ParamIdx].Param);
-  if (Param->hasUnparsedDefaultArg()) {
-NeedLateParse = true;
-break;
-  }
-}
-  }
+  DeclaratorChunk::FunctionTypeInfo &FTI = DeclaratorInfo.getFunctionTypeInfo();
+  auto ParamInfoRange = llvm::make_range(FTI.Params,
+ FTI.Params + FTI.NumParams);
 
-  if (NeedLateParse) {
-// Push this method onto the stack of late-parsed method
-// declarations.
-auto LateMethod = new LateParsedMethodDeclaration(this, ThisDecl);
-getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
-LateMethod->TemplateScope = getCurScope()->isTemplateParamScope();
+  const bool LateParseDefaultArgs =
+  llvm::any_of(ParamInfoRange, [](const DeclaratorChunk::ParamInfo &PI)
+{ return cast(PI.Param)->hasUnparsedDefaultArg(); });
 
-// Stash the exception-specification tokens in the late-pased method.
-LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens;
-FTI.ExceptionSpecTokens = nullptr;
+  const bool LateParseExceptionSpec =
+  FTI.getExceptionSpecType() == EST_Unparsed;
+
+  // If we didn't delay parsing for any parts of this function, then we're done.
+  if (!LateParseDefaultArgs && !LateParseExceptionSpec)
+return;
 
-// Push tokens for each parameter.  Those that do not have
-// defaults will be NULL.
-LateMethod->DefaultArgs.reserve(FTI.NumParams);
-for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
-  LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
-  FTI.Params[ParamIdx].Param,
-  std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
+  // Push this method onto the stack of late-parsed method declarations.
+  auto LateMethod = new LateParsedMethodDeclaration(this, ThisDecl);
+  getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
+  LateMethod->TemplateSco

[PATCH] D50764: [AST] Make NullStmt final and give it factory functions

2018-08-15 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.
hamzasood added reviewers: klimek, steveire, bkramer.
Herald added a subscriber: cfe-commits.

I've submitted a patch for contracts (review linked to this) that adds trailing 
objects to NullStmt. This patch contains the changes to make that possible.


Repository:
  rC Clang

https://reviews.llvm.org/D50764

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTImporter.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp

Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -3141,7 +3141,7 @@
   break;
 
 case STMT_NULL:
-  S = new (Context) NullStmt(Empty);
+  S = NullStmt::CreateEmpty(Context);
   break;
 
 case STMT_COMPOUND:
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6650,7 +6650,7 @@
 if (Then.isInvalid())
   return StmtError();
   } else {
-Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc());
+Then = NullStmt::Create(getSema().Context, S->getThen()->getBeginLoc());
   }
 
   // Transform the "else" branch.
@@ -7511,13 +7511,13 @@
 if (S->isIfExists())
   break;
 
-return new (getSema().Context) NullStmt(S->getKeywordLoc());
+return NullStmt::Create(getSema().Context, S->getKeywordLoc());
 
   case Sema::IER_DoesNotExist:
 if (S->isIfNotExists())
   break;
 
-return new (getSema().Context) NullStmt(S->getKeywordLoc());
+return NullStmt::Create(getSema().Context, S->getKeywordLoc());
 
   case Sema::IER_Dependent:
 Dependent = true;
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -67,7 +67,7 @@
 
 StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc,
bool HasLeadingEmptyMacro) {
-  return new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro);
+  return NullStmt::Create(Context, SemiLoc, HasLeadingEmptyMacro);
 }
 
 StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5044,8 +5044,8 @@
 
 Stmt *ASTNodeImporter::VisitNullStmt(NullStmt *S) {
   SourceLocation ToSemiLoc = Importer.Import(S->getSemiLoc());
-  return new (Importer.getToContext()) NullStmt(ToSemiLoc,
-S->hasLeadingEmptyMacro());
+  return NullStmt::Create(Importer.getToContext(), ToSemiLoc,
+  S->hasLeadingEmptyMacro());
 }
 
 Stmt *ASTNodeImporter::VisitCompoundStmt(CompoundStmt *S) {
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -587,26 +587,36 @@
 
 /// NullStmt - This is the null statement ";": C99 6.8.3p3.
 ///
-class NullStmt : public Stmt {
+class NullStmt final : public Stmt {
   SourceLocation SemiLoc;
 
   /// True if the null statement was preceded by an empty macro, e.g:
   /// @code
   ///   #define CALL(x)
   ///   CALL(0);
   /// @endcode
-  bool HasLeadingEmptyMacro = false;
+  bool HasLeadingEmptyMacro;
+
+  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro)
+  : Stmt(NullStmtClass), SemiLoc(L),
+HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
+
+  explicit NullStmt(EmptyShell Empty)
+  : Stmt(NullStmtClass, Empty), HasLeadingEmptyMacro(false) {}
 
 public:
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 
-  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
-  : Stmt(NullStmtClass), SemiLoc(L),
-HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
+  static NullStmt *Create(const ASTContext &C, SourceLocation L,
+  bool hasLeadingEmptyMacro = false) {
+return new (C) NullStmt(L, hasLeadingEmptyMacro);
+  }
 
   /// Build an empty null statement.
-  explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
+  static NullStmt *CreateEmpty(const ASTContext &C) {
+return new (C) NullStmt(EmptyShell{});
+  }
 
   SourceLocation getSemiLoc() const { return SemiLoc; }
   void setSemiLoc(SourceLocation L) { SemiLoc = L; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: include/clang/AST/Type.h:1634
+
+/// The number of template arguments in \c Arguments.
+/// Intentionally not a bitfield since we have plenty of space left.

erichkeane wrote:
> I would love it if we commented what a reasonable number for this is.  
> Additionally, we should probably make it 64 - NumTypeBits or something, to 
> ensure that if NumTypeBits gets too large that we don't blow 64 bits here as 
> well as communicate that it isn't necessary to keep this 32 bits.
The reason I did not do something like this is that
there is a penalty to access bit-fields due to the various
shifts and masks. IIRC I was actually able to measure it after
I went over each of these classes and only kept bit-fields
when strictly necessary. (however it is hard to be sure
since it was close to the noise of my measurement, and the
difference could be from totally unrelated sources).
In any case it is quite small (maybe ~0.1% in total, not just
from this single case) and IMHO not worth systematically
bothering about it but in this case why pay the penalty if
we can avoid it.

If `NumTypeBits` gets too large then this will be detected by the
the static_asserts and the person who did the modification will
have to convert `NumArgs` to a bit-field. In any case this will at least
also blow up `FunctionTypeBitfields`, `VectorTypeBitfields`,
`AttributedTypeBitfields`, `SubstTemplateTypeParmPackTypeBitfields`,
`TemplateSpecializationTypeBitfields`,
`DependentTemplateSpecializationTypeBitfields`,
and `PackExpansionTypeBitfields`.

Also I do not think that doing
`unsigned NumArgs : 64 - NumTypeBits;` will work because
since `NumTypeBits == 18` this will be
`unsigned NumArgs : 46;` and this will not pack nicely.

Given how many things will not work when `NumTypeBits > 32`
It seems to be that it is not worth converting it to a bit-field.
However a comment indicating how many bits are actually needed
would definitely be a good addition IMO. On this point I have
absolutely no idea and probably @rsmith should comment on this.


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50631: [AST] Stuff more data into FunctionTypeBitfields

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

@rsmith Could you comment on whether limiting the number of types
in a dynamic exception specification to 127 is acceptable ? I had
to steal two bits from `NumExceptions` to make all the fields fit.
If this is a bad idea then a possibility would be to put
`NumExceptions` in a trailing object.


Repository:
  rC Clang

https://reviews.llvm.org/D50631



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


[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.

2018-08-15 Thread Mateusz Janek via Phabricator via cfe-commits
stryku created this revision.
stryku added a reviewer: rsmith.
stryku added a project: clang.

In the [expr.sub] p1, we can read that for a given E1[E2], E1 is sequenced 
before E2.


Repository:
  rC Clang

https://reviews.llvm.org/D50766

Files:
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11658,30 +11658,40 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedLhsRhsExpressions(Expr *LHS, Expr *RHS) {
+SequenceTree::Seq LHSRegion = Tree.allocate(Region);
+SequenceTree::Seq RHSRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
   SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  Region = LHSRegion;
+  Visit(LHS);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = RHSRegion;
+Visit(RHS);
 
 Region = OldRegion;
 
 // Forget that LHS and RHS are sequenced. They are both unsequenced
 // with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(LHSRegion);
+Tree.merge(RHSRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// The expression E1[E2] is identical (by definition) to *((E1)+(E2)). The
+// expression E1 is sequenced before the expression E2.
+VisitSequencedLhsRhsExpressions(ASE->getLHS(), ASE->getLHS());
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedLhsRhsExpressions(BO->getLHS(), BO->getLHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11658,30 +11658,40 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedLhsRhsExpressions(Expr *LHS, Expr *RHS) {
+SequenceTree::Seq LHSRegion = Tree.allocate(Region);
+SequenceTree::Seq RHSRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
   SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  Region = LHSRegion;
+  Visit(LHS);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = RHSRegion;
+Visit(RHS);
 
 Region = OldRegion;
 
 // Forget that LHS and RHS are sequenced. They are both unsequenced
 // with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(LHSRegion);
+Tree.merge(RHSRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// The expression E1[E2] is identical (by definition) to *((E1)+(E2)). The
+// expression E1 is sequenced before the expression E2.
+VisitSequencedLhsRhsExpressions(ASE->getLHS(), ASE->getLHS());
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedLhsRhsExpressions(BO->getLHS(), BO->getLHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339766 - Use .cpp extension for certain tests instead of .cc

2018-08-15 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Aug 15 05:22:08 2018
New Revision: 339766

URL: http://llvm.org/viewvc/llvm-project?rev=339766&view=rev
Log:
Use .cpp extension for certain tests instead of .cc

The tests `CodeGen/aapcs[64]-align.cc` are not run since files with a `.cc`
suffix aren't recognisze as tests. This patch renames the above two files to
`.cpp`.

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

Comitting as obvious.


Added:
cfe/trunk/test/CodeGen/aapcs-align.cpp
  - copied unchanged from r339765, cfe/trunk/test/CodeGen/aapcs-align.cc
cfe/trunk/test/CodeGen/aapcs64-align.cpp
  - copied unchanged from r339765, cfe/trunk/test/CodeGen/aapcs64-align.cc
Removed:
cfe/trunk/test/CodeGen/aapcs-align.cc
cfe/trunk/test/CodeGen/aapcs64-align.cc

Removed: cfe/trunk/test/CodeGen/aapcs-align.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cc?rev=339765&view=auto
==
--- cfe/trunk/test/CodeGen/aapcs-align.cc (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cc (removed)
@@ -1,141 +0,0 @@
-// REQUIRES: arm-registered-target
-// RUN: %clang_cc1 -triple arm-none-none-eabi \
-// RUN:   -O2 \
-// RUN:   -target-cpu cortex-a8 \
-// RUN:   -emit-llvm -o - %s | FileCheck %s
-
-extern "C" {
-
-// Base case, nothing interesting.
-struct S {
-  int x, y;
-};
-
-void f0(int, S);
-void f0m(int, int, int, int, int, S);
-void g0() {
-  S s = {6, 7};
-  f0(1, s);
-  f0m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g0
-// CHECK: call void @f0(i32 1, [2 x i32] [i32 6, i32 7]
-// CHECK: call void @f0m(i32 1, i32 2, i32 3, i32 4, i32 5, [2 x i32] [i32 6, 
i32 7]
-// CHECK: declare void @f0(i32, [2 x i32])
-// CHECK: declare void @f0m(i32, i32, i32, i32, i32, [2 x i32])
-
-// Aligned struct, passed according to its natural alignment.
-struct __attribute__((aligned(8))) S8 {
-  int x, y;
-} s8;
-
-void f1(int, S8);
-void f1m(int, int, int, int, int, S8);
-void g1() {
-  S8 s = {6, 7};
-  f1(1, s);
-  f1m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g1
-// CHECK: call void @f1(i32 1, [2 x i32] [i32 6, i32 7]
-// CHECK: call void @f1m(i32 1, i32 2, i32 3, i32 4, i32 5, [2 x i32] [i32 6, 
i32 7]
-// CHECK: declare void @f1(i32, [2 x i32])
-// CHECK: declare void @f1m(i32, i32, i32, i32, i32, [2 x i32])
-
-// Aligned struct, passed according to its natural alignment.
-struct alignas(16) S16 {
-  int x, y;
-};
-
-extern "C" void f2(int, S16);
-extern "C" void f2m(int, int, int, int, int, S16);
-
-void g2() {
-  S16 s = {6, 7};
-  f2(1, s);
-  f2m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g2
-// CHECK: call void @f2(i32 1, [4 x i32] [i32 6, i32 7
-// CHECK: call void @f2m(i32 1, i32 2, i32 3, i32 4, i32 5, [4 x i32] [i32 6, 
i32 7
-// CHECK: declare void @f2(i32, [4 x i32])
-// CHECK: declare void @f2m(i32, i32, i32, i32, i32, [4 x i32])
-
-// Increased natural alignment.
-struct SF8 {
-  int x __attribute__((aligned(8)));
-  int y;
-};
-
-void f3(int, SF8);
-void f3m(int, int, int, int, int, SF8);
-void g3() {
-  SF8 s = {6, 7};
-  f3(1, s);
-  f3m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g3
-// CHECK: call void @f3(i32 1, [1 x i64] [i64 30064771078]
-// CHECK: call void @f3m(i32 1, i32 2, i32 3, i32 4, i32 5, [1 x i64] [i64 
30064771078]
-// CHECK: declare void @f3(i32, [1 x i64])
-// CHECK: declare void @f3m(i32, i32, i32, i32, i32, [1 x i64])
-
-// Increased natural alignment, capped to 8 though.
-struct SF16 {
-  int x;
-  int y alignas(16);
-  int z, a, b, c, d, e, f, g, h, i, j, k;
-};
-
-void f4(int, SF16);
-void f4m(int, int, int, int, int, SF16);
-void g4() {
-  SF16 s = {6, 7};
-  f4(1, s);
-  f4m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
-// CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
-// CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
-
-// Packed structure.
-struct  __attribute__((packed)) P {
-  int x;
-  long long u;
-};
-
-void f5(int, P);
-void f5m(int, int, int, int, int, P);
-void g5() {
-  P s = {6, 7};
-  f5(1, s);
-  f5m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g5
-// CHECK: call void @f5(i32 1, [3 x i32] [i32 6, i32 7, i32 0])
-// CHECK: call void @f5m(i32 1, i32 2, i32 3, i32 4, i32 5, [3 x i32] [i32 6, 
i32 7, i32 0])
-// CHECK: declare void @f5(i32, [3 x i32])
-// CHECK: declare void @f5m(i32, i32, i32, i32, i32, [3 x i32])
-
-
-// Packed and aligned, alignement causes padding at the end.
-struct  __attribute__((packed, aligned(8))) P8 {
-  int x;
-  long long u;
-};
-
-void f6(int, P8);
-void f6m(int, int, int, int, int, P8);
-void g6() {
-  P8 s = {6, 7};
-  f6(1, s);
-  f6m(1, 2, 3, 4, 5, s);
-}
-// CHECK: define void @g6
-// CHECK: call void @f6(i32 1, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
-// CHECK: call void @f6m(i32 1, i32 2, i32 3, i32 4, i32 5, [

[PATCH] D50771: [clang-tblgen] Add -print-records and -dump-json modes.

2018-08-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added a reviewer: nhaehnle.
Herald added a subscriber: cfe-commits.

Currently, if clang-tblgen is run without a mode option, it defaults
to the first mode in its 'enum Action', which happens to be
-gen-clang-attr-classes. I think it makes more sense for it to behave
the same way as llvm-tblgen, i.e. print a diagnostic dump if it's not
given any more specific instructions.

I've also added the same -dump-json that llvm-tblgen supports. This
means any tblgen command line (whether llvm- or clang-) can be
mechanically turned into one that processes the same input into JSON.


Repository:
  rC Clang

https://reviews.llvm.org/D50771

Files:
  utils/TableGen/TableGen.cpp


Index: utils/TableGen/TableGen.cpp
===
--- utils/TableGen/TableGen.cpp
+++ utils/TableGen/TableGen.cpp
@@ -23,6 +23,8 @@
 using namespace clang;
 
 enum ActionType {
+  PrintRecords,
+  DumpJSON,
   GenClangAttrClasses,
   GenClangAttrParserStringSwitches,
   GenClangAttrSubjectMatchRulesParserStringSwitches,
@@ -66,6 +68,10 @@
 cl::opt Action(
 cl::desc("Action to perform:"),
 cl::values(
+clEnumValN(PrintRecords, "print-records",
+   "Print all records to stdout (default)"),
+clEnumValN(DumpJSON, "dump-json",
+   "Dump all records as machine-readable JSON"),
 clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes",
"Generate clang attribute clases"),
 clEnumValN(GenClangAttrParserStringSwitches,
@@ -164,6 +170,12 @@
 
 bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
   switch (Action) {
+  case PrintRecords:
+OS << Records;   // No argument, dump all contents
+break;
+  case DumpJSON:
+EmitJSON(Records, OS);
+break;
   case GenClangAttrClasses:
 EmitClangAttrClass(Records, OS);
 break;


Index: utils/TableGen/TableGen.cpp
===
--- utils/TableGen/TableGen.cpp
+++ utils/TableGen/TableGen.cpp
@@ -23,6 +23,8 @@
 using namespace clang;
 
 enum ActionType {
+  PrintRecords,
+  DumpJSON,
   GenClangAttrClasses,
   GenClangAttrParserStringSwitches,
   GenClangAttrSubjectMatchRulesParserStringSwitches,
@@ -66,6 +68,10 @@
 cl::opt Action(
 cl::desc("Action to perform:"),
 cl::values(
+clEnumValN(PrintRecords, "print-records",
+   "Print all records to stdout (default)"),
+clEnumValN(DumpJSON, "dump-json",
+   "Dump all records as machine-readable JSON"),
 clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes",
"Generate clang attribute clases"),
 clEnumValN(GenClangAttrParserStringSwitches,
@@ -164,6 +170,12 @@
 
 bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
   switch (Action) {
+  case PrintRecords:
+OS << Records;   // No argument, dump all contents
+break;
+  case DumpJSON:
+EmitJSON(Records, OS);
+break;
   case GenClangAttrClasses:
 EmitClangAttrClass(Records, OS);
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/AST/Type.h:1634
+
+/// The number of template arguments in \c Arguments.
+/// Intentionally not a bitfield since we have plenty of space left.

riccibruno wrote:
> erichkeane wrote:
> > I would love it if we commented what a reasonable number for this is.  
> > Additionally, we should probably make it 64 - NumTypeBits or something, to 
> > ensure that if NumTypeBits gets too large that we don't blow 64 bits here 
> > as well as communicate that it isn't necessary to keep this 32 bits.
> The reason I did not do something like this is that
> there is a penalty to access bit-fields due to the various
> shifts and masks. IIRC I was actually able to measure it after
> I went over each of these classes and only kept bit-fields
> when strictly necessary. (however it is hard to be sure
> since it was close to the noise of my measurement, and the
> difference could be from totally unrelated sources).
> In any case it is quite small (maybe ~0.1% in total, not just
> from this single case) and IMHO not worth systematically
> bothering about it but in this case why pay the penalty if
> we can avoid it.
> 
> If `NumTypeBits` gets too large then this will be detected by the
> the static_asserts and the person who did the modification will
> have to convert `NumArgs` to a bit-field. In any case this will at least
> also blow up `FunctionTypeBitfields`, `VectorTypeBitfields`,
> `AttributedTypeBitfields`, `SubstTemplateTypeParmPackTypeBitfields`,
> `TemplateSpecializationTypeBitfields`,
> `DependentTemplateSpecializationTypeBitfields`,
> and `PackExpansionTypeBitfields`.
> 
> Also I do not think that doing
> `unsigned NumArgs : 64 - NumTypeBits;` will work because
> since `NumTypeBits == 18` this will be
> `unsigned NumArgs : 46;` and this will not pack nicely.
> 
> Given how many things will not work when `NumTypeBits > 32`
> It seems to be that it is not worth converting it to a bit-field.
> However a comment indicating how many bits are actually needed
> would definitely be a good addition IMO. On this point I have
> absolutely no idea and probably @rsmith should comment on this.
My biggest fear here is basically that a future programmer coming in is going 
to figure that NumArgs REQUIRES 32 bits and try to start the discussion as to 
whether we can blow this bitfields up.

A comment saying most of what you said above, plus a "This corresponds to 
implimits , so it needs to support at least .


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

The thing is that I have no idea what is the minimum number
of bits required. It was originally an unsigned but I suspect that
32 bits are not needed. Looking at [implimits] I see

  Template arguments in a template declaration [1 024].
  Recursively nested template instantiations, including substitution during 
template argument deduc-
  tion (17.8.2) [1 024].

But 1024 seems to be too small and easily exceeded by a doing a bit
of template meta-programming.


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D50713#1200564, @riccibruno wrote:

> The thing is that I have no idea what is the minimum number
>  of bits required. It was originally an unsigned but I suspect that
>  32 bits are not needed. Looking at [implimits] I see
>
>   Template arguments in a template declaration [1 024].
>   Recursively nested template instantiations, including substitution during 
> template argument deduc-
>   tion (17.8.2) [1 024].
>   
>
> But 1024 seems to be too small and easily exceeded by a doing a bit
>  of template meta-programming.


I suspect a minor rephrase of this comment would be more than sufficient for me:

"This field corresponds to the number of template arguments, which is expected 
to be at least 1024 according to [implimits].  However, as this limit is 
somewhat easy to hit with template metaprogramming we'd prefer to keep it as 
large as possible.  At the moment it has been left as a non-bitfield since this 
type safely fits in 64 bits as an unsigned, so there is no reason to introduce 
the performance impact of a bitfield."

I'd suspect you/someone will bikeshed that, but I think it gets the point 
across that I want to make sure is there.


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

This comment seems fine. I will also add a similar comment to
`TemplateSpecializationTypeBitfields`, 
`DependentTemplateSpecializationTypeBitfields`
and `PackExpansionTypeBitfields` since they all 3 have a similar `unsigned`.


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 160795.
riccibruno added a comment.

updated the comment in SubstTemplateTypeParmPackTypeBitfields


Repository:
  rC Clang

https://reviews.llvm.org/D50713

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp


Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3285,11 +3285,12 @@
   QualType Canon,
   const TemplateArgument &ArgPack)
 : Type(SubstTemplateTypeParmPack, Canon, true, true, false, true),
-  Replaced(Param),
-  Arguments(ArgPack.pack_begin()), NumArguments(ArgPack.pack_size()) {}
+  Replaced(Param), Arguments(ArgPack.pack_begin()) {
+  SubstTemplateTypeParmPackTypeBits.NumArgs = ArgPack.pack_size();
+}
 
 TemplateArgument SubstTemplateTypeParmPackType::getArgumentPack() const {
-  return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
+  return TemplateArgument(llvm::makeArrayRef(Arguments, getNumArgs()));
 }
 
 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1626,6 +1626,21 @@
 unsigned Keyword : 2;
   };
 
+  class SubstTemplateTypeParmPackTypeBitfields {
+friend class SubstTemplateTypeParmPackType;
+
+unsigned : NumTypeBits;
+
+/// The number of template arguments in \c Arguments, which is
+/// expected to be able to hold at least 1024 according to [implimits].
+/// However as this limit is somewhat easy to hit with template
+/// metaprogramming we'd prefer to keep it as large as possible.
+/// At the moment it has been left as a non-bitfield since this type
+/// safely fits in 64 bits as an unsigned, so there is no reason to
+/// introduce the performance impact of a bitfield.
+unsigned NumArgs;
+  };
+
   class TemplateSpecializationTypeBitfields {
 friend class TemplateSpecializationType;
 
@@ -1690,6 +1705,7 @@
 ReferenceTypeBitfields ReferenceTypeBits;
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
+SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
 DependentTemplateSpecializationTypeBitfields
   DependentTemplateSpecializationTypeBits;
@@ -1715,6 +1731,9 @@
   "TypeWithKeywordBitfields is larger than 8 bytes!");
 static_assert(sizeof(VectorTypeBitfields) <= 8,
   "VectorTypeBitfields is larger than 8 bytes!");
+static_assert(sizeof(SubstTemplateTypeParmPackTypeBitfields) <= 8,
+  "SubstTemplateTypeParmPackTypeBitfields is larger"
+  " than 8 bytes!");
 static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
   "TemplateSpecializationTypeBitfields is larger"
   " than 8 bytes!");
@@ -4555,9 +4574,6 @@
   /// parameter pack is instantiated with.
   const TemplateArgument *Arguments;
 
-  /// The number of template arguments in \c Arguments.
-  unsigned NumArguments;
-
   SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param,
 QualType Canon,
 const TemplateArgument &ArgPack);
@@ -4570,6 +4586,10 @@
 return Replaced;
   }
 
+  unsigned getNumArgs() const {
+return SubstTemplateTypeParmPackTypeBits.NumArgs;
+  }
+
   bool isSugared() const { return false; }
   QualType desugar() const { return QualType(this, 0); }
 


Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3285,11 +3285,12 @@
   QualType Canon,
   const TemplateArgument &ArgPack)
 : Type(SubstTemplateTypeParmPack, Canon, true, true, false, true),
-  Replaced(Param),
-  Arguments(ArgPack.pack_begin()), NumArguments(ArgPack.pack_size()) {}
+  Replaced(Param), Arguments(ArgPack.pack_begin()) {
+  SubstTemplateTypeParmPackTypeBits.NumArgs = ArgPack.pack_size();
+}
 
 TemplateArgument SubstTemplateTypeParmPackType::getArgumentPack() const {
-  return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
+  return TemplateArgument(llvm::makeArrayRef(Arguments, getNumArgs()));
 }
 
 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1626,6 +1626,21 @@
 unsigned Keyword : 2;
   };
 
+  class SubstTemplateTypeParmPackTypeBitfields {
+friend class SubstTemplateTypeParmPackType;
+
+unsigned : NumTypeBits;
+
+/// The number of template arguments in \c Arguments, which is
+/// exp

[PATCH] D50713: [AST] Pack the unsigned of SubstTemplateTypeParmPackType into Type

2018-08-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Sorry about the long discussion on the comment... These bitfields are just hell 
on the next guy through if he doesn't have the context/knowledge of what are 
appropriate sizes.


Repository:
  rC Clang

https://reviews.llvm.org/D50713



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


[PATCH] D50712: [AST] Pack the unsigned of DependentTemplateSpecializationType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 160800.
riccibruno added a comment.

updated the comment in DependentTemplateSpecializationTypeBitfields


Repository:
  rC Clang

https://reviews.llvm.org/D50712

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2604,7 +2604,8 @@
   : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true, true,
 /*VariablyModified=*/false,
 NNS && NNS->containsUnexpandedParameterPack()),
-NNS(NNS), Name(Name), NumArgs(Args.size()) {
+NNS(NNS), Name(Name) {
+  DependentTemplateSpecializationTypeBits.NumArgs = Args.size();
   assert((!NNS || NNS->isDependent()) &&
  "DependentTemplateSpecializatonType requires dependent qualifier");
   TemplateArgument *ArgBuffer = getArgBuffer();
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1589,6 +1589,8 @@
 unsigned Keyword : 8;
   };
 
+  enum { NumTypeWithKeywordBits = 8 };
+
   class VectorTypeBitfields {
 friend class VectorType;
 friend class DependentVectorType;
@@ -1642,6 +1644,22 @@
 unsigned NumArgs;
   };
 
+  class DependentTemplateSpecializationTypeBitfields {
+friend class DependentTemplateSpecializationType;
+
+unsigned : NumTypeBits;
+unsigned : NumTypeWithKeywordBits;
+
+/// The number of template arguments named in this class template
+/// specialization, which is expected to be able to hold at least 1024
+/// according to [implimits]. However, as this limit is somewhat easy to
+/// hit with template metaprogramming we'd prefer to keep it as large
+/// as possible. At the moment it has been left as a non-bitfield since
+/// this type safely fits in 64 bits as an unsigned, so there is no reason
+/// to introduce the performance impact of a bitfield.
+unsigned NumArgs;
+  };
+
   class PackExpansionTypeBitfields {
 friend class PackExpansionType;
 
@@ -1673,6 +1691,8 @@
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
+DependentTemplateSpecializationTypeBitfields
+  DependentTemplateSpecializationTypeBits;
 PackExpansionTypeBitfields PackExpansionTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
@@ -1698,6 +1718,9 @@
 static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
   "TemplateSpecializationTypeBitfields is larger"
   " than 8 bytes!");
+static_assert(sizeof(DependentTemplateSpecializationTypeBitfields) <= 8,
+  "DependentTemplateSpecializationTypeBitfields is larger"
+  " than 8 bytes!");
 static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
   "PackExpansionTypeBitfields is larger than 8 bytes");
   };
@@ -5127,10 +5150,6 @@
   /// The identifier of the template.
   const IdentifierInfo *Name;
 
-  /// The number of template arguments named in this class template
-  /// specialization.
-  unsigned NumArgs;
-
   DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
   NestedNameSpecifier *NNS,
   const IdentifierInfo *Name,
@@ -5155,12 +5174,14 @@
   }
 
   /// Retrieve the number of template arguments.
-  unsigned getNumArgs() const { return NumArgs; }
+  unsigned getNumArgs() const {
+return DependentTemplateSpecializationTypeBits.NumArgs;
+  }
 
   const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
 
   ArrayRef template_arguments() const {
-return {getArgs(), NumArgs};
+return {getArgs(), getNumArgs()};
   }
 
   using iterator = const TemplateArgument *;
@@ -5172,7 +5193,7 @@
   QualType desugar() const { return QualType(this, 0); }
 
   void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {
-Profile(ID, Context, getKeyword(), NNS, Name, {getArgs(), NumArgs});
+Profile(ID, Context, getKeyword(), NNS, Name, {getArgs(), getNumArgs()});
   }
 
   static void Profile(llvm::FoldingSetNodeID &ID,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50711: [AST] Pack the unsigned of PackExpansionType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 160804.
riccibruno added a comment.

update the comment in PackExpansionTypeBitfields


Repository:
  rC Clang

https://reviews.llvm.org/D50711

Files:
  include/clang/AST/Type.h


Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1642,6 +1642,25 @@
 unsigned NumArgs;
   };
 
+  class PackExpansionTypeBitfields {
+friend class PackExpansionType;
+
+unsigned : NumTypeBits;
+
+/// The number of expansions that this pack expansion will
+/// generate when substituted (+1), which is expected to be able to
+/// hold at least 1024 according to [implimits]. However, as this limit
+/// is somewhat easy to hit with template metaprogramming we'd prefer to
+/// keep it as large as possible. At the moment it has been left as a
+/// non-bitfield since this type safely fits in 64 bits as an unsigned, so
+/// there is no reason to introduce the performance impact of a bitfield.
+///
+/// This field will only have a non-zero value when some of the parameter
+/// packs that occur within the pattern have been substituted but others
+/// have not.
+unsigned NumExpansions;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1654,6 +1673,7 @@
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
+PackExpansionTypeBitfields PackExpansionTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1678,6 +1698,8 @@
 static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
   "TemplateSpecializationTypeBitfields is larger"
   " than 8 bytes!");
+static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
+  "PackExpansionTypeBitfields is larger than 8 bytes");
   };
 
 private:
@@ -5193,22 +5215,16 @@
   /// The pattern of the pack expansion.
   QualType Pattern;
 
-  /// The number of expansions that this pack expansion will
-  /// generate when substituted (+1), or indicates that
-  ///
-  /// This field will only have a non-zero value when some of the parameter
-  /// packs that occur within the pattern have been substituted but others have
-  /// not.
-  unsigned NumExpansions;
-
   PackExpansionType(QualType Pattern, QualType Canon,
 Optional NumExpansions)
   : Type(PackExpansion, Canon, /*Dependent=*/Pattern->isDependentType(),
  /*InstantiationDependent=*/true,
  /*VariablyModified=*/Pattern->isVariablyModifiedType(),
  /*ContainsUnexpandedParameterPack=*/false),
-Pattern(Pattern),
-NumExpansions(NumExpansions ? *NumExpansions + 1 : 0) {}
+Pattern(Pattern) {
+PackExpansionTypeBits.NumExpansions =
+NumExpansions ? *NumExpansions + 1 : 0;
+  }
 
 public:
   /// Retrieve the pattern of this pack expansion, which is the
@@ -5219,9 +5235,8 @@
   /// Retrieve the number of expansions that this pack expansion will
   /// generate, if known.
   Optional getNumExpansions() const {
-if (NumExpansions)
-  return NumExpansions - 1;
-
+if (PackExpansionTypeBits.NumExpansions)
+  return PackExpansionTypeBits.NumExpansions - 1;
 return None;
   }
 


Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1642,6 +1642,25 @@
 unsigned NumArgs;
   };
 
+  class PackExpansionTypeBitfields {
+friend class PackExpansionType;
+
+unsigned : NumTypeBits;
+
+/// The number of expansions that this pack expansion will
+/// generate when substituted (+1), which is expected to be able to
+/// hold at least 1024 according to [implimits]. However, as this limit
+/// is somewhat easy to hit with template metaprogramming we'd prefer to
+/// keep it as large as possible. At the moment it has been left as a
+/// non-bitfield since this type safely fits in 64 bits as an unsigned, so
+/// there is no reason to introduce the performance impact of a bitfield.
+///
+/// This field will only have a non-zero value when some of the parameter
+/// packs that occur within the pattern have been substituted but others
+/// have not.
+unsigned NumExpansions;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1654,6 +1673,7 @@
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
+PackExpansionTypeBitfields PackExpansionTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1678,6 +1698,8 @@
   

[PATCH] D50643: [AST] Pack the bits of TemplateSpecializationType into Type

2018-08-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 160805.
riccibruno added a comment.

update the comment in TemplateSpecializationTypeBitfields


Repository:
  rC Clang

https://reviews.llvm.org/D50643

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -3335,8 +3335,10 @@
  Canon.isNull()? true : Canon->isDependentType(),
  Canon.isNull()? true : Canon->isInstantiationDependentType(),
  false,
- T.containsUnexpandedParameterPack()),
-Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
+ T.containsUnexpandedParameterPack()), Template(T) {
+  TemplateSpecializationTypeBits.NumArgs = Args.size();
+  TemplateSpecializationTypeBits.TypeAlias = !AliasedType.isNull();
+
   assert(!T.getAsDependentTemplateName() &&
  "Use DependentTemplateSpecializationType for dependent template-name");
   assert((T.getKind() == TemplateName::Template ||
@@ -3365,7 +3367,7 @@
   }
 
   // Store the aliased type if this is a type alias template specialization.
-  if (TypeAlias) {
+  if (isTypeAlias()) {
 auto *Begin = reinterpret_cast(this + 1);
 *reinterpret_cast(Begin + getNumArgs()) = AliasedType;
   }
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1624,6 +1624,24 @@
 unsigned Keyword : 2;
   };
 
+  class TemplateSpecializationTypeBitfields {
+friend class TemplateSpecializationType;
+
+unsigned : NumTypeBits;
+
+/// Whether this template specialization type is a substituted type alias.
+unsigned TypeAlias : 1;
+
+/// The number of template arguments named in this class template
+/// specialization, which is expected to be able to hold at least 1024
+/// according to [implimits]. However, as this limit is somewhat easy to
+/// hit with template metaprogramming we'd prefer to keep it as large
+/// as possible. At the moment it has been left as a non-bitfield since
+/// this type safely fits in 64 bits as an unsigned, so there is no reason
+/// to introduce the performance impact of a bitfield.
+unsigned NumArgs;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1635,6 +1653,7 @@
 ReferenceTypeBitfields ReferenceTypeBits;
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
+TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1656,6 +1675,9 @@
   "TypeWithKeywordBitfields is larger than 8 bytes!");
 static_assert(sizeof(VectorTypeBitfields) <= 8,
   "VectorTypeBitfields is larger than 8 bytes!");
+static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
+  "TemplateSpecializationTypeBitfields is larger"
+  " than 8 bytes!");
   };
 
 private:
@@ -4673,13 +4695,6 @@
   /// replacement must, recursively, be one of these).
   TemplateName Template;
 
-  /// The number of template arguments named in this class template
-  /// specialization.
-  unsigned NumArgs : 31;
-
-  /// Whether this template specialization type is a substituted type alias.
-  unsigned TypeAlias : 1;
-
   TemplateSpecializationType(TemplateName T,
  ArrayRef Args,
  QualType Canon,
@@ -4714,7 +4729,7 @@
   ///   typedef A type; // not a type alias
   /// };
   /// \endcode
-  bool isTypeAlias() const { return TypeAlias; }
+  bool isTypeAlias() const { return TemplateSpecializationTypeBits.TypeAlias; }
 
   /// Get the aliased type, if this is a specialization of a type alias
   /// template.
@@ -4737,14 +4752,16 @@
   }
 
   /// Retrieve the number of template arguments.
-  unsigned getNumArgs() const { return NumArgs; }
+  unsigned getNumArgs() const {
+return TemplateSpecializationTypeBits.NumArgs;
+  }
 
   /// Retrieve a specific template argument as a type.
   /// \pre \c isArgType(Arg)
   const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
 
   ArrayRef template_arguments() const {
-return {getArgs(), NumArgs};
+return {getArgs(), getNumArgs()};
   }
 
   bool isSugared() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50783: [CodeGen] Merge identical block descriptor global variables

2018-08-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, arphaman.
Herald added a subscriber: dexonsmith.

Currently, clang generates a new block descriptor global variable for each 
block literal. This patch merges block descriptors that are identical inside 
and across translation units using the same approach taken in r339438.

To enable merging identical block descriptors, the information of each member 
of a block descriptor is encoded into the block descriptor name. Also, the 
linkage of the block descriptor is `linkonce_odr` unless the copy or dispose 
helper is internal.


Repository:
  rC Clang

https://reviews.llvm.org/D50783

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGObjCRuntime.h
  test/CodeGenCXX/blocks.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/fragile-arc.m
  test/CodeGenObjC/noescape.m

Index: test/CodeGenObjC/noescape.m
===
--- test/CodeGenObjC/noescape.m
+++ test/CodeGenObjC/noescape.m
@@ -17,7 +17,7 @@
 // helper functions.
 
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
-// CHECK: @[[BLOCK_DESCIPTOR_TMP_2:.*]] = internal constant { i64, i64, i8*, i64 } { i64 0, i64 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
+// CHECK: @[[BLOCK_DESCIPTOR_TMP_2:.*]] = linkonce_odr hidden constant { i64, i64, i8*, i64 } { i64 0, i64 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
 
 // CHECK-LABEL: define void @test0(
 // CHECK: call void @noescapeFunc0({{.*}}, {{.*}} nocapture {{.*}})
Index: test/CodeGenObjC/fragile-arc.m
===
--- test/CodeGenObjC/fragile-arc.m
+++ test/CodeGenObjC/fragile-arc.m
@@ -126,13 +126,13 @@
 extern void useBlock(void (^block)(void));
 
 //  256 == 0x100 == starts with 1 strong
-// GLOBALS: @__block_descriptor_tmp{{.*}} = internal constant {{.*}}, i32 256 }
+// GLOBALS: @"__block_descriptor{{.*}} = linkonce_odr hidden {{.*}}, i32 256 }
 void testBlockLayoutStrong(id x) {
   useBlock(^{ (void) x; });
 }
 
 //  1   == 0x001 == starts with 1 weak
-// GLOBALS: @__block_descriptor_tmp{{.*}} = internal constant {{.*}}, i32 1 }
+// GLOBALS: @"__block_descriptor{{.*}} = linkonce_odr hidden {{.*}}, i32 1 }
 void testBlockLayoutWeak(__weak id x) {
   useBlock(^{ (void) x; });
 }
Index: test/CodeGenObjC/arc-blocks.m
===
--- test/CodeGenObjC/arc-blocks.m
+++ test/CodeGenObjC/arc-blocks.m
@@ -2,15 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=CHECK-UNOPT -check-prefix=CHECK-COMMON %s
 
 // CHECK-COMMON: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
-// CHECK-COMMON: @{{.*}} = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32r to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32r to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 16 }, align 8
-// CHECK-COMMON: @[[BLOCK_DESCRIPTOR_TMP9:.*]] = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32r to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32r to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 16 }, align 8
-// CHECK-COMMON: @{{.*}} = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32s to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32s to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
-// CHECK-COMMON: @{{.*}} = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32s to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32s to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
-// CHECK-COMMON: @{{.*}} = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32s to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32s to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
-// CHECK-COMMON: @{{.*}} = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_8_32s to i8*), i8* bitcast (void (i8*)* @__destroy_helper_block_8_32s to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8
-// CHECK-COMMON: @[[BLOCK_DESCRIPTOR_TMP44:.*]] = internal constant { i64, i64, i8*, i8*, i8*, i64 } { i64 0, i64 40, i8* bitcast (void (i8*, i8*)* @__copy_helper_block_

[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Is this test that's being added libc++ specific, or would it apply to other 
implementations as well?




Comment at: 
test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp:18
+
+// template  explicit mersenne_twister_engine(Sseq &q);
+

Please add a comment here about what's being tested, because when I look at 
this a year from now, I won't know what's going on.

Something like:
`//  Finally, if the most significant w − r bits of X−n are zero, and if each 
of the other resulting Xi is 0, changes X−n to 2w−1.`




Comment at: 
test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp:47
+
+template  void test(void) {
+  const std::size_t state_size = 1u;

Need a line break before `void`


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736



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


[clang-tools-extra] r339781 - [clangd][tests] Fix typo in tests - invalid LSP exit message

2018-08-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Aug 15 08:50:45 2018
New Revision: 339781

URL: http://llvm.org/viewvc/llvm-project?rev=339781&view=rev
Log:
[clangd][tests] Fix typo in tests - invalid LSP exit message

Syntactically invalid JSON payload was causing clangd to terminate because of 
unexpected EOF rather than exit as a response to LSP exit message.

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

Modified:
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/formatting.test
clang-tools-extra/trunk/test/clangd/initialize-params.test
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
clang-tools-extra/trunk/test/clangd/unsupported-method.test

Modified: clang-tools-extra/trunk/test/clangd/extra-flags.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/extra-flags.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/extra-flags.test (original)
+++ clang-tools-extra/trunk/test/clangd/extra-flags.test Wed Aug 15 08:50:45 
2018
@@ -49,6 +49,6 @@
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
 
 

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Wed Aug 15 08:50:45 2018
@@ -184,4 +184,4 @@
 ---
 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/initialize-params.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/initialize-params.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/initialize-params.test (original)
+++ clang-tools-extra/trunk/test/clangd/initialize-params.test Wed Aug 15 
08:50:45 2018
@@ -46,4 +46,4 @@
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": null
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test Wed Aug 15 
08:50:45 2018
@@ -1,4 +1,4 @@
 # RUN: clangd -lit-test < %s
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test Wed Aug 15 
08:50:45 2018
@@ -1,2 +1,2 @@
 # RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/unsupported-method.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/unsupported-method.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test (original)
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test Wed Aug 15 
08:50:45 2018
@@ -13,4 +13,4 @@
 ---
 {"jsonrpc":"2.0","id":2,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}


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


[PATCH] D50641: [clangd][test] Fix exit messages in tests

2018-08-15 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339781: [clangd][tests] Fix typo in tests - invalid LSP exit 
message (authored by jkorous, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50641?vs=160367&id=160819#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50641

Files:
  clang-tools-extra/trunk/test/clangd/extra-flags.test
  clang-tools-extra/trunk/test/clangd/formatting.test
  clang-tools-extra/trunk/test/clangd/initialize-params.test
  clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
  clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
  clang-tools-extra/trunk/test/clangd/unsupported-method.test


Index: clang-tools-extra/trunk/test/clangd/extra-flags.test
===
--- clang-tools-extra/trunk/test/clangd/extra-flags.test
+++ clang-tools-extra/trunk/test/clangd/extra-flags.test
@@ -49,6 +49,6 @@
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
 
 
Index: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
===
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
@@ -1,2 +1,2 @@
 # RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/initialize-params.test
===
--- clang-tools-extra/trunk/test/clangd/initialize-params.test
+++ clang-tools-extra/trunk/test/clangd/initialize-params.test
@@ -46,4 +46,4 @@
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": null
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -184,4 +184,4 @@
 ---
 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/unsupported-method.test
===
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test
@@ -13,4 +13,4 @@
 ---
 {"jsonrpc":"2.0","id":2,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
===
--- clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
+++ clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
@@ -1,4 +1,4 @@
 # RUN: clangd -lit-test < %s
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}


Index: clang-tools-extra/trunk/test/clangd/extra-flags.test
===
--- clang-tools-extra/trunk/test/clangd/extra-flags.test
+++ clang-tools-extra/trunk/test/clangd/extra-flags.test
@@ -49,6 +49,6 @@
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
 
 
Index: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
===
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
@@ -1,2 +1,2 @@
 # RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/initialize-params.test
===
--- clang-tools-extra/trunk/test/clangd/initialize-params.test
+++ clang-tools-extra/trunk/test/clangd/initialize-params.test
@@ -46,4 +46,4 @@
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": null
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -184,4 +184,4 @@
 ---
 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/unsupported-method.test
===
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test
+++ clang-tools-extra/trunk/test/clangd/

[clang-tools-extra] r339782 - [clangd][tests] Rename tests of clangd instance termination

2018-08-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Aug 15 08:58:05 2018
New Revision: 339782

URL: http://llvm.org/viewvc/llvm-project?rev=339782&view=rev
Log:
[clangd][tests] Rename tests of clangd instance termination

Just making testnames better reflect their testing scenarios.

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

Added:
clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test
  - copied, changed from r339781, 
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test
  - copied, changed from r339781, 
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
Removed:
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test

Copied: clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test (from 
r339781, clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test?p2=clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test&p1=clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test&r1=339781&r2=339782&rev=339782&view=diff
==
(empty)

Copied: clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test (from 
r339781, clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test?p2=clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test&p1=clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test&r1=339781&r2=339782&rev=339782&view=diff
==
(empty)

Removed: clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test?rev=339781&view=auto
==
--- clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (removed)
@@ -1,4 +0,0 @@
-# RUN: clangd -lit-test < %s
-{"jsonrpc":"2.0","id":3,"method":"shutdown"}

-{"jsonrpc":"2.0","method":"exit"}

Removed: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test?rev=339781&view=auto
==
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (removed)
@@ -1,2 +0,0 @@
-# RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0","method":"exit"}


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


[clang-tools-extra] r339783 - Reland "[clang-doc] Updating BitcodeReader to use llvm::Error""

2018-08-15 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Aug 15 09:02:28 2018
New Revision: 339783

URL: http://llvm.org/viewvc/llvm-project?rev=339783&view=rev
Log:
Reland "[clang-doc] Updating BitcodeReader to use llvm::Error""

With explicit unique_ptr casts so that bots with older compilers don't
break.

Modified:
clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
clang-tools-extra/trunk/clang-doc/BitcodeReader.h

Modified: clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp?rev=339783&r1=339782&r2=339783&view=diff
==
--- clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp Wed Aug 15 09:02:28 2018
@@ -10,6 +10,7 @@
 #include "BitcodeReader.h"
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -17,49 +18,53 @@ namespace doc {
 
 using Record = llvm::SmallVector;
 
-bool decodeRecord(Record R, llvm::SmallVectorImpl &Field,
-  llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, llvm::SmallVectorImpl &Field,
+ llvm::StringRef Blob) {
   Field.assign(Blob.begin(), Blob.end());
-  return true;
+  return llvm::Error::success();
 }
 
-bool decodeRecord(Record R, SymbolID &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, SymbolID &Field, llvm::StringRef Blob) {
   if (R[0] != BitCodeConstants::USRHashSize)
-return false;
+return llvm::make_error("Incorrect USR size.\n",
+   llvm::inconvertibleErrorCode());
 
   // First position in the record is the length of the following array, so we
   // copy the following elements to the field.
   for (int I = 0, E = R[0]; I < E; ++I)
 Field[I] = R[I + 1];
-  return true;
+  return llvm::Error::success();
 }
 
-bool decodeRecord(Record R, bool &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, bool &Field, llvm::StringRef Blob) {
   Field = R[0] != 0;
-  return true;
+  return llvm::Error::success();
 }
 
-bool decodeRecord(Record R, int &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, int &Field, llvm::StringRef Blob) {
   if (R[0] > INT_MAX)
-return false;
+return llvm::make_error("Integer too large to parse.\n",
+   llvm::inconvertibleErrorCode());
   Field = (int)R[0];
-  return true;
+  return llvm::Error::success();
 }
 
-bool decodeRecord(Record R, AccessSpecifier &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, AccessSpecifier &Field,
+ llvm::StringRef Blob) {
   switch (R[0]) {
   case AS_public:
   case AS_private:
   case AS_protected:
   case AS_none:
 Field = (AccessSpecifier)R[0];
-return true;
+return llvm::Error::success();
   default:
-return false;
+return llvm::make_error(
+"Invalid value for AccessSpecifier.\n", 
llvm::inconvertibleErrorCode());
   }
 }
 
-bool decodeRecord(Record R, TagTypeKind &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, TagTypeKind &Field, llvm::StringRef Blob) {
   switch (R[0]) {
   case TTK_Struct:
   case TTK_Interface:
@@ -67,21 +72,23 @@ bool decodeRecord(Record R, TagTypeKind
   case TTK_Class:
   case TTK_Enum:
 Field = (TagTypeKind)R[0];
-return true;
+return llvm::Error::success();
   default:
-return false;
+return llvm::make_error(
+"Invalid value for TagTypeKind.\n", llvm::inconvertibleErrorCode());
   }
 }
 
-bool decodeRecord(Record R, llvm::Optional &Field,
-  llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, llvm::Optional &Field,
+ llvm::StringRef Blob) {
   if (R[0] > INT_MAX)
-return false;
+return llvm::make_error("Integer too large to parse.\n",
+   llvm::inconvertibleErrorCode());
   Field.emplace((int)R[0], Blob);
-  return true;
+  return llvm::Error::success();
 }
 
-bool decodeRecord(Record R, InfoType &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, InfoType &Field, llvm::StringRef Blob) {
   switch (auto IT = static_cast(R[0])) {
   case InfoType::IT_namespace:
   case InfoType::IT_record:
@@ -89,12 +96,13 @@ bool decodeRecord(Record R, InfoType &Fi
   case InfoType::IT_default:
   case InfoType::IT_enum:
 Field = IT;
-return true;
+return llvm::Error::success();
   }
-  return false;
+  return llvm::make_error("Invalid value for InfoType.\n",
+ llvm::inconvertibleErrorCode());
 }
 
-bool decodeRecord(Record R, FieldId &Field, llvm::StringRef Blob) {
+llvm::Error decodeRecord(Record R, FieldId &Field, llvm::StringRef Blob) {
   switch (auto F = static_cast(R[0])) {
   case FieldId:

[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In https://reviews.llvm.org/D50736#1200761, @mclow.lists wrote:

> Is this test that's being added libc++ specific, or would it apply to other 
> implementations as well?


The test can apply to other implementations as well (although I am not sure how 
the `initializer_list` include behaves under C++03 on other implementations). 
Is there some other place to put such tests?




Comment at: 
test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp:47
+
+template  void test(void) {
+  const std::size_t state_size = 1u;

mclow.lists wrote:
> Need a line break before `void`
I have no objection to adding a line break, but I would like to clarify that 
this line came straight out of a recent build of `clang-format` with 
`--style=llvm`. I would like to know whether there is something else here that 
I should be doing with `clang-format`, including if it is deemed that 
`clang-format` does not do the right thing here.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736



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


[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Does this hit new coverage in the vectorizer?




Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:46
 std::string VarRefToString(std::ostream &os, const VarRef &x) {
+  std::string var = inner_loop ? "inner" : "outer";
   std::string arr;

Please choose a better name than var.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:127
   }
+  inner_loop = true;
   return os;

This looks like a bug.  `inner_loop` never gets set to false again.  Might be a 
good reason to make it parameter instead.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:131
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-<< "%1 = icmp sgt i64 %s, 0\n"
-<< "br i1 %1, label %start, label %end\n"
-<< "start:\n"
-<< "br label %loop\n"
-<< "end:\n"
-<< "ret void\n"
-<< "loop:\n"
-<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-<< x.statements()
-<< "%ctnew = add i64 %ct, 1\n"
-<< "%j = icmp eq i64 %ctnew, %s\n"
-<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
-<< "!0 = distinct !{!0, !1, !2}\n"
-<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
-<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
-<< "}\n";
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"

Why do you change this to `pc` again?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:132
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
+ << "%cmp = icmp sgt i64 %s, 0\n"

I'm curious how this change affects coverage independent of the rest of this 
change.  Also what would happen if we set `%a` and `%b` to noalias as well?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:136
+ << "outer_loop_start:\n"
+ << "br label %inner_loop_start\n"
+ << "inner_loop_start:\n"

Looks like a pointless branch.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:144
+ << x.outer_statements()
+ << "%o_ct_new = add nuw nsw i64 %outer_ct, 1\n"
+ << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"

Why `nuw`, `nsw` here?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:154
+ << "}\n"
+ << "!0 = distinct !{!0, !1, !2}\n"
+ << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"

Can we simplify the order of blocks here?  It is confusing to follow all these 
jumps forward and backward.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50785: [clangd][tests] Add exit(EXIT_FAILURE) in case of JSON parsing failure in TestMode

2018-08-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: arphaman, ilya-biryukov.
jkorous added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, dexonsmith, MaskRay, ioeric.

This is meant to cause a visible fail when clangd gets invalid JSON payload in 
-lit-test mode.

Based on discussion in https://reviews.llvm.org/D50641 (and 
http://lists.llvm.org/pipermail/clangd-dev/2018-August/72.html).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50785

Files:
  ClangdLSPServer.cpp
  ClangdLSPServer.h
  JSONRPCDispatcher.cpp
  JSONRPCDispatcher.h
  tool/ClangdMain.cpp


Index: tool/ClangdMain.cpp
===
--- tool/ClangdMain.cpp
+++ tool/ClangdMain.cpp
@@ -308,5 +308,6 @@
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
-  return LSPServer.run(stdin, InputStyle) ? 0 : NoShutdownRequestErrorCode;
+  return LSPServer.run(stdin, Test, InputStyle) ? 0
+: NoShutdownRequestErrorCode;
 }
Index: JSONRPCDispatcher.h
===
--- JSONRPCDispatcher.h
+++ JSONRPCDispatcher.h
@@ -109,7 +109,8 @@
 /// with signals, which are sent by debuggers on some OSs.
 void runLanguageServerLoop(std::FILE *In, JSONOutput &Out,
JSONStreamStyle InputStyle,
-   JSONRPCDispatcher &Dispatcher, bool &IsDone);
+   JSONRPCDispatcher &Dispatcher, bool &IsDone,
+   bool TestMode);
 
 } // namespace clangd
 } // namespace clang
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -342,8 +342,8 @@
 // The C APIs seem to be clearer in this respect.
 void clangd::runLanguageServerLoop(std::FILE *In, JSONOutput &Out,
JSONStreamStyle InputStyle,
-   JSONRPCDispatcher &Dispatcher,
-   bool &IsDone) {
+   JSONRPCDispatcher &Dispatcher, bool &IsDone,
+   bool TestMode) {
   auto &ReadMessage =
   (InputStyle == Delimited) ? readDelimitedMessage : readStandardMessage;
   while (!IsDone && !feof(In)) {
@@ -362,6 +362,8 @@
 // Parse error. Log the raw message.
 vlog("<<< {0}\n", *JSON);
 elog("JSON parse error: {0}", llvm::toString(Doc.takeError()));
+if (TestMode)
+  exit(EXIT_FAILURE);
   }
 }
   }
Index: ClangdLSPServer.h
===
--- ClangdLSPServer.h
+++ ClangdLSPServer.h
@@ -43,7 +43,7 @@
   /// each instance of ClangdLSPServer.
   ///
   /// \return Whether we received a 'shutdown' request before an 'exit' 
request.
-  bool run(std::FILE *In,
+  bool run(std::FILE *In, bool TestMode,
JSONStreamStyle InputStyle = JSONStreamStyle::Standard);
 
 private:
Index: ClangdLSPServer.cpp
===
--- ClangdLSPServer.cpp
+++ ClangdLSPServer.cpp
@@ -447,7 +447,8 @@
   CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()),
   Server(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this, Opts) {}
 
-bool ClangdLSPServer::run(std::FILE *In, JSONStreamStyle InputStyle) {
+bool ClangdLSPServer::run(std::FILE *In, bool TestMode,
+  JSONStreamStyle InputStyle) {
   assert(!IsDone && "Run was called before");
 
   // Set up JSONRPCDispatcher.
@@ -457,7 +458,7 @@
   registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this);
 
   // Run the Language Server loop.
-  runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone);
+  runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone, TestMode);
 
   // Make sure IsDone is set to true after this method exits to ensure 
assertion
   // at the start of the method fires if it's ever executed again.


Index: tool/ClangdMain.cpp
===
--- tool/ClangdMain.cpp
+++ tool/ClangdMain.cpp
@@ -308,5 +308,6 @@
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
-  return LSPServer.run(stdin, InputStyle) ? 0 : NoShutdownRequestErrorCode;
+  return LSPServer.run(stdin, Test, InputStyle) ? 0
+: NoShutdownRequestErrorCode;
 }
Index: JSONRPCDispatcher.h
===
--- JSONRPCDispatcher.h
+++ JSONRPCDispatcher.h
@@ -109,7 +109,8 @@
 /// with signals, which are sent by debuggers on some OSs.
 void runLanguageServerLoop(std::FILE *In, JSONOutput &Out,
JSONStreamStyle InputStyle,
-   JSO

[clang-tools-extra] r339785 - [clang-doc] Explicitly cast to unique_ptr

2018-08-15 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Aug 15 09:18:46 2018
New Revision: 339785

URL: http://llvm.org/viewvc/llvm-project?rev=339785&view=rev
Log:
[clang-doc] Explicitly cast to unique_ptr

Older compilers don't like the implicit cast & move when returning a
unique_ptr to an llvm::Expected type.

Modified:
clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp

Modified: clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp?rev=339785&r1=339784&r2=339785&view=diff
==
--- clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/BitcodeReader.cpp Wed Aug 15 09:18:46 2018
@@ -657,7 +657,7 @@ ClangDocBitcodeReader::createInfo(unsign
   std::unique_ptr I = llvm::make_unique();
   if (auto Err = readBlock(ID, static_cast(I.get(
 return std::move(Err);
-  return I;
+  return std::unique_ptr{std::move(I)};;
 }
 
 llvm::Expected>


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


r339787 - [AST] Pack the bits of TemplateSpecializationType into Type

2018-08-15 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Wed Aug 15 09:21:17 2018
New Revision: 339787

URL: http://llvm.org/viewvc/llvm-project?rev=339787&view=rev
Log:
[AST] Pack the bits of TemplateSpecializationType into Type

Type has enough space for two members of
TemplateSpecializationType. Mechanical patch.

Reviewed By: erichkeane

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


Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=339787&r1=339786&r2=339787&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Aug 15 09:21:17 2018
@@ -1606,6 +1606,24 @@ protected:
 unsigned Keyword : 2;
   };
 
+  class TemplateSpecializationTypeBitfields {
+friend class TemplateSpecializationType;
+
+unsigned : NumTypeBits;
+
+/// Whether this template specialization type is a substituted type alias.
+unsigned TypeAlias : 1;
+
+/// The number of template arguments named in this class template
+/// specialization, which is expected to be able to hold at least 1024
+/// according to [implimits]. However, as this limit is somewhat easy to
+/// hit with template metaprogramming we'd prefer to keep it as large
+/// as possible. At the moment it has been left as a non-bitfield since
+/// this type safely fits in 64 bits as an unsigned, so there is no reason
+/// to introduce the performance impact of a bitfield.
+unsigned NumArgs;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1617,6 +1635,7 @@ protected:
 ReferenceTypeBitfields ReferenceTypeBits;
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
+TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1638,6 +1657,9 @@ protected:
   "TypeWithKeywordBitfields is larger than 8 bytes!");
 static_assert(sizeof(VectorTypeBitfields) <= 8,
   "VectorTypeBitfields is larger than 8 bytes!");
+static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
+  "TemplateSpecializationTypeBitfields is larger"
+  " than 8 bytes!");
   };
 
 private:
@@ -4669,13 +4691,6 @@ class alignas(8) TemplateSpecializationT
   /// replacement must, recursively, be one of these).
   TemplateName Template;
 
-  /// The number of template arguments named in this class template
-  /// specialization.
-  unsigned NumArgs : 31;
-
-  /// Whether this template specialization type is a substituted type alias.
-  unsigned TypeAlias : 1;
-
   TemplateSpecializationType(TemplateName T,
  ArrayRef Args,
  QualType Canon,
@@ -4710,7 +4725,7 @@ public:
   ///   typedef A type; // not a type alias
   /// };
   /// \endcode
-  bool isTypeAlias() const { return TypeAlias; }
+  bool isTypeAlias() const { return TemplateSpecializationTypeBits.TypeAlias; }
 
   /// Get the aliased type, if this is a specialization of a type alias
   /// template.
@@ -4733,14 +4748,16 @@ public:
   }
 
   /// Retrieve the number of template arguments.
-  unsigned getNumArgs() const { return NumArgs; }
+  unsigned getNumArgs() const {
+return TemplateSpecializationTypeBits.NumArgs;
+  }
 
   /// Retrieve a specific template argument as a type.
   /// \pre \c isArgType(Arg)
   const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
 
   ArrayRef template_arguments() const {
-return {getArgs(), NumArgs};
+return {getArgs(), getNumArgs()};
   }
 
   bool isSugared() const {

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=339787&r1=339786&r2=339787&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed Aug 15 09:21:17 2018
@@ -3335,8 +3335,10 @@ TemplateSpecializationType(TemplateName
  Canon.isNull()? true : Canon->isDependentType(),
  Canon.isNull()? true : Canon->isInstantiationDependentType(),
  false,
- T.containsUnexpandedParameterPack()),
-Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
+ T.containsUnexpandedParameterPack()), Template(T) {
+  TemplateSpecializationTypeBits.NumArgs = Args.size();
+  TemplateSpecializationTypeBits.TypeAlias = !AliasedType.isNull();
+
   assert(!T.getAsDependentTemplateName() &&
  "Use DependentTemplateSpecializationType for dependent 
template-name");
   assert((T.getKind() == TemplateName::Template ||
@@ -3365,7 +3367,7 @@ TemplateSpecializationType(TemplateName
   }
 
   // Sto

[PATCH] D50643: [AST] Pack the bits of TemplateSpecializationType into Type

2018-08-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339787: [AST] Pack the bits of TemplateSpecializationType 
into Type (authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50643?vs=160805&id=160828#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50643

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/lib/AST/Type.cpp

Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -3335,8 +3335,10 @@
  Canon.isNull()? true : Canon->isDependentType(),
  Canon.isNull()? true : Canon->isInstantiationDependentType(),
  false,
- T.containsUnexpandedParameterPack()),
-Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
+ T.containsUnexpandedParameterPack()), Template(T) {
+  TemplateSpecializationTypeBits.NumArgs = Args.size();
+  TemplateSpecializationTypeBits.TypeAlias = !AliasedType.isNull();
+
   assert(!T.getAsDependentTemplateName() &&
  "Use DependentTemplateSpecializationType for dependent template-name");
   assert((T.getKind() == TemplateName::Template ||
@@ -3365,7 +3367,7 @@
   }
 
   // Store the aliased type if this is a type alias template specialization.
-  if (TypeAlias) {
+  if (isTypeAlias()) {
 auto *Begin = reinterpret_cast(this + 1);
 *reinterpret_cast(Begin + getNumArgs()) = AliasedType;
   }
Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1606,6 +1606,24 @@
 unsigned Keyword : 2;
   };
 
+  class TemplateSpecializationTypeBitfields {
+friend class TemplateSpecializationType;
+
+unsigned : NumTypeBits;
+
+/// Whether this template specialization type is a substituted type alias.
+unsigned TypeAlias : 1;
+
+/// The number of template arguments named in this class template
+/// specialization, which is expected to be able to hold at least 1024
+/// according to [implimits]. However, as this limit is somewhat easy to
+/// hit with template metaprogramming we'd prefer to keep it as large
+/// as possible. At the moment it has been left as a non-bitfield since
+/// this type safely fits in 64 bits as an unsigned, so there is no reason
+/// to introduce the performance impact of a bitfield.
+unsigned NumArgs;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1617,6 +1635,7 @@
 ReferenceTypeBitfields ReferenceTypeBits;
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
+TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1638,6 +1657,9 @@
   "TypeWithKeywordBitfields is larger than 8 bytes!");
 static_assert(sizeof(VectorTypeBitfields) <= 8,
   "VectorTypeBitfields is larger than 8 bytes!");
+static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
+  "TemplateSpecializationTypeBitfields is larger"
+  " than 8 bytes!");
   };
 
 private:
@@ -4669,13 +4691,6 @@
   /// replacement must, recursively, be one of these).
   TemplateName Template;
 
-  /// The number of template arguments named in this class template
-  /// specialization.
-  unsigned NumArgs : 31;
-
-  /// Whether this template specialization type is a substituted type alias.
-  unsigned TypeAlias : 1;
-
   TemplateSpecializationType(TemplateName T,
  ArrayRef Args,
  QualType Canon,
@@ -4710,7 +4725,7 @@
   ///   typedef A type; // not a type alias
   /// };
   /// \endcode
-  bool isTypeAlias() const { return TypeAlias; }
+  bool isTypeAlias() const { return TemplateSpecializationTypeBits.TypeAlias; }
 
   /// Get the aliased type, if this is a specialization of a type alias
   /// template.
@@ -4733,14 +4748,16 @@
   }
 
   /// Retrieve the number of template arguments.
-  unsigned getNumArgs() const { return NumArgs; }
+  unsigned getNumArgs() const {
+return TemplateSpecializationTypeBits.NumArgs;
+  }
 
   /// Retrieve a specific template argument as a type.
   /// \pre \c isArgType(Arg)
   const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
 
   ArrayRef template_arguments() const {
-return {getArgs(), NumArgs};
+return {getArgs(), getNumArgs()};
   }
 
   bool isSugared() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: libcxx/include/__config:798-804
 #ifndef _LIBCPP_HIDE_FROM_ABI
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  ifdef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  else
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
+#  endif
 #endif

This doesn't leave a user-friendly way of opting out of internal linkage if a 
vendor decides to turn it on by default.  I suggest adding a layer of 
indirection:
```
// Elsewhere.
#cmakedefine _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE_BY_DEFAULT

// Here.
#ifndef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
#  ifdef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE_BY_DEFAULT
#define _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE 1
#  else
#define _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE 0
#  endif
#endif

#ifndef _LIBCPP_HIDE_FROM_ABI
#  if _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
#  else
#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
#  endif
#endif
```
Then users can set the behaviour with 
`-D_LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE=1` or 
`-D_LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE=0`, overriding the vendor default.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652



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


[PATCH] D50711: [AST] Pack the unsigned of PackExpansionType into Type

2018-08-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339789: [AST] Pack the unsigned of PackExpansionType into 
Type (authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50711?vs=160804&id=160831#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50711

Files:
  cfe/trunk/include/clang/AST/Type.h


Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1624,6 +1624,25 @@
 unsigned NumArgs;
   };
 
+  class PackExpansionTypeBitfields {
+friend class PackExpansionType;
+
+unsigned : NumTypeBits;
+
+/// The number of expansions that this pack expansion will
+/// generate when substituted (+1), which is expected to be able to
+/// hold at least 1024 according to [implimits]. However, as this limit
+/// is somewhat easy to hit with template metaprogramming we'd prefer to
+/// keep it as large as possible. At the moment it has been left as a
+/// non-bitfield since this type safely fits in 64 bits as an unsigned, so
+/// there is no reason to introduce the performance impact of a bitfield.
+///
+/// This field will only have a non-zero value when some of the parameter
+/// packs that occur within the pattern have been substituted but others
+/// have not.
+unsigned NumExpansions;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1636,6 +1655,7 @@
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
+PackExpansionTypeBitfields PackExpansionTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1660,6 +1680,8 @@
 static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
   "TemplateSpecializationTypeBitfields is larger"
   " than 8 bytes!");
+static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
+  "PackExpansionTypeBitfields is larger than 8 bytes");
   };
 
 private:
@@ -5189,22 +5211,16 @@
   /// The pattern of the pack expansion.
   QualType Pattern;
 
-  /// The number of expansions that this pack expansion will
-  /// generate when substituted (+1), or indicates that
-  ///
-  /// This field will only have a non-zero value when some of the parameter
-  /// packs that occur within the pattern have been substituted but others have
-  /// not.
-  unsigned NumExpansions;
-
   PackExpansionType(QualType Pattern, QualType Canon,
 Optional NumExpansions)
   : Type(PackExpansion, Canon, /*Dependent=*/Pattern->isDependentType(),
  /*InstantiationDependent=*/true,
  /*VariablyModified=*/Pattern->isVariablyModifiedType(),
  /*ContainsUnexpandedParameterPack=*/false),
-Pattern(Pattern),
-NumExpansions(NumExpansions ? *NumExpansions + 1 : 0) {}
+Pattern(Pattern) {
+PackExpansionTypeBits.NumExpansions =
+NumExpansions ? *NumExpansions + 1 : 0;
+  }
 
 public:
   /// Retrieve the pattern of this pack expansion, which is the
@@ -5215,9 +5231,8 @@
   /// Retrieve the number of expansions that this pack expansion will
   /// generate, if known.
   Optional getNumExpansions() const {
-if (NumExpansions)
-  return NumExpansions - 1;
-
+if (PackExpansionTypeBits.NumExpansions)
+  return PackExpansionTypeBits.NumExpansions - 1;
 return None;
   }
 


Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1624,6 +1624,25 @@
 unsigned NumArgs;
   };
 
+  class PackExpansionTypeBitfields {
+friend class PackExpansionType;
+
+unsigned : NumTypeBits;
+
+/// The number of expansions that this pack expansion will
+/// generate when substituted (+1), which is expected to be able to
+/// hold at least 1024 according to [implimits]. However, as this limit
+/// is somewhat easy to hit with template metaprogramming we'd prefer to
+/// keep it as large as possible. At the moment it has been left as a
+/// non-bitfield since this type safely fits in 64 bits as an unsigned, so
+/// there is no reason to introduce the performance impact of a bitfield.
+///
+/// This field will only have a non-zero value when some of the parameter
+/// packs that occur within the pattern have been substituted but others
+/// have not.
+unsigned NumExpansions;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1636,6 +1655,7 @@
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;

r339789 - [AST] Pack the unsigned of PackExpansionType into Type

2018-08-15 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Wed Aug 15 09:28:58 2018
New Revision: 339789

URL: http://llvm.org/viewvc/llvm-project?rev=339789&view=rev
Log:
[AST] Pack the unsigned of PackExpansionType into Type

The bit-fields of `Type` have enough space for
the `unsigned NumExpansions` of `PackExpansionType`

Reviewed By: erichkeane

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


Modified:
cfe/trunk/include/clang/AST/Type.h

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=339789&r1=339788&r2=339789&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Aug 15 09:28:58 2018
@@ -1624,6 +1624,25 @@ protected:
 unsigned NumArgs;
   };
 
+  class PackExpansionTypeBitfields {
+friend class PackExpansionType;
+
+unsigned : NumTypeBits;
+
+/// The number of expansions that this pack expansion will
+/// generate when substituted (+1), which is expected to be able to
+/// hold at least 1024 according to [implimits]. However, as this limit
+/// is somewhat easy to hit with template metaprogramming we'd prefer to
+/// keep it as large as possible. At the moment it has been left as a
+/// non-bitfield since this type safely fits in 64 bits as an unsigned, so
+/// there is no reason to introduce the performance impact of a bitfield.
+///
+/// This field will only have a non-zero value when some of the parameter
+/// packs that occur within the pattern have been substituted but others
+/// have not.
+unsigned NumExpansions;
+  };
+
   union {
 TypeBitfields TypeBits;
 ArrayTypeBitfields ArrayTypeBits;
@@ -1636,6 +1655,7 @@ protected:
 TypeWithKeywordBitfields TypeWithKeywordBits;
 VectorTypeBitfields VectorTypeBits;
 TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
+PackExpansionTypeBitfields PackExpansionTypeBits;
 
 static_assert(sizeof(TypeBitfields) <= 8,
   "TypeBitfields is larger than 8 bytes!");
@@ -1660,6 +1680,8 @@ protected:
 static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
   "TemplateSpecializationTypeBitfields is larger"
   " than 8 bytes!");
+static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
+  "PackExpansionTypeBitfields is larger than 8 bytes");
   };
 
 private:
@@ -5189,22 +5211,16 @@ class PackExpansionType : public Type, p
   /// The pattern of the pack expansion.
   QualType Pattern;
 
-  /// The number of expansions that this pack expansion will
-  /// generate when substituted (+1), or indicates that
-  ///
-  /// This field will only have a non-zero value when some of the parameter
-  /// packs that occur within the pattern have been substituted but others have
-  /// not.
-  unsigned NumExpansions;
-
   PackExpansionType(QualType Pattern, QualType Canon,
 Optional NumExpansions)
   : Type(PackExpansion, Canon, /*Dependent=*/Pattern->isDependentType(),
  /*InstantiationDependent=*/true,
  /*VariablyModified=*/Pattern->isVariablyModifiedType(),
  /*ContainsUnexpandedParameterPack=*/false),
-Pattern(Pattern),
-NumExpansions(NumExpansions ? *NumExpansions + 1 : 0) {}
+Pattern(Pattern) {
+PackExpansionTypeBits.NumExpansions =
+NumExpansions ? *NumExpansions + 1 : 0;
+  }
 
 public:
   /// Retrieve the pattern of this pack expansion, which is the
@@ -5215,9 +5231,8 @@ public:
   /// Retrieve the number of expansions that this pack expansion will
   /// generate, if known.
   Optional getNumExpansions() const {
-if (NumExpansions)
-  return NumExpansions - 1;
-
+if (PackExpansionTypeBits.NumExpansions)
+  return PackExpansionTypeBits.NumExpansions - 1;
 return None;
   }
 


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


[PATCH] D50783: [CodeGen] Merge identical block descriptor global variables

2018-08-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

A few points I forgot to mention:

- This optimization kicks in only in NonGC mode. I don't think we need to care 
much about GC anymore, so I think that's OK.

- There is a lot of redundancy among the copy/dispose helper function strings 
and the block layout string in the block descriptor name (they all encode the 
information about the captures), which can make the descriptor name long. If 
that becomes a problem, it's possible to encode the information in a way that 
shortens the descriptor name, but that would probably make the function that 
generates the name more complex.


Repository:
  rC Clang

https://reviews.llvm.org/D50783



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


[PATCH] D50455: Continue emitting diagnostics after a fatal error

2018-08-15 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov updated this revision to Diff 160837.
Dmitry.Kozhevnikov added a comment.

Add a unit test which explicitly builds preamble/AST


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50455

Files:
  clangd/ClangdUnit.cpp
  clangd/Compiler.cpp
  test/clangd/missing-includes.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -15,6 +15,8 @@
 #include "TestFS.h"
 #include "URI.h"
 #include "clang/Config/config.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/PCHContainerOperations.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Errc.h"
@@ -37,6 +39,7 @@
 using ::testing::Eq;
 using ::testing::Field;
 using ::testing::Gt;
+using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -963,6 +966,53 @@
Field(&CodeCompletion::Name, "baz")));
 }
 
+TEST(DiagnosticsTest, RecoverAfterFatalError) {
+  auto FooCpp = testPath("foo.cpp");
+
+  ParseInputs PI;
+  PI.CompileCommand.Directory = testRoot();
+  PI.CompileCommand.Filename = FooCpp;
+  PI.CompileCommand.CommandLine = {"clang", "-xc++", FooCpp};
+
+  llvm::StringMap Files;
+  Files[FooCpp] = "";
+  PI.FS = buildTestFS(Files);
+
+  PI.Contents = R"cpp(
+#include "preamble1"
+#include "preamble2"
+// end of the preamble
+int x;
+#include "main1"
+#include "main2"
+  )cpp";
+
+  auto PreambleCI = buildCompilerInvocation(PI);
+
+  auto Preamble = buildPreamble(
+  FooCpp, *PreambleCI, /*OldPreamble=*/nullptr, tooling::CompileCommand(),
+  PI, std::make_shared(), /*StoreInMemory=*/true,
+  /*PreambleCallback=*/nullptr);
+  ASSERT_TRUE(Preamble) << "Failed to build preamble";
+
+  ASSERT_EQ(Preamble->Diags.size(), 2u);
+  EXPECT_THAT(Preamble->Diags[0].Message, HasSubstr("preamble1"));
+  EXPECT_THAT(Preamble->Diags[1].Message, HasSubstr("preamble2"));
+
+  auto MainFileCI = buildCompilerInvocation(PI);
+  auto AST =
+  ParsedAST::build(std::move(MainFileCI), Preamble,
+   llvm::MemoryBuffer::getMemBufferCopy(PI.Contents),
+   std::make_shared(), PI.FS);
+  ASSERT_TRUE(AST.hasValue()) << "Failed to build AST";
+
+  ASSERT_EQ(AST->getDiagnostics().size(), 4u);
+  EXPECT_THAT(AST->getDiagnostics()[0].Message, HasSubstr("preamble1"));
+  EXPECT_THAT(AST->getDiagnostics()[1].Message, HasSubstr("preamble2"));
+  EXPECT_THAT(AST->getDiagnostics()[2].Message, HasSubstr("main1"));
+  EXPECT_THAT(AST->getDiagnostics()[3].Message, HasSubstr("main2"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: test/clangd/missing-includes.test
===
--- /dev/null
+++ test/clangd/missing-includes.test
@@ -0,0 +1,13 @@
+# RUN: clangd -lit-test < %s | FileCheck %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"#include \n#include \nint x;\n#include \n#include \n"}}}
+# CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK:  "message": "'a' file not found",
+# CHECK:  "message": "'b' file not found",
+# CHECK:  "message": "'c' file not found",
+# CHECK:  "message": "'d' file not found",
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/Compiler.cpp
===
--- clangd/Compiler.cpp
+++ clangd/Compiler.cpp
@@ -63,6 +63,7 @@
   auto Clang = llvm::make_unique(PCHs);
   Clang->setInvocation(std::move(CI));
   Clang->createDiagnostics(&DiagsClient, false);
+  Clang->getDiagnostics().setSuppressAfterFatalError(false);
 
   if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
   Clang->getInvocation(), Clang->getDiagnostics(), VFS))
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -328,6 +328,8 @@
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  PreambleDiagsEngine->setSuppressAfterFatalError(false);
+
   CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
   if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
 log("Couldn't set working directory when building the preamble.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50455: Continue emitting diagnostics after a fatal error

2018-08-15 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov added a comment.

In https://reviews.llvm.org/D50455#1193468, @ilya-biryukov wrote:

> I'm a bit worried that clang may emit too many irrelevant errors, because it 
> may not cope nicely with those fatal errors, i.e. wasn't tested that 
> thoroughly in that mode.


It sort of happens already: even if you have a fatal error in a preamble, 
diagnostics for the main file are still produced. This just expands it for the 
case the fatal error and the rest of the code happen to exist both in the 
preamble/main file.

> Nevertheless, I think this is moving clangd in the right direction and if we 
> see too many irrelevant errors, we should look into improving clang to show 
> less of those.

We've enabled it in CLion by default, hopefully, we'll get some feedback.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50455



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


[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments.



Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:410
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y"));
+}

JonasToth wrote:
> Out of curiosity: Why is the result with `y` different from the result for 
> `x`? Both time `x` is mutated and `g()` mutates them.
This is ultimately caused by not handling pointers yet.
As soon as the address of an object is taken we assume the object is mutated.
e.g.
```
void f(const int*);
void g() {
  int x;
  f(&x); // <-- address of x taken, assume mutation
  int y[10];
  f(y); // <-- address of y taken, assume mutation
}
```
And in all such cases the "mutated by" expression is the expression that takes 
the address.

So back in this case, `g(x)` mutates `x` because we're assuming `g` mutates its 
argument through non-const reference. Note that the declared `g` might not be 
the one actually being called because of overload resolution, there could be 
another `void g(char(&)[8])`
While for `g(y)` we know it's calling the `void g(char*)` so there's an array 
to pointer decay, and the decay is the point we assumed mutation not the 
function call.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619



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


[libcxx] r339794 - For FreeBSD, don't define _M in nasty_macros.hpp

2018-08-15 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Aug 15 10:30:32 2018
New Revision: 339794

URL: http://llvm.org/viewvc/llvm-project?rev=339794&view=rev
Log:
For FreeBSD, don't define _M in nasty_macros.hpp

Because FreeBSD uses _M in its , and it is hard to avoid
including that header, only define _M to NASTY_MACRO for other operating
systems.  This fixes almost 2000 unexpected test failures.

Discussed with Eric Fiselier.

Modified:
libcxx/trunk/test/support/nasty_macros.hpp

Modified: libcxx/trunk/test/support/nasty_macros.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/nasty_macros.hpp?rev=339794&r1=339793&r2=339794&view=diff
==
--- libcxx/trunk/test/support/nasty_macros.hpp (original)
+++ libcxx/trunk/test/support/nasty_macros.hpp Wed Aug 15 10:30:32 2018
@@ -22,7 +22,11 @@
 #define _J NASTY_MACRO
 #define _K NASTY_MACRO
 #define _L NASTY_MACRO
+// Because FreeBSD uses _M in its , and it is hard to avoid
+// including that header, only define _M for other operating systems.
+#ifndef __FreeBSD__
 #define _M NASTY_MACRO
+#endif
 #define _N NASTY_MACRO
 #define _O NASTY_MACRO
 #define _P NASTY_MACRO


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


[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.

2018-08-15 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:11678
 // Forget that LHS and RHS are sequenced. They are both unsequenced
 // with respect to other stuff.
+Tree.merge(LHSRegion);

Is this comment still relevant?


Repository:
  rC Clang

https://reviews.llvm.org/D50766



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


[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-15 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov updated this revision to Diff 160848.
Dmitry.Kozhevnikov changed the repository for this revision from rCTE Clang 
Tools Extra to rC Clang.
Dmitry.Kozhevnikov added a comment.

Addressed the review comment about separating "suppressing diagnostics" from 
"providing more complete AST"


Repository:
  rC Clang

https://reviews.llvm.org/D50462

Files:
  include/clang/Basic/Diagnostic.h
  lib/Lex/PPDirectives.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -77,7 +77,8 @@
 RemappedFiles[Filename] = Contents;
   }
 
-  std::unique_ptr ParseAST(const std::string &EntryFile) {
+  std::unique_ptr ParseAST(const std::string &EntryFile,
+bool SuppressAfterFatalError = true) {
 PCHContainerOpts = std::make_shared();
 std::shared_ptr CI(new CompilerInvocation);
 CI->getFrontendOpts().Inputs.push_back(
@@ -88,11 +89,15 @@
 
 CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
 
+CI->getLangOpts()->CPlusPlus = true;
+CI->getLangOpts()->CPlusPlus11 = true;
+
 PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
 PPOpts.RemappedFilesKeepOriginalName = true;
 
 IntrusiveRefCntPtr
   Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
+Diags->setSuppressAfterFatalError(SuppressAfterFatalError);
 
 FileManager *FileMgr = new FileManager(FSOpts, VFS);
 
@@ -197,4 +202,34 @@
   ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
 }
 
+TEST_F(PCHPreambleTest, MissingHeader) {
+  std::string Header1 = "//./header1.h";
+  AddFile(Header1, "template  class C;\n"
+   "template  class C{};\n");
+
+  std::string Header2 = "//./header2.h";
+  AddFile(Header2, "using Alias = C;\n");
+
+  std::string Main = "//./main.cpp";
+  AddFile(Main, "#include \"nonexistent1\"\n"
+"#include \"//./header1.h\"\n"
+"#include \"nonexistent2\"\n"
+"#include \"//./header2.h\"\n"
+"Alias Var;");
+
+  std::unique_ptr AST(
+  ParseAST(Main, /*SuppressAfterFatalError=*/false));
+  ASSERT_TRUE(AST.get());
+
+  // only "file not found" errors should be emitted,
+  // "Alias" should be visible for lookup.
+  auto ExpectedErrorsCount = 2u;
+
+  ASSERT_EQ(AST->getDiagnostics().getClient()->getNumErrors(),
+ExpectedErrorsCount);
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_EQ(AST->getDiagnostics().getClient()->getNumErrors(),
+ExpectedErrorsCount);
+}
+
 } // anonymous namespace
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -219,6 +219,7 @@
   // error have occurred. Any diagnostics we might have raised will not be
   // visible, and we do not need to construct a correct AST.
   if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  !SemaRef.Diags.shouldRecoverAfterFatalErrors() &&
   SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1899,7 +1899,8 @@
   // Any diagnostics after the fatal error will not be visible. As the
   // compilation failed already and errors in subsequently included files won't
   // be visible, avoid preprocessing those files.
-  if (ShouldEnter && Diags->hasFatalErrorOccurred())
+  if (ShouldEnter && Diags->hasFatalErrorOccurred() &&
+  !Diags->shouldRecoverAfterFatalErrors())
 ShouldEnter = false;
 
   // Determine whether we should try to import the module for this #include, if
Index: include/clang/Basic/Diagnostic.h
===
--- include/clang/Basic/Diagnostic.h
+++ include/clang/Basic/Diagnostic.h
@@ -752,6 +752,15 @@
   }
   bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
 
+  /// Determine whether the client should because a fatal error was issued, so
+  /// clients can cut off extra processing that might be wasteful in this case.
+  bool shouldRecoverAfterFatalErrors() const {
+// todo: a separate flag might be required for a client that doesn't want to
+// show any errors after the fatal, but still wants to collect as much
+// information from the source code as possible.
+return SuppressAfterFatalError;
+  }
+
   /// Determine whether any kind of unrecoverable error has occurred.
   bool hasUnrecoverableErrorOccurred() const {
 return FatalErrorOccurred || UnrecoverableErrorOccurred;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-15 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov added a comment.

In https://reviews.llvm.org/D50462#1193180, @arphaman wrote:

> On a second look I think that there is value separating the concepts of 
> 'producing diagnostics' after hitting the fatal error (which is 
> SuppressAfterFatalError currently does), and trying to build a more complete 
> AST.


Sorry for the delay.

I've introduced an accordingly-named method. I haven't created another flag 
yet, though, because it feels a bit weird currently since there are no clients 
that require it, added a todo note instead. What do you think?




Comment at: unittests/Frontend/PCHPreambleTest.cpp:220
+"#include \"//./header2.h\"\n"
+"Alias Var;");
+

The condition in `SemaTemplateInstantiate.cpp` was causing the lookup of 
`Alias` to fail: it was marked as invalid and wasn't stored in the preamble. 
I'll be happy to make a more straightforward test, but I've not yet managed to: 
when placing everything in a single file, the lookup succeeds.


Repository:
  rC Clang

https://reviews.llvm.org/D50462



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


[libcxx] r339797 - libcxx: Mark __temp_value::__temp_value as _LIBCPP_NO_CFI.

2018-08-15 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Aug 15 10:49:30 2018
New Revision: 339797

URL: http://llvm.org/viewvc/llvm-project?rev=339797&view=rev
Log:
libcxx: Mark __temp_value::__temp_value as _LIBCPP_NO_CFI.

This constructor needs to cast a pointer to uninitialized
memory to a pointer to object type in order to call
allocator_traits::construct(). This cast is not allowed when CFI cast
checks are enabled.

I did this instead of marking __addr() as _LIBCPP_NO_CFI so that we
don't lose CFI checks on get() or the dtor.

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

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=339797&r1=339796&r2=339797&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Aug 15 10:49:30 2018
@@ -5631,8 +5631,11 @@ struct __temp_value {
 _Tp &   get() { return *__addr(); }
 
 template
-__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
-{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
+_LIBCPP_NO_CFI
+__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+  _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
+ _VSTD::forward<_Args>(__args)...);
+}
 
 ~__temp_value() { _Traits::destroy(__a, __addr()); }
 };


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


[PATCH] D50743: libcxx: Mark __temp_value::__temp_value as _LIBCPP_NO_CFI.

2018-08-15 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX339797: libcxx: Mark __temp_value::__temp_value as 
_LIBCPP_NO_CFI. (authored by pcc, committed by ).
Herald added subscribers: cfe-commits, ldionne.

Changed prior to commit:
  https://reviews.llvm.org/D50743?vs=160712&id=160852#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D50743

Files:
  include/memory


Index: include/memory
===
--- include/memory
+++ include/memory
@@ -5631,8 +5631,11 @@
 _Tp &   get() { return *__addr(); }
 
 template
-__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
-{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
+_LIBCPP_NO_CFI
+__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+  _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
+ _VSTD::forward<_Args>(__args)...);
+}
 
 ~__temp_value() { _Traits::destroy(__a, __addr()); }
 };


Index: include/memory
===
--- include/memory
+++ include/memory
@@ -5631,8 +5631,11 @@
 _Tp &   get() { return *__addr(); }
 
 template
-__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
-{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
+_LIBCPP_NO_CFI
+__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+  _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
+ _VSTD::forward<_Args>(__args)...);
+}
 
 ~__temp_value() { _Traits::destroy(__a, __addr()); }
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50785: [clangd][tests] Add exit(EXIT_FAILURE) in case of JSON parsing failure in TestMode

2018-08-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I think propagating the 'test' yes/no value is not the best way to describe the 
intention of this change.
Our intention is to exit from the LSP server on JSON error. One way to describe 
this intention better is to propagate a boolean 'exitOnJSONError' value.
Furthermore, If you think about the '-llvm-lit' flag itself you'll see that it 
acts an abbreviation for these 3 options: `-input-style=delimited -pretty 
-run-synchronously`. I think that it would be valuable to follow this intention 
and to add a new option (e.g. `-exit-on-json-error`) that will then be set when 
`-llvm-lit` is set.
WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50785



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


[PATCH] D50792: [ASTImporter] Add test for member pointer types.

2018-08-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50792

Files:
  test/Import/cxx-member-pointers/Inputs/S.cpp
  test/Import/cxx-member-pointers/test.cpp


Index: test/Import/cxx-member-pointers/test.cpp
===
--- /dev/null
+++ test/Import/cxx-member-pointers/test.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+
+// CHECK: VarDecl
+// CHECK-SAME: int S::*
+// CHECK-NEXT: CallExpr
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-SAME: int S::*(*)()
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: int S::*()
+
+void expr() {
+  int S::*p = iptr();
+  S s;
+  s.i = 3;
+  int i = s.*p;
+}
Index: test/Import/cxx-member-pointers/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-member-pointers/Inputs/S.cpp
@@ -0,0 +1,7 @@
+struct S {
+  int i;
+};
+
+int S::*iptr() {
+  return &S::i;
+}


Index: test/Import/cxx-member-pointers/test.cpp
===
--- /dev/null
+++ test/Import/cxx-member-pointers/test.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+
+// CHECK: VarDecl
+// CHECK-SAME: int S::*
+// CHECK-NEXT: CallExpr
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-SAME: int S::*(*)()
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: int S::*()
+
+void expr() {
+  int S::*p = iptr();
+  S s;
+  s.i = 3;
+  int i = s.*p;
+}
Index: test/Import/cxx-member-pointers/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-member-pointers/Inputs/S.cpp
@@ -0,0 +1,7 @@
+struct S {
+  int i;
+};
+
+int S::*iptr() {
+  return &S::i;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41284: [Concepts] Associated constraints infrastructure.

2018-08-15 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 160861.
saar.raz added a comment.

- Address comments by rsmith, mainly removing associated constraints caching 
and instead returning a smallvector of constraint expressions from 
getAssociatedConstraints.


Repository:
  rC Clang

https://reviews.llvm.org/D41284

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Sema/Sema.h
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/var-template-decl.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/var-template-decl.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/var-template-decl.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+namespace nodiag {
+
+struct B {
+template  requires bool(T())
+static int A;
+};
+
+template  requires bool(U())
+int B::A = int(U());
+
+} // end namespace nodiag
+
+namespace diag {
+
+struct B {
+template  requires bool(T()) // expected-note{{previous template declaration is here}}
+static int A;
+};
+
+template  requires !bool(U())  // expected-error{{associated constraints differ in template redeclaration}}
+int B::A = int(U());
+
+} // end namespace diag
\ No newline at end of file
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
===
--- test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
@@ -1,65 +1,52 @@
-// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
 
 namespace nodiag {
 
 template  requires bool(T())
-struct A;
+int A();
 template  requires bool(U())
-struct A;
+int A();
 
 } // end namespace nodiag
 
 namespace diag {
 
 template  requires true // expected-note{{previous template declaration is here}}
-struct A;
-template  struct A; // expected-error{{associated constraints differ in template redeclaration}}
+int A();
+template  int A(); // expected-error{{associated constraints differ in template redeclaration}}
 
-template  struct B; // expected-note{{previous template declaration is here}}
+template  int B(); // expected-note{{previous template declaration is here}}
 template  requires true // expected-error{{associated constraints differ in template redeclaration}}
-struct B;
+int B();
 
 template  requires true // expected-note{{previous template declaration is here}}
-struct C;
+int C();
 template  requires !0 // expected-error{{associated constraints differ in template redeclaration}}
-struct C;
+int C();
 
 } // end namespace diag
 
 namespace nodiag {
 
 struct AA {
   template  requires someFunc(T())
-  struct A;
+  int A();
 };
 
 template  requires someFunc(T())
-struct AA::A { };
-
-struct AAF {
-  template  requires someFunc(T())
-  friend struct AA::A;
-};
+int AA::A() { return sizeof(T); }
 
 } // end namespace nodiag
 
 namespace diag {
 
 template 
 struct TA {
-  template  class TT> requires TT::happy // expected-note 2{{previous template declaration is here}}
-  struct A;
-
-  struct AF;
+  template  class TT> requires TT::happy // expected-note{{previous template declaration is here}}
+  int A();
 };
 
 template 
-template  class TT> struct TA::A { }; // expected-error{{associated constraints differ in template redeclaration}}
-
-template 
-struct TA::AF {
-  template  class TT> requires TT::happy // expected-error{{associated constraints differ in template redeclaration}}
-  friend struct TA::A;
-};
+template  class TT> int TA::A() { return sizeof(TT); } // expected-error{{associated constraints differ in template redeclaration}}
 
 } // end namespace diag
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
===
--- test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
 
 namespace nodiag {
 
@@ -33,7 +33,7 @@
   struct A;
 };
 
-template  requires someFunc(T())
+template  requires someFunc(U())
 struct AA::A { };
 
 struct AAF {
@@ -47,18 +47,26 @@
 
 template 
 struct TA {
-  template  class TT> requ

[PATCH] D50793: [ASTImporter] Add test for importing CompoundAssignOperators

2018-08-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50793

Files:
  test/Import/compound-assign-op/Inputs/F.cpp
  test/Import/compound-assign-op/test.cpp


Index: test/Import/compound-assign-op/test.cpp
===
--- /dev/null
+++ test/Import/compound-assign-op/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '+='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '-='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '*='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '/='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '&='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '^='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '<<='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '>>='
+
+void expr() {
+  f();
+}
Index: test/Import/compound-assign-op/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/compound-assign-op/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  unsigned iadd_eq = 0U;
+  iadd_eq += 1U;
+  unsigned isub_eq = 0U;
+  isub_eq -= 1U;
+  unsigned imul_eq = 0U;
+  imul_eq *= 1U;
+  unsigned idiv_eq = 0U;
+  idiv_eq /= 1U;
+  unsigned iand_eq = 0U;
+  iand_eq &= 1U;
+  unsigned ixor_eq = 0U;
+  ixor_eq ^= 1U;
+  unsigned ilsh_eq = 0U;
+  ilsh_eq <<= 1U;
+  unsigned irsh_eq = 0U;
+  irsh_eq >>= 1U;
+}


Index: test/Import/compound-assign-op/test.cpp
===
--- /dev/null
+++ test/Import/compound-assign-op/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '+='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '-='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '*='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '/='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '&='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '^='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '<<='
+
+// CHECK: VarDecl
+// CHECK-NEXT: Integer
+// CHECK-NEXT: CompoundAssignOperator
+// CHECK-SAME: '>>='
+
+void expr() {
+  f();
+}
Index: test/Import/compound-assign-op/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/compound-assign-op/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  unsigned iadd_eq = 0U;
+  iadd_eq += 1U;
+  unsigned isub_eq = 0U;
+  isub_eq -= 1U;
+  unsigned imul_eq = 0U;
+  imul_eq *= 1U;
+  unsigned idiv_eq = 0U;
+  idiv_eq /= 1U;
+  unsigned iand_eq = 0U;
+  iand_eq &= 1U;
+  unsigned ixor_eq = 0U;
+  ixor_eq ^= 1U;
+  unsigned ilsh_eq = 0U;
+  ilsh_eq <<= 1U;
+  unsigned irsh_eq = 0U;
+  irsh_eq >>= 1U;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added a comment.

In https://reviews.llvm.org/D50670#1200784, @morehouse wrote:

> Does this hit new coverage in the vectorizer?


Yes, this does hit new coverage in the loop vectorizer code.




Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:131
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-<< "%1 = icmp sgt i64 %s, 0\n"
-<< "br i1 %1, label %start, label %end\n"
-<< "start:\n"
-<< "br label %loop\n"
-<< "end:\n"
-<< "ret void\n"
-<< "loop:\n"
-<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-<< x.statements()
-<< "%ctnew = add i64 %ct, 1\n"
-<< "%j = icmp eq i64 %ctnew, %s\n"
-<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
-<< "!0 = distinct !{!0, !1, !2}\n"
-<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
-<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
-<< "}\n";
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"

morehouse wrote:
> Why do you change this to `pc` again?
Sorry, it got changed back when I copy/pasted the IR.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:136
+ << "outer_loop_start:\n"
+ << "br label %inner_loop_start\n"
+ << "inner_loop_start:\n"

morehouse wrote:
> Looks like a pointless branch.
I realize it's just a label with a branch instruction but I think I need it for 
the phi instruction. I will move the `outer_loop_start` label above the `icmp` 
instruction and change the branch from `outer_loop_start` to `inner_loop_start`.




Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:144
+ << x.outer_statements()
+ << "%o_ct_new = add nuw nsw i64 %outer_ct, 1\n"
+ << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"

morehouse wrote:
> Why `nuw`, `nsw` here?
Sorry, it got changed back when I copy/pasted the IR.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:154
+ << "}\n"
+ << "!0 = distinct !{!0, !1, !2}\n"
+ << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"

morehouse wrote:
> Can we simplify the order of blocks here?  It is confusing to follow all 
> these jumps forward and backward.
Yes, I think it might be cleaner to have the blocks like this: 

```
define @foo... {

outer_loop_start

outer_loop

inner_loop_start

inner_loop

end
}
```


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 160866.
emmettneyman edited the summary of this revision.
emmettneyman added a comment.

Small changes to generated IR


Repository:
  rC Clang

https://reviews.llvm.org/D50670

Files:
  clang/tools/clang-fuzzer/cxx_loop_proto.proto
  clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp

Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -30,17 +30,20 @@
 std::string StateSeqToString(std::ostream &os, const StatementSeq &x);
 
 // Counter variable to generate new LLVM IR variable names and wrapper function
-std::string get_var() {
+static std::string get_var() {
   static int ctr = 0;
   return "%var" + std::to_string(ctr++);
 }
 
+static bool inner_loop = false;
+
 // Proto to LLVM.
 
 std::string ConstToString(const Const &x) {
   return std::to_string(x.val());
 }
 std::string VarRefToString(std::ostream &os, const VarRef &x) {
+  std::string which_loop = inner_loop ? "inner" : "outer";
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
@@ -54,7 +57,8 @@
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr
+ << ", i64 %" << which_loop << "_ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -120,27 +124,37 @@
   for (auto &st : x.statements()) {
 os << st;
   }
+  inner_loop = true;
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-<< "%1 = icmp sgt i64 %s, 0\n"
-<< "br i1 %1, label %start, label %end\n"
-<< "start:\n"
-<< "br label %loop\n"
-<< "end:\n"
-<< "ret void\n"
-<< "loop:\n"
-<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-<< x.statements()
-<< "%ctnew = add i64 %ct, 1\n"
-<< "%j = icmp eq i64 %ctnew, %s\n"
-<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
-<< "!0 = distinct !{!0, !1, !2}\n"
-<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
-<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
-<< "}\n";
+  inner_loop = false;
+  os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
+ << "outer_loop_start:\n"
+ << "%cmp = icmp sgt i64 %s, 0\n"
+ << "br i1 %cmp, label %inner_loop_start, label %end\n"
+ << "inner_loop_start:\n"
+ << "%outer_ct = phi i64 [%o_ct_new, %outer_loop], [0, %outer_loop_start]\n"
+ << "br label %inner_loop\n"
+ << "end:\n"
+ << "ret void\n"
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"
+ << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"
+ << "br i1 %jmp_outer, label %end, label %inner_loop_start\n"
+ << "inner_loop:\n"
+ << "%inner_ct = phi i64 [0, %inner_loop_start], [%i_ct_new, %inner_loop]\n"
+ << x.inner_statements()
+ << "%i_ct_new = add i64 %inner_ct, 1\n"
+ << "%jmp_inner = icmp eq i64 %i_ct_new, %s\n"
+ << "br i1 %jmp_inner, label %outer_loop, label %inner_loop, !llvm.loop !0\n"
+ << "}\n"
+ << "!0 = distinct !{!0, !1, !2}\n"
+ << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+ << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize << "}\n";
+  return os;
 }
 
 // -
Index: clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -28,6 +28,8 @@
 
 namespace clang_fuzzer {
 
+static bool inner_loop;
+
 // Forward decls.
 std::ostream &operator<<(std::ostream &os, const BinaryOp &x);
 std::ostream &operator<<(std::ostream &os, const StatementSeq &x);
@@ -37,13 +39,14 @@
   return os << "(" << x.val() << ")";
 }
 std::ostream &operator<<(std::ostream &os, const VarRef &x) {
+  std::string var = inner_loop ? "i" : "j";
   switch (x.arr()) {
 case VarRef::ARR_A:
-  return os << "a[i]";
+  return os << "a[" << var << "]";
 case VarRef::ARR_B:
-  return os << "b[i]";
+  return os << "b[" << var << "]";
 case VarRef::ARR_C:
-  return os << "c[i]";
+  return os << "c[" << var << "]";
   }
 }
 std::ostream &operator<<(std::ostream &os, const Rvalue &x) {

[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 160870.
emmettneyman added a comment.

Small changes to generated IR, my last change hadn't saved


Repository:
  rC Clang

https://reviews.llvm.org/D50670

Files:
  clang/tools/clang-fuzzer/cxx_loop_proto.proto
  clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp

Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -30,17 +30,20 @@
 std::string StateSeqToString(std::ostream &os, const StatementSeq &x);
 
 // Counter variable to generate new LLVM IR variable names and wrapper function
-std::string get_var() {
+static std::string get_var() {
   static int ctr = 0;
   return "%var" + std::to_string(ctr++);
 }
 
+static bool inner_loop = false;
+
 // Proto to LLVM.
 
 std::string ConstToString(const Const &x) {
   return std::to_string(x.val());
 }
 std::string VarRefToString(std::ostream &os, const VarRef &x) {
+  std::string which_loop = inner_loop ? "inner" : "outer";
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
@@ -54,7 +57,8 @@
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr
+ << ", i64 %" << which_loop << "_ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -120,27 +124,37 @@
   for (auto &st : x.statements()) {
 os << st;
   }
+  inner_loop = true;
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-<< "%1 = icmp sgt i64 %s, 0\n"
-<< "br i1 %1, label %start, label %end\n"
-<< "start:\n"
-<< "br label %loop\n"
-<< "end:\n"
-<< "ret void\n"
-<< "loop:\n"
-<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-<< x.statements()
-<< "%ctnew = add i64 %ct, 1\n"
-<< "%j = icmp eq i64 %ctnew, %s\n"
-<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
-<< "!0 = distinct !{!0, !1, !2}\n"
-<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
-<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
-<< "}\n";
+  inner_loop = false;
+  os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
+ << "outer_loop_start:\n"
+ << "%cmp = icmp sgt i64 %s, 0\n"
+ << "br i1 %cmp, label %inner_loop_start, label %end\n"
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"
+ << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"
+ << "br i1 %jmp_outer, label %end, label %inner_loop_start\n"
+ << "inner_loop_start:\n"
+ << "%outer_ct = phi i64 [%o_ct_new, %outer_loop], [0, %outer_loop_start]\n"
+ << "br label %inner_loop\n"
+ << "inner_loop:\n"
+ << "%inner_ct = phi i64 [0, %inner_loop_start], [%i_ct_new, %inner_loop]\n"
+ << x.inner_statements()
+ << "%i_ct_new = add i64 %inner_ct, 1\n"
+ << "%jmp_inner = icmp eq i64 %i_ct_new, %s\n"
+ << "br i1 %jmp_inner, label %outer_loop, label %inner_loop, !llvm.loop !0\n"
+ << "end:\n"
+ << "ret void\n"
+ << "}\n"
+ << "!0 = distinct !{!0, !1, !2}\n"
+ << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+ << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize << "}\n";
+  return os;
 }
 
 // -
Index: clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -28,6 +28,8 @@
 
 namespace clang_fuzzer {
 
+static bool inner_loop;
+
 // Forward decls.
 std::ostream &operator<<(std::ostream &os, const BinaryOp &x);
 std::ostream &operator<<(std::ostream &os, const StatementSeq &x);
@@ -37,13 +39,14 @@
   return os << "(" << x.val() << ")";
 }
 std::ostream &operator<<(std::ostream &os, const VarRef &x) {
+  std::string var = inner_loop ? "i" : "j";
   switch (x.arr()) {
 case VarRef::ARR_A:
-  return os << "a[i]";
+  return os << "a[" << var << "]";
 case VarRef::ARR_B:
-  return os << "b[i]";
+  return os << "b[" << var << "]";
 case VarRef::ARR_C:
-  return os << "c[i]";
+  return os << "c[" << var << "]";
   }
 }
 std::ostream &operator<<(std::ostream &os, const Rvalue &x) {
@@ -109,9 +112,13 @@

[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:127
   }
+  inner_loop = true;
   return os;

Maybe this fixes the bug, but modifying `inner_loop` from different functions 
is still error-prone.

Please either make this a scoped variable (with a wrapper class that sets it to 
true in the constructor and sets it to false in the destructor), or make it a 
parameter.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:140
+ << "br label %inner_loop\n"
+ << "end:\n"
+ << "ret void\n"

I don't see any jumps to `end`.  I think this will be an infinite loop.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:143
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"

IIUC this creates loop structure always like this:

```
for (int i = 0; i < s; i++) {
  for (int j = 0; j < s; j++) {
// statements
  }
  // statements
}
```

Maybe not necessary for this patch, but I'm curious if adding statements before 
the inner loop would exercise different coverage in the vectorizer.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:143
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"

morehouse wrote:
> IIUC this creates loop structure always like this:
> 
> ```
> for (int i = 0; i < s; i++) {
>   for (int j = 0; j < s; j++) {
> // statements
>   }
>   // statements
> }
> ```
> 
> Maybe not necessary for this patch, but I'm curious if adding statements 
> before the inner loop would exercise different coverage in the vectorizer.
Will all loops be double-nested now?


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 160873.
ldionne added a comment.

Allow picking a custom default behavior for vendors, per Duncan's comment.

Also, revert to a better name for the macro.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652

Files:
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/DesignDocs/VisibilityMacros.rst
  libcxx/include/__config
  libcxx/include/__config_site.in
  libcxx/utils/libcxx/test/config.py

Index: libcxx/utils/libcxx/test/config.py
===
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -677,7 +677,8 @@
 if feature_macros[m]:
 define += '=%s' % (feature_macros[m])
 self.cxx.compile_flags += [define]
-if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS':
+if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS' or \
+   m == '_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT':
 continue
 if m == '_LIBCPP_ABI_VERSION':
 self.config.available_features.add('libcpp-abi-version-v%s'
Index: libcxx/include/__config_site.in
===
--- libcxx/include/__config_site.in
+++ libcxx/include/__config_site.in
@@ -14,6 +14,7 @@
 #cmakedefine _LIBCPP_ABI_UNSTABLE
 #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
 #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
+#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
 #cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 #cmakedefine _LIBCPP_HAS_NO_STDIN
 #cmakedefine _LIBCPP_HAS_NO_STDOUT
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -795,8 +795,20 @@
 #  define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
 #endif
 
+#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU
+#  ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
+#define _LIBCPP_HIDE_FROM_ABI_PER_TU 0
+#  else
+#define _LIBCPP_HIDE_FROM_ABI_PER_TU 1
+#  endif
+#endif
+
 #ifndef _LIBCPP_HIDE_FROM_ABI
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  if _LIBCPP_HIDE_FROM_ABI_PER_TU
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  else
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
+#  endif
 #endif
 
 #ifdef _LIBCPP_BUILDING_LIBRARY
Index: libcxx/docs/DesignDocs/VisibilityMacros.rst
===
--- libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -42,9 +42,7 @@
 
 **_LIBCPP_HIDE_FROM_ABI**
   Mark a function as not being part of the ABI of any final linked image that
-  uses it, and also as being internal to each TU that uses that function. In
-  other words, the address of a function marked with this attribute is not
-  guaranteed to be the same across translation units.
+  uses it.
 
 **_LIBCPP_HIDE_FROM_ABI_AFTER_V1**
   Mark a function as being hidden from the ABI (per `_LIBCPP_HIDE_FROM_ABI`)
@@ -61,6 +59,41 @@
   ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can
   use it to start removing symbols from the ABI after that stable version.
 
+**_LIBCPP_HIDE_FROM_ABI_PER_TU**
+  This macro controls whether symbols hidden from the ABI with `_LIBCPP_HIDE_FROM_ABI`
+  are local to each translation unit in addition to being local to each final
+  linked image. This macro is defined to either 0 or 1. When it is defined to
+  1, translation units compiled with different versions of libc++ can be linked
+  together, since all non ABI-facing functions are local to each translation unit.
+  This allows static archives built with different versions of libc++ to be linked
+  together. This also means that functions marked with `_LIBCPP_HIDE_FROM_ABI`
+  are not guaranteed to have the same address across translation unit boundaries.
+
+  When the macro is defined to 0, there is no guarantee that translation units
+  compiled with different versions of libc++ can interoperate. However, this
+  leads to code size improvements, since non ABI-facing functions can be
+  deduplicated across translation unit boundaries.
+
+  This macro can be defined by users to control the behavior they want from
+  libc++. The default value of this macro (0 or 1) is controlled by whether
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT` is defined, which is intended to
+  be used by vendors only (see below).
+
+**_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT**
+  This macro controls the default value for `_LIBCPP_HIDE_FROM_ABI_PER_TU`.
+  When the macro is defined, per TU ABI insulation is enabled by default, and
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU` is defined to 1 unless overriden by users.
+  Otherwise, per TU ABI insulation is disabled by default, and
+  `_LIBCPP_HIDE_FROM_ABI_PER_TU` is defined to 0 unless overriden by users.
+
+  This mac

[PATCH] D50796: [ASTImporter] Add test for IfStmt

2018-08-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50796

Files:
  test/Import/if-stmt/Inputs/F.cpp
  test/Import/if-stmt/test.cpp


Index: test/Import/if-stmt/test.cpp
===
--- /dev/null
+++ test/Import/if-stmt/test.cpp
@@ -0,0 +1,47 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: ReturnStmt
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ReturnStmt
+
+void expr() {
+  f();
+}
Index: test/Import/if-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/if-stmt/Inputs/F.cpp
@@ -0,0 +1,21 @@
+void f() {
+  if (true)
+return;
+
+  if (int j = 3)
+return;
+
+  if (int j; true)
+return;
+
+  if (true)
+return;
+  else
+return;
+
+  if (true) {
+return;
+  } else {
+return;
+  }
+}


Index: test/Import/if-stmt/test.cpp
===
--- /dev/null
+++ test/Import/if-stmt/test.cpp
@@ -0,0 +1,47 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: <>
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: ReturnStmt
+
+// CHECK: IfStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ReturnStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ReturnStmt
+
+void expr() {
+  f();
+}
Index: test/Import/if-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/if-stmt/Inputs/F.cpp
@@ -0,0 +1,21 @@
+void f() {
+  if (true)
+return;
+
+  if (int j = 3)
+return;
+
+  if (int j; true)
+return;
+
+  if (true)
+return;
+  else
+return;
+
+  if (true) {
+return;
+  } else {
+return;
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46081: [analyzer] Expand conversion check to check more expressions for overflow and underflow

2018-08-15 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: mikhail.ramalho.

To me it seems like @pfultz2 hasn't been on the site for a couple months. Is 
this patch going to be commited anytime?


https://reviews.llvm.org/D46081



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:1886
   case BuiltinType::ObjCId:
-mangleArtificalTagType(TTK_Struct, "objc_object");
+mangleArtificalTagType(TTK_Struct, ".objc_object");
 break;

theraven wrote:
> compnerd wrote:
> > DHowett-MSFT wrote:
> > > I'm interested in @smeenai's take on this, as well.
> > Hmm, doesn't this break ObjC/ObjC++ interoperability?  I don't think that 
> > we should be changing the decoration here for the MS ABI case.
> No, this fixes ObjC++ interop.  Throwing an exception from a `@throw` and 
> catching it with `catch` now works and we avoid the problem that a C++ 
> compilation unit declares a `struct` that happens to have the same name as an 
> Objective-C class (which is very common for wrapper code) may catch things of 
> the wrong type.
I've seen a lot of code which does something like this in a header

```lang=cpp
#ifdef __OBJC__
@class I;
#else
struct I;
#endif

void f(I *);
```

You want `f` to be mangled consistently across C++ and Objective-C++, otherwise 
you'll get link errors if `f` is e.g. defined in a C++ TU and referenced in an 
Objective-C++ TU. This was the case before your change and isn't the case after 
your change, which is what @compnerd was pointing out. They are mangled 
consistently in the Itanium ABI, and we want them to be mangled consistently in 
the MS ABI as well.

Not wanting the catch mix-up is completely reasonable, of course, but it can be 
done in a more targeted way. I'll put up a patch that undoes this part of the 
change while still preventing incorrect catching.


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


r339803 - clang-format: Change Google style wrt. the formatting of empty messages.

2018-08-15 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Aug 15 12:07:55 2018
New Revision: 339803

URL: http://llvm.org/viewvc/llvm-project?rev=339803&view=rev
Log:
clang-format: Change Google style wrt. the formatting of empty messages.

Before:
  message Empty {
  }

After:
  message Empty {}

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=339803&r1=339802&r2=339803&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Aug 15 12:07:55 2018
@@ -819,7 +819,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.JavaScriptQuotes = FormatStyle::JSQS_Single;
 GoogleStyle.JavaScriptWrapImports = false;
   } else if (Language == FormatStyle::LK_Proto) {
-GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.SpacesInContainerLiterals = false;
 GoogleStyle.Cpp11BracedListStyle = false;

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=339803&r1=339802&r2=339803&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Wed Aug 15 12:07:55 2018
@@ -397,29 +397,25 @@ TEST_F(FormatTestProto, FormatsService)
 }
 
 TEST_F(FormatTestProto, ExtendingMessage) {
-  verifyFormat("extend .foo.Bar {\n"
-   "}");
+  verifyFormat("extend .foo.Bar {}");
 }
 
 TEST_F(FormatTestProto, FormatsImports) {
   verifyFormat("import \"a.proto\";\n"
"import \"b.proto\";\n"
"// comment\n"
-   "message A {\n"
-   "}");
+   "message A {}");
 
   verifyFormat("import public \"a.proto\";\n"
"import \"b.proto\";\n"
"// comment\n"
-   "message A {\n"
-   "}");
+   "message A {}");
 
   // Missing semicolons should not confuse clang-format.
   verifyFormat("import \"a.proto\"\n"
"import \"b.proto\"\n"
"// comment\n"
-   "message A {\n"
-   "}");
+   "message A {}");
 }
 
 TEST_F(FormatTestProto, KeepsLongStringLiteralsOnSameLine) {


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


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-08-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 160884.
leonardchan marked 3 inline comments as done.
leonardchan added a comment.

- Added check for if we should check for saturation when converting to a 
saturated fixed point type.
- Replaced `llvm_unreachable()`s with temporary diagnostic to be eventually 
replaced when the conversions get implemented.


Repository:
  rC Clang

https://reviews.llvm.org/D50616

Files:
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticCommonKinds.td
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_conversions.c
  test/Frontend/fixed_point_unknown_conversions.c

Index: test/Frontend/fixed_point_unknown_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_unknown_conversions.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+void func() {
+  _Bool b;
+  char c;
+  int i;
+  float f;
+  double d;
+  double _Complex dc;
+  int _Complex ic;
+  struct S {
+int i;
+  } s;
+  enum E {
+A
+  } e;
+  int *ptr;
+  typedef int int_t;
+  int_t i2;
+
+  _Accum accum;
+  _Fract fract = accum; // ok
+  _Accum *accum_ptr;
+
+  accum = b;   // expected-error{{conversion between fixed point and '_Bool' is not yet supported}}
+  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
+  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
+  accum = f;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
+  accum = d;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
+  accum = dc;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
+  accum = ic;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
+  accum = s;   // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}}
+  accum = e;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
+  accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}}
+  accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}}
+  accum = i2;  // expected-error{{conversion between fixed point and 'int_t' (aka 'int') is not yet supported}}
+
+  b = accum;   // expected-error{{conversion between fixed point and '_Bool' is not yet supported}}
+  c = accum;   // expected-error{{conversion between fixed point and 'char' is not yet supported}}
+  i = accum;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
+  f = accum;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
+  d = accum;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
+  dc = accum;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
+  ic = accum;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
+  s = accum;   // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}}
+  e = accum;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
+  ptr = accum; // expected-error{{assigning to 'int *' from incompatible type '_Accum'}}
+  ptr = accum_ptr; // expected-warning{{incompatible pointer types assigning to 'int *' from '_Accum *'}}
+  i2 = accum;  // expected-error{{conversion between fixed point and 'int' is not yet supported}}
+}
Index: test/Frontend/fixed_point_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_conversions.c
@@ -0,0 +1,326 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s -check-prefix=SAME
+
+void TestFixedPointCastSameType() {
+  _Accum a = 2.5k;
+  _Accum a2 = a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+
+  a2 = (_Accum)a;
+  // DEFAULT:  [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4
+  // DEFAULT-NEXT: store i32 [[ACCUM]], i32* %a2, align 4
+}
+
+void TestFixedPointCastDown() {
+  long _Accum la = 2.5lk;
+  _Accum a = la;
+  // DEFAULT:  [[LACCUM:%[0-9]+]] = load i64, i64* %la, align 8
+  // DEFAULT-NEXT: [[ACCUM_AS_I64:%[0-9]

[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-08-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1016
+  if (DstScale > SrcScale) {
+// Need to allocate space before shifting left
+ResultWidth = SrcWidth + DstScale - SrcScale;

rjmccall wrote:
> In IR, this isn't really "allocating" space.
My bad. Poor comment wording.



Comment at: lib/CodeGen/CGExprScalar.cpp:1034
+  if (DstFPSema.isSaturated() &&
+  (CGF.getContext().getCorrespondingSaturatedType(SrcTy) != DstTy)) {
+auto Mask = APInt::getBitsSetFrom(

rjmccall wrote:
> Why is this condition based on the formal types exactly matching rather than 
> something about the FP semantics being different?  Formal types can 
> correspond to the same format, right?
> 
> We need to check for saturation if we're either (1) decreasing the magnitude 
> of the highest usable bit or (2) going signed->unsigned, (2) we're going 
> signed->unsigned, or (3) we're going unsigned->signed without increasing the 
> number of integral bits.  And I'd expect the checks we have to do in each 
> case to be different.
For simplicity, I more or less copied the logic from `APFixedPoint::convert()` 
which performs a saturation check that covers all of these cases if the 
destination semantics were saturated.

Added another condition that checks if we need to perform saturation checks. I 
think your (1) and (3) might be the same thing since I think we only really 
need to check if the magnitude decreases or if going from signed -> unsigned. 

I think though that the IR emission would be the same since both cases will 
require checking for a change in the magnitude (via the mask). The only 
difference is that if going from signed->unsigned, the min saturation is zero 
if the value is negative.



Comment at: lib/Sema/SemaExpr.cpp:5889
+case Type::STK_MemberPointer:
+  llvm_unreachable("Unimplemented conversion from FixedPoint to type");
+}

rjmccall wrote:
> Is there something I'm missing that actually diagnoses the unimplemented 
> cases here?  There's a lot of code that seems to assume that any two 
> arithmetic types can be converted to each other, and we do prefer not to 
> crash the compiler, especially on valid code.
The plan was to implement these in other patches. I wasn't sure if 
`llvm_unreachable()` was ok to use as a placeholder for features that will 
eventually be implemented.

Added diagnostics here for now to be eventually removed once these casts are 
implemented in later patches.


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.

2018-08-15 Thread Mateusz Janek via Phabricator via cfe-commits
stryku updated this revision to Diff 160885.
stryku added a comment.

Thanks for pointing that out. You're probably right, these two calls are 
self-explanatory.


https://reviews.llvm.org/D50766

Files:
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11658,30 +11658,38 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedLhsRhsExpressions(Expr *LHS, Expr *RHS) {
+SequenceTree::Seq LHSRegion = Tree.allocate(Region);
+SequenceTree::Seq RHSRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
   SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  Region = LHSRegion;
+  Visit(LHS);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = RHSRegion;
+Visit(RHS);
 
 Region = OldRegion;
 
-// Forget that LHS and RHS are sequenced. They are both unsequenced
-// with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(LHSRegion);
+Tree.merge(RHSRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// The expression E1[E2] is identical (by definition) to *((E1)+(E2)). The
+// expression E1 is sequenced before the expression E2.
+VisitSequencedLhsRhsExpressions(ASE->getLHS(), ASE->getLHS());
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedLhsRhsExpressions(BO->getLHS(), BO->getLHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11658,30 +11658,38 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedLhsRhsExpressions(Expr *LHS, Expr *RHS) {
+SequenceTree::Seq LHSRegion = Tree.allocate(Region);
+SequenceTree::Seq RHSRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
   SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  Region = LHSRegion;
+  Visit(LHS);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = RHSRegion;
+Visit(RHS);
 
 Region = OldRegion;
 
-// Forget that LHS and RHS are sequenced. They are both unsequenced
-// with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(LHSRegion);
+Tree.merge(RHSRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// The expression E1[E2] is identical (by definition) to *((E1)+(E2)). The
+// expression E1 is sequenced before the expression E2.
+VisitSequencedLhsRhsExpressions(ASE->getLHS(), ASE->getLHS());
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedLhsRhsExpressions(BO->getLHS(), BO->getLHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50631: [AST] Stuff more data into FunctionTypeBitfields

2018-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Our experience is that we keep adding more complexity to `FunctionType`, so 
it'd be nice if the bits weren't pressed up against the absolute limit.  
Dynamic exception specifications are really common, but only in the 
zero-exceptions case, so as long as we can efficiently represent and detect 
that I think putting the rest of the count out-of-line is fine.


Repository:
  rC Clang

https://reviews.llvm.org/D50631



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


[libcxx] r339804 - Mark the at_exit and at_quick_exit tests as unsupported under C++98 an 03, since those calls were introduced in C++11. They're already guarded by an ifdef in the code, so this is a

2018-08-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug 15 12:27:53 2018
New Revision: 339804

URL: http://llvm.org/viewvc/llvm-project?rev=339804&view=rev
Log:
Mark the at_exit and at_quick_exit tests as unsupported under C++98 an 03, 
since those calls were introduced in C++11.  They're already guarded by an 
ifdef in the code, so this is a 'belt-and-suspenders' change.

Modified:

libcxx/trunk/test/std/language.support/support.start.term/quick_exit.pass.cpp

libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp

libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.start.term/quick_exit.pass.cpp?rev=339804&r1=339803&r2=339804&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit.pass.cpp 
Wed Aug 15 12:27:53 2018
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test quick_exit and at_quick_exit
 

Modified: 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp?rev=339804&r1=339803&r2=339804&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
 Wed Aug 15 12:27:53 2018
@@ -7,6 +7,7 @@
 //
 
//===--===//
 //
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing at_quick_exit when _LIBCPP_HAS_QUICK_EXIT is not 
defined
 // results in a compile error.

Modified: 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp?rev=339804&r1=339803&r2=339804&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
 Wed Aug 15 12:27:53 2018
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
 // results in a compile error.


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


[PATCH] D50410: Removing -debug-info-macros from option suggestions test

2018-08-15 Thread Arnaud Coomans via Phabricator via cfe-commits
acoomans added subscribers: mattd, Sunil_Srivastava.
acoomans added a comment.

@mattd @Sunil_Srivastava if you have access to the PS4 SDK, could you tell if 
the `-debug-info-macro` command line clang option is available? Thank you


Repository:
  rC Clang

https://reviews.llvm.org/D50410



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


[PATCH] D50796: [ASTImporter] Add test for IfStmt

2018-08-15 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya accepted this revision.
hiraditya added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the test.


Repository:
  rC Clang

https://reviews.llvm.org/D50796



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


[PATCH] D50640: Fix for bug 38508 - Don't do PCH processing when only generating preprocessor output

2018-08-15 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

The approach lgtm, thanks.

How does the gcc driver codepath handle this? Does it just not have to worry 
about this because it doesn't have something like 
warn_pp_macro_def_mismatch_with_pch?




Comment at: test/Driver/cl-pch.cpp:368
+// CHECK-YU-E-NOT: -emit-pch
+// CHECK-YU-E-NOT: -include-pch

Can we have an integration-test type test that creates a pch and uses it, and 
checks that there are no warnings? (Like in 
https://bugs.llvm.org/show_bug.cgi?id=38508#c1) Probably fairly easy to add to 
one of the test/PCH/pch-through* files.


Repository:
  rC Clang

https://reviews.llvm.org/D50640



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


[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I haven't read all the messages in these threads, forgive me if someone asked 
this already. It's a bit weird to me that we have to override this behavior in 
Chromium while the default is different. Why isn't the executable size blowup 
we see in chromium a problem for everyone else too? Is the plan to fix ld64's 
string pooling at the same time as rolling this change out, and this is just a 
workaround for people who have head libc++ but not head ld64?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 160892.
leonardchan marked 6 inline comments as done.

Repository:
  rC Clang

https://reviews.llvm.org/D49511

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/noderef.c
  test/Frontend/noderef_on_non_pointers.cpp
  test/Frontend/noderef_on_non_pointers.m

Index: test/Frontend/noderef_on_non_pointers.m
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+@interface NSObject
++ (id)new;
+@end
+
+void func() {
+  id NODEREF obj = [NSObject new]; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
Index: test/Frontend/noderef_on_non_pointers.cpp
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fblocks -verify %s
+
+/**
+ * Test 'noderef' attribute against other pointer-like types.
+ */
+
+#define NODEREF __attribute__((noderef))
+
+void Normal() {
+  int NODEREF i;// expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int NODEREF *i_ptr;   // ok
+  int NODEREF **i_ptr2; // ok
+  int *NODEREF i_ptr3;  // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *NODEREF *i_ptr4; // ok
+
+  auto NODEREF *auto_i_ptr = i_ptr;
+  auto NODEREF auto_i = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+
+  struct {
+int x;
+int y;
+  } NODEREF *s;
+
+  int __attribute__((noderef(10))) * no_args; // expected-error{{'noderef' attribute takes no arguments}}
+}
+
+const int NODEREF *const_i_ptr;
+static int NODEREF *static_i_ptr;
+
+void ParenTypes() {
+  int NODEREF(*i_ptr);// ok (same as `int NODEREF *`)
+  int NODEREF *(*i_ptr2); // ok (same as `int NODEREF **`)
+}
+
+// Function declarations
+int NODEREF func();   // expected-warning{{'noderef' can only be used on an array or pointer type}}
+int NODEREF *func2(); // ok (returning pointer)
+
+typedef int NODEREF (*func3)(int); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+typedef int NODEREF *(*func4)(int);
+
+void Arrays() {
+  int NODEREF i_arr[10];  // ok
+  int NODEREF i_arr2[10][10]; // ok
+  int NODEREF *i_arr3[10];// ok
+  int NODEREF i_arr4[] = {1, 2};
+}
+
+void ParenArrays() {
+  int NODEREF(i_ptr[10]);
+  int NODEREF(i_ptr2[10])[10];
+}
+
+typedef int NODEREF *(*func5[10])(int);
+
+// Arguments
+void func6(int NODEREF x); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+void func7(int NODEREF *x);
+void func8() NODEREF;
+
+void References() {
+  int x = 2;
+  int NODEREF &y = x; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *xp = &x;
+  int NODEREF *&a = xp; // ok (reference to a NODEREF *)
+  int *NODEREF &b = xp; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+void BlockPointers() {
+  typedef int NODEREF (^IntBlock)(); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+class A {
+public:
+  int member;
+  int NODEREF *member2;
+  int NODEREF member3; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+};
+
+void MemberPointer() {
+  int NODEREF A::*var = &A::member; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+template 
+class B {
+  Ty NODEREF *member;
+  Ty NODEREF member2; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+};
Index: test/Frontend/noderef.c
===
--- /dev/null
+++ test/Frontend/noderef.c
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -Wno-unused-value -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+struct S {
+  int a;
+  int b;
+};
+
+struct S2 {
+  int a[2];
+  int NODEREF a2[2];
+  int *b;
+  int NODEREF *b2;
+  struct S *s;
+  struct S NODEREF *s2;
+};
+
+int NODEREF *func(int NODEREF *arg) {  // expected-note{{arg declared here}}
+  int y = *arg; // expected-warning{{dereferencing arg; was declared with a 'noderef' type}}
+  return arg;
+}
+
+void func2(int x) {}
+
+int test() {
+  int NODEREF *p; // expected-note 37 {{p declared here}}
+  int *p2;
+
+  int x = *p;   // expected-warning{{dereferencing p; was declared with a 'noderef' type}}
+  x = *((int NODEREF *)p2); // expected-warning{{dereferencing expression marked as 'noderef'}}
+
+  int NODEREF **q;
+  int *NODEREF *q2; // expected-note 4 {{q2 declared here}

[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D50652#1201236, @thakis wrote:

> I haven't read all the messages in these threads, forgive me if someone asked 
> this already. It's a bit weird to me that we have to override this behavior 
> in Chromium while the default is different. Why isn't the executable size 
> blowup we see in chromium a problem for everyone else too? Is the plan to fix 
> ld64's string pooling at the same time as rolling this change out, and this 
> is just a workaround for people who have head libc++ but not head ld64?


It's the other way around -- the default behavior introduced in this patch is 
the one before the `internal_linkage` change. If you want to opt-in, you can 
define `_LIBCPP_HIDE_FROM_ABI_PER_TU`.

As a separate goal, we will (in the future) make things better for the default 
case, i.e. we will get rid of `__always_inline__` too and allow 
ODR-deduplication.

Does that make sense?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652



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


r339805 - [OPENMP] FIx processing of declare target variables.

2018-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 15 12:45:12 2018
New Revision: 339805

URL: http://llvm.org/viewvc/llvm-project?rev=339805&view=rev
Log:
[OPENMP] FIx processing of declare target variables.

The compiler may produce unexpected error messages/crashes when declare
target variables were used. Patch fixes problems with the declarations
marked as declare target to or link.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
cfe/trunk/test/OpenMP/declare_target_link_codegen.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=339805&r1=339804&r2=339805&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 15 12:45:12 2018
@@ -9774,6 +9774,12 @@ bool ASTContext::DeclMustBeEmitted(const
   const auto *VD = cast(D);
   assert(VD->isFileVarDecl() && "Expected file scoped var");
 
+  // If the decl is marked as `declare target to`, it should be emitted for the
+  // host and for the device.
+  if (LangOpts.OpenMP &&
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+return true;
+
   if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly &&
   !isMSStaticDataMemberInlineDefinition(VD))
 return false;
@@ -9805,11 +9811,6 @@ bool ASTContext::DeclMustBeEmitted(const
 if (DeclMustBeEmitted(BindingVD))
   return true;
 
-  // If the decl is marked as `declare target`, it should be emitted.
-  if (const llvm::Optional Res =
-  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
-return *Res != OMPDeclareTargetDeclAttr::MT_Link;
-
   return false;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=339805&r1=339804&r2=339805&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Aug 15 12:45:12 2018
@@ -2270,18 +2270,14 @@ static LValue EmitThreadPrivateVarDeclLV
 
 static Address emitDeclTargetLinkVarDeclLValue(CodeGenFunction &CGF,
const VarDecl *VD, QualType T) {
-  for (const auto *D : VD->redecls()) {
-if (!VD->hasAttrs())
-  continue;
-if (const auto *Attr = D->getAttr())
-  if (Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_Link) {
-QualType PtrTy = CGF.getContext().getPointerType(VD->getType());
-Address Addr =
-CGF.CGM.getOpenMPRuntime().getAddrOfDeclareTargetLink(VD);
-return CGF.EmitLoadOfPointer(Addr, PtrTy->castAs());
-  }
-  }
-  return Address::invalid();
+  llvm::Optional Res =
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+  if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_To)
+return Address::invalid();
+  assert(*Res == OMPDeclareTargetDeclAttr::MT_Link && "Expected link clause");
+  QualType PtrTy = CGF.getContext().getPointerType(VD->getType());
+  Address Addr = CGF.CGM.getOpenMPRuntime().getAddrOfDeclareTargetLink(VD);
+  return CGF.EmitLoadOfPointer(Addr, PtrTy->castAs());
 }
 
 Address

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=339805&r1=339804&r2=339805&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Aug 15 12:45:12 2018
@@ -2622,7 +2622,7 @@ bool CGOpenMPRuntime::emitDeclareTargetV
   Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link)
-return false;
+return CGM.getLangOpts().OpenMPIsDevice;
   VD = VD->getDefinition(CGM.getContext());
   if (VD && !DeclareTargetWithDefinition.insert(VD).second)
 return CGM.getLangOpts().OpenMPIsDevice;
@@ -8089,8 +8089,7 @@ bool CGOpenMPRuntime::emitTargetGlobalVa
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(
   cast(GD.getDecl()));
   if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link) {
-if (CGM.getContext().DeclMustBeEmitted(GD.getDecl()))
-  DeferredGlobalVariables.insert(cast(GD.getDecl()));
+DeferredGlobalVariables.insert(cast(GD.getDecl()));
 return true;
   }
   return false;
@@ -8154,10 +8153,14 @@ void CGOpenMPRuntime::emitDeferredTarget
   for (const VarDecl *VD : DeferredGlobalVariables) {
 llvm::Optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTar

[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.

2018-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Szelethus.

This looks great, thanks, this is exactly how i imagined it!


Repository:
  rC Clang

https://reviews.llvm.org/D48027



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


[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.

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

Generally looks good, I only wonder if this works well with inline namespaces. 
Could you test?


Repository:
  rC Clang

https://reviews.llvm.org/D48027



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


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF, dim.

Fixes this by adding a new config macro  `_LIBCPP_HAS_TIMESPEC_GET` (sigh)

There's also a drive-by fix in here about not importing `aligned_alloc` into 
namespace `std` before C++17.


https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -331,6 +331,7 @@
 #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
 #  if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_TIMESPEC_GET
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
@@ -342,9 +343,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 160897.
mclow.lists added a comment.

Copy/paste error in original diff.


https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -342,9 +342,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check

2018-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: cfe/trunk/test/Analysis/cstring-syntax.c:45
+  strlcpy(dest, "012345678", sizeof(dest));
+  strlcat(dest, "910", sizeof(dest)); // expected-warning {{The third argument 
allows to potentially copy more bytes than it should. Replace with the value  
  - strlen(dest) - 1 or lower}}
+  strlcpy(dest, "0123456789", sizeof(dest));

There seem to be two spaces around ``.


Repository:
  rL LLVM

https://reviews.llvm.org/D49722



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


[PATCH] D50767: [C++2a] Parsing and semantic analysis for contracts (P0542R5)

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:272
 bool HasLeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
-return Actions.ActOnNullStmt(ConsumeToken(), HasLeadingEmptyMacro);
+SourceLocation SemiLoc = ConsumeToken();
+return Actions.ActOnNullStmt(SemiLoc, HasLeadingEmptyMacro,

Any reason to create the intermediate variable here, instead of leaving the 
`ConsumeToken()` call where it was?


Repository:
  rC Clang

https://reviews.llvm.org/D50767



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


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 160898.

https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -334,6 +334,7 @@
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_TIMESPEC_GET
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
@@ -342,9 +343,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50764: [AST] Make NullStmt final and give it factory functions

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

This looks like a NFC change.

Given that the next patch moves these methods out of line, you might consider 
introducing them out of line here (and moving the constructors out of line). 
That would make the next patch easier to review because the addition of 
assertion handling would be move visible.

LGTM, but I'm new here, so you may want to wait for another reviewer if you 
wish.


Repository:
  rC Clang

https://reviews.llvm.org/D50764



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


[PATCH] D50755: [Driver] -print-target-triple and -print-effective-triple options

2018-08-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D50755



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


[PATCH] D50801: [rename] Use isPointWithin when looking for a declaration at location

2018-08-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: jkorous, hokein, ioeric.
Herald added a subscriber: dexonsmith.

This patch is a followup to https://reviews.llvm.org/D50740 .

This patch fixes the issue where clang-refactor local-rename was unable to find 
a declaration in a header file if that header file was included more than once, 
and the location of the point of interest was in a different included instance 
of a file than then declaration itself. The use of `isPointWithin` ensures that 
we're checking if the point is in the source range regardless of the included 
file.


Repository:
  rC Clang

https://reviews.llvm.org/D50801

Files:
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  test/Refactor/LocalRename/Inputs/MultiHeader.h
  test/Refactor/LocalRename/IsPointWithinDifferentInclude.c


Index: test/Refactor/LocalRename/IsPointWithinDifferentInclude.c
===
--- /dev/null
+++ test/Refactor/LocalRename/IsPointWithinDifferentInclude.c
@@ -0,0 +1,16 @@
+// RUN: clang-refactor local-rename -selection=%S/Inputs/MultiHeader.h:5:9 
-new-name=renamedField %s -- -I %S/Inputs 2>&1 | FileCheck %s
+
+// The MultiHeader file included twice.
+// The first inclusion contains no declarations. However, the selection
+// "MultiHeader:5:9" is mapped to a location in this inclusion of the file.
+#include "MultiHeader.h"
+
+// The second inclusion contains the declarations. The range of the
+// declaration we would like is located in this inclusion.
+#define HAVE_DECLS
+#include "MultiHeader.h"
+
+// Ensure that we still find the declaration even though the location and the
+// declaration's range are located in two different inclusions.
+// CHECK:  struct Foo {
+// CHECK-NEXT:   int renamedField;
Index: test/Refactor/LocalRename/Inputs/MultiHeader.h
===
--- /dev/null
+++ test/Refactor/LocalRename/Inputs/MultiHeader.h
@@ -0,0 +1,9 @@
+#ifdef HAVE_DECLS
+
+struct MyStruct {
+  struct Foo {
+int field;
+  } bar;
+};
+
+#endif
Index: lib/Tooling/Refactoring/Rename/USRFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRFinder.cpp
@@ -48,7 +48,8 @@
   SourceLocation Start = Range.getBegin();
   SourceLocation End = Range.getEnd();
   if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
-  !End.isFileID() || !isPointWithin(Start, End))
+  !End.isFileID() ||
+  !Context.getSourceManager().isPointWithin(Point, Start, End))
 return true;
 }
 Result = ND;
@@ -58,14 +59,6 @@
   const NamedDecl *getNamedDecl() const { return Result; }
 
 private:
-  // Determines if the Point is within Start and End.
-  bool isPointWithin(const SourceLocation Start, const SourceLocation End) {
-// FIXME: Add tests for Point == End.
-return Point == Start || Point == End ||
-   (Context.getSourceManager().isBeforeInTranslationUnit(Start,
- Point) &&
-Context.getSourceManager().isBeforeInTranslationUnit(Point, End));
-  }
 
   const NamedDecl *Result = nullptr;
   const SourceLocation Point; // The location to find the NamedDecl.
@@ -80,14 +73,15 @@
   NamedDeclOccurrenceFindingVisitor Visitor(Point, Context);
 
   // Try to be clever about pruning down the number of top-level declarations 
we
-  // see. If both start and end is either before or after the point we're
-  // looking for the point cannot be inside of this decl. Don't even look at 
it.
+  // see. If the range of the declaration doesn't contain the source location,
+  // then don't even look at it.
   for (auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
-SourceLocation StartLoc = CurrDecl->getBeginLoc();
-SourceLocation EndLoc = CurrDecl->getEndLoc();
-if (StartLoc.isValid() && EndLoc.isValid() &&
-SM.isBeforeInTranslationUnit(StartLoc, Point) !=
-SM.isBeforeInTranslationUnit(EndLoc, Point))
+CharSourceRange DeclRange = Lexer::makeFileCharRange(
+CharSourceRange::getTokenRange(CurrDecl->getSourceRange()),
+Context.getSourceManager(), Context.getLangOpts());
+// FIXME: Use early break if the decl is found.
+if (DeclRange.isValid() &&
+SM.isPointWithin(Point, DeclRange.getBegin(), DeclRange.getEnd()))
   Visitor.TraverseDecl(CurrDecl);
   }
 


Index: test/Refactor/LocalRename/IsPointWithinDifferentInclude.c
===
--- /dev/null
+++ test/Refactor/LocalRename/IsPointWithinDifferentInclude.c
@@ -0,0 +1,16 @@
+// RUN: clang-refactor local-rename -selection=%S/Inputs/MultiHeader.h:5:9 -new-name=renamedField %s -- -I %S/Inputs 2>&1 | FileCheck %s
+
+// The MultiHeader file included twice.
+// The first inclusion contains no declarations. However,

r339807 - Refactor Darwin driver to refer to runtimes by component

2018-08-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Wed Aug 15 13:09:38 2018
New Revision: 339807

URL: http://llvm.org/viewvc/llvm-project?rev=339807&view=rev
Log:
Refactor Darwin driver to refer to runtimes by component

Summary:
In r335809, Petr Hosek lays out support for what he calls the multiarch
runtimes layout. This new way of laying out the directories for runtime
libraries is workable for all platforms. Petr did some of the common
infrastructure and made it work for Linux and Fuscia. This patch is a
cleanup to the Darwin and MachO drivers to serve as a step toward
supporting it in Darwin.

This patch does primarily two things:
(1) Changes the APIs for how the Darwin driver refers to compiler-rt
libraries to use the component names, similar to how Linux and Fuscia do

(2) Removes some legacy functionality for supporting macOS versions
before 10.6. This functionality is effectively dead code because in
r339277, the support was removed from compiler-rt for generating the 10.4
runtime support library, and Xcode 10 (currently in beta) removes
libgcc_s.10.4 and libgcc_s.10.5 from the macOS SDK.

With this patch landed a subsequent patch can modify
MachO::AddLinkRuntimeLib to support the multiarch runtimes layout.

Worth noting: None of the removed functionality was actually covered in
the test suite. So no test case updates are required.

Reviewers: phosek, bruno, arphaman

Reviewed By: phosek, arphaman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=339807&r1=339806&r2=339807&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Aug 15 13:09:38 2018
@@ -908,8 +908,17 @@ unsigned DarwinClang::GetDefaultDwarfVer
 }
 
 void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
-  StringRef DarwinLibName,
-  RuntimeLinkOptions Opts) const {
+  StringRef Component, RuntimeLinkOptions Opts,
+  bool IsShared) const {
+  SmallString<64> DarwinLibName = StringRef("libclang_rt.");
+  // an Darwin the builtins compomnent is not in the library name
+  if (Component != "builtins") {
+DarwinLibName += Component;
+if (!(Opts & RLO_IsEmbedded))
+  DarwinLibName += "_";
+  }
+  DarwinLibName += getOSLibraryNameSuffix();
+  DarwinLibName += IsShared ? "_dynamic.dylib" : ".a";
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(
   Dir, "lib", (Opts & RLO_IsEmbedded) ? "macho_embedded" : "darwin");
@@ -1013,10 +1022,8 @@ void Darwin::addProfileRTLibs(const ArgL
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
-  AddLinkRuntimeLib(
-  Args, CmdArgs,
-  (Twine("libclang_rt.profile_") + getOSLibraryNameSuffix() + ".a").str(),
-  RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
+  AddLinkRuntimeLib(Args, CmdArgs, "profile",
+RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
 
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
@@ -1033,12 +1040,7 @@ void DarwinClang::AddLinkSanitizerLibArg
   StringRef Sanitizer,
   bool Shared) const {
   auto RLO = RuntimeLinkOptions(RLO_AlwaysLink | (Shared ? RLO_AddRPath : 0U));
-  AddLinkRuntimeLib(Args, CmdArgs,
-(Twine("libclang_rt.") + Sanitizer + "_" +
- getOSLibraryNameSuffix() +
- (Shared ? "_dynamic.dylib" : ".a"))
-.str(),
-RLO);
+  AddLinkRuntimeLib(Args, CmdArgs, Sanitizer, RLO, Shared);
 }
 
 ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
@@ -1092,10 +1094,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 AddCXXStdlibLibArgs(Args, CmdArgs);
   }
   if (Sanitize.needsStatsRt()) {
-StringRef OS = isTargetMacOS() ? "osx" : "iossim";
-AddLinkRuntimeLib(Args, CmdArgs,
-  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
-  RLO_AlwaysLink);
+AddLinkRuntimeLib(Args, CmdArgs, "stats_client", RLO_AlwaysLink);
 AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
   }
   if (Sanitize.needsEsanRt())
@@ -1106,52 +1105,15 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  if (isTargetWatchOSBased()) {
-// We currently always need a static runtime library for watchOS.
-AddLi

[PATCH] D50618: Refactor Darwin driver to refer to runtimes by component

2018-08-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339807: Refactor Darwin driver to refer to runtimes by 
component (authored by cbieneman, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50618?vs=160279&id=160903#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50618

Files:
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h

Index: lib/Driver/ToolChains/Darwin.h
===
--- lib/Driver/ToolChains/Darwin.h
+++ lib/Driver/ToolChains/Darwin.h
@@ -189,9 +189,9 @@
 
   /// Add a runtime library to the list of items to link.
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs,
- StringRef DarwinLibName,
- RuntimeLinkOptions Opts = RuntimeLinkOptions()) const;
+ llvm::opt::ArgStringList &CmdArgs, StringRef Component,
+ RuntimeLinkOptions Opts = RuntimeLinkOptions(),
+ bool IsShared = false) const;
 
   /// Add any profiling runtime libraries that are needed. This is essentially a
   /// MachO specific version of addProfileRT in Tools.cpp.
@@ -252,6 +252,8 @@
 return llvm::ExceptionHandling::None;
   }
 
+  virtual StringRef getOSLibraryNameSuffix() const { return ""; }
+
   /// }
 };
 
@@ -418,7 +420,7 @@
  Action::OffloadKind DeviceOffloadKind) const override;
 
   StringRef getPlatformFamily() const;
-  StringRef getOSLibraryNameSuffix() const;
+  StringRef getOSLibraryNameSuffix() const override;
 
 public:
   static StringRef getSDKName(StringRef isysroot);
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -908,8 +908,17 @@
 }
 
 void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
-  StringRef DarwinLibName,
-  RuntimeLinkOptions Opts) const {
+  StringRef Component, RuntimeLinkOptions Opts,
+  bool IsShared) const {
+  SmallString<64> DarwinLibName = StringRef("libclang_rt.");
+  // an Darwin the builtins compomnent is not in the library name
+  if (Component != "builtins") {
+DarwinLibName += Component;
+if (!(Opts & RLO_IsEmbedded))
+  DarwinLibName += "_";
+  }
+  DarwinLibName += getOSLibraryNameSuffix();
+  DarwinLibName += IsShared ? "_dynamic.dylib" : ".a";
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(
   Dir, "lib", (Opts & RLO_IsEmbedded) ? "macho_embedded" : "darwin");
@@ -1013,10 +1022,8 @@
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
-  AddLinkRuntimeLib(
-  Args, CmdArgs,
-  (Twine("libclang_rt.profile_") + getOSLibraryNameSuffix() + ".a").str(),
-  RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
+  AddLinkRuntimeLib(Args, CmdArgs, "profile",
+RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
 
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
@@ -1033,12 +1040,7 @@
   StringRef Sanitizer,
   bool Shared) const {
   auto RLO = RuntimeLinkOptions(RLO_AlwaysLink | (Shared ? RLO_AddRPath : 0U));
-  AddLinkRuntimeLib(Args, CmdArgs,
-(Twine("libclang_rt.") + Sanitizer + "_" +
- getOSLibraryNameSuffix() +
- (Shared ? "_dynamic.dylib" : ".a"))
-.str(),
-RLO);
+  AddLinkRuntimeLib(Args, CmdArgs, Sanitizer, RLO, Shared);
 }
 
 ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
@@ -1092,10 +1094,7 @@
 AddCXXStdlibLibArgs(Args, CmdArgs);
   }
   if (Sanitize.needsStatsRt()) {
-StringRef OS = isTargetMacOS() ? "osx" : "iossim";
-AddLinkRuntimeLib(Args, CmdArgs,
-  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
-  RLO_AlwaysLink);
+AddLinkRuntimeLib(Args, CmdArgs, "stats_client", RLO_AlwaysLink);
 AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
   }
   if (Sanitize.needsEsanRt())
@@ -1106,52 +1105,15 @@
   CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  if (isTargetWatchOSBased()) {
-// We currently always need a static runtime library for watchOS.
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.watchos.a");
-  } else if (isTargetTvOSBased()) {
-// We currently always need a static runtime library for tvOS.
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.tvos.a");
-  } else if (isTargetIOSBased()) {

r339808 - [CStringSyntaxChecker] Reduces space around error message for strlcat.

2018-08-15 Thread David Carlier via cfe-commits
Author: devnexen
Date: Wed Aug 15 13:09:52 2018
New Revision: 339808

URL: http://llvm.org/viewvc/llvm-project?rev=339808&view=rev
Log:
[CStringSyntaxChecker] Reduces space around error message for strlcat.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
cfe/trunk/test/Analysis/cstring-syntax.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp?rev=339808&r1=339807&r2=339808&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp Wed Aug 15 
13:09:52 2018
@@ -273,7 +273,7 @@ void WalkAST::VisitCallExpr(CallExpr *CE
   if (!LenName.empty())
 os << "'" << LenName << "'";
   else
-os << "  ";
+os << "";
   if (!DstName.empty())
 os << " - strlen(" << DstName << ")";
   else

Modified: cfe/trunk/test/Analysis/cstring-syntax.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cstring-syntax.c?rev=339808&r1=339807&r2=339808&view=diff
==
--- cfe/trunk/test/Analysis/cstring-syntax.c (original)
+++ cfe/trunk/test/Analysis/cstring-syntax.c Wed Aug 15 13:09:52 2018
@@ -42,7 +42,7 @@ void testStrlcat(const char *src) {
   strlcpy(dest, "a", sizeof("a") - 1);
   strlcat(dest, "", (sizeof("") - 1) - sizeof(dest) - 1);
   strlcpy(dest, "012345678", sizeof(dest));
-  strlcat(dest, "910", sizeof(dest)); // expected-warning {{The third argument 
allows to potentially copy more bytes than it should. Replace with the value  
  - strlen(dest) - 1 or lower}}
+  strlcat(dest, "910", sizeof(dest)); // expected-warning {{The third argument 
allows to potentially copy more bytes than it should. Replace with the value 
 - strlen(dest) - 1 or lower}}
   strlcpy(dest, "0123456789", sizeof(dest));
   strlcat(dest, "0123456789", badlen); // expected-warning {{The third 
argument allows to potentially copy more bytes than it should. Replace with the 
value 'badlen' - strlen(dest) - 1 or lower}}
   strlcat(dest, "0123456789", badlen - strlen(dest) - 1);


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


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1042
+std::min(DstScale + DstFPSema.getIntegralBits(), ResultWidth));
+Value *Zero = ConstantInt::get(CGF.getLLVMContext(), APInt(ResultWidth, 
0));
+

You can just pass 0 here and it'll be zero-extended to the necessary width.



Comment at: lib/CodeGen/CGExprScalar.cpp:1044
+
+Value *IsNegative = nullptr;
+if (Mask != 0) {

I'm sorry, but this code is really impenetrable.  The variable names are 
non-descriptive, and there are a lot of uncommented dependencies between 
values, like how `IsNegative` propagates out, and like how it's checking 
without explanation that there's not a magnitude change using whether the mask 
ends up being all-zero.  Please just assign the two components of 
`ShouldCheckSaturation` to reasonably-named local variables and then use those 
to guide the code-generation here.

Also, the code being generated here is pretty weird.  I'm not sure the mask is 
helping; it might both produce better code and be easier to understand if you 
just broke it down into cases, like this:

```
  if a magnitude check is required {
auto Max = maximum value of dest type;
auto TooHigh = IsSigned ? Builder.CreateICmpSGT(Result, Max) : 
Builder.CreateICmpUGT(Result, Max);
Result = Builder.CreateSelect(TooHigh, Max, Result);
  }

  if signed -> unsigned {
auto Zero = zero value of dest type;
Result = Builder.CreateSelect(Builder.CreateICmpSLT(Result, Zero), Zero, 
Result);
  } else if (IsSigned) {
auto Min = minimum value of dest type;
Result = Builder.CreateSelect(Builder.CreateICmpSLT(Result, Min), Min, 
Result);
  }
```



Comment at: lib/CodeGen/CGExprScalar.cpp:1034
+  if (DstFPSema.isSaturated() &&
+  (CGF.getContext().getCorrespondingSaturatedType(SrcTy) != DstTy)) {
+auto Mask = APInt::getBitsSetFrom(

leonardchan wrote:
> rjmccall wrote:
> > Why is this condition based on the formal types exactly matching rather 
> > than something about the FP semantics being different?  Formal types can 
> > correspond to the same format, right?
> > 
> > We need to check for saturation if we're either (1) decreasing the 
> > magnitude of the highest usable bit or (2) going signed->unsigned, (2) 
> > we're going signed->unsigned, or (3) we're going unsigned->signed without 
> > increasing the number of integral bits.  And I'd expect the checks we have 
> > to do in each case to be different.
> For simplicity, I more or less copied the logic from 
> `APFixedPoint::convert()` which performs a saturation check that covers all 
> of these cases if the destination semantics were saturated.
> 
> Added another condition that checks if we need to perform saturation checks. 
> I think your (1) and (3) might be the same thing since I think we only really 
> need to check if the magnitude decreases or if going from signed -> unsigned. 
> 
> I think though that the IR emission would be the same since both cases will 
> require checking for a change in the magnitude (via the mask). The only 
> difference is that if going from signed->unsigned, the min saturation is zero 
> if the value is negative.
Wow, sorry for the edit failure in that review comment.  You're right, it 
should've been just (1) and the first (2).

Are there no fixed-point formats for which the range doesn't go up to (almost) 
1?  I guess there probably aren't.



Comment at: lib/Sema/SemaExpr.cpp:5889
+case Type::STK_MemberPointer:
+  llvm_unreachable("Unimplemented conversion from FixedPoint to type");
+}

leonardchan wrote:
> rjmccall wrote:
> > Is there something I'm missing that actually diagnoses the unimplemented 
> > cases here?  There's a lot of code that seems to assume that any two 
> > arithmetic types can be converted to each other, and we do prefer not to 
> > crash the compiler, especially on valid code.
> The plan was to implement these in other patches. I wasn't sure if 
> `llvm_unreachable()` was ok to use as a placeholder for features that will 
> eventually be implemented.
> 
> Added diagnostics here for now to be eventually removed once these casts are 
> implemented in later patches.
You can still use `llvm_unreachable` for the cases here that aren't arithmetic 
types, namely all the pointer types.


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:132
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
+ << "%cmp = icmp sgt i64 %s, 0\n"

morehouse wrote:
> I'm curious how this change affects coverage independent of the rest of this 
> change.  Also what would happen if we set `%a` and `%b` to noalias as well?
`%c` was always supposed to be `noalias`. It got changed accidentally in the 
last patch. I'm not sure what would change in the coverage if `%a` and `%b` 
also got set to be `noalias`.

@kcc and I had originally planned for `foo (int *a, int *b, int *__restrict__ 
c, size_t s)` to be just the first function signature we tried for this fuzz 
target and to change it up and try different signatures.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:127
   }
+  inner_loop = true;
   return os;

morehouse wrote:
> Maybe this fixes the bug, but modifying `inner_loop` from different functions 
> is still error-prone.
> 
> Please either make this a scoped variable (with a wrapper class that sets it 
> to true in the constructor and sets it to false in the destructor), or make 
> it a parameter.
Would it be better if `inner_loop` was only modified in the `LoopFunction` 
operator override? For example:

```
std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
  inner_loop = false;
  os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
 
 << << "outer_loop:\n"
 << x.outer_statements();
  inner_loop = true;
  os << "%o_ct_new = add i64 %outer_ct, 1\n"
 
 << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize << "}\n";
  return os;

```
And removed `inner_loop = true;` from the above function?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:140
+ << "br label %inner_loop\n"
+ << "end:\n"
+ << "ret void\n"

morehouse wrote:
> I don't see any jumps to `end`.  I think this will be an infinite loop.
There are two jumps to `end`, one before entering the `outer_loop` and one at 
the end of `outer_loop`.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:143
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"

morehouse wrote:
> morehouse wrote:
> > IIUC this creates loop structure always like this:
> > 
> > ```
> > for (int i = 0; i < s; i++) {
> >   for (int j = 0; j < s; j++) {
> > // statements
> >   }
> >   // statements
> > }
> > ```
> > 
> > Maybe not necessary for this patch, but I'm curious if adding statements 
> > before the inner loop would exercise different coverage in the vectorizer.
> Will all loops be double-nested now?
Yes, that's correct. It's also worth noting that all the statements in the 
inner loop will only use `j` to index into the arrays, never `i`. It shouldn't 
be hard to add outer loop statements before the inner loop. A third 
`StatementSeq` could be added to the `LoopFunction` proto: one for outer loop 
statements before the inner loop, one for inner loop statements, and one for 
outer loop statements after the inner loop.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:143
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"

emmettneyman wrote:
> morehouse wrote:
> > morehouse wrote:
> > > IIUC this creates loop structure always like this:
> > > 
> > > ```
> > > for (int i = 0; i < s; i++) {
> > >   for (int j = 0; j < s; j++) {
> > > // statements
> > >   }
> > >   // statements
> > > }
> > > ```
> > > 
> > > Maybe not necessary for this patch, but I'm curious if adding statements 
> > > before the inner loop would exercise different coverage in the vectorizer.
> > Will all loops be double-nested now?
> Yes, that's correct. It's also worth noting that all the statements in the 
> inner loop will only use `j` to index into the arrays, never `i`. It 
> shouldn't be hard to add outer loop statements before the inner loop. A third 
> `StatementSeq` could be added to the `LoopFunction` proto: one for outer loop 
> statements before the inner loop, one for inner loop statements, and one for 
> outer loop statements after the inner loop.
Yes, all loops will be double-nested. It shouldn't be difficult to make the 
inner loop optional though. In `cxx_loop_proto`, the first `Statement_Seq`, 
`inner_statements`, can be made `optional` and then a different IR structures 
can be generated depending on whether or not `inner_statements` exists.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

[PATCH] D50783: [CodeGen] Merge identical block descriptor global variables

2018-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D50783#1200868, @ahatanak wrote:

> A few points I forgot to mention:
>
> - This optimization kicks in only in NonGC mode. I don't think we need to 
> care much about GC anymore, so I think that's OK.


Yes, that's fine.

> - There is a lot of redundancy among the copy/dispose helper function strings 
> and the block layout string in the block descriptor name (they all encode the 
> information about the captures), which can make the descriptor name long. If 
> that becomes a problem, it's possible to encode the information in a way that 
> shortens the descriptor name, but that would probably make the function that 
> generates the name more complex.

It should be straightforward to at least get merge the copy/dispose helper 
function names, right?  Those make basically the same pass over the captures 
and just check for slightly different things; the block-descriptor summary just 
has to include a little of both.

To unique the block layout string as well, we'd just have to cover the captures 
for which we haven't added any other description.  If you want to punt on that, 
I think that's fine.


Repository:
  rC Clang

https://reviews.llvm.org/D50783



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


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

This doesn't seem necessary. `NewAlign` specifies the alignment beyond which 
types acquire "new-extended alignment" per the C++ standard, or equivalently 
the alignment beyond which we need to pass an `align_val_t` argument to 
`operator new`.

If all types of size <= 8 are provided with sufficiently-aligned storage (which 
8 byte alignment definitely is), then they are irrelevant for the computation 
of this value, because `new T` for such a type never needs to pass an 
alignment. (A similar argument applies for the array-new case.)


Repository:
  rC Clang

https://reviews.llvm.org/D50683



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


r339810 - Add a newline to SourceLocation dump output

2018-08-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Aug 15 13:32:06 2018
New Revision: 339810

URL: http://llvm.org/viewvc/llvm-project?rev=339810&view=rev
Log:
Add a newline to SourceLocation dump output

Summary:
Migrate callers to print().

dump() should be useful to downstreams and third parties as a debugging
aid.  Everyone trips up on this and creates confusing output.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/AST/CommentLexer.cpp
cfe/trunk/lib/Analysis/LiveVariables.cpp
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Basic/SourceLocation.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Wed Aug 15 13:32:06 2018
@@ -340,7 +340,7 @@ void MigrationContext::dumpGCAttrs() {
 llvm::errs() << "KIND: "
 << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
 llvm::errs() << "\nLOC: ";
-Attr.Loc.dump(Pass.Ctx.getSourceManager());
+Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
 llvm::errs() << "\nTYPE: ";
 Attr.ModifiedType.dump();
 if (Attr.Dcl) {

Modified: cfe/trunk/lib/AST/CommentLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/AST/CommentLexer.cpp (original)
+++ cfe/trunk/lib/AST/CommentLexer.cpp Wed Aug 15 13:32:06 2018
@@ -21,7 +21,7 @@ namespace comments {
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Wed Aug 15 13:32:06 2018
@@ -626,7 +626,7 @@ void LiveVariablesImpl::dumpBlockLivenes
  de = declVec.end(); di != de; ++di) {
   llvm::errs() << " " << (*di)->getDeclName().getAsString()
<< " <";
-  (*di)->getLocation().dump(M);
+  (*di)->getLocation().print(llvm::errs(), M);
   llvm::errs() << ">\n";
 }
   }

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Aug 15 13:32:06 2018
@@ -239,7 +239,7 @@ DiagnosticsEngine::DiagStateMap::getFile
 void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
StringRef DiagName) const {
   llvm::errs() << "diagnostic state at ";
-  CurDiagStateLoc.dump(SrcMgr);
+  CurDiagStateLoc.print(llvm::errs(), SrcMgr);
   llvm::errs() << ": " << CurDiagState << "\n";
 
   for (auto &F : Files) {
@@ -261,7 +261,7 @@ void DiagnosticsEngine::DiagStateMap::du
  << Decomp.first.getHashValue() << "> ";
 SrcMgr.getLocForStartOfFile(Decomp.first)
   .getLocWithOffset(Decomp.second)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
   }
   if (File.HasLocalTransitions)
 llvm::errs() << " has_local_transitions";
@@ -281,7 +281,7 @@ void DiagnosticsEngine::DiagStateMap::du
 llvm::errs() << "  ";
 SrcMgr.getLocForStartOfFile(ID)
   .getLocWithOffset(Transition.Offset)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
 llvm::errs() << ": state " << Transition.State << ":\n";
   };
 

Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Wed Aug 15 13:32:06 2018
@@ -77,6 +77,7 @@ SourceLocation::printToString(const Sour
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 
//===--===//

Modifie

[PATCH] D50661: Add a newline to SourceLocation dump output

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339810: Add a newline to SourceLocation dump output 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50661

Files:
  cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
  cfe/trunk/lib/AST/CommentLexer.cpp
  cfe/trunk/lib/Analysis/LiveVariables.cpp
  cfe/trunk/lib/Basic/Diagnostic.cpp
  cfe/trunk/lib/Basic/SourceLocation.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp


Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: cfe/trunk/lib/AST/CommentLexer.cpp
===
--- cfe/trunk/lib/AST/CommentLexer.cpp
+++ cfe/trunk/lib/AST/CommentLexer.cpp
@@ -21,7 +21,7 @@
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 
Index: cfe/trunk/lib/Analysis/LiveVariables.cpp
===
--- cfe/trunk/lib/Analysis/LiveVariables.cpp
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp
@@ -626,7 +626,7 @@
  de = declVec.end(); di != de; ++di) {
   llvm::errs() << " " << (*di)->getDeclName().getAsString()
<< " <";
-  (*di)->getLocation().dump(M);
+  (*di)->getLocation().print(llvm::errs(), M);
   llvm::errs() << ">\n";
 }
   }
Index: cfe/trunk/lib/Basic/SourceLocation.cpp
===
--- cfe/trunk/lib/Basic/SourceLocation.cpp
+++ cfe/trunk/lib/Basic/SourceLocation.cpp
@@ -77,6 +77,7 @@
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 
//===--===//
Index: cfe/trunk/lib/Basic/Diagnostic.cpp
===
--- cfe/trunk/lib/Basic/Diagnostic.cpp
+++ cfe/trunk/lib/Basic/Diagnostic.cpp
@@ -239,7 +239,7 @@
 void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
StringRef DiagName) const {
   llvm::errs() << "diagnostic state at ";
-  CurDiagStateLoc.dump(SrcMgr);
+  CurDiagStateLoc.print(llvm::errs(), SrcMgr);
   llvm::errs() << ": " << CurDiagState << "\n";
 
   for (auto &F : Files) {
@@ -261,7 +261,7 @@
  << Decomp.first.getHashValue() << "> ";
 SrcMgr.getLocForStartOfFile(Decomp.first)
   .getLocWithOffset(Decomp.second)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
   }
   if (File.HasLocalTransitions)
 llvm::errs() << " has_local_transitions";
@@ -281,7 +281,7 @@
 llvm::errs() << "  ";
 SrcMgr.getLocForStartOfFile(ID)
   .getLocWithOffset(Transition.Offset)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
 llvm::errs() << ": state " << Transition.State << ":\n";
   };
 
Index: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
===
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
@@ -340,7 +340,7 @@
 llvm::errs() << "KIND: "
 << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
 llvm::errs() << "\nLOC: ";
-Attr.Loc.dump(Pass.Ctx.getSourceManager());
+Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
 llvm::errs() << "\nTYPE: ";
 Attr.ModifiedType.dump();
 if (Attr.Dcl) {


Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: cfe/trunk/lib/AST/CommentLexer.cpp
===
--- cfe/trunk/lib/AST/CommentLexer.cpp
+++ cfe/trunk/lib/AST/CommentLexer.cpp
@@ -21,7 +21,7 @@
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 
Index: cfe/trunk/lib/Analysi

[PATCH] D50410: Removing -debug-info-macros from option suggestions test

2018-08-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

I don't have access to the PS4 SDK, but this is the most plausible explanation 
I've seen for why I was experiencing issues on these platforms. Thanks for this!

Do you have commit access or would you like me to land this on your behalf?


Repository:
  rC Clang

https://reviews.llvm.org/D50410



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


[PATCH] D50670: Implementation of nested loops in cxx_loop_proto

2018-08-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:127
   }
+  inner_loop = true;
   return os;

emmettneyman wrote:
> morehouse wrote:
> > Maybe this fixes the bug, but modifying `inner_loop` from different 
> > functions is still error-prone.
> > 
> > Please either make this a scoped variable (with a wrapper class that sets 
> > it to true in the constructor and sets it to false in the destructor), or 
> > make it a parameter.
> Would it be better if `inner_loop` was only modified in the `LoopFunction` 
> operator override? For example:
> 
> ```
> std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
>   inner_loop = false;
>   os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
>  
>  << << "outer_loop:\n"
>  << x.outer_statements();
>   inner_loop = true;
>   os << "%o_ct_new = add i64 %outer_ct, 1\n"
>  
>  << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize << "}\n";
>   return os;
> 
> ```
> And removed `inner_loop = true;` from the above function?
That would be better.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:140
+ << "br label %inner_loop\n"
+ << "end:\n"
+ << "ret void\n"

emmettneyman wrote:
> morehouse wrote:
> > I don't see any jumps to `end`.  I think this will be an infinite loop.
> There are two jumps to `end`, one before entering the `outer_loop` and one at 
> the end of `outer_loop`.
Right, sorry not sure what I missed there.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:143
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add i64 %outer_ct, 1\n"

emmettneyman wrote:
> emmettneyman wrote:
> > morehouse wrote:
> > > morehouse wrote:
> > > > IIUC this creates loop structure always like this:
> > > > 
> > > > ```
> > > > for (int i = 0; i < s; i++) {
> > > >   for (int j = 0; j < s; j++) {
> > > > // statements
> > > >   }
> > > >   // statements
> > > > }
> > > > ```
> > > > 
> > > > Maybe not necessary for this patch, but I'm curious if adding 
> > > > statements before the inner loop would exercise different coverage in 
> > > > the vectorizer.
> > > Will all loops be double-nested now?
> > Yes, that's correct. It's also worth noting that all the statements in the 
> > inner loop will only use `j` to index into the arrays, never `i`. It 
> > shouldn't be hard to add outer loop statements before the inner loop. A 
> > third `StatementSeq` could be added to the `LoopFunction` proto: one for 
> > outer loop statements before the inner loop, one for inner loop statements, 
> > and one for outer loop statements after the inner loop.
> Yes, all loops will be double-nested. It shouldn't be difficult to make the 
> inner loop optional though. In `cxx_loop_proto`, the first `Statement_Seq`, 
> `inner_statements`, can be made `optional` and then a different IR structures 
> can be generated depending on whether or not `inner_statements` exists.
Can we do that in this patch?  I think it makes sense to be able to generate 
either single loops or nested loops.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50805: Don't warn on returning the address of a label

2018-08-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: niravd, rsmith, nickdesaulniers.

There aren't any lifetime issues inherent in returning a local label.
Hypothetically, it could be used to drive a state machine driven by
computed goto the next time that same scope is re-entered. In any case,
the Linux kernel uses this code pattern to get PCs, and we don't want to
warn on that code pattern.

Fixes PR38569


https://reviews.llvm.org/D50805

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Analysis/stack-addr-ps.cpp
  clang/test/Sema/statements.c


Index: clang/test/Sema/statements.c
===
--- clang/test/Sema/statements.c
+++ clang/test/Sema/statements.c
@@ -29,9 +29,22 @@
 }
 
 
-void *test10() { 
+// PR38569: Clang used to warn on returning the address of a label, but we 
don't
+// anymore. Labels aren't exactly destroyed when they go out of scope, and the
+// Linux kernel uses this functionality.
+void *test10() {
 bar:
-  return &&bar;  // expected-warning {{returning address of label, which is 
local}}
+  return &&bar;
+}
+
+// Linux actually does something more like this, and we don't want to warn on
+// it.
+void test10_logpc(void*);
+void test10a() {
+  test10_logpc(({
+my_pc:
+  &&my_pc;
+  }));
 }
 
 // PR6034
Index: clang/test/Analysis/stack-addr-ps.cpp
===
--- clang/test/Analysis/stack-addr-ps.cpp
+++ clang/test/Analysis/stack-addr-ps.cpp
@@ -74,10 +74,12 @@
   return &x; // expected-warning{{Address of stack memory associated with 
local variable 's1' returned}} expected-warning {{address of stack memory 
associated with local variable 's1' returned}}
 }
 
+// PR38569: Clang used to warn when returning label addresses, but now it
+// doesn't.
 void *lf() {
 label:
-void *const &x = &&label; // expected-note {{binding reference variable 
'x' here}}
-return x; // expected-warning {{returning address of label, which is 
local}}
+void *const &x = &&label;
+return x;
 }
 
 template 
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6291,7 +6291,6 @@
 /// A temporary or local variable. This will be one of:
 ///  * A MaterializeTemporaryExpr.
 ///  * A DeclRefExpr whose declaration is a local.
-///  * An AddrLabelExpr.
 ///  * A BlockExpr for a block with captures.
 using Local = Expr*;
 
@@ -6735,11 +6734,6 @@
 }
 break;
 
-  case Stmt::AddrLabelExprClass:
-// We want to warn if the address of a label would escape the function.
-Visit(Path, Local(cast(Init)), RK_ReferenceBinding);
-break;
-
   default:
 break;
   }
@@ -6923,8 +6917,6 @@
 << isa(DRE->getDecl()) << DiagRange;
   } else if (isa(L)) {
 Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
-  } else if (isa(L)) {
-Diag(DiagLoc, diag::warn_ret_addr_label) << DiagRange;
   } else {
 Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
  << Entity.getType()->isReferenceType() << DiagRange;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7869,9 +7869,6 @@
 def warn_ret_local_temp_addr_ref : Warning<
   "returning %select{address of|reference to}0 local temporary object">,
   InGroup;
-def warn_ret_addr_label : Warning<
-  "returning address of label, which is local">,
-  InGroup;
 def err_ret_local_block : Error<
   "returning block that lives on the local stack">;
 def note_local_var_initializer : Note<


Index: clang/test/Sema/statements.c
===
--- clang/test/Sema/statements.c
+++ clang/test/Sema/statements.c
@@ -29,9 +29,22 @@
 }
 
 
-void *test10() { 
+// PR38569: Clang used to warn on returning the address of a label, but we don't
+// anymore. Labels aren't exactly destroyed when they go out of scope, and the
+// Linux kernel uses this functionality.
+void *test10() {
 bar:
-  return &&bar;  // expected-warning {{returning address of label, which is local}}
+  return &&bar;
+}
+
+// Linux actually does something more like this, and we don't want to warn on
+// it.
+void test10_logpc(void*);
+void test10a() {
+  test10_logpc(({
+my_pc:
+  &&my_pc;
+  }));
 }
 
 // PR6034
Index: clang/test/Analysis/stack-addr-ps.cpp
===
--- clang/test/Analysis/stack-addr-ps.cpp
+++ clang/test/Analysis/stack-addr-ps.cpp
@@ -74,10 +74,12 @@
   return &x; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{address of stack memory associated with local variable 's1' returned}}
 }
 
+// PR38569

[PATCH] D50805: Don't warn on returning the address of a label

2018-08-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7872-7874
-def warn_ret_addr_label : Warning<
-  "returning address of label, which is local">,
-  InGroup;

Why completely drop the diagnostic just because it is undesired in linux code?
Why not just add an `-Wreturn-stack-address` diag option instead, and disable 
it if undesired?


https://reviews.llvm.org/D50805



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


[PATCH] D50805: Don't warn on returning the address of a label

2018-08-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7872-7874
-def warn_ret_addr_label : Warning<
-  "returning address of label, which is local">,
-  InGroup;

lebedev.ri wrote:
> Why completely drop the diagnostic just because it is undesired in linux code?
> Why not just add an `-Wreturn-stack-address` diag option instead, and disable 
> it if undesired?
There's just no use for it. There is no actual lifetime issue here. Just 
because a label goes out of scope doesn't invalidate it for use with some 
future execution of the scope. Labels aren't variables, we should never have 
had this check in the first place, IMO.


https://reviews.llvm.org/D50805



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


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D50799



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


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The C++ standard just says "An integer literal of type std::size_t whose value 
is the alignment guaranteed by a call to operator new(std::size_t) or operator 
new[](std::size_t)."  I would take that in the obvious sense, that any pointer 
returned by operator new must have alignment `__STDCPP_DEFAULT_NEW_ALIGNMENT__`.

Granted, I can see how that might not be the intent, given that `alignof(T) >= 
sizeof(T)` for all C++ types.


Repository:
  rC Clang

https://reviews.llvm.org/D50683



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


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.

LGTM.


https://reviews.llvm.org/D50799



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


[libcxx] r339816 - Selectively import timespec_get into namespace std, since some C libraries don't have it. Reviewed as https://reviews.llvm.org/D50799

2018-08-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug 15 14:19:08 2018
New Revision: 339816

URL: http://llvm.org/viewvc/llvm-project?rev=339816&view=rev
Log:
Selectively import timespec_get into namespace std, since some C libraries 
don't have it. Reviewed as https://reviews.llvm.org/D50799

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/cstdlib
libcxx/trunk/include/ctime
libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp
libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Aug 15 14:19:08 2018
@@ -334,6 +334,7 @@
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_TIMESPEC_GET
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
@@ -342,9 +343,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__

Modified: libcxx/trunk/include/cstdlib
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdlib?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/cstdlib Wed Aug 15 14:19:08 2018
@@ -151,11 +151,11 @@ using ::mbtowc;
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 

Modified: libcxx/trunk/include/ctime
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctime?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/include/ctime (original)
+++ libcxx/trunk/include/ctime Wed Aug 15 14:19:08 2018
@@ -73,7 +73,7 @@ using ::gmtime;
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 

Modified: libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp Wed 
Aug 15 14:19:08 2018
@@ -45,7 +45,7 @@ int main()
 static_assert((std::is_same::value), 
"");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS

Modified: libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp Wed Aug 15 
14:19:08 2018
@@ -47,7 +47,7 @@ int main()
 static_assert((std::is_same::value), 
"");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=339816&r1=339815&r2=339816&view=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Wed Aug 15 14:19:08 2018
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling

[PATCH] D50810: [ASTImporter] Add test for DoStmt

2018-08-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50810

Files:
  test/Import/do-stmt/Inputs/F.cpp
  test/Import/do-stmt/test.cpp


Index: test/Import/do-stmt/test.cpp
===
--- /dev/null
+++ test/Import/do-stmt/test.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: DoStmt
+// CHECK-NEXT: NullStmt
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-SAME: true
+
+// CHECK: DoStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-SAME: false
+
+void expr() {
+  f();
+}
Index: test/Import/do-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/do-stmt/Inputs/F.cpp
@@ -0,0 +1,7 @@
+void f() {
+  do
+;
+  while (true);
+  do {
+  } while (false);
+}


Index: test/Import/do-stmt/test.cpp
===
--- /dev/null
+++ test/Import/do-stmt/test.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: DoStmt
+// CHECK-NEXT: NullStmt
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-SAME: true
+
+// CHECK: DoStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXBoolLiteralExpr
+// CHECK-SAME: false
+
+void expr() {
+  f();
+}
Index: test/Import/do-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/do-stmt/Inputs/F.cpp
@@ -0,0 +1,7 @@
+void f() {
+  do
+;
+  while (true);
+  do {
+  } while (false);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >