r312877 - set the svn:executable property, seems that it is necessary for apache (discussed with Tanya by email)

2017-09-10 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Sun Sep 10 01:00:03 2017
New Revision: 312877

URL: http://llvm.org/viewvc/llvm-project?rev=312877&view=rev
Log:
set the svn:executable property, seems that it is necessary for apache 
(discussed with Tanya by email)

Modified:
cfe/trunk/www/menu.html.incl   (props changed)

Propchange: cfe/trunk/www/menu.html.incl
--
svn:executable = *


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


[PATCH] D37416: Use the VFS from the CompilerInvocation by default

2017-09-10 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 114504.
teemperor added a comment.
Herald added a subscriber: mgorny.

- Added test case.


https://reviews.llvm.org/D37416

Files:
  lib/Frontend/CompilerInstance.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/CompilerInstanceTest.cpp

Index: unittests/Frontend/CompilerInstanceTest.cpp
===
--- /dev/null
+++ unittests/Frontend/CompilerInstanceTest.cpp
@@ -0,0 +1,74 @@
+//===- unittests/Frontend/CompilerInstanceTest.cpp - CI tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) {
+  // Create a temporary VFS overlay yaml file.
+  int FD;
+  SmallString<256> FileName;
+  ASSERT_FALSE(sys::fs::createTemporaryFile("vfs", "yaml", FD, FileName));
+  tool_output_file File(FileName, FD);
+
+  SmallString<256> CurrentPath;
+  sys::fs::current_path(CurrentPath);
+  sys::fs::make_absolute(CurrentPath, FileName);
+
+  // Mount the VFS file itself on the path 'virtual.file'. Makes this test
+  // a bit shorter than creating a new dummy file just for this purpose.
+  const std::string CurrentPathStr = CurrentPath.str();
+  const std::string FileNameStr = FileName.str();
+  const char *VFSYaml = "{ 'version': 0, 'roots': [\n"
+"  { 'name': '%s',\n"
+"'type': 'directory',\n"
+"'contents': [\n"
+"  { 'name': 'vfs-virtual.file', 'type': 'file',\n"
+"'external-contents': '%s'\n"
+"  }\n"
+"]\n"
+"  }\n"
+"]}\n";
+  File.os() << format(VFSYaml, CurrentPathStr.c_str(), FileName.c_str());
+  File.os().flush();
+
+  // Create a CompilerInvocation that uses this overlay file.
+  const std::string VFSArg = "-ivfsoverlay" + FileNameStr;
+  const char *Args[] = {"clang", VFSArg.c_str(), "-xc++", "-"};
+
+  IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions());
+
+  std::shared_ptr CInvok =
+  createInvocationFromCommandLine(Args, Diags);
+
+  if (!CInvok)
+FAIL() << "could not create compiler invocation";
+  // Create a minimal CompilerInstance which should use the VFS we specified
+  // in the CompilerInvocation (as we don't explicitly set our own).
+  CompilerInstance Instance;
+  Instance.setDiagnostics(Diags.get());
+  Instance.setInvocation(CInvok);
+  Instance.createFileManager();
+
+  // Check if the virtual file exists which means that our VFS is used by the
+  // CompilerInstance.
+  ASSERT_TRUE(Instance.getFileManager().getFile("vfs-virtual.file"));
+}
+
+} // anonymous namespace
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(FrontendTests
   ASTUnitTest.cpp
+  CompilerInstanceTest.cpp
   FrontendActionTest.cpp
   CodeGenActionTest.cpp
   )
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -302,8 +302,8 @@
 
 void CompilerInstance::createFileManager() {
   if (!hasVirtualFileSystem()) {
-// TODO: choose the virtual file system based on the CompilerInvocation.
-setVirtualFileSystem(vfs::getRealFileSystem());
+setVirtualFileSystem(
+createVFSFromCompilerInvocation(getInvocation(), getDiagnostics()));
   }
   FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37667: [C++14][Sema] Disallow decltype(auto) deduction for lambdas

2017-09-10 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete created this revision.

`decltype(auto) lambda = []{};` is currently allowed by clang, gcc and MSVC, 
but it is actually not valid, because `decltype([]{})` (which is how the type 
of `lambda` is deduced) is ill-formed, I think. I honestly could argue both 
ways (and I did once), but the fact that `decltype(auto) list = {0,1};` is 
already rejected by all three, it seems like the most sensible way is to 
disallow it for lambdas too.


https://reviews.llvm.org/D37667

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaTemplateDeduction.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
@@ -96,3 +96,10 @@
 
 auto init_list_1() { return { 1, 2, 3 }; } // expected-error {{cannot deduce 
return type from initializer list}}
 decltype(auto) init_list_2() { return { 1, 2, 3 }; } // expected-error 
{{cannot deduce return type from initializer list}}
+
+auto auto_lambda() { return []{}; }
+decltype(auto) decltype_lambda() { return []{}; } // expected-error {{cannot 
deduce 'decltype(auto)' from lambda}}
+
+auto AutoLambda = []{};
+decltype(auto) DecltypeLambda = []{}; // expected-error {{cannot deduce 
'decltype(auto)' from lambda}}
+
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -4314,6 +4314,9 @@
   if (isa(Init)) {
 Diag(Init->getLocStart(), diag::err_decltype_auto_initializer_list);
 return DAR_FailedAlreadyDiagnosed;
+  } else if (isa(Init)) {
+Diag(Init->getLocStart(), diag::err_decltype_auto_lambda);
+return DAR_FailedAlreadyDiagnosed;
   }
 
   QualType Deduced = BuildDecltypeType(Init, Init->getLocStart(), false);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2021,6 +2021,8 @@
   "cannot form %select{pointer to|reference to|array of}0 'decltype(auto)'">;
 def err_decltype_auto_initializer_list : Error<
   "cannot deduce 'decltype(auto)' from initializer list">;
