r288654 - DR1213: element access on an array xvalue or prvalue produces an xvalue. In the

2016-12-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Dec  5 01:49:14 2016
New Revision: 288654

URL: http://llvm.org/viewvc/llvm-project?rev=288654&view=rev
Log:
DR1213: element access on an array xvalue or prvalue produces an xvalue. In the
latter case, a temporary array object is materialized, and can be
lifetime-extended by binding a reference to the member access. Likewise, in an
array-to-pointer decay, an rvalue array is materialized before being converted
into a pointer.

This caused IR generation to stop treating file-scope array compound literals
as having static storage duration in some cases in C++; that has been rectified
by modeling such a compound literal as an lvalue. This also improves clang's
compatibility with GCC for those cases.

Modified:
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/Analysis/explain-svals.cpp
cfe/trunk/test/CXX/drs/dr12xx.cpp
cfe/trunk/test/CodeGenCXX/compound-literals.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse.cpp
cfe/trunk/test/CodeGenCXX/temporaries.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=288654&r1=288653&r2=288654&view=diff
==
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Mon Dec  5 01:49:14 2016
@@ -141,10 +141,9 @@ static Cl::Kinds ClassifyInternal(ASTCon
 return Cl::CL_LValue;
 
 // C99 6.5.2.5p5 says that compound literals are lvalues.
-// In C++, they're prvalue temporaries.
+// In C++, they're prvalue temporaries, except for file-scope arrays.
   case Expr::CompoundLiteralExprClass:
-return Ctx.getLangOpts().CPlusPlus ? ClassifyTemporary(E->getType())
-   : Cl::CL_LValue;
+return !E->isLValue() ? ClassifyTemporary(E->getType()) : Cl::CL_LValue;
 
 // Expressions that are prvalues.
   case Expr::CXXBoolLiteralExprClass:
@@ -196,11 +195,20 @@ static Cl::Kinds ClassifyInternal(ASTCon
 return ClassifyInternal(Ctx,
  cast(E)->getReplacement());
 
-// C++ [expr.sub]p1: The result is an lvalue of type "T".
-// However, subscripting vector types is more like member access.
+// C, C++98 [expr.sub]p1: The result is an lvalue of type "T".
+// C++11 (DR1213): in the case of an array operand, the result is an lvalue
+// if that operand is an lvalue and an xvalue otherwise.
+// Subscripting vector types is more like member access.
   case Expr::ArraySubscriptExprClass:
 if (cast(E)->getBase()->getType()->isVectorType())
   return ClassifyInternal(Ctx, cast(E)->getBase());
+if (Lang.CPlusPlus11) {
+  // Step over the array-to-pointer decay if present, but not over the
+  // temporary materialization.
+  auto *Base = cast(E)->getBase()->IgnoreImpCasts();
+  if (Base->getType()->isArrayType())
+return ClassifyInternal(Ctx, Base);
+}
 return Cl::CL_LValue;
 
 // C++ [expr.prim.general]p3: The result is an lvalue if the entity is a

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=288654&r1=288653&r2=288654&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Dec  5 01:49:14 2016
@@ -2907,7 +2907,6 @@ static bool handleLValueToRValueConversi
   // In C99, a CompoundLiteralExpr is an lvalue, and we defer evaluating 
the
   // initializer until now for such expressions. Such an expression can't 
be
   // an ICE in C, so this only matters for fold.
-  assert(!Info.getLangOpts().CPlusPlus && "lvalue compound literal in 
c++?");
   if (Type.isVolatileQualified()) {
 Info.FFDiag(Conv);
 return false;
@@ -4711,7 +4710,7 @@ public:
 //  * VarDecl
 //  * FunctionDecl
 // - Literals
-//  * CompoundLiteralExpr in C
+//  * CompoundLiteralExpr in C (and in global scope in C++)
 //  * StringLiteral
 //  * CXXTypeidExpr
 //  * PredefinedExpr
@@ -4906,7 +4905,8 @@ bool LValueExprEvaluator::VisitMateriali
 
 bool
 LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
-  assert(!Info.getLangOpts().CPlusPlus && "lvalue compound literal in c++?");
+  assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) &&
+ "lvalue compound literal in c++?");
   // Defer visiting the literal until the lvalue-to-rvalue conversion. We can
   // only see this when folding in C, so there's no standard to follow here.
   return Success(E);

Modified: cfe/t

[PATCH] D27387: [libc++] Add a key function for bad_function_call

2016-12-04 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D27387#612975, @EricWF wrote:

> I wonder if we should consider this a breaking ABI change and control it 
> using a `_LIBCPP_ABI` macro. @mclow.lists thoughts?


This is forward-compatible (as in clients built against an older libc++ would 
be happy with this version) but not backwards-compatible (as in clients built 
against this version would not be able to run against an older libc++). Has 
libc++ been aiming to maintain compatibility in both directions?


https://reviews.llvm.org/D27387



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


[PATCH] D27300: [OpenCL] Fix SPIR version generation.

2016-12-04 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 80229.
echuraev marked 2 inline comments as done.

https://reviews.llvm.org/D27300

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/spir_version.cl


Index: test/CodeGenOpenCL/spir_version.cl
===
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -13,19 +13,22 @@
 
 // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0}
-// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
-// CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]}
+// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]}
+// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2}
 
+// CHECK-SPIR-CL20: !opencl.spir.version = !{[[VER:![0-9]+]]}
+// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[VER]]}
+// CHECK-SPIR-CL20: [[VER]] = !{i32 2, i32 0}
+
+// CHECK-AMDGCN-CL10-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL10: [[OCL]] = !{i32 1, i32 0}
+// CHECK-AMDGCN-CL12-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2}
+// CHECK-AMDGCN-CL20-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
\ No newline at end of file
+// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7778,8 +7778,10 @@
   // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
   // opencl.spir.version named metadata.
   llvm::Metadata *SPIRVerElts[] = {
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+  llvm::ConstantAsMetadata::get(
+  llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 
100)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))};
   llvm::NamedMDNode *SPIRVerMD =
   M.getOrInsertNamedMetadata("opencl.spir.version");
   SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));


