r245810 - Instantiate function declarations in instantiated functions.

2015-08-23 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sun Aug 23 05:22:28 2015
New Revision: 245810

URL: http://llvm.org/viewvc/llvm-project?rev=245810&view=rev
Log:
Instantiate function declarations in instantiated functions.

If a function declaration is found inside a template function as in:

template void f() {
  void g(int x = T::v) except(T::w);
}

it must be instantiated along with the enclosing template function,
including default arguments and exception specification.

Together with the patch committed in r240974 this implements DR1484.

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

Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp
cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=245810&r1=245809&r2=245810&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sun Aug 23 05:22:28 2015
@@ -728,6 +728,15 @@ public:
 return getParentFunctionOrMethod() == nullptr;
   }
 
+  /// \brief Returns true if this declaration lexically is inside a function.
+  /// It recognizes non-defining declarations as well as members of local
+  /// classes:
+  /// \code
+  /// void foo() { void bar(); }
+  /// void foo2() { class ABC { void bar(); }; }
+  /// \endcode
+  bool isLexicallyWithinFunctionOrMethod() const;
+
   /// \brief If this decl is defined inside a function/method/block it returns
   /// the corresponding DeclContext, otherwise it returns null.
   const DeclContext *getParentFunctionOrMethod() const;

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=245810&r1=245809&r2=245810&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Aug 23 05:22:28 2015
@@ -266,6 +266,18 @@ void Decl::setDeclContextsImpl(DeclConte
   }
 }
 
+bool Decl::isLexicallyWithinFunctionOrMethod() const {
+  const DeclContext *LDC = getLexicalDeclContext();
+  do {
+if (LDC->isFunctionOrMethod())
+  return true;
+if (!isa(LDC))
+  return false;
+LDC = LDC->getParent();
+  } while (LDC);
+  return false;
+}
+
 bool Decl::isInAnonymousNamespace() const {
   const DeclContext *DC = getDeclContext();
   do {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=245810&r1=245809&r2=245810&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Sun Aug 23 05:22:28 2015
@@ -1682,11 +1682,10 @@ ParmVarDecl *Sema::SubstParmVarDecl(Parm
 UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm);
   } else if (Expr *Arg = OldParm->getDefaultArg()) {
 FunctionDecl *OwningFunc = cast(OldParm->getDeclContext());
-CXXRecordDecl *ClassD = 
dyn_cast(OwningFunc->getDeclContext());
-if (ClassD && ClassD->isLocalClass() && !ClassD->isLambda()) {
-  // If this is a method of a local class, as per DR1484 its default
-  // arguments must be instantiated.
-  Sema::ContextRAII SavedContext(*this, ClassD);
+if (OwningFunc->isLexicallyWithinFunctionOrMethod()) {
+  // Instantiate default arguments for methods of local classes (DR1484)
+  // and non-defining declarations.
+  Sema::ContextRAII SavedContext(*this, OwningFunc);
   LocalInstantiationScope Local(*this);
   ExprResult NewArg = SubstExpr(Arg, TemplateArgs);
   if (NewArg.isUsable())

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=245810&r1=245809&r2=245810&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Aug 23 05:22:28 2015
@@ -3247,16 +3247,11 @@ TemplateDeclInstantiator::InitFunctionIn
 // exception specification.
 // DR1484: Local classes and their members are instantiated along with the
 // containing function.
-bool RequireInstantiation = false;
-if (CXXRecordDecl *Cls = dyn_cast(Tmpl->getDeclContext())) {
-  if (Cls->isLocalClass())
-RequireInstantiation = true;
-}
 if (SemaRef.getLangOpts().CPlusPlus11 &&
 EPI.Exception

Re: [PATCH] D11194: Instantiate function declarations in instantiated functions.

2015-08-23 Thread Serge Pavlov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245810: Instantiate function declarations in instantiated 
functions. (authored by sepavloff).

Changed prior to commit:
  http://reviews.llvm.org/D11194?vs=32597&id=32923#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11194

Files:
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
  cfe/trunk/test/SemaTemplate/default-arguments.cpp
  cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp

Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -728,6 +728,15 @@
 return getParentFunctionOrMethod() == nullptr;
   }
 
+  /// \brief Returns true if this declaration lexically is inside a function.
+  /// It recognizes non-defining declarations as well as members of local
+  /// classes:
+  /// \code
+  /// void foo() { void bar(); }
+  /// void foo2() { class ABC { void bar(); }; }
+  /// \endcode
+  bool isLexicallyWithinFunctionOrMethod() const;
+
   /// \brief If this decl is defined inside a function/method/block it returns
   /// the corresponding DeclContext, otherwise it returns null.
   const DeclContext *getParentFunctionOrMethod() const;
Index: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
===
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
@@ -26,23 +26,26 @@
 };
 
 struct NoDefaultCtor {
-  NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}}
+  NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} \
+   // expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}}
   ~NoDefaultCtor();
 };
 
 template
 void defargs_in_template_unused(T t) {
-  auto l1 = [](const T& value = T()) { };
+  auto l1 = [](const T& value = T()) { };  // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
   l1(t);
 }
 
 template void defargs_in_template_unused(NonPOD);