+def err_decltype_auto_lambda : Error<
+  "cannot deduce 'decltype(auto)' from lambda">;
 
 // C++17 deduced class template specialization types
 def err_deduced_class_template_compound_type : Error<


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
@@ -96,3 +96,10 @@
 
 auto init_list_1() { return { 1, 2, 3 }; } // expected-error {{cannot deduce return type from initializer list}}
 decltype(auto) init_list_2() { return { 1, 2, 3 }; } // expected-error {{cannot deduce return type from initializer list}}
+
+auto auto_lambda() { return []{}; }
+decltype(auto) decltype_lambda() { return []{}; } // expected-error {{cannot deduce 'decltype(auto)' from lambda}}
+
+auto AutoLambda = []{};
+decltype(auto) DecltypeLambda = []{}; // expected-error {{cannot deduce 'decltype(auto)' from lambda}}
+
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -4314,6 +4314,9 @@
   if (isa(Init)) {
 Diag(Init->getLocStart(), diag::err_decltype_auto_initializer_list);
 return DAR_FailedAlreadyDiagnosed;
+  } else if (isa(Init)) {
+Diag(Init->getLocStart(), diag::err_decltype_auto_lambda);
+return DAR_FailedAlreadyDiagnosed;
   }
 
   QualType Deduced = BuildDecltypeType(Init, Init->getLocStart(), false);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2021,6 +2021,8 @@
   "cannot form %select{pointer to|reference to|array of}0 'decltype(auto)'">;
 def err_decltype_auto_initializer_list : Error<
   "cannot deduce 'decltype(auto)' from initializer list">;
+def err_decltype_auto_lambda : Error<
+  "cannot deduce 'decltype(auto)' from lambda">;
 
 // C++17 deduced class template specialization types
 def err_deduced_class_template_compound_type : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-10 Thread jina via Phabricator via cfe-commits
jina.nahias created this revision.

this is clang part , the llvm part is 
https://reviews.llvm.org/differential/diff/114515/


https://reviews.llvm.org/D37668

Files:
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c

Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2602,28 +2602,196 @@
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
   return _mm256_maskz_broadcastw_epi16(__M, __A);
 }