Index: test/CodeGenOpenCL/spir_version.cl
===
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -13,19 +13,22 @@
 
 // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0}
-// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
-// CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
-// CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]}
+// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]}
+// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2}
 
+// CHECK-SPIR-CL20: !opencl.spir.version = !{[[VER:![0-9]+]]}
+// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[VER]]}
+// CHECK-SPIR-CL20: [[VER]] = !{i32 2, i32 0}
+
+// CHECK-AMDGCN-CL10-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL10: [[OCL]] = !{i32 1, i32 0}
+// CHECK-AMDGCN-CL12-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2}
+// CHECK-AMDGCN-CL20-NOT: !opencl.spir.version
 // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
\ No newline at end of file
+// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7778,8 +7778,10 @@
   // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
   // opencl.spir.version named metadata.
   llvm::Metadata *SPIRVerElts[] = {
-  llvm::Co

r288645 - Adapt to llvm/TableGen DagInit changes.

2016-12-04 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Dec  5 00:00:51 2016
New Revision: 288645

URL: http://llvm.org/viewvc/llvm-project?rev=288645&view=rev
Log:
Adapt to llvm/TableGen DagInit changes.

Modified:
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=288645&r1=288644&r2=288645&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Mon Dec  5 00:00:51 2016
@@ -1478,14 +1478,14 @@ std::pair Intrinsic::
   if (DI->getNumArgs() == 2) {
 // Unary op.
 std::pair R =
-emitDagArg(DI->getArg(1), DI->getArgName(1));
+emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
 return std::make_pair(R.first, Op + R.second);
   } else {
 assert(DI->getNumArgs() == 3 && "Can only handle unary and binary ops!");
 std::pair R1 =
-emitDagArg(DI->getArg(1), DI->getArgName(1));
+emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
 std::pair R2 =
-emitDagArg(DI->getArg(2), DI->getArgName(2));
+emitDagArg(DI->getArg(2), DI->getArgNameStr(2));
 assert_with_loc(R1.first == R2.first, "Argument type mismatch!");
 return std::make_pair(R1.first, R1.second + " " + Op + " " + R2.second);
   }
@@ -1496,7 +1496,7 @@ std::pair Intrinsic::
   std::vector Values;
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 std::pair R =
-emitDagArg(DI->getArg(I + 1), DI->getArgName(I + 1));
+emitDagArg(DI->getArg(I + 1), DI->getArgNameStr(I + 1));
 Types.push_back(R.first);
 Values.push_back(R.second);
   }