-template void defargs_in_template_unused(NoDefaultCtor);
+template void defargs_in_template_unused(NoDefaultCtor);  // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused' requested here}}
 
 template
 void defargs_in_template_used() {
-  auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
-  l1(); // expected-note{{in instantiation of default function argument expression for 'operator()' required here}}
+  auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \
+  // expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}} \
+  // expected-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}}
+  l1(); // expected-error{{no matching function for call to object of type '(lambda at }}
 }
 
 template void defargs_in_template_used();
Index: cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
===
--- cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -178,3 +178,11 @@
   }
 
 }
+
+namespace NondefDecls {
+  template void f1() {
+int g1(int) noexcept(T::error); // expected-error{{type 'int' cannot be used prior to '::' because it has no members}}
+  }
+  template void f1(); // expected-note{{in instantiation of function template specialization 'NondefDecls::f1' requested here}}
+}
+
Index: cfe/trunk/test/SemaTemplate/default-arguments.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp
@@ -159,3 +159,10 @@
 
   int g() { X::f(0); } // expected-note {{in instantiation of template class 'DR1635::X' requested here}}
 }
+
+namespace NondefDecls {
+  template void f1() {
+int g1(int defarg = T::error);  // expected-error{{type 'int' cannot be used prior to '::' because it has no members}}
+  }
+  template void f1();  // expected-note{{in instantiation of function template specialization 'NondefDecls::f1' requested here}}
+}
Index: cfe/trunk/lib/AST/DeclBase.cpp
===
--- cfe/trunk/lib/

r245811 - Changes missed from r245810

2015-08-23 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sun Aug 23 06:09:40 2015
New Revision: 245811

URL: http://llvm.org/viewvc/llvm-project?rev=245811&view=rev
Log:
Changes missed from r245810

Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=245811&r1=245810&r2=245811&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sun Aug 23 06:09:40 2015
@@ -268,13 +268,13 @@ void Decl::setDeclContextsImpl(DeclConte
 
 bool Decl::isLexicallyWithinFunctionOrMethod() const {
   const DeclContext *LDC = getLexicalDeclContext();
-  do {
+  while (true) {
 if (LDC->isFunctionOrMethod())
   return true;
 if (!isa(LDC))
   return false;
-LDC = LDC->getParent();
-  } while (LDC);
+LDC = LDC->getLexicalParent();
+  }
   return false;
 }
 


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


r245812 - Add a missing 'classof' to AST Node TypoExpr to identify its 'Kind'.

2015-08-23 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sun Aug 23 08:14:42 2015
New Revision: 245812

URL: http://llvm.org/viewvc/llvm-project?rev=245812&view=rev
Log:
Add a missing 'classof' to AST Node TypoExpr to identify its 'Kind'.

I'm not sure why TypoExpr had its classof left out - but I expect every AST 
node should fulfill the 'contract of classof' 
(http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html).

There should be no functionality change.  I just happened to notice it was 
missing, while messing around with something else.


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

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=245812&r1=245811&r2=245812&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Aug 23 08:14:42 2015
@@ -4980,6 +4980,11 @@ public:
   }
   SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
+  
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == TypoExprClass;
+  }
+
 };
 }  // end namespace clang
 


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


[PATCH] D12271: [X86] Expose the various _rot intrinsics on non-MS platforms