+  __m128i test_mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A){
+// CHECK-LABEL: @test_mm_mask_set1_epi8
+// CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+// CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
+	return _mm_mask_set1_epi8(__O, __M, __A);
+	}
+
+  __m128i test_mm_maskz_set1_epi8 ( __mmask16 __M, char __A){
+// CHECK-LABEL: @test_mm_maskz_set1_epi8
+	// CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+// CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+// CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
+	return _mm_maskz_set1_epi8( __M, __A);
+	}
+
+__m256i test_mm256_mask_set1_epi8(__m256i __O, __mmask32 __M, char __A) {
+  // CHECK-LABEL: @test_mm256_mask_set1_epi8
+// CHECK: insertelement <32 x i8> undef, i8 %{{.*}}, i32 0
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 16
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 17
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 18
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 19
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 20
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 21
+  // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 22
+  // CHECK: in

[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR

2017-09-10 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

As with https://reviews.llvm.org/D37562, strip the builtins from 
include/clang/Basic/BuiltinsX86.def


https://reviews.llvm.org/D37668



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


r312882 - [clang][SemaStmtAsm] small refactoring, NFC.

2017-09-10 Thread Coby Tayree via cfe-commits
Author: coby
Date: Sun Sep 10 05:39:21 2017
New Revision: 312882

URL: http://llvm.org/viewvc/llvm-project?rev=312882&view=rev
Log:
[clang][SemaStmtAsm] small refactoring, NFC.


Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=312882&r1=312881&r2=312882&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Sun Sep 10 05:39:21 2017
@@ -62,11 +62,13 @@ static bool CheckAsmLValue(const Expr *E
 
 /// isOperandMentioned - Return true if the specified operand # is mentioned
 /// anywhere in the decomposed asm string.
-static bool isOperandMentioned(unsigned OpNo,
- ArrayRef AsmStrPieces) {
+static bool
+isOperandMentioned(unsigned OpNo,
+   ArrayRef AsmStrPieces) {
   for (unsigned p = 0, e = AsmStrPieces.size(); p != e; ++p) {
 const GCCAsmStmt::AsmStringPiece &Piece = AsmStrPieces[p];
-if (!Piece.isOperand()) continue;
+if (!Piece.isOperand())
+  continue;
 
 // If this is a reference to the input and if the input was the smaller
 // one, then we have to reject this asm.


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


[PATCH] D37413: [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions

2017-09-10 Thread coby via Phabricator via cfe-commits
coby updated this revision to Diff 114520.
coby added a comment.
Herald added a subscriber: eraman.

addressed Simon's comments


Repository:
  rL LLVM

https://reviews.llvm.org/D37413

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/ms-inline-asm-enums.cpp
  test/CodeGen/ms-inline-asm-variables.c

Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -54,17 +54,17 @@
 assert(AsmToks.size() == AsmTokOffsets.size());
   }
 
-  void *LookupInlineAsmIdentifier(StringRef &LineBuf,
-  llvm::InlineAsmIdentifierInfo &Info,
-  bool IsUnevaluatedContext) override {
+  void LookupInlineAsmIdentifier(StringRef &LineBuf,
+ llvm::InlineAsmIdentifierInfo &Info,
+ bool IsUnevaluatedContext) override {
 // Collect the desired tokens.
 SmallVector LineToks;
 const Token *FirstOrigToken = nullptr;
 findTokensForString(LineBuf, LineToks, FirstOrigToken);
 
 unsigned NumConsumedToks;
 ExprResult Result = TheParser.ParseMSAsmIdentifier(
-LineToks, NumConsumedToks, &Info, IsUnevaluatedContext);
+LineToks, NumConsumedToks, IsUnevaluatedContext);
 
 // If we consumed the entire line, tell MC that.
 // Also do this if we consumed nothing as a way of reporting failure.
@@ -89,9 +89,10 @@
   LineBuf = LineBuf.substr(0, TotalOffset);
 }
 
-// Initialize the "decl" with the lookup result.
-Info.OpDecl = static_cast(Result.get());
-return Info.OpDecl;
+// Initialize Info with the lookup result.
+if (!Result.isUsable())
+  return;
+TheParser.getActions().FillInlineAsmIdentifierInfo(Result.get(), Info);
   }
 
   StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr &LSM,
@@ -178,16 +179,9 @@
 }
 
 /// Parse an identifier in an MS-style inline assembly block.
-///
-/// \param CastInfo - a void* so that we don't have to teach Parser.h
-///   about the actual type.
 ExprResult Parser::ParseMSAsmIdentifier(llvm::SmallVectorImpl &LineToks,
 unsigned &NumLineToksConsumed,
-void *CastInfo,
 bool IsUnevaluatedContext) {
-  llvm::InlineAsmIdentifierInfo &Info =
-  *(llvm::InlineAsmIdentifierInfo *)CastInfo;
-
   // Push a fake token on the end so that we don't overrun the token
   // stream.  We use ';' because it expression-parsing should never
   // overrun it.
@@ -227,7 +221,7 @@
  /*AllowDeductionGuide=*/false,
  /*ObjectType=*/nullptr, TemplateKWLoc, Id);
 // Perform the lookup.
-Result = Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id, Info,
+Result = Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id,
IsUnevaluatedContext);
   }
   // While the next two tokens are 'period' 'identifier', repeatedly parse it as
@@ -241,7 +235,7 @@
 IdentifierInfo *Id = Tok.getIdentifierInfo();
 ConsumeToken(); // Consume the identifier.
 Result = Actions.LookupInlineAsmVarDeclField(Result.get(), Id->getName(),
- Info, Tok.getLocation());
+ Tok.getLocation());
   }
 
   // Figure out how many tokens we are into LineToks.
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -48,10 +48,10 @@
   if (E != E2 && E2->isLValue()) {
 if (!S.getLangOpts().HeinousExtensions)
   S.Diag(E2->getLocStart(), diag::err_invalid_asm_cast_lvalue)
-<< E->getSourceRange();
+  << E->getSourceRange();
 else
   S.Diag(E2->getLocStart(), diag::warn_invalid_asm_cast_lvalue)
-<< E->getSourceRange();
+  << E->getSourceRange();
 // Accept, even if we emitted an error diagnostic.
 return false;
   }
@@ -607,23 +607,32 @@
   return NS;
 }
 