@@ -1529,7 +1529,8 @@ std::pair Intrinsic::
 bool 
IsBitCast){
   // (cast MOD* VAL) -> cast VAL to type given by MOD.
   std::pair R = emitDagArg(
-  DI->getArg(DI->getNumArgs() - 1), DI->getArgName(DI->getNumArgs() - 1));
+  DI->getArg(DI->getNumArgs() - 1),
+  DI->getArgNameStr(DI->getNumArgs() - 1));
   Type castToType = R.first;
   for (unsigned ArgIdx = 0; ArgIdx < DI->getNumArgs() - 1; ++ArgIdx) {
 
@@ -1540,11 +1541,11 @@ std::pair Intrinsic::
 //   4. The value "U" or "S" to switch the signedness.
 //   5. The value "H" or "D" to half or double the bitwidth.
 //   6. The value "8" to convert to 8-bit (signed) integer lanes.
-if (!DI->getArgName(ArgIdx).empty()) {
-  assert_with_loc(Intr.Variables.find(DI->getArgName(ArgIdx)) !=
+if (!DI->getArgNameStr(ArgIdx).empty()) {
+  assert_with_loc(Intr.Variables.find(DI->getArgNameStr(ArgIdx)) !=
   Intr.Variables.end(),
   "Variable not found");
-  castToType = Intr.Variables[DI->getArgName(ArgIdx)].getType();
+  castToType = Intr.Variables[DI->getArgNameStr(ArgIdx)].getType();
 } else {
   StringInit *SI = dyn_cast(DI->getArg(ArgIdx));
   assert_with_loc(SI, "Expected string type or $Name for cast type");
@@ -1659,9 +1660,9 @@ std::pair Intrinsic::
 
   // (shuffle arg1, arg2, sequence)
   std::pair Arg1 =
-  emitDagArg(DI->getArg(0), DI->getArgName(0));
+  emitDagArg(DI->getArg(0), DI->getArgNameStr(0));
   std::pair Arg2 =
-  emitDagArg(DI->getArg(1), DI->getArgName(1));
+  emitDagArg(DI->getArg(1), DI->getArgNameStr(1));
   assert_with_loc(Arg1.first == Arg2.first,
   "Different types in arguments to shuffle!");
 
@@ -1703,7 +1704,8 @@ std::pair Intrinsic::
 
 std::pair Intrinsic::DagEmitter::emitDagDup(DagInit *DI) {
   assert_with_loc(DI->getNumArgs() == 1, "dup() expects one argument");
-  std::pair A = emitDagArg(DI->getArg(0), 
DI->getArgName(0));
+  std::pair A = emitDagArg(DI->getArg(0),
+  DI->getArgNameStr(0));
   assert_with_loc(A.first.isScalar(), "dup() expects a scalar argument");
 
   Type T = Intr.getBaseType();
@@ -1721,8 +1723,10 @@ std::pair Intrinsic::
 
 std::pair Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) {
   assert_with_loc(DI->getNumArgs() == 2, "splat() expects two arguments");
-  std::pair A = emitDagArg(DI->getArg(0), 
DI->getArgName(0));
-  std::pair B = emitDagArg(DI->getArg(1), 
DI->getArgName(1));
+  std::pair A = emitDagArg(DI->getArg(0),
+  DI->getArgNameStr(0));
+  std::pair B = emitDagArg(DI->getArg(1),
+  DI->getArgNameStr(1));
 
   assert_with_loc(B.first.isScalar(),
   "splat() requires a scalar int as the second argument");
@@ -1738,12 +1742,13 @@ std::pair Intrinsic::
 
 std::pair Intrinsic::DagEmitter::emitDagSaveTemp(DagInit 
*DI) {
   assert_with_loc(DI->getNumArgs() == 2, "save_temp() expects two arguments");
-  std::pair A = emitDagArg(DI->getArg(1), 
DI->getArgName(1));
+  std::pair A = emitDagArg(DI->getArg(1),
+  

Re: r288626 - Revert "Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules se

2016-12-04 Thread Richard Smith via cfe-commits
On 4 Dec 2016 2:44 pm, "Daniel Jasper via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: djasper
Date: Sun Dec  4 16:34:37 2016
New Revision: 288626

URL: http://llvm.org/viewvc/llvm-project?rev=288626&view=rev
Log:
Revert "Recover better from an incompatible .pcm file being provided by
-fmodule-file=. We try to include the headers of the module textually in
this case, still enforcing the modules semantic rules. In order to make
that work, we need to still track that we're entering and leaving the
module. Also, if the module was also marked as unavailable (perhaps because
it was missing a file), we shouldn't mark the module unavailable -- we
don't need the module to be complete if we're going to enter it textually."

This reverts commit r288449.

I believe that this is currently faulty wrt. modules being imported
inside namespaces. Adding these lines to the new test:

  namespace n {
  #include "foo.h"
  }

Makes it break with

  fatal error: import of module 'M' appears within namespace 'n'

However, I believe it should fail with

  error: redundant #include of module 'M' appears within namespace 'n'


Is that really worse than the broken internal state and asserts we get in
the same situation without this patch? The ability to continue like this
after a config mismatch is best-effort as is (and we're working towards
removing it...); I don't think we should be all that picky about which
error diagnostic we get here.

Mind if I revert your revert?

I have tracked this down to us now inserting a tok::annot_module_begin
instead of a tok::annot_module_include in
Preprocessor::HandleIncludeDirective() and then later in
Parser::parseMisplacedModuleImport(), we hit the code path for
tok::annot_module_begin, which doesn't set FromInclude of
checkModuleImportContext to true (thus leading to the "wrong"
diagnostic).

Removed:
cfe/trunk/test/Modules/config-mismatch.cpp
Modified:
cfe/trunk/include/clang/Lex/ModuleLoader.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
clang/Lex/ModuleLoader.h?rev=288626&r1=288625&r2=288626&view=diff

==
--- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleLoader.h Sun Dec  4 16:34:37 2016
@@ -31,22 +31,13 @@ typedef ArrayRef Storage;
+  llvm::PointerIntPair Storage;

+public:
   ModuleLoadResult() : Storage() { }
-  ModuleLoadResult(Module *M) : Storage(M, Normal) {}
-  ModuleLoadResult(LoadResultKind Kind) : Storage(nullptr, Kind) {}
+
+  ModuleLoadResult(Module *module, bool missingExpected)
+: Storage(module, missingExpected) { }

   operator Module *() const { return Storage.getPointer(); }

@@ -54,11 +45,7 @@ public:
   /// actually a submodule that we expected to see (based on implying the
   /// submodule from header structure), but didn't materialize in the
actual
   /// module.
-  bool isMissingExpected() const { return Storage.getInt() ==
MissingExpected; }
-
-  /// \brief Determines whether the module failed to load due to a
configuration
-  /// mismatch with an explicitly-named .pcm file from the command line.
-  bool isConfigMismatch() const { return Storage.getInt() ==
ConfigMismatch; }
+  bool isMissingExpected() const { return Storage.getInt(); }
 };

 /// \brief Abstract interface for a module loader.

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
Frontend/CompilerInstance.cpp?rev=288626&r1=288625&r2=288626&view=diff

==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Dec  4 16:34:37 2016
@@ -1393,21 +1393,8 @@ bool CompilerInstance::loadModuleFile(St
 if (Module *M = CI.getPreprocessor()
 .getHeaderSearchInfo()
 .getModuleMap()
-.findModule(II->getName())) {
+.findModule(II->getName()))
   M->HasIncompatibleModuleFile = true;
-
-  // Mark module as available if the only reason it was unavailable
-  // was missing headers.
-  SmallVector Stack;
-  Stack.push_back(M);
-  while (!Stack.empty()) {
-Module *Current = Stack.pop_back_val();
-if (Current->IsMissingRequirement) continue;
-Current->IsAvailable = true;
-Stack.insert(Stack.end(),
- Current->submodule_begin(),
Current->submodule_end());
-  }
-}
   }
   LoadedModules.clear();
 }
@@ -1511,7 +1498,7 @@ CompilerInstance::loadModule(SourceLocat
   if (Module && Module->HasIncompatibleModuleFile) {
 // We tried and failed to load a module file for this 

r288629 - IRGen: Remove an unused overload of CreateAlignedLoad.

2016-12-04 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Sun Dec  4 18:02:18 2016
New Revision: 288629

URL: http://llvm.org/viewvc/llvm-project?rev=288629&view=rev
Log:
IRGen: Remove an unused overload of CreateAlignedLoad.

Modified:
cfe/trunk/lib/CodeGen/CGBuilder.h

Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=288629&r1=288628&r2=288629&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Sun Dec  4 18:02:18 2016
@@ -102,11 +102,6 @@ public:
 assert(Addr->getType()->getPointerElementType() == Ty);
 return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
   }
-  llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
-bool IsVolatile,
-const llvm::Twine &Name = "") {
-return CreateAlignedLoad(Addr, Align.getQuantity(), IsVolatile, Name);
-  }
 
   // Note that we intentionally hide the CreateStore APIs that don't
   // take an alignment.


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


Re: r288449 - Recover better from an incompatible .pcm file being provided by -fmodule-file=.

2016-12-04 Thread Daniel Jasper via cfe-commits
This is unfortunately causing problems as is, as it can change the
diagnostic that's created when the include of a module with config-mismatch
is inside a namespace. I have tried to fix this for a bit, but I am not
sure what the right solution is. For now, I have reverted this in r288626
and left the details of my investigation on that patch description.

On Fri, Dec 2, 2016 at 2:52 AM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Thu Dec  1 19:52:28 2016
> New Revision: 288449
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288449&view=rev
> Log:
> Recover better from an incompatible .pcm file being provided by
> -fmodule-file=.
> We try to include the headers of the module textually in this case, still
> enforcing the modules semantic rules. In order to make that work, we need
> to
> still track that we're entering and leaving the module. Also, if the
> module was
> also marked as unavailable (perhaps because it was missing a file), we
> shouldn't mark the module unavailable -- we don't need the module to be
> complete if we're going to enter it textually.
>
> Added:
> cfe/trunk/test/Modules/config-mismatch.cpp
> Modified:
> cfe/trunk/include/clang/Lex/ModuleLoader.h
> cfe/trunk/lib/Frontend/CompilerInstance.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
>
> Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Lex/ModuleLoader.h?rev=288449&r1=288448&r2=288449&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)
> +++ cfe/trunk/include/clang/Lex/ModuleLoader.h Thu Dec  1 19:52:28 2016
> @@ -31,13 +31,22 @@ typedef ArrayRef
>  /// \brief Describes the result of attempting to load a module.
>  class ModuleLoadResult {
> -  llvm::PointerIntPair Storage;
> -
>  public:
> -  ModuleLoadResult() : Storage() { }
> +  enum LoadResultKind {
> +// We either succeeded or failed to load the named module.
> +Normal,
> +// The module exists, but does not actually contain the named
> submodule.
> +// This should only happen if the named submodule was inferred from an
> +// umbrella directory, but not actually part of the umbrella header.
> +MissingExpected,
> +// The module exists but cannot be imported due to a configuration
> mismatch.
> +ConfigMismatch
> +  };
> +  llvm::PointerIntPair Storage;
>
> -  ModuleLoadResult(Module *module, bool missingExpected)
> -: Storage(module, missingExpected) { }
> +  ModuleLoadResult() : Storage() { }
> +  ModuleLoadResult(Module *M) : Storage(M, Normal) {}
> +  ModuleLoadResult(LoadResultKind Kind) : Storage(nullptr, Kind) {}
>
>operator Module *() const { return Storage.getPointer(); }
>
> @@ -45,7 +54,11 @@ public:
>/// actually a submodule that we expected to see (based on implying the
>/// submodule from header structure), but didn't materialize in the
> actual
>/// module.
> -  bool isMissingExpected() const { return Storage.getInt(); }
> +  bool isMissingExpected() const { return Storage.getInt() ==
> MissingExpected; }
> +
> +  /// \brief Determines whether the module failed to load due to a
> configuration
> +  /// mismatch with an explicitly-named .pcm file from the command line.
> +  bool isConfigMismatch() const { return Storage.getInt() ==
> ConfigMismatch; }
>  };
>
>  /// \brief Abstract interface for a module loader.
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInstance.cpp?rev=288449&r1=288448&r2=288449&view=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Dec  1 19:52:28 2016
> @@ -1393,8 +1393,21 @@ bool CompilerInstance::loadModuleFile(St
>  if (Module *M = CI.getPreprocessor()
>  .getHeaderSearchInfo()
>  .getModuleMap()
> -.findModule(II->getName()))
> +.findModule(II->getName())) {
>M->HasIncompatibleModuleFile = true;
> +
> +  // Mark module as available if the only reason it was
> unavailable
> +  // was missing headers.
> +  SmallVector Stack;
> +  Stack.push_back(M);
> +  while (!Stack.empty()) {
> +Module *Current = Stack.pop_back_val();
> +if (Current->IsMissingRequirement) continue;
> +Current->IsAvailable = true;
> +Stack.insert(Stack.end(),
> + Current->submodule_begin(),
> Current->submodule_end());
> +  }
> +}
>}
>LoadedModules.clear();
>  }
> @@ -1498,7 +1511,7 @@ CompilerInstance::loadModule(SourceLocat
>if (Module && Module->HasIncompatibleModuleFi

r288626 - Revert "Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semant

2016-12-04 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Sun Dec  4 16:34:37 2016
New Revision: 288626

URL: http://llvm.org/viewvc/llvm-project?rev=288626&view=rev
Log:
Revert "Recover better from an incompatible .pcm file being provided by 
-fmodule-file=. We try to include the headers of the module textually in this 
case, still enforcing the modules semantic rules. In order to make that work, 
we need to still track that we're entering and leaving the module. Also, if the 
module was also marked as unavailable (perhaps because it was missing a file), 
we shouldn't mark the module unavailable -- we don't need the module to be 
complete if we're going to enter it textually."

This reverts commit r288449.

I believe that this is currently faulty wrt. modules being imported
inside namespaces. Adding these lines to the new test:

  namespace n {
  #include "foo.h"
  }

Makes it break with

  fatal error: import of module 'M' appears within namespace 'n'

However, I believe it should fail with

  error: redundant #include of module 'M' appears within namespace 'n'

I have tracked this down to us now inserting a tok::annot_module_begin
instead of a tok::annot_module_include in
Preprocessor::HandleIncludeDirective() and then later in
Parser::parseMisplacedModuleImport(), we hit the code path for
tok::annot_module_begin, which doesn't set FromInclude of
checkModuleImportContext to true (thus leading to the "wrong"
diagnostic).

Removed:
cfe/trunk/test/Modules/config-mismatch.cpp
Modified:
cfe/trunk/include/clang/Lex/ModuleLoader.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=288626&r1=288625&r2=288626&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleLoader.h Sun Dec  4 16:34:37 2016
@@ -31,22 +31,13 @@ typedef ArrayRef Storage;
+  llvm::PointerIntPair Storage;
 
+public:
   ModuleLoadResult() : Storage() { }
-  ModuleLoadResult(Module *M) : Storage(M, Normal) {}
-  ModuleLoadResult(LoadResultKind Kind) : Storage(nullptr, Kind) {}
+
+  ModuleLoadResult(Module *module, bool missingExpected)
+: Storage(module, missingExpected) { }
 
   operator Module *() const { return Storage.getPointer(); }
 
@@ -54,11 +45,7 @@ public:
   /// actually a submodule that we expected to see (based on implying the
   /// submodule from header structure), but didn't materialize in the actual
   /// module.
-  bool isMissingExpected() const { return Storage.getInt() == MissingExpected; 
}
-
-  /// \brief Determines whether the module failed to load due to a 
configuration
-  /// mismatch with an explicitly-named .pcm file from the command line.
-  bool isConfigMismatch() const { return Storage.getInt() == ConfigMismatch; }
+  bool isMissingExpected() const { return Storage.getInt(); }
 };
 
 /// \brief Abstract interface for a module loader.

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=288626&r1=288625&r2=288626&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Dec  4 16:34:37 2016
@@ -1393,21 +1393,8 @@ bool CompilerInstance::loadModuleFile(St
 if (Module *M = CI.getPreprocessor()
 .getHeaderSearchInfo()
 .getModuleMap()
-.findModule(II->getName())) {
+.findModule(II->getName()))
   M->HasIncompatibleModuleFile = true;
-
-  // Mark module as available if the only reason it was unavailable
-  // was missing headers.
-  SmallVector Stack;
-  Stack.push_back(M);
-  while (!Stack.empty()) {
-Module *Current = Stack.pop_back_val();
-if (Current->IsMissingRequirement) continue;
-Current->IsAvailable = true;
-Stack.insert(Stack.end(),
- Current->submodule_begin(), Current->submodule_end());
-  }
-}
   }
   LoadedModules.clear();
 }