2015-08-23 Thread Michael Kuperstein via cfe-commits
mkuper created this revision.
mkuper added reviewers: majnemer, rnk.
mkuper added a subscriber: cfe-commits.

_rotl, _rotwl and _lrotl (and their right-shift counterparts) are official x86 
intrinsics, and should be supported regardless of environment.
This is in contrast to _rotl8, _rotl16, and _rotl64 which are MS-specific.

Note that the MS documentation for _lrotl is different from the Intel 
documentation. Intel explicitly documents it as a 64-bit rotate, while for MS, 
since sizeof(unsigned long) for MSVC is 4, a 32-bit rotate is clearly implied.
Compare:
https://msdn.microsoft.com/en-us/library/a0w705h5.aspx
vs.
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=rot&techs=Other&expand=3193

Note that this doesn't change the implementations of these intrinsics, which 
are currently pretty awful.
We only manage to match the 32-bit versions to a rotate, and even then, still 
have the "and" and the control flow in place. That should be dealt with 
separately.

http://reviews.llvm.org/D12271

Files:
  lib/Headers/Intrin.h
  lib/Headers/immintrin.h
  test/CodeGen/x86-rot-intrinsics.c
  test\CodeGen\x86-rot-intrinsics.c

Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -148,4 +148,58 @@
  * whereas others are also available at all times. */
 #include 
 
+static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))
+_rotwl(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value << _Shift) | (_Value >> (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))
+_rotwr(unsigned short _Value, int _Shift) {
+  _Shift &= 0xf;
+  return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotl(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+_rotr(unsigned int _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+
+/* 
+ * MS defines _lrotl/_lrotr in a slightly incompatible way, since 
+ * unsigned long is always 32-bit in MSVC. 
+ */
+#ifdef _MSC_VER
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x1f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
+}
+#else
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotl(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value << _Shift) | (_Value >> (64 - _Shift)) : _Value;
+}
+
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
+_lrotr(unsigned long _Value, int _Shift) {
+  _Shift &= 0x3f;
+  return _Shift ? (_Value >> _Shift) | (_Value << (64 - _Shift)) : _Value;
+}
+#endif
+
 #endif /* __IMMINTRIN_H */
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -463,26 +463,6 @@
   _Shift &= 0xf;
   return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value;
 }
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_rotl(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_rotr(unsigned int _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS
-_lrotl(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value;
-}
-static __inline__ unsigned long __DEFAULT_FN_ATTRS
-_lrotr(unsigned long _Value, int _Shift) {
-  _Shift &= 0x1f;
-  return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value;
-}
 static
 __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
 _rotl64(unsigned __int64 _Value, int _Shift) {
Index: test/CodeGen/x86-rot-intrinsics.c
===
--- test/CodeGen/x86-rot-intrinsics.c
+++ test/CodeGen/x86-rot-intrinsics.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-linux -emit-llvm -o - | FileCheck %s 
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN:-triple i686--windows -emit-llvm %s -o - \ 
+// RUN:   | FileCheck %s -check-pref

r245815 - Added missing tests for SSE41 pmovsx/pmovzx extension intrinsics

2015-08-23 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Aug 23 11:19:38 2015
New Revision: 245815

URL: http://llvm.org/viewvc/llvm-project?rev=245815&view=rev
Log:
Added missing tests for SSE41 pmovsx/pmovzx extension intrinsics

Modified:
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=245815&r1=245814&r2=245815&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Sun Aug 23 11:19:38 2015
@@ -577,3 +577,75 @@ __m128i test2_mm_alignr_epi8(__m128i a,
   // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> zeroinitializer, <16 x 
i32> 
   return _mm_alignr_epi8(a, b, 17);
 }
+
+__m128i test_mm_cvtepi8_epi16(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi8_epi16
+  // CHECK: call <8 x i16> @llvm.x86.sse41.pmovsxbw(<16 x i8> {{.*}})
+  return _mm_cvtepi8_epi16(a);
+}
+
+__m128i test_mm_cvtepi8_epi32(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi8_epi32
+  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxbd(<16 x i8> {{.*}})
+  return _mm_cvtepi8_epi32(a);
+}
+
+__m128i test_mm_cvtepi8_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi8_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxbq(<16 x i8> {{.*}})
+  return _mm_cvtepi8_epi64(a);
+}
+
+__m128i test_mm_cvtepi16_epi32(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi16_epi32
+  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovsxwd(<8 x i16> {{.*}})
+  return _mm_cvtepi16_epi32(a);
+}
+
+__m128i test_mm_cvtepi16_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi16_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxwq(<8 x i16> {{.*}})
+  return _mm_cvtepi16_epi64(a);
+}
+
+__m128i test_mm_cvtepi32_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepi32_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovsxdq(<4 x i32> {{.*}})
+  return _mm_cvtepi32_epi64(a);
+}
+
+__m128i test_mm_cvtepu8_epi16(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu8_epi16
+  // CHECK: call <8 x i16> @llvm.x86.sse41.pmovzxbw(<16 x i8> {{.*}})
+  return _mm_cvtepu8_epi16(a);
+}
+
+__m128i test_mm_cvtepu8_epi32(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu8_epi32
+  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovzxbd(<16 x i8> {{.*}})
+  return _mm_cvtepu8_epi32(a);
+}
+
+__m128i test_mm_cvtepu8_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu8_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovzxbq(<16 x i8> {{.*}})
+  return _mm_cvtepu8_epi64(a);
+}
+
+__m128i test_mm_cvtepu16_epi32(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu16_epi32
+  // CHECK: call <4 x i32> @llvm.x86.sse41.pmovzxwd(<8 x i16> {{.*}})
+  return _mm_cvtepu16_epi32(a);
+}
+
+__m128i test_mm_cvtepu16_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu16_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovzxwq(<8 x i16> {{.*}})
+  return _mm_cvtepu16_epi64(a);
+}
+
+__m128i test_mm_cvtepu32_epi64(__m128i a) {
+  // CHECK-LABEL: @test_mm_cvtepu32_epi64
+  // CHECK: call <2 x i64> @llvm.x86.sse41.pmovzxdq(<4 x i32> {{.*}})
+  return _mm_cvtepu32_epi64(a);
+}


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