-static void fillInlineAsmTypeInfo(const ASTContext &Context, QualType T,
-  llvm::InlineAsmIdentifierInfo &Info) {
-  // Compute the type size (and array length if applicable?).
-  Info.Type = Info.Size = Context.getTypeSizeInChars(T).getQuantity();
-  if (T->isArrayType()) {
-const ArrayType *ATy = Context.getAsArrayType(T);
-Info.Type = Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
-Info.Length = Info.Size / Info.Type;
-  }
+void Sema::FillInlineAsmIdentifierInfo(Expr *Res,
+   llvm::InlineAsmIdentifierInfo &Info) {
+  QualType T = Res->getType();
+  Expr::EvalResult Eval;
+  if (T->isFunctionType() || T-

[PATCH] D37416: Use the VFS from the CompilerInvocation by default

2017-09-10 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 114524.
teemperor added a comment.

- Moved code from FrontendAction.cpp into createFileManager()


https://reviews.llvm.org/D37416

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendAction.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/CompilerInstanceTest.cpp

Index: unittests/Frontend/CompilerInstanceTest.cpp
===
--- /dev/null
+++ unittests/Frontend/CompilerInstanceTest.cpp
@@ -0,0 +1,74 @@
+//===- unittests/Frontend/CompilerInstanceTest.cpp - CI tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) {
+  // Create a temporary VFS overlay yaml file.
+  int FD;
+  SmallString<256> FileName;
+  ASSERT_FALSE(sys::fs::createTemporaryFile("vfs", "yaml", FD, FileName));
+  tool_output_file File(FileName, FD);
+
+  SmallString<256> CurrentPath;
+  sys::fs::current_path(CurrentPath);
+  sys::fs::make_absolute(CurrentPath, FileName);
+
+  // Mount the VFS file itself on the path 'virtual.file'. Makes this test
+  // a bit shorter than creating a new dummy file just for this purpose.
+  const std::string CurrentPathStr = CurrentPath.str();
+  const std::string FileNameStr = FileName.str();
+  const char *VFSYaml = "{ 'version': 0, 'roots': [\n"
+"  { 'name': '%s',\n"
+"'type': 'directory',\n"
+"'contents': [\n"
+"  { 'name': 'vfs-virtual.file', 'type': 'file',\n"
+"'external-contents': '%s'\n"
+"  }\n"
+"]\n"
+"  }\n"
+"]}\n";
+  File.os() << format(VFSYaml, CurrentPathStr.c_str(), FileName.c_str());
+  File.os().flush();
+
+  // Create a CompilerInvocation that uses this overlay file.
+  const std::string VFSArg = "-ivfsoverlay" + FileNameStr;
+  const char *Args[] = {"clang", VFSArg.c_str(), "-xc++", "-"};
+
+  IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions());
+
+  std::shared_ptr CInvok =
+  createInvocationFromCommandLine(Args, Diags);
+
+  if (!CInvok)
+FAIL() << "could not create compiler invocation";
+  // Create a minimal CompilerInstance which should use the VFS we specified
+  // in the CompilerInvocation (as we don't explicitly set our own).
+  CompilerInstance Instance;
+  Instance.setDiagnostics(Diags.get());
+  Instance.setInvocation(CInvok);
+  Instance.createFileManager();
+
+  // Check if the virtual file exists which means that our VFS is used by the
+  // CompilerInstance.
+  ASSERT_TRUE(Instance.getFileManager().getFile("vfs-virtual.file"));
+}
+
+} // anonymous namespace
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(FrontendTests
   ASTUnitTest.cpp
+  CompilerInstanceTest.cpp
   FrontendActionTest.cpp
   CodeGenActionTest.cpp
   )
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -633,18 +633,12 @@
 return true;
   }
 