@@ -1511,7 +1498,7 @@ CompilerInstance::loadModule(SourceLocat
   if (Module && Module->HasIncompatibleModuleFile) {
 // We tried and failed to load a module file for this module. Fall
 // back to textual inclusion for its headers.
-return ModuleLoadResult::ConfigMismatch;
+return ModuleLoadResult(nullptr, /*missingExpected*/true);
   }
 
   getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
@@ -1718,7 +1705,7 @@ CompilerInstance::loadModule(SourceLocat
 << Module->getFullModuleName()
 << SourceRange(Path.front().second, Path.back().

[libcxx] r288625 - Update status page for variant implementation

2016-12-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Dec  4 16:14:53 2016
New Revision: 288625

URL: http://llvm.org/viewvc/llvm-project?rev=288625&view=rev
Log:
Update status page for variant implementation

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=288625&r1=288624&r2=288625&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Sun Dec  4 16:14:53 2016
@@ -119,7 +119,7 @@
http://wg21.link/p0358r1";>p0358r1LWGFixes for 
not_fnOuluComplete3.9
http://wg21.link/p0371r1";>p0371r1LWGTemporarily 
discourage memory_order_consumeOuluNothing to 
don/a
http://wg21.link/p0392r0";>p0392r0LWGAdapting 
string_view by filesystem 
pathsOuluComplete4.0
-   http://wg21.link/p0393r3";>p0393r3LWGMaking Variant 
Greater EqualOulu
+   http://wg21.link/p0393r3";>p0393r3LWGMaking Variant 
Greater EqualOuluComplete4.0
http://wg21.link/P0394r4";>P0394r4LWGHotel 
Parallelifornia: terminate() for Parallel Algorithms Exception 
HandlingOulu

http://wg21.link/P0003R5";>P0003R5LWGRemoving 
Deprecated Exception Specifications from 
C++17Issaquah


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


[libcxx] r288623 - Choose better hash values for std::monostate and valueless variants.

2016-12-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Dec  4 15:37:37 2016
New Revision: 288623

URL: http://llvm.org/viewvc/llvm-project?rev=288623&view=rev
Log:
Choose better hash values for std::monostate and valueless variants.

Previously these hashes were 0 and -1 respectively. These seem like common
sentinel values and should be avoided to prevent needless collisions.

This patch changes those values to different arbitrary numbers, which should
hopefully cause less collisions. Because I couldn't help myself I choose the
fundamental constants for gravity and the speed of light.

Modified:
libcxx/trunk/include/variant

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=288623&r1=288622&r2=288623&view=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Sun Dec  4 15:37:37 2016
@@ -1538,7 +1538,7 @@ struct _LIBCPP_TYPE_VIS_ONLY hash;
@@ -1556,7 +1556,9 @@ struct _LIBCPP_TYPE_VIS_ONLY hash 14


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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2016-12-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: src/functional.cpp:1
+//===--- functional.cpp 
---===//
+//

smeenai wrote:
> Should I clang-format new files? I based the style of this file on the 
> existing source files, but clang-format suggests something very different.
That's at your discretion for source/headers. This file seems fine as-is.


https://reviews.llvm.org/D27387



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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2016-12-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I wonder if we should consider this a breaking ABI change and control it using 
a `_LIBCPP_ABI` macro. @mclow.lists thoughts?


https://reviews.llvm.org/D27387



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-04 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Rejecting -mno-sse2 for x86_64 is even worse. Dynamic linkers e.g. in FreeBSD 
and NetBSD depend on that. They also don't contain floating point code, but 
that's a separate question. Similar constraints exist for the kernels.


https://reviews.llvm.org/D27304



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added reviewers: mkuper, dim, RKSimon.
RKSimon added a comment.

https://llvm.org/bugs/show_bug.cgi?id=30426#c3

On PR30426 the proposal was that we should just not accept x86_64 triples with 
no-sse/no-sse2 at the command line parsing level - we just have no way to guess 
what the coder was expecting and performing the check later on is just delaying 
the (almost) inevitable.

Also, please remember to include context in the diff.


https://reviews.llvm.org/D27304



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


[PATCH] D27384: [libclang] Restore clang_getNumTemplateArguments/clang_getTemplateArgumentAsType functionality

2016-12-04 Thread Sergey Kalinichev via Phabricator via cfe-commits
skalinichev abandoned this revision.
skalinichev added a comment.

Turns out we already have another patch that fixes the same problem: 
https://reviews.llvm.org/D26907


https://reviews.llvm.org/D27384



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


[PATCH] D27334: [OpenCL] Ambiguous function call.

2016-12-04 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:

> This change seems to modify normal C behavior again. Is there any strong 
> motivation for doing this and if yes could it be done generically with C?


Motivation:

  // Non-portable OpenCL 1.2 code 
  __kernel void foo(global float* out) {
out[get_global_id(0)] = sin(get_global_id(0));
  }

This program compiles fine on OpenCL platform w/o doubles support and fails 
otherwise.
If OpenCL driver supports doubles it provides at least two versions of 'sin' 
built-in math function and compiler will not be able to choose the right one 
for 'size_t' argument.
The goal of this warning is to let OpenCL developer know about potential issues 
with code portability.

This might be not so serious issue for C, since C doesn't support function 
overloading, whereas OpenCL built-in functions library must overload most of 
the functions.


https://reviews.llvm.org/D27334



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