[PATCH] D12272: [X86] Remove unnecessary MMX declarations from Intrin.h

2015-08-23 Thread Simon Pilgrim via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: echristo, silvas, craig.topper.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

As discussed in PR23648 - the intrinsics _m_from_int, _m_to_int and _m_prefetch 
are defined in mmintrin.h and prfchwintrin.h so we don't need to in Intrin.h

Added tests for _m_from_int and _m_to_int

D11338 already added a test for _m_prefetch 

I'll add _m_from_float and _m_to_float in a future (3dNow) patch which will 
remove the last of the 'missing' declarations from Intrin.h

Repository:
  rL LLVM

http://reviews.llvm.org/D12272

Files:
  lib/Headers/Intrin.h
  test/CodeGen/mmx-builtins.c

Index: test/CodeGen/mmx-builtins.c
===
--- test/CodeGen/mmx-builtins.c
+++ test/CodeGen/mmx-builtins.c
@@ -451,3 +451,13 @@
   // CHECK: pcmpgtd
   return _mm_cmpgt_pi32(a, b);
 }
+
+__m64 test90(int a) {
+  // CHECK: movd
+  return _m_from_int(a);
+}
+
+int test91(__m64 a) {
+  // CHECK: movd
+  return _m_to_int(a);
+}
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -49,10 +49,7 @@
 #if defined(__MMX__)
 /* And the random ones that aren't in those files. */
 __m64 _m_from_float(float);
-__m64 _m_from_int(int _l);
-void _m_prefetch(void *);
 float _m_to_float(__m64);
-int _m_to_int(__m64 _M);
 #endif
 
 /* Other assorted instruction intrinsics. */


Index: test/CodeGen/mmx-builtins.c
===
--- test/CodeGen/mmx-builtins.c
+++ test/CodeGen/mmx-builtins.c
@@ -451,3 +451,13 @@
   // CHECK: pcmpgtd
   return _mm_cmpgt_pi32(a, b);
 }
+
+__m64 test90(int a) {
+  // CHECK: movd
+  return _m_from_int(a);
+}
+
+int test91(__m64 a) {
+  // CHECK: movd
+  return _m_to_int(a);
+}
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -49,10 +49,7 @@
 #if defined(__MMX__)
 /* And the random ones that aren't in those files. */
 __m64 _m_from_float(float);