-  if (!CI.hasVirtualFileSystem()) {
-if (IntrusiveRefCntPtr VFS =
-  createVFSFromCompilerInvocation(CI.getInvocation(),
-  CI.getDiagnostics()))
-  CI.setVirtualFileSystem(VFS);
-else
+  // Set up the file and source managers, if needed.
+  if (!CI.hasFileManager()) {
+if (!CI.createFileManager()) {
   goto failure;
+}
   }
-
-  // Set up the file and source managers, if needed.
-  if (!CI.hasFileManager())
-CI.createFileManager();
   if (!CI.hasSourceManager())
 CI.createSourceManager(CI.getFileManager());
 
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -300,12 +300,16 @@
 
 // File Manager
 
-void CompilerInstance::createFileManager() {
+FileManager *CompilerInstance::createFileManager() {
   if (!hasVirtualFileSystem()) {
-// TODO: choose the virtual file system based on the CompilerInvocation

[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR

2017-09-10 Thread Yael Tsafrir via Phabricator via cfe-commits
ytsafrir updated this revision to Diff 114523.
ytsafrir added a comment.

Removed the AVG builtins from  ./include/clang/Basic/BuiltinsX86.def


https://reviews.llvm.org/D37562

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx2intrin.h
  lib/Headers/avx512bwintrin.h
  lib/Headers/emmintrin.h
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/builtins-x86.c
  test/CodeGen/sse2-builtins.c

Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -97,13 +97,25 @@
 
 __m128i test_mm_avg_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_avg_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: add <16 x i16> %{{.*}}, 
+  // CHECK: lshr <16 x i16> %{{.*}}, 
+  // CHECK:trunc <16 x i16> %{{.*}} to <16 x i8>
   return _mm_avg_epu8(A, B);
 }
 
 __m128i test_mm_avg_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_avg_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.pavg.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.pavg.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: zext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: zext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: add <8 x i32> %{{.*}}, %{{.*}}
+  // CHECK: add <8 x i32> %{{.*}}, 
+  // CHECK: lshr <8 x i32> %{{.*}}, 
+  // CHECK: trunc <8 x i32> %{{.*}} to <8 x i16>
   return _mm_avg_epu16(A, B);
 }
 
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -160,8 +160,6 @@
   tmp_V4s = __builtin_ia32_psubusw(tmp_V4s, tmp_V4s);
   tmp_V4s = __builtin_ia32_pmulhw(tmp_V4s, tmp_V4s);
   tmp_V4s = __builtin_ia32_pmulhuw(tmp_V4s, tmp_V4s);
-  tmp_V8c = __builtin_ia32_pavgb(tmp_V8c, tmp_V8c);
-  tmp_V4s = __builtin_ia32_pavgw(tmp_V4s, tmp_V4s);
   tmp_V8c = __builtin_ia32_pcmpeqb(tmp_V8c, tmp_V8c);
   tmp_V4s = __builtin_ia32_pcmpeqw(tmp_V4s, tmp_V4s);
   tmp_V2i = __builtin_ia32_pcmpeqd(tmp_V2i, tmp_V2i);
@@ -201,8 +199,6 @@
   tmp_V16c = __builtin_ia32_psubusb128(tmp_V16c, tmp_V16c);
   tmp_V8s = __builtin_ia32_psubusw128(tmp_V8s, tmp_V8s);
   tmp_V8s = __builtin_ia32_pmulhw128(tmp_V8s, tmp_V8s);
-  tmp_V16c = __builtin_ia32_pavgb128(tmp_V16c, tmp_V16c);
-  tmp_V8s = __builtin_ia32_pavgw128(tmp_V8s, tmp_V8s);
   tmp_V16c = __builtin_ia32_pmaxub128(tmp_V16c, tmp_V16c);
   tmp_V8s = __builtin_ia32_pmaxsw128(tmp_V8s, tmp_V8s);
   tmp_V16c = __builtin_ia32_pminub128(tmp_V16c, tmp_V16c);
Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -1155,49 +1155,101 @@
 }
 __m128i test_mm_mask_avg_epu8(__m128i __W, __mmask16 __U, __m128i __A,   __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_avg_epu8
-  // CHECK: @llvm.x86.sse2.pavg.b
+  // CHECK-NOT: @llvm.x86.sse2.pavg.b
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: add <16 x i16> %{{.*}}, 
+  // CHECK: lshr <16 x i16> %{{.*}}, 
+  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_mask_avg_epu8(__W,__U,__A,__B); 
 }
 __m128i test_mm_maskz_avg_epu8(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_avg_epu8
-  // CHECK: @llvm.x86.sse2.pavg.b
+  // CHECK-NOT: @llvm.x86.sse2.pavg.b
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: add <16 x i16> %{{.*}}, 
+  // CHECK: lshr <16 x i16> %{{.*}}, 
+  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
+  // CHECK: store <2 x i64> zeroinitializer
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_maskz_avg_epu8(__U,__A,__B); 
 }
 __m256i test_mm256_mask_avg_epu8(__m256i __W, __mmask32 __U, __m256i __A,  __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_avg_epu8
-  // CHECK: @llvm.x86.avx2.pavg.b
+  // CHECK-NOT: @llvm.x86.avx2.pavg.b
+  // CHECK: zext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: zext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: add <32 x i16> %{{.*}}, %{{.*}}
+  // CHECK: add <32 x i16> %{{.*}}, 
+  // CHECK: lshr <32 x i16> %{{.*}}, 
+  // CHECK: trunc <32 x i16> %{{.*}} to <32 x i8>
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
   return _mm256_mask_avg_epu8(__W,__U,__A,__B); 
 }
 __m

Re: [clang-tools-extra] r312769 - Update for PrintHelpMessage not calling exit.

2017-09-10 Thread Alexander Kornienko via cfe-commits
On Fri, Sep 8, 2017 at 2:33 AM, Rafael Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rafael
> Date: Thu Sep  7 17:33:39 2017
> New Revision: 312769
>
> URL: http://llvm.org/viewvc/llvm-project?rev=312769&view=rev
> Log:
> Update for PrintHelpMessage not calling exit.
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
> clang-tools-extra/trunk/modularize/Modularize.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=312769&
> r1=312768&r2=312769&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Sep  7
> 17:33:39 2017
> @@ -392,13 +392,13 @@ static int clangTidyMain(int argc, const
>if (EnabledChecks.empty()) {
>  llvm::errs() << "Error: no checks enabled.\n";
>  llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
> -return 1;
> +return 0;
>}
>
>if (PathList.empty()) {
>  llvm::errs() << "Error: no input files specified.\n";
>  llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
> -return 1;
> +return 0;
>}
>

Actually, both of these should return non-zero exit code, since these code
paths are executed when the command line arguments are incorrect. Or am I
missing something?


>
>ProfileData Profile;
>
> Modified: clang-tools-extra/trunk/modularize/Modularize.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/modularize/Modularize.cpp?rev=312769&r1=312768&r2=312769&view=diff
> 
> ==
> --- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
> +++ clang-tools-extra/trunk/modularize/Modularize.cpp Thu Sep  7 17:33:39
> 2017
> @@ -825,7 +825,7 @@ int main(int Argc, const char **Argv) {
>// No go if we have no header list file.
>if (ListFileNames.size() == 0) {
>  cl::PrintHelpMessage();
> -return 1;
> +return 0;
>

IIUC, this path is also corresponds to incorrect command line arguments.


>}
>
>std::unique_ptr ModUtil;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxxabi] r308470 - Drop 'svn' suffix from version number.

2017-09-10 Thread Shoaib Meenai via cfe-commits
Note that Reid restored the old behavior in r312043.

Configuring with -DLLVM_APPEND_VC_REV=OFF should also restore the old
behavior, I believe.

On 9/9/17, 1:55 PM, "cfe-commits on behalf of Dimitry Andric via cfe-commits" 
 
wrote:

On 19 Jul 2017, at 16:04, Hans Wennborg via cfe-commits 
 wrote:
> 
> Author: hans
> Date: Wed Jul 19 07:04:19 2017
> New Revision: 308470
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=308470&view=rev
> Log:
> Drop 'svn' suffix from version number.

[Replying to this commit, since I don't have r308469 (which does the same 
for llvm itself) in my mailboxes.]

Note this approach isn't effective anymore after Rafael's
https://reviews.llvm.org/rL306858, which turns on the LLVM_APPEND_VC_REV
option by default.

The handling of that option will overwrite the PACKAGE_VERSION value set
earlier in CMakeLists.txt, with the value returned from
add_version_info_from_vcs().  When using Subversion, that will always be
of the form X.Y.Zsvn-rNN.

I noticed this when preparing the 5.0.0 final import into FreeBSD, where
for example "opt -version" outputs:

LLVM (http://llvm.org/):
  LLVM version 5.0.0svn-r312559
  Optimized build with assertions.
  Default target: x86_64-unknown-freebsd12.0
  Host CPU: ivybridge

-Dimitry



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


[PATCH] D37667: [C++14][Sema] Disallow decltype(auto) deduction for lambdas

2017-09-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

`decltype(auto) lambda = []{};` and `decltype(auto) list = {0,1};` seem like 
very different situations to me; in the latter case, the initializer is not 
even an expression.

The rule that bans `decltype([]{})` is that a *lambda-expression* shall not 
appear in an unevaluated operand. But the initializer in `decltype(auto) lambda 
= []{};` is not an unevaluated operand. The relevant rule is 
[dcl.type.auto.deduct]p5, which says: "The type deduced for T is determined as 
described in 10.1.7.2, as though e had been the operand of the decltype." -- 
so, while this is certainly not completely clear, this suggests that we only 
consider the expression as the operand of decltype for the purpose of 
determining the type, not for the purpose of determining whether the deduction 
is valid. And certainly seems to be the interpretation that is more friendly to 
users.


https://reviews.llvm.org/D37667



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


r312889 - Add objcImplementationDecl matcher

2017-09-10 Thread Dave Lee via cfe-commits
Author: kastiglione
Date: Sun Sep 10 14:00:15 2017
New Revision: 312889

URL: http://llvm.org/viewvc/llvm-project?rev=312889&view=rev
Log:
Add objcImplementationDecl matcher

Summary:
Add the `objcImplementationDecl` matcher. See related: D30854

Tested with:

```
./tools/clang/unittests/ASTMatchers/ASTMatchersTests
```

Reviewers: aaron.ballman, compnerd, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=312889&r1=312888&r2=312889&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Sun Sep 10 14:00:15 2017
@@ -346,6 +346,15 @@ Example matches Foo (Additions)
 
 
 
+MatcherDecl>objcImplementationDeclMatcherObjCImplementationDecl>...
+Matches 
Objective-C implementation declarations.
+
+Example matches Foo
+  @implementation Foo
+  @end
+
+
+
 MatcherDecl>objcInterfaceDeclMatcherObjCInterfaceDecl>...
 Matches 
Objective-C interface declarations.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=312889&r1=312888&r2=312889&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun Sep 10 14:00:15 2017
@@ -1145,6 +1145,17 @@ const internal::VariadicDynCastAllOfMatc
   Decl,
   ObjCInterfaceDecl> objcInterfaceDecl;
 
+/// \brief Matches Objective-C implementation declarations.
+///
+/// Example matches Foo
+/// \code
+///   @implementation Foo
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCImplementationDecl> objcImplementationDecl;
+
 /// \brief Matches Objective-C protocol declarations.
 ///
 /// Example matches FooDelegate

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=312889&r1=312888&r2=312889&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sun Sep 10 14:00:15 2017
@@ -374,6 +374,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcMessageExpr);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=312889&r1=312888&r2=312889&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Sun Sep 10 14:00:15 
2017
@@ -1612,6 +1612,9 @@ TEST(ObjCDeclMacher, CoreDecls) {
 objcProtocolDecl(hasName("Proto";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcImplementationDecl(hasName("Thing";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,


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


[PATCH] D37643: Add objcImplementationDecl matcher

2017-09-10 Thread Dave Lee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312889: Add objcImplementationDecl matcher (authored by 
kastiglione).

Changed prior to commit:
  https://reviews.llvm.org/D37643?vs=114442&id=114526#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37643

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -374,6 +374,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcMessageExpr);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1612,6 +1612,9 @@
 objcProtocolDecl(hasName("Proto";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcImplementationDecl(hasName("Thing";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
 
 
 
+MatcherDecl>objcImplementationDeclMatcherObjCImplementationDecl>...
+Matches 
Objective-C implementation declarations.
+
+Example matches Foo
+  @implementation Foo
+  @end
+
+
+
 MatcherDecl>objcInterfaceDeclMatcherObjCInterfaceDecl>...
 Matches 
Objective-C interface declarations.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1145,6 +1145,17 @@
   Decl,
   ObjCInterfaceDecl> objcInterfaceDecl;
 
+/// \brief Matches Objective-C implementation declarations.
+///
+/// Example matches Foo
+/// \code
+///   @implementation Foo
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCImplementationDecl> objcImplementationDecl;
+
 /// \brief Matches Objective-C protocol declarations.
 ///
 /// Example matches FooDelegate


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -374,6 +374,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcMessageExpr);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1612,6 +1612,9 @@
 objcProtocolDecl(hasName("Proto";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
+objcImplementationDecl(hasName("Thing";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
 objcCategoryDecl(hasName("ABC";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
 
 
 
+MatcherDecl>objcImplementationDeclMatcherObjCImplementationDecl>...
+Matches Objective-C implementation declarations.
+
+Example matches Foo
+  @implementation Foo
+  @end
+
+
+
 MatcherDecl>objcInterfaceDeclMatcherObjCInterfaceDecl>...
 Matches Objective-C interface declarations.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/i

[libcxx] r312890 - Fix PR34298 - Allow std::function with an incomplete return type.

2017-09-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep 10 16:12:33 2017
New Revision: 312890

URL: http://llvm.org/viewvc/llvm-project?rev=312890&view=rev
Log:
Fix PR34298 - Allow std::function with an incomplete return type.

This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated
the __invokable trait via the converting constructor `function(Tp)` [with Tp = 
std::function]
whenever the copy constructor or copy assignment operator
was required. This patch further constrains that constructor to short
circut before evaluating the troublesome SFINAE when `Tp` matches
std::function.

The original patch is from Alex Lorenz.

Modified:
libcxx/trunk/include/functional
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=312890&r1=312889&r2=312890&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Sun Sep 10 16:12:33 2017
@@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
   return reinterpret_cast<__base*>(p);
 }
 
-template ::value &&
-__invokable<_Fp&, _ArgTypes...>::value>
-struct __callable;
+template , function>::value>,
+__invokable<_Fp&, _ArgTypes...>
+>::value>
+struct __callable;
 template 
 struct __callable<_Fp, true>
 {
@@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
 {
 static const bool value = false;
 };
+
+  template 
+  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
 public:
 typedef _Rp result_type;
 
@@ -1622,9 +1627,7 @@ public:
 function(nullptr_t) _NOEXCEPT : __f_(0) {}
 function(const function&);
 function(function&&) _NOEXCEPT;
-template::value && !is_same<_Fp, function>::value
->::type>
+template>
 function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -1638,21 +1641,15 @@ public:
   function(allocator_arg_t, const _Alloc&, const function&);
 template
   function(allocator_arg_t, const _Alloc&, function&&);
-template::value>::type>
+template>
   function(allocator_arg_t, const _Alloc& __a, _Fp __f);
 #endif
 
 function& operator=(const function&);
 function& operator=(function&&) _NOEXCEPT;
 function& operator=(nullptr_t) _NOEXCEPT;
-template
-  typename enable_if
-  <
-__callable::type>::value &&
-!is_same::type, function>::value,
-function&
-  >::type
-  operator=(_Fp&&);
+template>
+function& operator=(_Fp&&);
 
 ~function();
 
@@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(n
 }
 
 template
-template 
-typename enable_if
-<
-function<_Rp(_ArgTypes...)>::template __callable::type>::value &&
-!is_same::type, 
function<_Rp(_ArgTypes...)>>::value,
-function<_Rp(_ArgTypes...)>&
->::type
+template 
+function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 {
 function(_VSTD::forward<_Fp>(__f)).swap(*this);

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=312890&r1=312889&r2=312890&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sun Sep 10 16:12:33 2017
@@ -4339,8 +4339,8 @@ struct __invokable_r
 using _Result = decltype(
 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
 
-static const bool value =
-conditional<
+using type =
+typename conditional<
 !is_same<_Result, __nat>::value,
 typename conditional<
 is_void<_Ret>::value,
@@ -4348,7 +4348,8 @@ struct __invokable_r
 is_convertible<_Result, _Ret>
 >::type,
 false_type
->::type::value;
+>::type;
+static const bool value = type::value;
 };
 
 template 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp?rev=312890&r1=312889&r2=312890&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 Sun Sep 10 16:12:33 2017
@@ -16,6 +16,7 @@
 // Allow incomplete argument types in the __is_callable check
 
 #include 

[PATCH] D37104: [libc++] PR34298: Change std::function constructor and move assignment operator SFINAE checks to allow std::function with an incomplete return type

2017-09-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF commandeered this revision.
EricWF edited reviewers, added: arphaman; removed: EricWF.
EricWF added a comment.

I committed a different version of this fix in r312890.

Commandeering and closing this review. @arphaman Thanks for the initial patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D37104



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


[libcxx] r312891 - Revert "Fix PR34298 - Allow std::function with an incomplete return type."

2017-09-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep 10 16:37:47 2017
New Revision: 312891

URL: http://llvm.org/viewvc/llvm-project?rev=312891&view=rev
Log:
Revert "Fix PR34298 - Allow std::function with an incomplete return type."

This reverts commit r312890 because the test case fails to compile for
older versions of Clang that reject initializing a const object without
a user defined constructor.

Since this patch should go into 5.0.1, I want to keep it an atomic change,
and will re-commit it with a fixed test case.

Modified:
libcxx/trunk/include/functional
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=312891&r1=312890&r2=312891&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Sun Sep 10 16:37:47 2017
@@ -1597,11 +1597,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
   return reinterpret_cast<__base*>(p);
 }
 
-template , function>::value>,
-__invokable<_Fp&, _ArgTypes...>
->::value>
-struct __callable;
+template ::value &&
+__invokable<_Fp&, _ArgTypes...>::value>
+struct __callable;
 template 
 struct __callable<_Fp, true>
 {
@@ -1614,9 +1612,6 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
 {
 static const bool value = false;
 };
-
-  template 
-  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
 public:
 typedef _Rp result_type;
 
@@ -1627,7 +1622,9 @@ public:
 function(nullptr_t) _NOEXCEPT : __f_(0) {}
 function(const function&);
 function(function&&) _NOEXCEPT;
-template>
+template::value && !is_same<_Fp, function>::value
+>::type>
 function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -1641,15 +1638,21 @@ public:
   function(allocator_arg_t, const _Alloc&, const function&);
 template
   function(allocator_arg_t, const _Alloc&, function&&);
-template>
+template::value>::type>
   function(allocator_arg_t, const _Alloc& __a, _Fp __f);
 #endif
 
 function& operator=(const function&);
 function& operator=(function&&) _NOEXCEPT;
 function& operator=(nullptr_t) _NOEXCEPT;
-template>
-function& operator=(_Fp&&);
+template
+  typename enable_if
+  <
+__callable::type>::value &&
+!is_same::type, function>::value,
+function&
+  >::type
+  operator=(_Fp&&);
 
 ~function();
 
@@ -1851,8 +1854,13 @@ function<_Rp(_ArgTypes...)>::operator=(n
 }
 
 template
-template 
-function<_Rp(_ArgTypes...)>&
+template 
+typename enable_if
+<
+function<_Rp(_ArgTypes...)>::template __callable::type>::value &&
+!is_same::type, 
function<_Rp(_ArgTypes...)>>::value,
+function<_Rp(_ArgTypes...)>&
+>::type
 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 {
 function(_VSTD::forward<_Fp>(__f)).swap(*this);

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=312891&r1=312890&r2=312891&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sun Sep 10 16:37:47 2017
@@ -4339,8 +4339,8 @@ struct __invokable_r
 using _Result = decltype(
 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
 
-using type =
-typename conditional<
+static const bool value =
+conditional<
 !is_same<_Result, __nat>::value,
 typename conditional<
 is_void<_Ret>::value,
@@ -4348,8 +4348,7 @@ struct __invokable_r
 is_convertible<_Result, _Ret>
 >::type,
 false_type
->::type;
-static const bool value = type::value;
+>::type::value;
 };
 
 template 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp?rev=312891&r1=312890&r2=312891&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 Sun Sep 10 16:37:47 2017
@@ -16,7 +16,6 @@
 // Allow incomplete argument types in the __is_callable check
 
 #include 
-#include 
 
 struct X{
 typedef std::function callback_type;
@@ -25,40 +24,6 @@ private:
 callback_type _cb;

[libcxx] r312892 - Fix PR34298 - Allow std::function with an incomplete return type.

2017-09-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Sep 10 16:41:20 2017
New Revision: 312892

URL: http://llvm.org/viewvc/llvm-project?rev=312892&view=rev
Log:
Fix PR34298 - Allow std::function with an incomplete return type.

This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated
the __invokable trait via the converting constructor `function(Tp)` [with Tp = 
std::function]
whenever the copy constructor or copy assignment operator
was required. This patch further constrains that constructor to short
circut before evaluating the troublesome SFINAE when `Tp` matches
std::function.

The original patch is from Alex Lorenz.

Modified:
libcxx/trunk/include/functional
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=312892&r1=312891&r2=312892&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Sun Sep 10 16:41:20 2017
@@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
   return reinterpret_cast<__base*>(p);
 }
 
-template ::value &&
-__invokable<_Fp&, _ArgTypes...>::value>
-struct __callable;
+template , function>::value>,
+__invokable<_Fp&, _ArgTypes...>
+>::value>
+struct __callable;
 template 
 struct __callable<_Fp, true>
 {
@@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
 {
 static const bool value = false;
 };
+
+  template 
+  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
 public:
 typedef _Rp result_type;
 
@@ -1622,9 +1627,7 @@ public:
 function(nullptr_t) _NOEXCEPT : __f_(0) {}
 function(const function&);
 function(function&&) _NOEXCEPT;
-template::value && !is_same<_Fp, function>::value
->::type>
+template>
 function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -1638,21 +1641,15 @@ public:
   function(allocator_arg_t, const _Alloc&, const function&);
 template
   function(allocator_arg_t, const _Alloc&, function&&);
-template::value>::type>
+template>
   function(allocator_arg_t, const _Alloc& __a, _Fp __f);
 #endif
 
 function& operator=(const function&);
 function& operator=(function&&) _NOEXCEPT;
 function& operator=(nullptr_t) _NOEXCEPT;
-template
-  typename enable_if
-  <
-__callable::type>::value &&
-!is_same::type, function>::value,
-function&
-  >::type
-  operator=(_Fp&&);
+template>
+function& operator=(_Fp&&);
 
 ~function();
 
@@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(n
 }
 
 template
-template 
-typename enable_if
-<
-function<_Rp(_ArgTypes...)>::template __callable::type>::value &&
-!is_same::type, 
function<_Rp(_ArgTypes...)>>::value,
-function<_Rp(_ArgTypes...)>&
->::type
+template 
+function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 {
 function(_VSTD::forward<_Fp>(__f)).swap(*this);

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=312892&r1=312891&r2=312892&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sun Sep 10 16:41:20 2017
@@ -4339,8 +4339,8 @@ struct __invokable_r
 using _Result = decltype(
 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
 
-static const bool value =
-conditional<
+using type =
+typename conditional<
 !is_same<_Result, __nat>::value,
 typename conditional<
 is_void<_Ret>::value,
@@ -4348,7 +4348,8 @@ struct __invokable_r
 is_convertible<_Result, _Ret>
 >::type,
 false_type
->::type::value;
+>::type;
+static const bool value = type::value;
 };
 
 template 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp?rev=312892&r1=312891&r2=312892&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
 Sun Sep 10 16:41:20 2017
@@ -16,6 +16,7 @@
 // Allow incomplete argument types in the __is_callable check
 
 #include