-__m64 _m_from_int(int _l);
-void _m_prefetch(void *);
 float _m_to_float(__m64);
-int _m_to_int(__m64 _M);
 #endif
 
 /* Other assorted instruction intrinsics. */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245817 - [test] Fix typos in a few tests (NFC)

2015-08-23 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Sun Aug 23 13:53:59 2015
New Revision: 245817

URL: http://llvm.org/viewvc/llvm-project?rev=245817&view=rev
Log:
[test] Fix typos in a few tests (NFC)

Patch by Kai Zhao!

Modified:
cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
cfe/trunk/test/CodeGenCXX/homogeneous-aggregates.cpp

cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp

Modified: cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp?rev=245817&r1=245816&r2=245817&view=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp Sun Aug 23 13:53:59 2015
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O1 | FileCheck 
%s --check-prefix=O1
 
 // Check that GlobalOpt can eliminate static constructors for simple implicit
-// constructors. This is a targetted integration test to make sure that LLVM's
+// constructors. This is a targeted integration test to make sure that LLVM's
 // optimizers are able to process Clang's IR. GlobalOpt in particular is
 // sensitive to the casts we emit.
 

Modified: cfe/trunk/test/CodeGenCXX/homogeneous-aggregates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/homogeneous-aggregates.cpp?rev=245817&r1=245816&r2=245817&view=diff
==
--- cfe/trunk/test/CodeGenCXX/homogeneous-aggregates.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/homogeneous-aggregates.cpp Sun Aug 23 13:53:59 
2015
@@ -91,7 +91,7 @@ struct HVAWithEmptyBase : Float1, Empty,
 // ARM32: define arm_aapcs_vfpcc void 
@_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
 void CC with_empty_base(HVAWithEmptyBase a) {}
 
-// FIXME: MSVC doesn't consider this an HVA becuase of the empty base.
+// FIXME: MSVC doesn't consider this an HVA because of the empty base.
 // X64: define x86_vectorcallcc void 
@"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(float %a.0, float %a.1, float 
%a.2)
 
 struct HVAWithEmptyBitField : Float1, Float2 {

Modified: 
cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp?rev=245817&r1=245816&r2=245817&view=diff
==
--- 
cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
 (original)
+++ 
cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
 Sun Aug 23 13:53:59 2015
@@ -33,7 +33,7 @@ void use_somewhere_else(void*);
 
 namespace simple {
 // In case of a single-layer virtual inheritance, the "this" adjustment for a
-// virtual method is done staically:
+// virtual method is done statically:
 //   struct A {
 // virtual void f();  // Expects "(A*)this" in ECX
 //   };
@@ -222,7 +222,7 @@ G::G() {}
 
 namespace extended {
 // If a virtual function requires vtordisp adjustment and the final overrider
-// is defined in another vitual base of the most derived class,
+// is defined in another virtual base of the most derived class,
 // we need to know two vbase offsets.
 // In this case, we should use the extended form of vtordisp thunks, called
 // vtordispex thunks.


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


Re: [PATCH][Solaris] Clang/Driver, stop hardcoding GCC paths in crt/ld.so lookup

2015-08-23 Thread Rafael Espíndola via cfe-commits
SolarisScanLibDirForGCCTriple should start with a lower case. Starting
it with "scan" would probably also be more in line with the code
style.

LGTM

On 11 August 2015 at 16:33, Xan López  wrote:
> Hi,
>
> thanks for the review, I was not even aware that this could be
> tested. Adding a test helped to fix me a couple extra issues (plus the
> one you already mentioned). New patch attached.
>
> Xan
>
> On Wed, Aug 05, 2015 at 09:14:30AM -0400, Rafael Espíndola wrote:
>> Please git-clang-format this patch.
>>
>> +  // /usr/gcc/./lib/gcc/../,
>>
>> The code appends a triple after the "/lib/gcc". Is the comment missing it?
>>
>> The inner loop has no version comparison. Are you depending on the
>> directory iteration order?
>>
>> Can you add a testcase?
>>
>>
>> On 28 July 2015 at 12:35, Xan López  wrote:
>> > Here it is.
>> >
>> > On Tue, Jul 28, 2015 at 01:21:06PM +0200, Xan López wrote:
>> >> On Tue, Jul 28, 2015 at 01:55:23PM +0300, Yaron Keren wrote:
>> >> > +cfe-commits
>> >> >
>> >> > This is a very large Solaris special case in ScanLibDirForGCCTriple 
>> >> > which
>> >> > shares almost no code with the function.
>> >> > How about splitting it out to a helper function or
>> >> > making ScanLibDirForGCCTriple virtual and overriding on Solaris?
>> >>
>> >> Yep, at least a helper function makes sense, you are right. I'll send
>> >> another patch with either of those suggestions later today.
>> >>
>> >>
>> >> Xan
>> >> ___
>> >> llvm-commits mailing list
>> >> llvm-comm...@cs.uiuc.edu
>> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
>> > ___
>> > llvm-commits mailing list
>> > llvm-comm...@cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-23 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 32930.
nmusgrave added a comment.

- Refactoring dtor sanitizing emission order
- support for virtual functions & virtual bases WIP
- Repress dtor aliasing when sanitizing in dtor
- CFE test for dtor aliasing, and repression of aliasing in dtor code 
generation.
- More complex testing for destruction order.
- Poison trivial members one-by-one.
- Poisoning on field-by-field basis, with collective poisoning of trivial 
members when possible.
- Cleaned up implementation of calculating region to poison in dtor.
- Checking for existence of a single trivial field.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass

r245821 - [modules] Stop updating all identifiers when writing a module. This is

2015-08-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Aug 23 22:33:22 2015
New Revision: 245821

URL: http://llvm.org/viewvc/llvm-project?rev=245821&view=rev
Log:
[modules] Stop updating all identifiers when writing a module. This is
unnecessary in C++ modules (where we don't need the identifiers for their
Decls) and expensive.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderInternals.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/macros.c

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245821&r1=245820&r2=245821&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Aug 23 22:33:22 2015
@@ -755,6 +755,12 @@ static bool readBit(unsigned &Bits) {
   return Value;
 }
 
+IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
+  using namespace llvm::support;
+  unsigned RawID = endian::readNext(d);
+  return Reader.getGlobalIdentifierID(F, RawID >> 1);
+}
+
 IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
const unsigned char* d,
unsigned DataLen) {
@@ -3455,7 +3461,20 @@ ASTReader::ASTReadResult ASTReader::Read
   ASTIdentifierLookupTrait Trait(*this, F);
   auto KeyDataLen = Trait.ReadKeyDataLength(Data);
   auto Key = Trait.ReadKey(Data, KeyDataLen.first);
-  PP.getIdentifierTable().getOwn(Key).setOutOfDate(true);
+  auto &II = PP.getIdentifierTable().getOwn(Key);
+  II.setOutOfDate(true);
+
+  // Mark this identifier as being from an AST file so that we can track
+  // whether we need to serialize it.
+  if (!II.isFromAST()) {
+II.setIsFromAST();
+if (isInterestingIdentifier(*this, II, F.isModule()))
+  II.setChangedSinceDeserialization();
+  }
+
+  // Associate the ID with the identifier so that the writer can reuse it.
+  auto ID = Trait.ReadIdentifierID(Data + KeyDataLen.first);
+  SetIdentifierInfo(ID, &II);
 }
   }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderInternals.h?rev=245821&r1=245820&r2=245821&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderInternals.h (original)
+++ cfe/trunk/lib/Serialization/ASTReaderInternals.h Sun Aug 23 22:33:22 2015
@@ -137,6 +137,8 @@ public:
  const unsigned char* d,
  unsigned DataLen);
   
+  IdentID ReadIdentifierID(const unsigned char *d);
+
   ASTReader &getReader() const { return Reader; }
 };
   

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=245821&r1=245820&r2=245821&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Sun Aug 23 22:33:22 2015
@@ -4273,22 +4273,24 @@ void ASTWriter::WriteASTCore(Sema &SemaR
   }
 
   // Make sure all decls associated with an identifier are registered for
-  // serialization.
-  llvm::SmallVector IIs;
-  for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),
-  IDEnd = PP.getIdentifierTable().end();
-   ID != IDEnd; ++ID) {
-const IdentifierInfo *II = ID->second;
-if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
-  IIs.push_back(II);
-  }
-  // Sort the identifiers to visit based on their name.
-  std::sort(IIs.begin(), IIs.end(), llvm::less_ptr());
-  for (const IdentifierInfo *II : IIs) {
-for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),
-   DEnd = SemaRef.IdResolver.end();
- D != DEnd; ++D) {
-  GetDeclRef(*D);
+  // serialization, if we're storing decls with identifiers.
+  if (!WritingModule || !getLangOpts().CPlusPlus) {
+llvm::SmallVector IIs;
+for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),
+IDEnd = PP.getIdentifierTable().end();
+ ID != IDEnd; ++ID) {
+  const IdentifierInfo *II = ID->second;
+  if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
+IIs.push_back(II);
+}
+// Sort the identifiers to visit based on their name.
+std::sort(IIs.begin(), IIs.end(), llvm::less_ptr());
+for (const IdentifierInfo *II : IIs) {
+  for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),
+ DEnd = SemaRef.IdResolver.end();
+   D != DEnd; ++D) {
+GetDe

r245822 - [modules] If local submodule visibility is disabled, don't bother checking

2015-08-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Aug 23 22:38:11 2015
New Revision: 245822

URL: http://llvm.org/viewvc/llvm-project?rev=245822&view=rev
Log:
[modules] If local submodule visibility is disabled, don't bother checking
whether the owning module of a hidden declaration is visible -- it can't be.

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

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=245822&r1=245821&r2=245822&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sun Aug 23 22:38:11 2015
@@ -1410,22 +1410,22 @@ bool Sema::hasVisibleDefaultArgument(con
 /// your module can see, including those later on in your module).
 bool LookupResult::isVisibleSlow(Sema &SemaRef, NamedDecl *D) {
   assert(D->isHidden() && "should not call this: not in slow case");
-  Module *DeclModule = SemaRef.getOwningModule(D);
-  if (!DeclModule) {
-// getOwningModule() may have decided the declaration should not be hidden.
-assert(!D->isHidden() && "hidden decl not from a module");
-return true;
-  }
-
-  // If the owning module is visible, and the decl is not module private,
-  // then the decl is visible too. (Module private is ignored within the same
-  // top-level module.)
-  if (!D->isFromASTFile() || !D->isModulePrivate()) {
-if (SemaRef.isModuleVisible(DeclModule))
+  Module *DeclModule = nullptr;
+  
+  if (SemaRef.getLangOpts().ModulesLocalVisibility) {
+DeclModule = SemaRef.getOwningModule(D);
+if (!DeclModule) {
+  // getOwningModule() may have decided the declaration should not be 
hidden.
+  assert(!D->isHidden() && "hidden decl not from a module");
   return true;
-// Also check merged definitions.
-if (SemaRef.getLangOpts().ModulesLocalVisibility &&
-SemaRef.hasVisibleMergedDefinition(D))
+}
+
+// If the owning module is visible, and the decl is not module private,
+// then the decl is visible too. (Module private is ignored within the same
+// top-level module.)
+if ((!D->isFromASTFile() || !D->isModulePrivate()) &&
+(SemaRef.isModuleVisible(DeclModule) ||
+ SemaRef.hasVisibleMergedDefinition(D)))
   return true;
   }
 
@@ -1457,6 +1457,11 @@ bool LookupResult::isVisibleSlow(Sema &S
   if (LookupModules.empty())
 return false;
 
+  if (!DeclModule) {
+DeclModule = SemaRef.getOwningModule(D);
+assert(DeclModule && "hidden decl not from a module");
+  }
+
   // If our lookup set contains the decl's module, it's visible.
   if (LookupModules.count(DeclModule))
 return true;


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


r245823 - [OPENMP] Info about OpenMP Support in Users Manual, NFC.

2015-08-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Aug 24 00:31:10 2015
New Revision: 245823

URL: http://llvm.org/viewvc/llvm-project?rev=245823&view=rev
Log:
[OPENMP] Info about OpenMP Support in Users Manual, NFC.
Differential Revision: http://reviews.llvm.org/D12152

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=245823&r1=245822&r2=245823&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Aug 24 00:31:10 2015
@@ -1852,6 +1852,32 @@ Objective-C Language Features
 Objective-C++ Language Features
 ===
 
+.. _openmp:
+
+OpenMP Features
+===
+
+Clang supports all OpenMP 3.1 directives and clauses.  In addition, some
+features of OpenMP 4.0 are supported.  For example, ``#pragma omp simd``,
+``#pragma omp for simd``, ``#pragma omp parallel for simd`` directives, 
extended
+set of atomic constructs, ``proc_bind`` clause for all parallel-based
+directives, ``depend`` clause for ``#pragma omp task`` directive (except for
+array sections), ``#pragma omp cancel`` and ``#pragma omp cancellation point``
+directives, and ``#pragma omp taskgroup`` directive.
+
+OpenMP support is disabled by default. Use :option:`-fopenmp=libomp` to enable
+it. Support for OpenMP can be disabled with :option:`-fno-openmp`.
+
+Controlling implementation limits
+-
+
+.. option:: -fopenmp-use-tls
+
+ Controls code generation for OpenMP threadprivate variables. In presence of
+ this option all threadprivate variables are generated the same way as thread
+ local variables, using TLS support. If :option:`-fno-openmp-use-tls`
+ is provided or target does not support TLS, code generation for threadprivate
+ variables relies on OpenMP runtime library.
 
 .. _target_features:
 


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


Re: [PATCH] D12152: [OPENMP] Info about OpenMP Support in Users Manual

2015-08-23 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245823: [OPENMP] Info about OpenMP Support in Users Manual, 
NFC. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D12152?vs=32790&id=32933#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12152

Files:
  cfe/trunk/docs/UsersManual.rst

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1852,6 +1852,32 @@
 Objective-C++ Language Features
 ===
 
+.. _openmp:
+
+OpenMP Features
+===
+
+Clang supports all OpenMP 3.1 directives and clauses.  In addition, some
+features of OpenMP 4.0 are supported.  For example, ``#pragma omp simd``,
+``#pragma omp for simd``, ``#pragma omp parallel for simd`` directives, 
extended
+set of atomic constructs, ``proc_bind`` clause for all parallel-based
+directives, ``depend`` clause for ``#pragma omp task`` directive (except for
+array sections), ``#pragma omp cancel`` and ``#pragma omp cancellation point``
+directives, and ``#pragma omp taskgroup`` directive.
+
+OpenMP support is disabled by default. Use :option:`-fopenmp=libomp` to enable
+it. Support for OpenMP can be disabled with :option:`-fno-openmp`.
+
+Controlling implementation limits
+-
+
+.. option:: -fopenmp-use-tls
+
+ Controls code generation for OpenMP threadprivate variables. In presence of
+ this option all threadprivate variables are generated the same way as thread
+ local variables, using TLS support. If :option:`-fno-openmp-use-tls`
+ is provided or target does not support TLS, code generation for threadprivate
+ variables relies on OpenMP runtime library.
 
 .. _target_features:
 


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1852,6 +1852,32 @@
 Objective-C++ Language Features
 ===
 
+.. _openmp:
+
+OpenMP Features
+===
+
+Clang supports all OpenMP 3.1 directives and clauses.  In addition, some
+features of OpenMP 4.0 are supported.  For example, ``#pragma omp simd``,
+``#pragma omp for simd``, ``#pragma omp parallel for simd`` directives, extended
+set of atomic constructs, ``proc_bind`` clause for all parallel-based
+directives, ``depend`` clause for ``#pragma omp task`` directive (except for
+array sections), ``#pragma omp cancel`` and ``#pragma omp cancellation point``
+directives, and ``#pragma omp taskgroup`` directive.
+
+OpenMP support is disabled by default. Use :option:`-fopenmp=libomp` to enable
+it. Support for OpenMP can be disabled with :option:`-fno-openmp`.
+
+Controlling implementation limits
+-
+
+.. option:: -fopenmp-use-tls
+
+ Controls code generation for OpenMP threadprivate variables. In presence of
+ this option all threadprivate variables are generated the same way as thread
+ local variables, using TLS support. If :option:`-fno-openmp-use-tls`
+ is provided or target does not support TLS, code generation for threadprivate
+ variables relies on OpenMP runtime library.
 
 .. _target_features:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits