Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 6:58 PM, Richard Smith  wrote:

> On Thu, Oct 8, 2015 at 6:25 PM, Eric Fiselier  wrote:
>
>> Patch #12 needs revision. A bunch of function definitions were moved
>> out of the std namespace and into the global.
>> That change is incorrect.
>
>
> Slightly updated version attached. I should probably explain what's going
> on here in more detail:
>
> Per [c.strings]p4-p13, we're supposed to replace C functions of the form
>
>   char *foo(const char*);
>
> with a pair of const-correct overloads of the form
>
>   char *foo(char *);
>   const char *foo(const char*);
>
> Now, most C standard libraries will do this for us when included in C++
> mode (because it's not possible for the C++ library to fix this up after
> the fact). For the cases where we *don't* believe we have such a
> considerate C library, we add one declaration to C's overload, to get:
>
>   char *foo(char*);
>   char *foo(const char*)
>
> ... which doesn't really help much, but is the closest we can get to the
> right set of declarations. The declarations we add just dispatch to the C
> declarations.
>
> These new declarations *should* be in the global namespace when including
> , and it makes sense for us to put them in the global namespace
> when including  (otherwise, that header leaves us with a broken
> overload set in the global namespace, containing just one of the two
> expected functions).
>
> Anyway, most of the above is a description of what we did before. What's
> new here is that we attempt to fix the overload set for both  and
> for , not just for the latter. At the end of all these changes,
> you'll see that all that the  headers do is to include the 
> header and use using-declarations to pull the names into namespace std;
> this is no exception to that pattern.
>

Per Eric and my discussion on IRC, the pattern used by  seems
better here:

If libc has left us with a bad overload set, don't try to fix the names in
::, just provide a complete set of overloads in namespace std.

A patch for that approach is attached.

On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
>> > Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
>> > "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
>> > I would like to leave it in so this test doesn't fail with older clang
>> > versions.
>> >
>> > /Eric
>> >
>> > On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
>> >> Patch #10 LGTM.
>> >>
>> >> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith 
>> wrote:
>> >>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow > >
>> >>> wrote:
>> 
>>  On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith > >
>>  wrote:
>> >
>> > . This one is tricky:
>> >
>> > 1) There's an (undocumented) interface between the C standard
>> library and
>> > this header, where the macros __need_ptrdiff_t, __need_size_t,
>> > __need_wchar_t, __need_NULL, __need_wint_t request just a piece of
>> this
>> > header rather than the whole thing. If we see any of those, just go
>> straight
>> > to the underlying header.
>> 
>> 
>>  Ok, but in that case we don't get nullptr.  I suspect that's OK.
>> 
>> >
>> > 2) We probably don't want  to include  (for
>> > consistency with other headers)
>> 
>> 
>>  No, we do not! :-)
>> 
>> >
>> > , but  must provide a ::nullptr_t (which we don't want
>> >  to provide). So neither header includes the other.
>> Instead, both
>> > include <__nullptr> for std::nullptr_t, and we duplicate the
>> definition of
>> > max_align_t between them, in the case where the compiler's
>> 
>> > doesn't provide it.
>> >
>> > If you prefer, I could make  include  to avoid
>> the
>> > duplication of the max_align_t logic.
>> 
>> 
>>  No; this is a minor annoyance, and layer jumping (
>> including
>>  ) is a major annoyance - and I'm pretty sure that that
>> would come
>>  back to bite us in the future.
>> 
>>  Looks ok to me.
>> >>>
>> >>>
>> >>> Thanks, everything up to and including patch 09 is now committed.
>>
>
>
Index: include/cstring
===
--- include/cstring (revision 249736)
+++ include/cstring (working copy)
@@ -78,37 +78,34 @@
 using ::strncmp;
 using ::strcoll;
 using ::strxfrm;
+using ::strcspn;
+using ::strspn;
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+using ::strtok;
+#endif
+using ::memset;
+using ::strerror;
+using ::strlen;
 
-using ::memchr;
-
+#ifdef _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
 using ::strchr;
-
-using ::strcspn;
-
 using ::strpbrk;
-
 using ::strrchr;
-
-using ::strspn;
-
+using ::memchr;
 using ::strstr;
-
-// MSVCRT, GNU libc and its derivates already have the correct prototype in 
 #ifdef __cplusplus
-#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && 
!defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
+#else
+inline _LIBCPP_INLINE_VISIBILITY const cha

Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-08 Thread Alexey Bataev via cfe-commits
ABataev updated this revision to Diff 36924.
ABataev marked 2 inline comments as done.
ABataev added a comment.

Update after review


http://reviews.llvm.org/D13546

Files:
  include/clang/Basic/Attr.td
  lib/AST/DeclPrinter.cpp
  test/Misc/ast-print-pragmas.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -96,6 +96,7 @@
 void PrintTemplateParameters(const TemplateParameterList *Params,
  const TemplateArgumentList *Args = nullptr);
 void prettyPrintAttributes(Decl *D);
+void prettyPrintPragmas(Decl *D);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
   };
 }
@@ -197,12 +198,40 @@
 void DeclPrinter::prettyPrintAttributes(Decl *D) {
   if (Policy.PolishForDeclaration)
 return;
-  
+
   if (D->hasAttrs()) {
 AttrVec &Attrs = D->getAttrs();
-for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) {
-  Attr *A = *i;
-  A->printPretty(Out, Policy);
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+A->printPretty(Out, Policy);
+break;
+  }
+}
+  }
+}
+
+void DeclPrinter::prettyPrintPragmas(Decl *D) {
+  if (Policy.PolishForDeclaration)
+return;
+
+  if (D->hasAttrs()) {
+AttrVec &Attrs = D->getAttrs();
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+A->printPretty(Out, Policy);
+Indent();
+break;
+  default:
+break;
+  }
 }
   }
 }
@@ -408,6 +437,10 @@
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+  if (!D->getDescribedFunctionTemplate() &&
+  !D->isFunctionTemplateSpecialization())
+prettyPrintPragmas(D);
+
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
@@ -643,6 +676,7 @@
 }
 
 void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isMutable())
 Out << "mutable ";
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
@@ -672,6 +706,7 @@
 }
 
 void DeclPrinter::VisitVarDecl(VarDecl *D) {
+  prettyPrintPragmas(D);
   if (!Policy.SuppressSpecifiers) {
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
@@ -779,6 +814,7 @@
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
   Out << D->getKindName();
@@ -914,11 +950,13 @@
   if (PrintInstantiation) {
 TemplateParameterList *Params = D->getTemplateParameters();
 for (auto *I : D->specializations()) {
+  prettyPrintPragmas(I);
   PrintTemplateParameters(Params, I->getTemplateSpecializationArgs());
   Visit(I);
 }
   }
 
+  prettyPrintPragmas(D->getTemplatedDecl());
   return VisitRedeclarableTemplateDecl(D);
 }
 
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1180,6 +1180,7 @@
 if (Variety == "Pragma") {
   OS << " \";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
+  OS << "OS << \"\\n\";";
   OS << "break;\n";
   OS << "  }\n";
   continue;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2048,17 +2048,15 @@
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the
Index: test/Misc/ast-print-pragmas.cpp
===
--- test/Misc/ast-print-pragmas.cpp
+++ test/Misc/ast-print-pragmas.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DMS_EXT -fsyntax-only -fms-extensions %s -triple x86_64

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
Attached patch adds a test that all required functions from the C standard
library (and any required overloads) are present with the correct types,
and that the declarations in the  and  headers declare the
same entity as required by [depr.c.headers]p2.

On Thu, Oct 8, 2015 at 6:58 PM, Richard Smith  wrote:

> On Thu, Oct 8, 2015 at 6:25 PM, Eric Fiselier  wrote:
>
>> Patch #12 needs revision. A bunch of function definitions were moved
>> out of the std namespace and into the global.
>> That change is incorrect.
>
>
> Slightly updated version attached. I should probably explain what's going
> on here in more detail:
>
> Per [c.strings]p4-p13, we're supposed to replace C functions of the form
>
>   char *foo(const char*);
>
> with a pair of const-correct overloads of the form
>
>   char *foo(char *);
>   const char *foo(const char*);
>
> Now, most C standard libraries will do this for us when included in C++
> mode (because it's not possible for the C++ library to fix this up after
> the fact). For the cases where we *don't* believe we have such a
> considerate C library, we add one declaration to C's overload, to get:
>
>   char *foo(char*);
>   char *foo(const char*)
>
> ... which doesn't really help much, but is the closest we can get to the
> right set of declarations. The declarations we add just dispatch to the C
> declarations.
>
> These new declarations *should* be in the global namespace when including
> , and it makes sense for us to put them in the global namespace
> when including  (otherwise, that header leaves us with a broken
> overload set in the global namespace, containing just one of the two
> expected functions).
>
> Anyway, most of the above is a description of what we did before. What's
> new here is that we attempt to fix the overload set for both  and
> for , not just for the latter. At the end of all these changes,
> you'll see that all that the  headers do is to include the 
> header and use using-declarations to pull the names into namespace std;
> this is no exception to that pattern.
>
>
>> On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
>> > Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
>> > "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
>> > I would like to leave it in so this test doesn't fail with older clang
>> > versions.
>> >
>> > /Eric
>> >
>> > On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
>> >> Patch #10 LGTM.
>> >>
>> >> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith 
>> wrote:
>> >>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow > >
>> >>> wrote:
>> 
>>  On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith > >
>>  wrote:
>> >
>> > . This one is tricky:
>> >
>> > 1) There's an (undocumented) interface between the C standard
>> library and
>> > this header, where the macros __need_ptrdiff_t, __need_size_t,
>> > __need_wchar_t, __need_NULL, __need_wint_t request just a piece of
>> this
>> > header rather than the whole thing. If we see any of those, just go
>> straight
>> > to the underlying header.
>> 
>> 
>>  Ok, but in that case we don't get nullptr.  I suspect that's OK.
>> 
>> >
>> > 2) We probably don't want  to include  (for
>> > consistency with other headers)
>> 
>> 
>>  No, we do not! :-)
>> 
>> >
>> > , but  must provide a ::nullptr_t (which we don't want
>> >  to provide). So neither header includes the other.
>> Instead, both
>> > include <__nullptr> for std::nullptr_t, and we duplicate the
>> definition of
>> > max_align_t between them, in the case where the compiler's
>> 
>> > doesn't provide it.
>> >
>> > If you prefer, I could make  include  to avoid
>> the
>> > duplication of the max_align_t logic.
>> 
>> 
>>  No; this is a minor annoyance, and layer jumping (
>> including
>>  ) is a major annoyance - and I'm pretty sure that that
>> would come
>>  back to bite us in the future.
>> 
>>  Looks ok to me.
>> >>>
>> >>>
>> >>> Thanks, everything up to and including patch 09 is now committed.
>>
>
>
diff --git test/std/depr/depr.c.headers/same_decls.pass.cpp 
test/std/depr/depr.c.headers/same_decls.pass.cpp
new file mode 100644
index 000..c5a5cf1
--- /dev/null
+++ test/std/depr/depr.c.headers/same_decls.pass.cpp
@@ -0,0 +1,513 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Every C header behaves as if the names in namespace std are placed into the
+// global namespace. This implies that the addresses of such functions must
+// match between the declaration in the global namespace and the declaration in
+// namespace std.
+
+#include <__

Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread don hinton via cfe-commits
hintonda added a comment.

Btw, I don't have commit access, so if you are happy with this change, could 
you commit it for me?


http://reviews.llvm.org/D13453



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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 6:25 PM, Eric Fiselier  wrote:

> Patch #12 needs revision. A bunch of function definitions were moved
> out of the std namespace and into the global.
> That change is incorrect.


Slightly updated version attached. I should probably explain what's going
on here in more detail:

Per [c.strings]p4-p13, we're supposed to replace C functions of the form

  char *foo(const char*);

with a pair of const-correct overloads of the form

  char *foo(char *);
  const char *foo(const char*);

Now, most C standard libraries will do this for us when included in C++
mode (because it's not possible for the C++ library to fix this up after
the fact). For the cases where we *don't* believe we have such a
considerate C library, we add one declaration to C's overload, to get:

  char *foo(char*);
  char *foo(const char*)

... which doesn't really help much, but is the closest we can get to the
right set of declarations. The declarations we add just dispatch to the C
declarations.

These new declarations *should* be in the global namespace when including
, and it makes sense for us to put them in the global namespace
when including  (otherwise, that header leaves us with a broken
overload set in the global namespace, containing just one of the two
expected functions).

Anyway, most of the above is a description of what we did before. What's
new here is that we attempt to fix the overload set for both  and
for , not just for the latter. At the end of all these changes,
you'll see that all that the  headers do is to include the 
header and use using-declarations to pull the names into namespace std;
this is no exception to that pattern.


> On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
> > Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
> > "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
> > I would like to leave it in so this test doesn't fail with older clang
> > versions.
> >
> > /Eric
> >
> > On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
> >> Patch #10 LGTM.
> >>
> >> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith 
> wrote:
> >>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
> >>> wrote:
> 
>  On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
>  wrote:
> >
> > . This one is tricky:
> >
> > 1) There's an (undocumented) interface between the C standard
> library and
> > this header, where the macros __need_ptrdiff_t, __need_size_t,
> > __need_wchar_t, __need_NULL, __need_wint_t request just a piece of
> this
> > header rather than the whole thing. If we see any of those, just go
> straight
> > to the underlying header.
> 
> 
>  Ok, but in that case we don't get nullptr.  I suspect that's OK.
> 
> >
> > 2) We probably don't want  to include  (for
> > consistency with other headers)
> 
> 
>  No, we do not! :-)
> 
> >
> > , but  must provide a ::nullptr_t (which we don't want
> >  to provide). So neither header includes the other.
> Instead, both
> > include <__nullptr> for std::nullptr_t, and we duplicate the
> definition of
> > max_align_t between them, in the case where the compiler's 
> > doesn't provide it.
> >
> > If you prefer, I could make  include  to avoid the
> > duplication of the max_align_t logic.
> 
> 
>  No; this is a minor annoyance, and layer jumping ( including
>  ) is a major annoyance - and I'm pretty sure that that would
> come
>  back to bite us in the future.
> 
>  Looks ok to me.
> >>>
> >>>
> >>> Thanks, everything up to and including patch 09 is now committed.
>
Index: include/cstring
===
--- include/cstring (revision 249736)
+++ include/cstring (working copy)
@@ -78,30 +78,13 @@
 using ::strncmp;
 using ::strcoll;
 using ::strxfrm;
-
 using ::memchr;
-
 using ::strchr;
-
 using ::strcspn;
-
 using ::strpbrk;
-
 using ::strrchr;
-
 using ::strspn;
-
 using ::strstr;
-
-// MSVCRT, GNU libc and its derivates already have the correct prototype in 
 #ifdef __cplusplus
-#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && 
!defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
-inline _LIBCPP_INLINE_VISIBILITY   char* strchr(  char* __s, int __c) 
{return ::strchr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY   char* strpbrk(  char* __s1, const 
char* __s2) {return ::strpbrk(__s1, __s2);}
-inline _LIBCPP_INLINE_VISIBILITY   char* strrchr(  char* __s, int __c) 
{return ::strrchr(__s, __c);}
-inline _LIBCPP_INLINE_VISIBILITY   void* memchr(  void* __s, int __c, 
size_t __n) {return ::memchr(__s, __c, __n);}
-inline _LIBCPP_INLINE_VISIBILITY   char* strstr(  char* __s1, const 
char* __s2) {return ::strstr(__s1, __s2);}
-#endif
-
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::strtok;
 #endif
Index: include/string.h
=

Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 36916.
hintonda added a comment.

Add support for cmake version 3, i.e., 3.0.0...


http://reviews.llvm.org/D13453

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,8 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
+CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, 
but
   # the usual CMake convention seems to be ${Project}Targets.cmake.


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,8 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
+CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, but
   # the usual CMake convention seems to be ${Project}Targets.cmake.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249801 - [Sema] Add "Ty" suffix to QualType variables for clarity (NFC)

2015-10-08 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Oct  8 20:47:26 2015
New Revision: 249801

URL: http://llvm.org/viewvc/llvm-project?rev=249801&view=rev
Log:
[Sema] Add "Ty" suffix to QualType variables for clarity (NFC)

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=249801&r1=249800&r2=249801&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  8 20:47:26 2015
@@ -5516,15 +5516,15 @@ bool Sema::areLaxCompatibleVectorTypes(Q
   if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
 
   uint64_t srcLen, destLen;
-  QualType srcElt, destElt;
-  if (!breakDownVectorType(srcTy, srcLen, srcElt)) return false;
-  if (!breakDownVectorType(destTy, destLen, destElt)) return false;
+  QualType srcEltTy, destEltTy;
+  if (!breakDownVectorType(srcTy, srcLen, srcEltTy)) return false;
+  if (!breakDownVectorType(destTy, destLen, destEltTy)) return false;
   
   // ASTContext::getTypeSize will return the size rounded up to a
   // power of 2, so instead of using that, we need to use the raw
   // element size multiplied by the element count.
-  uint64_t srcEltSize = Context.getTypeSize(srcElt);
-  uint64_t destEltSize = Context.getTypeSize(destElt);
+  uint64_t srcEltSize = Context.getTypeSize(srcEltTy);
+  uint64_t destEltSize = Context.getTypeSize(destEltTy);
   
   return (srcLen * srcEltSize == destLen * destEltSize);
 }


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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Eric Fiselier via cfe-commits
Patch #14 LGTM modulo pragmas.

On Thu, Oct 8, 2015 at 7:39 PM, Eric Fiselier  wrote:
> Patch #13 LGTM after revision.
>
> a system header pragma needs to be added to the __need_wint_t path of wchar.h.
> The existing pragma also needs fixing as previously discussed.
>
> On Thu, Oct 8, 2015 at 7:25 PM, Eric Fiselier  wrote:
>> Patch #12 needs revision. A bunch of function definitions were moved
>> out of the std namespace and into the global.
>> That change is incorrect.
>>
>>
>>
>> On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
>>> Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
>>> "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
>>> I would like to leave it in so this test doesn't fail with older clang
>>> versions.
>>>
>>> /Eric
>>>
>>> On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
 Patch #10 LGTM.

 On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith  
 wrote:
> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
> wrote:
>>
>> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
>> wrote:
>>>
>>> . This one is tricky:
>>>
>>> 1) There's an (undocumented) interface between the C standard library 
>>> and
>>> this header, where the macros __need_ptrdiff_t, __need_size_t,
>>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
>>> header rather than the whole thing. If we see any of those, just go 
>>> straight
>>> to the underlying header.
>>
>>
>> Ok, but in that case we don't get nullptr.  I suspect that's OK.
>>
>>>
>>> 2) We probably don't want  to include  (for
>>> consistency with other headers)
>>
>>
>> No, we do not! :-)
>>
>>>
>>> , but  must provide a ::nullptr_t (which we don't want
>>>  to provide). So neither header includes the other. Instead, 
>>> both
>>> include <__nullptr> for std::nullptr_t, and we duplicate the definition 
>>> of
>>> max_align_t between them, in the case where the compiler's 
>>> doesn't provide it.
>>>
>>> If you prefer, I could make  include  to avoid the
>>> duplication of the max_align_t logic.
>>
>>
>> No; this is a minor annoyance, and layer jumping ( including
>> ) is a major annoyance - and I'm pretty sure that that would 
>> come
>> back to bite us in the future.
>>
>> Looks ok to me.
>
>
> Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249800 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 20:41:45 2015
New Revision: 249800

URL: http://llvm.org/viewvc/llvm-project?rev=249800&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/stdlib.h
  - copied, changed from r249736, libcxx/trunk/include/cstdlib
Modified:
libcxx/trunk/include/cstdlib
libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp

Modified: libcxx/trunk/include/cstdlib
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdlib?rev=249800&r1=249799&r2=249800&view=diff
==
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/cstdlib Thu Oct  8 20:41:45 2015
@@ -84,9 +84,6 @@ void *aligned_alloc(size_t alignment, si
 
 #include <__config>
 #include 
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -131,20 +128,14 @@ using ::getenv;
 using ::system;
 using ::bsearch;
 using ::qsort;
-#undef abs
 using ::abs;
-#undef labs
 using ::labs;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef llabs
 using ::llabs;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
-#undef div
 using ::div;
-#undef ldiv
 using ::ldiv;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef lldiv
 using ::lldiv;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
@@ -162,19 +153,6 @@ using ::quick_exit;
 using ::aligned_alloc;
 #endif
 
-// MSVCRT already has the correct prototype in  #ifdef __cplusplus
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
-inline _LIBCPP_INLINE_VISIBILITY long  abs( long __x) _NOEXCEPT 
{return  labs(__x);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT 
{return llabs(__x);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-
-inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div( long __x,  long __y) 
_NOEXCEPT {return  ldiv(__x, __y);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) 
_NOEXCEPT {return lldiv(__x, __y);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CSTDLIB

Copied: libcxx/trunk/include/stdlib.h (from r249736, 
libcxx/trunk/include/cstdlib)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdlib.h?p2=libcxx/trunk/include/stdlib.h&p1=libcxx/trunk/include/cstdlib&r1=249736&r2=249800&rev=249800&view=diff
==
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/stdlib.h Thu Oct  8 20:41:45 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cstdlib 
--===//
+//===--- stdlib.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,19 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSTDLIB
-#define _LIBCPP_CSTDLIB
+#if defined(__need_malloc_and_calloc)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next 
+
+#elif !defined(_LIBCPP_STDLIB_H)
+#define _LIBCPP_STDLIB_H
 
 /*
-cstdlib synopsis
+stdlib.h synopsis
 
 Macros:
 
@@ -22,9 +30,6 @@ Macros:
 NULL
 RAND_MAX
 
-namespace std
-{
-
 Types:
 
 size_t
@@ -78,91 +83,33 @@ int at_quick_exit(void (*func)(void))
 void quick_exit(int status);  // 
C++11
 void *aligned_alloc(size_t alignment, size_t size);   // 
C11
 
-}  // std
-
 */
 
 #include <__config>
-#include 
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#include_next 
+
+#ifdef __cplusplus
+extern "C++" {
+
+#ifdef _LIBCPP_MSVCRT
+#include "support/win32/locale_win32.h"
+#endif // _LIBCPP_MSVCRT
 
-using ::size_t;
-using ::div_t;
-using ::ldiv_t;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::lldiv_t;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::atof;
-using ::atoi;
-using ::atol;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::atoll;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtod;
-using ::strtof;
-using ::strtold;
-using ::strtol;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoll;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoul;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoull;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::rand;
-using ::srand;
-using ::calloc;
-using ::free;
-using ::malloc;
-using ::realloc;
-using ::abort;
-using ::atexit;
-using ::exit;
-using ::_Exit;
-using ::getenv;
-using ::system;
-using ::bsearch;
-using ::qsort;
 #undef abs
-using ::abs;
-#undef labs
-using ::labs;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef llabs
-usi

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Eric Fiselier via cfe-commits
Patch #13 LGTM after revision.

a system header pragma needs to be added to the __need_wint_t path of wchar.h.
The existing pragma also needs fixing as previously discussed.

On Thu, Oct 8, 2015 at 7:25 PM, Eric Fiselier  wrote:
> Patch #12 needs revision. A bunch of function definitions were moved
> out of the std namespace and into the global.
> That change is incorrect.
>
>
>
> On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
>> Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
>> "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
>> I would like to leave it in so this test doesn't fail with older clang
>> versions.
>>
>> /Eric
>>
>> On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
>>> Patch #10 LGTM.
>>>
>>> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith  wrote:
 On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
 wrote:
>
> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
> wrote:
>>
>> . This one is tricky:
>>
>> 1) There's an (undocumented) interface between the C standard library and
>> this header, where the macros __need_ptrdiff_t, __need_size_t,
>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
>> header rather than the whole thing. If we see any of those, just go 
>> straight
>> to the underlying header.
>
>
> Ok, but in that case we don't get nullptr.  I suspect that's OK.
>
>>
>> 2) We probably don't want  to include  (for
>> consistency with other headers)
>
>
> No, we do not! :-)
>
>>
>> , but  must provide a ::nullptr_t (which we don't want
>>  to provide). So neither header includes the other. Instead, 
>> both
>> include <__nullptr> for std::nullptr_t, and we duplicate the definition 
>> of
>> max_align_t between them, in the case where the compiler's 
>> doesn't provide it.
>>
>> If you prefer, I could make  include  to avoid the
>> duplication of the max_align_t logic.
>
>
> No; this is a minor annoyance, and layer jumping ( including
> ) is a major annoyance - and I'm pretty sure that that would come
> back to bite us in the future.
>
> Looks ok to me.


 Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249798 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 20:29:09 2015
New Revision: 249798

URL: http://llvm.org/viewvc/llvm-project?rev=249798&view=rev
Log:
Split  out of .

As with , skip our custom header if __need_FILE or __need___FILE is 
defined.

Added:
libcxx/trunk/include/stdio.h
  - copied, changed from r249736, libcxx/trunk/include/cstdio
Modified:
libcxx/trunk/include/cstdio
libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp

Modified: libcxx/trunk/include/cstdio
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=249798&r1=249797&r2=249798&view=diff
==
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/cstdio Thu Oct  8 20:29:09 2015
@@ -103,16 +103,6 @@ void perror(const char* s);
 #pragma GCC system_header
 #endif
 
-// snprintf
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#endif
-
-#undef getc
-#undef putc
-#undef clearerr
-#undef feof
-#undef ferror
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::FILE;

Copied: libcxx/trunk/include/stdio.h (from r249736, libcxx/trunk/include/cstdio)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdio.h?p2=libcxx/trunk/include/stdio.h&p1=libcxx/trunk/include/cstdio&r1=249736&r2=249798&rev=249798&view=diff
==
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/stdio.h Thu Oct  8 20:29:09 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//=== cstdio 
--===//
+//=== stdio.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,19 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSTDIO
-#define _LIBCPP_CSTDIO
+#if defined(__need_FILE) || defined(__need___FILE)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next 
+
+#elif !defined(_LIBCPP_STDIO_H)
+#define _LIBCPP_STDIO_H
 
 /*
-cstdio synopsis
+stdio.h synopsis
 
 Macros:
 
@@ -33,9 +41,6 @@ Macros:
 stdin
 stdout
 
-namespace std
-{
-
 Types:
 
 FILE
@@ -92,20 +97,23 @@ void clearerr(FILE* stream);
 int feof(FILE* stream);
 int ferror(FILE* stream);
 void perror(const char* s);
-
-}  // std
 */
 
 #include <__config>
-#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
+#ifdef __cplusplus
+
 // snprintf
 #if defined(_LIBCPP_MSVCRT)
+extern "C++" {
 #include "support/win32/support.h"
+}
 #endif
 
 #undef getc
@@ -113,72 +121,7 @@ void perror(const char* s);
 #undef clearerr
 #undef feof
 #undef ferror
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::FILE;
-using ::fpos_t;
-using ::size_t;
-
-using ::fclose;
-using ::fflush;
-using ::setbuf;
-using ::setvbuf;
-using ::fprintf;
-using ::fscanf;
-using ::snprintf;
-using ::sprintf;
-using ::sscanf;
-#ifndef _LIBCPP_MSVCRT
-using ::vfprintf;
-using ::vfscanf;
-using ::vsscanf;
-#endif // _LIBCPP_MSVCRT
-using ::vsnprintf;
-using ::vsprintf;
-using ::fgetc;
-using ::fgets;
-using ::fputc;
-using ::fputs;
-using ::getc;
-using ::putc;
-using ::ungetc;
-using ::fread;
-using ::fwrite;
-using ::fgetpos;
-using ::fseek;
-using ::fsetpos;
-using ::ftell;
-using ::rewind;
-using ::clearerr;
-using ::feof;
-using ::ferror;
-using ::perror;
-
-#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
-using ::fopen;
-using ::freopen;
-using ::remove;
-using ::rename;
-using ::tmpfile;
-using ::tmpnam;
-#endif
 
-#ifndef _LIBCPP_HAS_NO_STDIN
-using ::getchar;
-#if _LIBCPP_STD_VER <= 11
-using ::gets;
 #endif
-using ::scanf;
-using ::vscanf;
-#endif
-
-#ifndef _LIBCPP_HAS_NO_STDOUT
-using ::printf;
-using ::putchar;
-using ::puts;
-using ::vprintf;
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
 
-#endif  // _LIBCPP_CSTDIO
+#endif  // _LIBCPP_STDIO_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp?rev=249798&r1=249797&r2=249798&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp Thu Oct  8 
20:29:09 2015
@@ -13,6 +13,26 @@
 #include 
 #include "test_macros.h"
 
+#ifdef getc
+#error getc is defined
+#endif
+
+#ifdef putc
+#error putc is defined
+#endif
+
+#ifdef clearerr
+#error clearerr is defined
+#endif
+
+#ifdef feof
+#error feof is defined
+#endif
+
+#ifdef ferror
+#error ferror is defined
+#endif
+
 #ifndef BUFSIZ
 #error BUFSIZ not defined
 #endif


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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Eric Fiselier via cfe-commits
Patch #12 needs revision. A bunch of function definitions were moved
out of the std namespace and into the global.
That change is incorrect.



On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier  wrote:
> Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
> "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
> I would like to leave it in so this test doesn't fail with older clang
> versions.
>
> /Eric
>
> On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
>> Patch #10 LGTM.
>>
>> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith  wrote:
>>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
>>> wrote:

 On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
 wrote:
>
> . This one is tricky:
>
> 1) There's an (undocumented) interface between the C standard library and
> this header, where the macros __need_ptrdiff_t, __need_size_t,
> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
> header rather than the whole thing. If we see any of those, just go 
> straight
> to the underlying header.


 Ok, but in that case we don't get nullptr.  I suspect that's OK.

>
> 2) We probably don't want  to include  (for
> consistency with other headers)


 No, we do not! :-)

>
> , but  must provide a ::nullptr_t (which we don't want
>  to provide). So neither header includes the other. Instead, both
> include <__nullptr> for std::nullptr_t, and we duplicate the definition of
> max_align_t between them, in the case where the compiler's 
> doesn't provide it.
>
> If you prefer, I could make  include  to avoid the
> duplication of the max_align_t logic.


 No; this is a minor annoyance, and layer jumping ( including
 ) is a major annoyance - and I'm pretty sure that that would come
 back to bite us in the future.

 Looks ok to me.
>>>
>>>
>>> Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Eric Fiselier via cfe-commits
Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
"-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
I would like to leave it in so this test doesn't fail with older clang
versions.

/Eric

On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier  wrote:
> Patch #10 LGTM.
>
> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith  wrote:
>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
>> wrote:
>>>
>>> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
>>> wrote:

 . This one is tricky:

 1) There's an (undocumented) interface between the C standard library and
 this header, where the macros __need_ptrdiff_t, __need_size_t,
 __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
 header rather than the whole thing. If we see any of those, just go 
 straight
 to the underlying header.
>>>
>>>
>>> Ok, but in that case we don't get nullptr.  I suspect that's OK.
>>>

 2) We probably don't want  to include  (for
 consistency with other headers)
>>>
>>>
>>> No, we do not! :-)
>>>

 , but  must provide a ::nullptr_t (which we don't want
  to provide). So neither header includes the other. Instead, both
 include <__nullptr> for std::nullptr_t, and we duplicate the definition of
 max_align_t between them, in the case where the compiler's 
 doesn't provide it.

 If you prefer, I could make  include  to avoid the
 duplication of the max_align_t logic.
>>>
>>>
>>> No; this is a minor annoyance, and layer jumping ( including
>>> ) is a major annoyance - and I'm pretty sure that that would come
>>> back to bite us in the future.
>>>
>>> Looks ok to me.
>>
>>
>> Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Eric Fiselier via cfe-commits
Patch #10 LGTM.

On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith  wrote:
> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
> wrote:
>>
>> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
>> wrote:
>>>
>>> . This one is tricky:
>>>
>>> 1) There's an (undocumented) interface between the C standard library and
>>> this header, where the macros __need_ptrdiff_t, __need_size_t,
>>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
>>> header rather than the whole thing. If we see any of those, just go straight
>>> to the underlying header.
>>
>>
>> Ok, but in that case we don't get nullptr.  I suspect that's OK.
>>
>>>
>>> 2) We probably don't want  to include  (for
>>> consistency with other headers)
>>
>>
>> No, we do not! :-)
>>
>>>
>>> , but  must provide a ::nullptr_t (which we don't want
>>>  to provide). So neither header includes the other. Instead, both
>>> include <__nullptr> for std::nullptr_t, and we duplicate the definition of
>>> max_align_t between them, in the case where the compiler's 
>>> doesn't provide it.
>>>
>>> If you prefer, I could make  include  to avoid the
>>> duplication of the max_align_t logic.
>>
>>
>> No; this is a minor annoyance, and layer jumping ( including
>> ) is a major annoyance - and I'm pretty sure that that would come
>> back to bite us in the future.
>>
>> Looks ok to me.
>
>
> Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249790 - Fix a few typos in the required feature set for some of the x86

2015-10-08 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Oct  8 19:35:30 2015
New Revision: 249790

URL: http://llvm.org/viewvc/llvm-project?rev=249790&view=rev
Log:
Fix a few typos in the required feature set for some of the x86
builtins:

avx512vd -> avx512vl
rdrand -> rdrnd
avx512ff -> avx512f

no functional change.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=249790&r1=249789&r2=249790&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Oct  8 19:35:30 2015
@@ -645,9 +645,9 @@ TARGET_BUILTIN(__builtin_ia32_vcvtph2ps2
 TARGET_BUILTIN(__builtin_ia32_vcvtph2ps512, "V16fV16s", "", "avx512f")
 
 // RDRAND
-TARGET_BUILTIN(__builtin_ia32_rdrand16_step, "UiUs*", "", "rdrand")
-TARGET_BUILTIN(__builtin_ia32_rdrand32_step, "UiUi*", "", "rdrand")
-TARGET_BUILTIN(__builtin_ia32_rdrand64_step, "UiULLi*", "", "rdrand")
+TARGET_BUILTIN(__builtin_ia32_rdrand16_step, "UiUs*", "", "rdrnd")
+TARGET_BUILTIN(__builtin_ia32_rdrand32_step, "UiUi*", "", "rdrnd")
+TARGET_BUILTIN(__builtin_ia32_rdrand64_step, "UiULLi*", "", "rdrnd")
 
 // FSGSBASE
 TARGET_BUILTIN(__builtin_ia32_rdfsbase32, "Ui", "", "fsgsbase")
@@ -737,92 +737,92 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddsubp
 TARGET_BUILTIN(__builtin_ia32_vfmsubaddps256, "V8fV8fV8fV8f", "", "fma")
 TARGET_BUILTIN(__builtin_ia32_vfmsubaddpd256, "V4dV4dV4dV4d", "", "fma")
 
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask3, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_maskz, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_mask3, "V4dV4dV4dV4dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_maskz, "V4dV4dV4dV4dUc", "", 
"avx512vd")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_mask3, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd128_maskz, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_mask3, "V4dV4dV4dV4dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddpd256_maskz, "V4dV4dV4dV4dUc", "", 
"avx512vl")
 
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_mask, "V8dV8dV8dV8dUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_mask3, "V8dV8dV8dV8dUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd512_maskz, "V8dV8dV8dV8dUcIi", "", 
"avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_vfmaddps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps128_mask3, "V4fV4fV4fV4fUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps128_maskz, "V4fV4fV4fV4fUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps256_mask3, "V8fV8fV8fV8fUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddps256_maskz, "V8fV8fV8fV8fUc", "", 
"avx512vd")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps128_mask3, "V4fV4fV4fV4fUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps128_maskz, "V4fV4fV4fV4fUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps256_mask3, "V8fV8fV8fV8fUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddps256_maskz, "V8fV8fV8fV8fUc", "", 
"avx512vl")
 
 TARGET_BUILTIN(__builtin_ia32_vfmaddps512_mask, "V16fV16fV16fV16fUsIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_vfmaddps512_mask3, "V16fV16fV16fV16fUsIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_vfmaddps512_maskz, "V16fV16fV16fV16fUsIi", "", 
"avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_mask3, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_maskz, "V2dV2dV2dV2dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd256_mask3, "V4dV4dV4dV4dUc", "", 
"avx512vd")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd256_maskz, "V4dV4dV4dV4dUc", "", 
"avx512vd")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_mask3, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd128_maskz, "V2dV2dV2dV2dUc", "", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmadd

[libcxx] r249788 - PR25118: move system_header pragma before uses of include_next to avoid extension warnings for people finding libc++ headers via -I paths.

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 19:26:50 2015
New Revision: 249788

URL: http://llvm.org/viewvc/llvm-project?rev=249788&view=rev
Log:
PR25118: move system_header pragma before uses of include_next to avoid 
extension warnings for people finding libc++ headers via -I paths.

Modified:
libcxx/trunk/include/complex.h
libcxx/trunk/include/cstddef
libcxx/trunk/include/ctype.h
libcxx/trunk/include/errno.h
libcxx/trunk/include/float.h
libcxx/trunk/include/inttypes.h
libcxx/trunk/include/math.h
libcxx/trunk/include/setjmp.h
libcxx/trunk/include/stddef.h

Modified: libcxx/trunk/include/complex.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/complex.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/complex.h (original)
+++ libcxx/trunk/include/complex.h Thu Oct  8 19:26:50 2015
@@ -18,6 +18,12 @@
 
 */
 
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #ifdef __cplusplus
 
 #include 
@@ -28,8 +34,4 @@
 
 #endif  // __cplusplus
 
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
 #endif  // _LIBCPP_COMPLEX_H

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Oct  8 19:26:50 2015
@@ -34,14 +34,15 @@ Types:
 */
 
 #include <__config>
-// Don't include our own ; we don't want to declare ::nullptr_t.
-#include_next 
-#include <__nullptr>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+// Don't include our own ; we don't want to declare ::nullptr_t.
+#include_next 
+#include <__nullptr>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::ptrdiff_t;

Modified: libcxx/trunk/include/ctype.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/ctype.h (original)
+++ libcxx/trunk/include/ctype.h Thu Oct  8 19:26:50 2015
@@ -31,12 +31,13 @@ int toupper(int c);
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 #if defined(_LIBCPP_MSVCRT)

Modified: libcxx/trunk/include/errno.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/errno.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/errno.h (original)
+++ libcxx/trunk/include/errno.h Thu Oct  8 19:26:50 2015
@@ -24,12 +24,13 @@ Macros:
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 #ifdef ELAST

Modified: libcxx/trunk/include/float.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/float.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/float.h (original)
+++ libcxx/trunk/include/float.h Thu Oct  8 19:26:50 2015
@@ -61,12 +61,13 @@ Macros:
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifndef FLT_EVAL_METHOD
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
 #endif

Modified: libcxx/trunk/include/inttypes.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/inttypes.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/inttypes.h (original)
+++ libcxx/trunk/include/inttypes.h Thu Oct  8 19:26:50 2015
@@ -232,12 +232,13 @@ uintmax_t wcstoumax(const wchar_t* restr
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 #include 

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=249788&r1=249787&r2=249788&view=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Thu Oct  8 19:26:50 2015
@@ -293,12 +293,13 @@ long doubletruncl(long double x);
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch

Modified: libcxx/t

Re: [libc++] PR25118: move include_next after #pragma system_header

2015-10-08 Thread Eric Fiselier via cfe-commits
The patch LGTM.  However I would rather see the pragma in 
wrap itself in the `#if !defined(_LIBPP_HAS_NO_SYSTEM_HEADER_PRAGMA)`.
I agree that we probably
shouldn't include "<__config>". However people are still free to add
the definition to the command line (line libc++ does when building and
testing).

/Eric

On Thu, Oct 8, 2015 at 5:36 PM, Richard Smith  wrote:
> Hi,
>
> As noted in PR25118, people who include libc++'s headers via a -I path with
> -pedantic_errors will see errors due to the use of #include_next. This patch
> moves the #include_next after the #pragma system_header line to suppress the
> error.
>
> (For the __need_* case in , I'm not checking whether pragma
> system_header is available: these macros should only be defined for systems
> where the pragma is available, and it doesn't seem like a good idea to
> include <__config> in this case.)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249787 - Skip NonNull sema checks in unevaluated contexts.

2015-10-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct  8 19:17:57 2015
New Revision: 249787

URL: http://llvm.org/viewvc/llvm-project?rev=249787&view=rev
Log:
Skip NonNull sema checks in unevaluated contexts.

Summary:
Currently when a function annotated with __attribute__((nonnull)) is called in 
an unevaluated context with a null argument a -Wnonnull warning is emitted. 
This warning seems like a false positive unless the call expression is 
potentially evaluated. Change this behavior so that the non-null warnings use 
DiagRuntimeBehavior so they wont emit when they won't be evaluated.

Reviewers: majnemer, rsmith

Subscribers: mclow.lists, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/non-null-warning.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=249787&r1=249786&r2=249787&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Oct  8 19:17:57 2015
@@ -1151,7 +1151,8 @@ static void CheckNonNullArgument(Sema &S
  const Expr *ArgExpr,
  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+   S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {

Modified: cfe/trunk/test/Sema/non-null-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/non-null-warning.c?rev=249787&r1=249786&r2=249787&view=diff
==
--- cfe/trunk/test/Sema/non-null-warning.c (original)
+++ cfe/trunk/test/Sema/non-null-warning.c Thu Oct  8 19:17:57 2015
@@ -37,6 +37,9 @@ int * ret_nonnull() {
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }


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


Re: [PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.

2015-10-08 Thread Eric Fiselier via cfe-commits
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 36910.

http://reviews.llvm.org/D13408

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/non-null-warning.c

Index: test/Sema/non-null-warning.c
===
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1151,7 +1151,8 @@
  const Expr *ArgExpr,
  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+   S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {


Index: test/Sema/non-null-warning.c
===
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1151,7 +1151,8 @@
  const Expr *ArgExpr,
  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+   S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249780 - Fix test failure in C++98 mode due to imperfect static_assert emulation.

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 18:44:26 2015
New Revision: 249780

URL: http://llvm.org/viewvc/llvm-project?rev=249780&view=rev
Log:
Fix test failure in C++98 mode due to imperfect static_assert emulation.

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp?rev=249780&r1=249779&r2=249780&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp Thu Oct  8 
18:44:26 2015
@@ -38,7 +38,7 @@ int main()
   "std::is_signed::value");
 static_assert(std::is_integral::value,
   "std::is_integral::value");
-static_assert(std::is_same::value,
+static_assert((std::is_same::value),
   "decltype(nullptr) == nullptr_t");
 static_assert(sizeof(nullptr_t) == sizeof(void*),
   "sizeof(nullptr_t) == sizeof(void*)");


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


[libc++] PR25118: move include_next after #pragma system_header

2015-10-08 Thread Richard Smith via cfe-commits
Hi,

As noted in PR25118, people who include libc++'s headers via a -I path with
-pedantic_errors will see errors due to the use of #include_next. This
patch moves the #include_next after the #pragma system_header line to
suppress the error.

(For the __need_* case in , I'm not checking whether pragma
system_header is available: these macros should only be defined for systems
where the pragma is available, and it doesn't seem like a good idea to
include <__config> in this case.)
Index: complex.h
===
--- complex.h   (revision 249736)
+++ complex.h   (working copy)
@@ -18,6 +18,12 @@
 
 */
 
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #ifdef __cplusplus
 
 #include 
@@ -28,8 +34,4 @@
 
 #endif  // __cplusplus
 
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
 #endif  // _LIBCPP_COMPLEX_H
Index: cstddef
===
--- cstddef (revision 249761)
+++ cstddef (working copy)
@@ -34,14 +34,15 @@
 */
 
 #include <__config>
-// Don't include our own ; we don't want to declare ::nullptr_t.
-#include_next 
-#include <__nullptr>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+// Don't include our own ; we don't want to declare ::nullptr_t.
+#include_next 
+#include <__nullptr>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::ptrdiff_t;
Index: ctype.h
===
--- ctype.h (revision 249738)
+++ ctype.h (working copy)
@@ -31,12 +31,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 #if defined(_LIBCPP_MSVCRT)
Index: errno.h
===
--- errno.h (revision 249739)
+++ errno.h (working copy)
@@ -24,12 +24,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 #ifdef ELAST
Index: float.h
===
--- float.h (revision 249740)
+++ float.h (working copy)
@@ -61,12 +61,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifndef FLT_EVAL_METHOD
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
 #endif
Index: inttypes.h
===
--- inttypes.h  (revision 249741)
+++ inttypes.h  (working copy)
@@ -232,12 +232,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 #include 
Index: math.h
===
--- math.h  (revision 249742)
+++ math.h  (working copy)
@@ -293,12 +293,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch
Index: setjmp.h
===
--- setjmp.h(revision 249743)
+++ setjmp.h(working copy)
@@ -27,12 +27,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifndef setjmp
 #define setjmp(env) setjmp(env)
 #endif
Index: stddef.h
===
--- stddef.h(revision 249761)
+++ stddef.h(working copy)
@@ -10,6 +10,8 @@
 
 #if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
 defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+
+#pragma GCC system_header
 #include_next 
 
 #elif !defined(_LIBCPP_STDDEF_H)
@@ -33,12 +35,13 @@
 */
 
 #include <__config>
-#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 extern "C++" {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread NAKAMURA Takumi via cfe-commits
chapuni accepted this revision.
This revision is now accepted and ready to land.


Comment at: CMakeLists.txt:553
@@ -552,3 +552,3 @@
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can

I'm afraid you mistook "conditionally skipped" as "worked".

Please change the condition, like

  - 2.9
  - 3.0.1 (Not sure any distros might take <3.0.2)
  - EQUAL 3 OR GREATER 3
  - NOT LESS 3


http://reviews.llvm.org/D13453



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


r249775 - Expose -f[no]ms-{compatibility, extensions} in clang-cl (PR25114)

2015-10-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Oct  8 18:13:28 2015
New Revision: 249775

URL: http://llvm.org/viewvc/llvm-project?rev=249775&view=rev
Log:
Expose -f[no]ms-{compatibility,extensions} in clang-cl (PR25114)

These are enabled by default in clang-cl, because the whole idea is that
it should work like cl.exe, but I suppose it can make sense to disable
them if someone wants to compile code in a more strict mode.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=249775&r1=249774&r2=249775&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct  8 18:13:28 2015
@@ -694,9 +694,9 @@ def fmacro_backtrace_limit_EQ : Joined<[
 Group, Flags<[DriverOption, 
CoreOption]>;
 def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group;
 def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
-def fms_extensions : Flag<["-"], "fms-extensions">, Group, 
Flags<[CC1Option]>,
+def fms_extensions : Flag<["-"], "fms-extensions">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">;
-def fms_compatibility : Flag<["-"], "fms-compatibility">, Group, 
Flags<[CC1Option]>,
+def fms_compatibility : Flag<["-"], "fms-compatibility">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Enable full Microsoft Visual C++ compatibility">;
 def fms_volatile : Joined<["-"], "fms-volatile">, Group, 
Flags<[CC1Option]>;
 def fmsc_version : Joined<["-"], "fmsc-version=">, Group, 
Flags<[DriverOption, CoreOption]>,
@@ -842,8 +842,10 @@ def fmodule_file_deps : Flag <["-"], "fm
   Flags<[DriverOption]>;
 def fno_module_file_deps : Flag <["-"], "fno-module-file-deps">, 
Group,
   Flags<[DriverOption]>;
-def fno_ms_extensions : Flag<["-"], "fno-ms-extensions">, Group;
-def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group;
+def fno_ms_extensions : Flag<["-"], "fno-ms-extensions">, Group,
+  Flags<[CoreOption]>;
+def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group,
+  Flags<[CoreOption]>;
 def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=249775&r1=249774&r2=249775&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Thu Oct  8 18:13:28 2015
@@ -411,6 +411,10 @@
 // RUN: -fno-strict-aliasing \
 // RUN: -fstrict-aliasing \
 // RUN: -fsyntax-only \
+// RUN: -fms-compatibility \
+// RUN: -fno-ms-compatibility \
+// RUN: -fms-extensions \
+// RUN: -fno-ms-extensions \
 // RUN: -mllvm -disable-llvm-optzns \
 // RUN: -Wunused-variable \
 // RUN: -fmacro-backtrace-limit=0 \


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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Moved the test.
Feel free to commit it for me :)


On Oct 8, 2015, at 3:29 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

Please add the test to some existing test file for the ownership_takes 
attribute, such as test/Sema/attr-ownership.c. Otherwise, LGTM.

On Thu, Oct 8, 2015 at 3:25 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:
Yay! It worked, thank you!


On Oct 8, 2015, at 3:10 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:59 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:
Same story:
 warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) void f();
   ^

Oh, I see, you're building in C, and the diagnostic here is broken (we give the 
"only applies to functions" diagnostic when it's applied to a function without 
a prototype). =( Aaron, can I tempt you to fix that? ;)

Try this one:

__attribute__((ownership_takes(__, 1))) void f(void*);
On Oct 8, 2015, at 2:52 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:

On Oct 8, 2015, at 2:17 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix

Please add a testcase ("__attribute__((ownership_takes(__))) void f();" maybe?).
I tried different attributes but none of them triggers the assert though. They 
all spit out warning:
warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) f();
   ^

You missed the 'void'.

Do you have some other idea?



The '&&' should go at the end of the previous line.

Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> mailto:aa...@aaronballman.com>> wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> mailto:rich...@metafoo.co.uk>> wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> mailto:aa...@aaronballman.com>>
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> mailto:rich...@metafoo.co.uk>>
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
 mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to b

Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-10-08 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang-c/Index.h:3815-3823
@@ -3814,2 +3814,11 @@
 
 /**
+ * \brief Returns true if a variable with function scope is a non-static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_hasLocalStorage(CXCursor C);
+
+/*
+ * \brief  Returns true if a variable with function scope is a static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_isStaticLocal(CXCursor C);
+

It might be better to combine these into a single function (`getLocalVarKind`?) 
returning an enum { not local, non-static local, static local }.


http://reviews.llvm.org/D10834



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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
Please add the test to some existing test file for the ownership_takes
attribute, such as test/Sema/attr-ownership.c. Otherwise, LGTM.

On Thu, Oct 8, 2015 at 3:25 PM, Adrian Zgorzalek  wrote:

> Yay! It worked, thank you!
>
>
> On Oct 8, 2015, at 3:10 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:59 PM, Adrian Zgorzalek  wrote:
>
> Same story:
>  warning: 'ownership_takes' attribute only applies to functions
> [-Wignored-attributes]
> __attribute__((ownership_takes(__))) void f();
>^
>
>
> Oh, I see, you're building in C, and the diagnostic here is broken (we
> give the "only applies to functions" diagnostic when it's applied to a
> function without a prototype). =( Aaron, can I tempt you to fix that? ;)
>
> Try this one:
>
> __attribute__((ownership_takes(__, 1))) void f(void*);
>
> On Oct 8, 2015, at 2:52 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek  wrote:
>
>
> On Oct 8, 2015, at 2:17 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> You are right, my bad, I thought this if covers all the cases, but 
> part could be empty.
>
> Here is the fix
>
>
> Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
> maybe?).
>
> I tried different attributes but none of them triggers the assert though.
> They all spit out warning:
> warning: 'ownership_takes' attribute only applies to functions
> [-Wignored-attributes]
> __attribute__((ownership_takes(__))) f();
>^
>
>
> You missed the 'void'.
>
>
> Do you have some other idea?
>
>
>
> The '&&' should go at the end of the previous line.
>
> Adrian
> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> wrote:
> >
> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> wrote:
> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
> >> wrote:
> >>>
> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
> >>> wrote:
>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>   wrote:
> >
> > Author: aaronballman
> > Date: Thu Oct  8 14:24:08 2015
> > New Revision: 249721
> >
> > URL:
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> > Log:
> > When mapping no_sanitize_* attributes to no_sanitize attributes,
> handle
> > GNU-style formatting that involves prefix and suffix underscores.
> > Cleans up
> > other usages of similar functionality.
> >
> > Patch by Adrian Zgorzalek!
> >
> > Modified:
> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > URL:
> >
> >
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
> >
> >
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> > AssumeAlignedAttr(AttrRange, Context, E, OE,
> > SpellingListIndex));
> > }
> >
> > +/// Normalize the attribute, __foo__ becomes foo.
> > +/// Returns true if normalization was applied.
> > +static bool normalizeName(StringRef &AttrName) {
> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> > +assert(AttrName.size() > 4 && "Name too short");
> 
> 
>  This assert will fire on the strings __, ___, and , which are
> valid
>  in
>  some of the below cases.
> >>>
> >>> That assert won't fire on anything but  because it's &&, not ||.
> >>
> >>
> >> I disagree. __ starts with __ and ends with __. The right thing to do
> here
> >> is remove the assert and put back the AttrName.size() > 4 check that the
> >> callers used to have.
> >
> > Hah, you are correct. I hadn't considered that point. I agree with you.
> :-)
> >
> > ~Aaron
> >
> >>
> >>> I
> >>> don't think these names were intended to be valid in their uses.
> >>> However, you are correct that this will trigger assertions instead of
> >>> diagnostics. Adrian, can you investigate?
> >>>
> 
> >
> > +AttrName = AttrName.drop_front(2).drop_back

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow 
wrote:

> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith 
> wrote:
>
>> . This one is tricky:
>>
>> 1) There's an (undocumented) interface between the C standard library and
>> this header, where the macros __need_ptrdiff_t, __need_size_t,
>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
>> header rather than the whole thing. If we see any of those, just go
>> straight to the underlying header.
>>
>
> Ok, but in that case we don't get nullptr.  I suspect that's OK.
>
>
>> 2) We probably don't want  to include  (for
>> consistency with other headers)
>>
>
> No, we do not! :-)
>
>
>> , but  must provide a ::nullptr_t (which we don't want
>>  to provide). So neither header includes the other. Instead, both
>> include <__nullptr> for std::nullptr_t, and we duplicate the definition of
>> max_align_t between them, in the case where the compiler's 
>> doesn't provide it.
>>
>> If you prefer, I could make  include  to avoid the
>> duplication of the max_align_t logic.
>>
>
> No; this is a minor annoyance, and layer jumping ( including
> ) is a major annoyance - and I'm pretty sure that that would come
> back to bite us in the future.
>
> Looks ok to me.
>

Thanks, everything up to and including patch 09 is now committed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249761 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 17:25:27 2015
New Revision: 249761

URL: http://llvm.org/viewvc/llvm-project?rev=249761&view=rev
Log:
Split  out of .

There are a bunch of macros (__need_size_t etc) that request just one piece of
; if any one of these is defined, we just directly include the
underlying header.

Note that  provides a ::nullptr_t. We don't want that available to
includers of , so instead of following the usual pattern where 
includes  then pulls things from :: into std:: with using-declarations,
we implement  and  separately; both include <__nullptr> for
the definition of std::nullptr_t.

Added:
libcxx/trunk/include/stddef.h
  - copied, changed from r249737, libcxx/trunk/include/cstddef
Modified:
libcxx/trunk/include/cstddef
libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=249761&r1=249760&r2=249761&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Oct  8 17:25:27 2015
@@ -34,10 +34,10 @@ Types:
 */
 
 #include <__config>
+// Don't include our own ; we don't want to declare ::nullptr_t.
+#include_next 
 #include <__nullptr>
 
-#include 
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif

Copied: libcxx/trunk/include/stddef.h (from r249737, 
libcxx/trunk/include/cstddef)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stddef.h?p2=libcxx/trunk/include/stddef.h&p1=libcxx/trunk/include/cstddef&r1=249737&r2=249761&rev=249761&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/stddef.h Thu Oct  8 17:25:27 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cstddef 
--===//
+//===--- stddef.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,20 +8,21 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSTDDEF
-#define _LIBCPP_CSTDDEF
+#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
+defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+#include_next 
+
+#elif !defined(_LIBCPP_STDDEF_H)
+#define _LIBCPP_STDDEF_H
 
 /*
-cstddef synopsis
+stddef.h synopsis
 
 Macros:
 
 offsetof(type,member-designator)
 NULL
 
-namespace std
-{
-
 Types:
 
 ptrdiff_t
@@ -29,31 +30,27 @@ Types:
 max_align_t
 nullptr_t
 
-}  // std
-
 */
 
 #include <__config>
-#include <__nullptr>
-
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#ifdef __cplusplus
 
-using ::ptrdiff_t;
-using ::size_t;
+extern "C++" {
+#include <__nullptr>
+using std::nullptr_t;
+}
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
 // Re-use the compiler's  max_align_t where possible.
-using ::max_align_t;
-#else
+#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T)
 typedef long double max_align_t;
 #endif
 
-_LIBCPP_END_NAMESPACE_STD
+#endif
 
-#endif  // _LIBCPP_CSTDDEF
+#endif  // _LIBCPP_STDDEF_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp?rev=249761&r1=249760&r2=249761&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stddef_h.pass.cpp Thu Oct  8 
17:25:27 2015
@@ -10,6 +10,7 @@
 // 
 
 #include 
+#include 
 #include 
 
 #ifndef NULL
@@ -22,6 +23,9 @@
 
 int main()
 {
+void *p = NULL;
+assert(!p);
+
 static_assert(sizeof(size_t) == sizeof(void*),
   "sizeof(size_t) == sizeof(void*)");
 static_assert(std::is_unsigned::value,
@@ -34,4 +38,22 @@ int main()
   "std::is_signed::value");
 static_assert(std::is_integral::value,
   "std::is_integral::value");
+static_assert(std::is_same::value,
+  "decltype(nullptr) == nullptr_t");
+static_assert(sizeof(nullptr_t) == sizeof(void*),
+  "sizeof(nullptr_t) == sizeof(void*)");
+static_assert(std::is_pod::value,
+  "std::is_pod::value");
+static_assert((std::alignment_of::value >=
+  std::alignment_of::value),
+  "std::alignment_of::value >= "
+  "std::alignment_of::value");
+static_assert(std::alignment_of::value >=
+  std::alignment_of::value,
+  "std::alignment_of::value >= "
+  "std::align

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Yay! It worked, thank you!


On Oct 8, 2015, at 3:10 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:59 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:
Same story:
 warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) void f();
   ^

Oh, I see, you're building in C, and the diagnostic here is broken (we give the 
"only applies to functions" diagnostic when it's applied to a function without 
a prototype). =( Aaron, can I tempt you to fix that? ;)

Try this one:

__attribute__((ownership_takes(__, 1))) void f(void*);
On Oct 8, 2015, at 2:52 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:

On Oct 8, 2015, at 2:17 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix

Please add a testcase ("__attribute__((ownership_takes(__))) void f();" maybe?).
I tried different attributes but none of them triggers the assert though. They 
all spit out warning:
warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) f();
   ^

You missed the 'void'.

Do you have some other idea?



The '&&' should go at the end of the previous line.

Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> mailto:aa...@aaronballman.com>> wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> mailto:rich...@metafoo.co.uk>> wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> mailto:aa...@aaronballman.com>>
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> mailto:rich...@metafoo.co.uk>>
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
 mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, 

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 2:59 PM, Adrian Zgorzalek  wrote:

> Same story:
>  warning: 'ownership_takes' attribute only applies to functions
> [-Wignored-attributes]
> __attribute__((ownership_takes(__))) void f();
>^
>

Oh, I see, you're building in C, and the diagnostic here is broken (we give
the "only applies to functions" diagnostic when it's applied to a function
without a prototype). =( Aaron, can I tempt you to fix that? ;)

Try this one:

__attribute__((ownership_takes(__, 1))) void f(void*);

> On Oct 8, 2015, at 2:52 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek  wrote:
>
>>
>> On Oct 8, 2015, at 2:17 PM, Richard Smith  wrote:
>>
>> On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> You are right, my bad, I thought this if covers all the cases, but 
>>> part could be empty.
>>>
>>> Here is the fix
>>>
>>
>> Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
>> maybe?).
>>
>> I tried different attributes but none of them triggers the assert though.
>> They all spit out warning:
>> warning: 'ownership_takes' attribute only applies to functions
>> [-Wignored-attributes]
>> __attribute__((ownership_takes(__))) f();
>>^
>>
>
> You missed the 'void'.
>
>
>> Do you have some other idea?
>>
>>
>>
>> The '&&' should go at the end of the previous line.
>>
>> Adrian
>>> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
>>> wrote:
>>> >
>>> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
>>> wrote:
>>> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman >> >
>>> >> wrote:
>>> >>>
>>> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith >> >
>>> >>> wrote:
>>>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>>>   wrote:
>>> >
>>> > Author: aaronballman
>>> > Date: Thu Oct  8 14:24:08 2015
>>> > New Revision: 249721
>>> >
>>> > URL:
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
>>> > Log:
>>> > When mapping no_sanitize_* attributes to no_sanitize attributes,
>>> handle
>>> > GNU-style formatting that involves prefix and suffix underscores.
>>> > Cleans up
>>> > other usages of similar functionality.
>>> >
>>> > Patch by Adrian Zgorzalek!
>>> >
>>> > Modified:
>>> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>>> >
>>> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> > URL:
>>> >
>>> >
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>>> >
>>> >
>>> >
>>> ==
>>> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>>> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>>> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>>> > AssumeAlignedAttr(AttrRange, Context, E, OE,
>>> > SpellingListIndex));
>>> > }
>>> >
>>> > +/// Normalize the attribute, __foo__ becomes foo.
>>> > +/// Returns true if normalization was applied.
>>> > +static bool normalizeName(StringRef &AttrName) {
>>> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>>> > +assert(AttrName.size() > 4 && "Name too short");
>>> 
>>> 
>>>  This assert will fire on the strings __, ___, and , which are
>>> valid
>>>  in
>>>  some of the below cases.
>>> >>>
>>> >>> That assert won't fire on anything but  because it's &&, not ||.
>>> >>
>>> >>
>>> >> I disagree. __ starts with __ and ends with __. The right thing to do
>>> here
>>> >> is remove the assert and put back the AttrName.size() > 4 check that
>>> the
>>> >> callers used to have.
>>> >
>>> > Hah, you are correct. I hadn't considered that point. I agree with
>>> you. :-)
>>> >
>>> > ~Aaron
>>> >
>>> >>
>>> >>> I
>>> >>> don't think these names were intended to be valid in their uses.
>>> >>> However, you are correct that this will trigger assertions instead of
>>> >>> diagnostics. Adrian, can you investigate?
>>> >>>
>>> 
>>> >
>>> > +AttrName = AttrName.drop_front(2).drop_back(2);
>>> > +return true;
>>> > +  }
>>> > +  return false;
>>> >

Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-10-08 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:6311-6314
@@ +6310,6 @@
+  QualType BaseType;
+  if (auto *E = Base.dyn_cast())
+BaseType = E->getType();
+  else
+BaseType = Base.get()->getType();
+  // The outermost BaseType may be a pointer if we got an expression like

`BaseType = getType(Base);`


Comment at: lib/AST/ExprConstant.cpp:6315-6318
@@ +6314,6 @@
+BaseType = Base.get()->getType();
+  // The outermost BaseType may be a pointer if we got an expression like
+  // `Foo->Bar`.
+  if (BaseType->isPointerType())
+BaseType = BaseType->getPointeeType();
+

This seems like the wrong way to handle this case (we'll be computing the wrong 
type for such `LValue`s in other cases). In 
`LValueExprEvaluatorBase::VisitMemberExpr`, we should use

  Result.setInvalid(E);
  return false;

instead of

  Result.setInvalid(E->getBase());
  // fall through to perform member access

I thought we'd already made that change, but it appears not.


Comment at: lib/AST/ExprConstant.cpp:6331-6333
@@ +6330,5 @@
+  BaseType = CAT->getElementType();
+} else if (BaseType->isAnyComplexType()) {
+  auto *CT = BaseType->castAs();
+  BaseType = CT->getElementType();
+} else if (auto *FD = getAsField(LVal.Designator.Entries[I])) {

You should check that the `ArrayIndex` is 1 in this case (a pointer to the 
`__real__` component doesn't point to the end of the object).


Comment at: lib/AST/ExprConstant.cpp:6343-6348
@@ +6342,8 @@
+} else {
+  // Don't update BaseType because we don't want to answer 'true' in:
+  // struct Base { char Foo[1]; };
+  // struct Derived : public Base { char Bar[1]; } d;
+  // __builtin_object_size(((Base*)&d)->Foo, 1)
+  assert(getAsBaseClass(LVal.Designator.Entries[I]) != nullptr &&
+  "Expecting cast to a base class");
+}

Not updating `BaseType` will cause odd things to happen on the later iterations 
of this loop. You should probably just `return false` here.


http://reviews.llvm.org/D12821



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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Same story:
 warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) void f();
   ^
On Oct 8, 2015, at 2:52 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek 
mailto:a...@fb.com>> wrote:

On Oct 8, 2015, at 2:17 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix

Please add a testcase ("__attribute__((ownership_takes(__))) void f();" maybe?).
I tried different attributes but none of them triggers the assert though. They 
all spit out warning:
warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) f();
   ^

You missed the 'void'.

Do you have some other idea?



The '&&' should go at the end of the previous line.

Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> mailto:aa...@aaronballman.com>> wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> mailto:rich...@metafoo.co.uk>> wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> mailto:aa...@aaronballman.com>>
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> mailto:rich...@metafoo.co.uk>>
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
 mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>   // This attribute must be applied to a function declaration. The
> first
>   // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>   StringRef ModuleName = Module->getName();
> -  if (Modul

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread via cfe-commits

Yes, these are functionally equivalent. However, the difference between
these two is that the call to f() in 1st is in sub-expression of throw
statement, while the call in 2nd is not.
If the call is in the sub-expression of throw statements, we can guarantee
that the call is only invoked to be thrown. I just wanted to chase this
clear case.



> On Thu, Oct 8, 2015 at 9:54 AM,  wrote:
>
>> > I think this actually makes it less general. You would presumably
>> perform
>> > different inlining for:
>> >
>> >   throw f(x, y);
>> >
>> > versus
>> >
>> >   auto k = f(x, y);
>> >   throw k;
>>
>> We need to differentiate between these two. For the second case, we
>> should
>> not add any attribute because it’s not invoked in the EH region and it
>> could have any other purposes other than exception handling. I believe
>> we
>> need to specifically handle only the case where we can guarantee that
>> the
>> call is invoked only in exception handling context.
>
>
> Modulo copying the value returned by f, those two are equivalent, and it's
> entirely reasonable to want to refactor one into the other. Such
> refactoring should not affect the optimizer's behavior on this code. Why
> do
> you think they should be treated differently?
>


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


Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-08 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 36897.
beanz added a comment.

Updates to fix dependency mapping.

Compiler-rt will be cleaned and rebuilt if clang changes and reconfigured if 
llvm-config or clang changes.


http://reviews.llvm.org/D13399

Files:
  runtime/CMakeLists.txt

Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -24,85 +24,101 @@
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
-  if(CMAKE_GENERATOR MATCHES "Ninja")
-message(FATAL_ERROR
-"Ninja generator can't build compiler-rt as ExternalProject."
-"Unset LLVM_BUILD_EXTERNAL_COMPILER_RT, or don't use Ninja."
-"See http://www.cmake.org/Bug/view.php?id=14771";)
+  if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
+set(cmake_3_4_USES_TERMINAL_OPTIONS
+  USES_TERMINAL_CONFIGURE 1
+  USES_TERMINAL_BUILD 1
+  USES_TERMINAL_INSTALL 1
+  )
   endif()
 
   # Add compiler-rt as an external project.
   set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
-  
+
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+
+  add_custom_target(compiler-rt-clear
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
+COMMENT "Clobberring compiler-rt build and stamp directories"
+)
+
   ExternalProject_Add(compiler-rt
 PREFIX ${COMPILER_RT_PREFIX}
 SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
-CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+STAMP_DIR ${STAMP_DIR}
+BINARY_DIR ${BINARY_DIR}
+CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
+   -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
-   -DCMAKE_BUILD_TYPE=Release
+   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-   -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
+   -DCOMPILER_RT_INSTALL_PATH=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
+${cmake_3_4_USES_TERMINAL_OPTIONS}
 )
-  # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
-  # in CMake 2.8.9 and 2.8.10.
-  add_dependencies(compiler-rt llvm-config clang)
-
-  # Add a custom step to always re-configure compiler-rt (in case some of its
-  # sources have changed).
-  ExternalProject_Add_Step(compiler-rt force-reconfigure
-DEPENDERS configure
-ALWAYS 1
+
+  get_ext_project_build_command(run_clean_compiler_rt clean)
+  ExternalProject_Add_Step(compiler-rt clean
+COMMAND ${run_clean_compiler_rt}
+COMMENT "Cleaning compiler-rt..."
+DEPENDEES configure
+DEPENDERS build
+DEPENDS clang
+WORKING_DIRECTORY ${BINARY_DIR}
 )
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
+  add_dependencies(compiler-rt-configure clang llvm-config)
 
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  install(CODE "execute_process\(COMMAND ${CMAKE_COMMAND} -P ${BINARY_DIR}/cmake_install.cmake \)"
+COMPONENT compiler-rt)
+
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt
+COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=compiler-rt
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
 get_ext_project_build_command(build_runtime_cmd ${runtime})
 add_custom_target(${runtime}
   COMMAND ${build_runtime_cmd}
   DEPENDS compiler-rt-configure
-  WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
+  WORKING_DIRECTORY ${BINARY_DIR}
   VERBATIM)
   endforeach()
 
-  # Add binaries that compiler-rt tests depend on.
-  set(COMPILER_RT_TEST_DEPENDENCIES
-FileCheck count not llvm-nm llvm-symbolizer)
-
-  # Add top-level targets fo

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek  wrote:

>
> On Oct 8, 2015, at 2:17 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> You are right, my bad, I thought this if covers all the cases, but 
>> part could be empty.
>>
>> Here is the fix
>>
>
> Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
> maybe?).
>
> I tried different attributes but none of them triggers the assert though.
> They all spit out warning:
> warning: 'ownership_takes' attribute only applies to functions
> [-Wignored-attributes]
> __attribute__((ownership_takes(__))) f();
>^
>

You missed the 'void'.


> Do you have some other idea?
>
>
>
> The '&&' should go at the end of the previous line.
>
> Adrian
>> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
>> wrote:
>> >
>> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
>> wrote:
>> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> >> wrote:
>> >>>
>> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>> >>> wrote:
>>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>>   wrote:
>> >
>> > Author: aaronballman
>> > Date: Thu Oct  8 14:24:08 2015
>> > New Revision: 249721
>> >
>> > URL:
>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
>> > Log:
>> > When mapping no_sanitize_* attributes to no_sanitize attributes,
>> handle
>> > GNU-style formatting that involves prefix and suffix underscores.
>> > Cleans up
>> > other usages of similar functionality.
>> >
>> > Patch by Adrian Zgorzalek!
>> >
>> > Modified:
>> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> > URL:
>> >
>> >
>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>> >
>> >
>> >
>> ==
>> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>> > AssumeAlignedAttr(AttrRange, Context, E, OE,
>> > SpellingListIndex));
>> > }
>> >
>> > +/// Normalize the attribute, __foo__ becomes foo.
>> > +/// Returns true if normalization was applied.
>> > +static bool normalizeName(StringRef &AttrName) {
>> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> > +assert(AttrName.size() > 4 && "Name too short");
>> 
>> 
>>  This assert will fire on the strings __, ___, and , which are
>> valid
>>  in
>>  some of the below cases.
>> >>>
>> >>> That assert won't fire on anything but  because it's &&, not ||.
>> >>
>> >>
>> >> I disagree. __ starts with __ and ends with __. The right thing to do
>> here
>> >> is remove the assert and put back the AttrName.size() > 4 check that
>> the
>> >> callers used to have.
>> >
>> > Hah, you are correct. I hadn't considered that point. I agree with you.
>> :-)
>> >
>> > ~Aaron
>> >
>> >>
>> >>> I
>> >>> don't think these names were intended to be valid in their uses.
>> >>> However, you are correct that this will trigger assertions instead of
>> >>> diagnostics. Adrian, can you investigate?
>> >>>
>> 
>> >
>> > +AttrName = AttrName.drop_front(2).drop_back(2);
>> > +return true;
>> > +  }
>> > +  return false;
>> > +}
>> > +
>> > static void handleOwnershipAttr(Sema &S, Decl *D, const
>> AttributeList
>> > &AL) {
>> >   // This attribute must be applied to a function declaration. The
>> > first
>> >   // argument to the attribute must be an identifier, the name of
>> the
>> > resource,
>> > @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>> >
>> >   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>> >
>> > -  // Normalize the argument, __foo__ becomes foo.
>> >   StringRef ModuleName = Module->getName();
>> > -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> > -  ModuleName.size() > 4) {
>> > -ModuleName = 

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits

On Oct 8, 2015, at 2:17 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix

Please add a testcase ("__attribute__((ownership_takes(__))) void f();" maybe?).
I tried different attributes but none of them triggers the assert though. They 
all spit out warning:
warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) f();
   ^

Do you have some other idea?



The '&&' should go at the end of the previous line.

Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> mailto:aa...@aaronballman.com>> wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> mailto:rich...@metafoo.co.uk>> wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> mailto:aa...@aaronballman.com>>
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> mailto:rich...@metafoo.co.uk>>
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
 mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>   // This attribute must be applied to a function declaration. The
> first
>   // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>   StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
> Module = &S.PP.getIdentifierTable().get(ModuleName);
>   }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>   Id

Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-10-08 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Friendly Ping™


http://reviews.llvm.org/D12821



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


Re: Implict casts disappeared from syntactic init list expressions in C++

2015-10-08 Thread Richard Smith via cfe-commits
There are some other open problems in this area:

- RecursiveASTVisitor on nested InitListExprs is currently worst-case
exponential time because it walks the syntactic and semantic forms
separately
- Tools such as "find all references to this function" need the semantic
form of every initializer, whether or not that initializer is actually used
for the initialization (it might be overridden through the use of a
designator)
- ...

Having thought about this for a while, I think the right answer is this:

The only difference between the syntactic and semantic forms of an
InitListExpr should be designated initializers and brace elision. In all
other respects, the syntactic and semantic forms should be identical -- in
particular, both should contain the results of performing the relevant
initialization sequences on the list elements, and we should extend the
syntactic form to include the implicit initializations for trailing
elements.

With that in hand, we should make RecursiveASTVisitor visit /only/ the
syntactic form. The semantic ("simplified") form should only be used in
places where we want to know the semantic effect of the initialization
(after applying the designated initialization overriding rules and
inserting the elided braces), and is always derivable in a fairly
straightforward fashion from the syntactic form.

I think that's largely what you were suggesting below. Do you agree?

On Wed, Oct 7, 2015 at 11:54 PM, Abramo Bagnara 
wrote:

> Ping^2
>
> Il 12/09/2015 09:40, Abramo Bagnara ha scritto:
> > Ping...
> >
> > Il 29/08/2015 10:01, Abramo Bagnara ha scritto:
> >> Il 28/08/2015 23:27, Richard Smith ha scritto:
> >>> On Tue, Aug 25, 2015 at 10:27 AM, Abramo Bagnara
> >>> mailto:abramo.bagn...@bugseng.com>>
> wrote:
> >>>
> >>> Comparing the result of InitListExpr::getSyntacticForm between
> r224986
> >>> and r245836 I've discovered that integer to char implicit cast for
> >>> integer literal 3 is no longer added to AST for C++ (while it is
> present
> >>> in C).
> >>>
> >>> This is the source used to test:
> >>>
> >>> char v[10] = { 3 };
> >>>
> >>> Taken in account that:
> >>>
> >>> - implicit cast (and other conversions, constructor calls, etc.)
> are
> >>> very important also for who need to visit the syntactic form
> (obvious in
> >>> *both* C and C++)
> >>>
> >>> - to generate that for the syntactic form permit to increase the
> >>> efficiency and the sharing when using designated range extensions
> (as
> >>> the conversion chain don't need to be replicated for each entry)
> >>>
> >>> I think it is a regression. Am I missing something?
> >>>
> >>>
> >>> Why do you expect this semantic information to appear in the syntactic
> >>> form of the initializer?
> >>
> >> Compare:
> >>
> >> int x = 2.0;
> >>
> >> with
> >>
> >> struct s {
> >>   int x;
> >> } v = { .x = 2.0 };
> >>
> >> For first declaration I have non-syntactic nodes (namely
> >> ImplicitCastExpr) along with syntactic nodes, while for the second I
> >> don't have that (for C++). This is an obstacle to write semi-syntactic
> >> checkers that aims to find e.g. implicit cast from double to int in its
> >> syntactic context.
> >> Note that although we might visit the semantic form, we'll lose the
> >> designators (not present in semantic form).
> >>
> >> To resume, the reason why I would expect that are:
> >>
> >> 1) this is how it always has worked for C (and fortunately still works
> >> this way)
> >>
> >>
> >> 2) this is how it always has worked (although partially, there was some
> >> bugs) for C++. In past we have had patches to fix the areas where this
> >> invariant was not respected (see commit 3146766
> >>
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20111212/050339.html
> >> as an example).
> >>
> >> This behavior has changed rather recently (if you think it is useful I
> >> can find the commit that has removed the implicit casts from syntactic
> >> form in C++)
> >>
> >> Before such commit(s) the only bug I was aware where AST was missing
> >> conversion chain was the following:
> >>
> >> struct R2 {
> >>   R2(int) {
> >>   }
> >> };
> >> R2 v2[] = { 1.0 };
> >>
> >>
> >> 3) this way it would be congruent with other areas of AST where we have
> >> non-syntactic nodes along with syntactic ones
> >>
> >>
> >> 4) it would permit to share more nodes in semantic form (and avoid to
> >> rebuild many times the same conversion chain).
> >>
> >> Looking at following typescript you can observe that ImplicitCastExpr is
> >> shared only for C, but not for C++. I've initialized only two entries,
> >> but it might be 1000 or 1000.
> >>
> >> $ cat p.c
> >> int x[100] = { [0 ... 1] = 3.0 };
> >> $ clang-3.8 -cc1 -ast-dump -x c p.c
> >> TranslationUnitDecl 0x272de40 <> 
> >> |-TypedefDecl 0x272e338 <>  implicit
> >> __int128_t '__int128'
> >> |-TypedefDecl 0x272e398 <>  implicit
> >> __uint128_t 'unsigned __int128'
> >> |-TypedefDecl 0x272e648 <>  implicit
> >> __bu

Re: [PATCH] D12726: [analyzer] A fix for symbolic element region index lifetime.

2015-10-08 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Now that we have a way to test symbol reaper, please, add more coverage to the 
symbol-reaper.c test, including the test that Jordan mentioned. Even if it is 
not fixed, it's good to include it with a FIXME note.

What is the performance impact of this change?

The changes to the RegionStore and Environment seem inconsistent and 
repetitive.. For example, we can remove a lot of this just by changing 
SymbolReaper::markLive(const MemRegion *region), see below. How is this patch 
different from your solution? Can it be generalized to handle more cases?

  diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/lib/StaticAnalyzer/Core/RegionStore.cpp
  index 49b5ac3..55db545 100644
  --- a/lib/StaticAnalyzer/Core/RegionStore.cpp
  +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp
  @@ -2320,8 +2320,14 @@ void removeDeadBindingsWorker::VisitCluster(const 
MemRegion *baseR,
 if (const SymbolicRegion *SymR = dyn_cast(baseR))
   SymReaper.markLive(SymR->getSymbol());
   
  -  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I)
  +  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
  +// Mark the key of each binding as live.
  +const BindingKey &K = I.getKey();
  +if (auto subR = dyn_cast(K.getRegion()))
  +  SymReaper.markLive(subR);
  +
   VisitBinding(I.getData());
  +  }
   }
   
   void removeDeadBindingsWorker::VisitBinding(SVal V) {
  @@ -2342,6 +2348,7 @@ void removeDeadBindingsWorker::VisitBinding(SVal V) {
 // If V is a region, then add it to the worklist.
 if (const MemRegion *R = V.getAsRegion()) {
   AddToWorkList(R);
  +SymReaper.markLive(R);
   
   // All regions captured by a block are also live.
   if (const BlockDataRegion *BR = dyn_cast(R)) {
  diff --git a/lib/StaticAnalyzer/Core/SymbolManager.cpp 
b/lib/StaticAnalyzer/Core/SymbolManager.cpp
  index df4d22a..793f53e 100644
  --- a/lib/StaticAnalyzer/Core/SymbolManager.cpp
  +++ b/lib/StaticAnalyzer/Core/SymbolManager.cpp
  @@ -391,6 +391,16 @@ void SymbolReaper::markLive(SymbolRef sym) {
   
   void SymbolReaper::markLive(const MemRegion *region) {
 RegionRoots.insert(region);
  +  
  +  // Mark the element index as live.
  +  if (const ElementRegion *ER = dyn_cast(region)) {
  +SVal Idx = ER->getIndex();
  +for (SymExpr::symbol_iterator SI = Idx.symbol_begin(),
  + SE = Idx.symbol_end();
  + SI != SE; ++SI) {
  +  markLive(*SI);
  +}
  +  }
   }



Comment at: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:177
@@ +176,3 @@
+
+C.emitReport(llvm::make_unique(*BT, "SYMBOL DEAD", N));
+  }

Thank you for adding this!!! This can be part of this commit or separate; up to 
you.

Please, update the debugger checkers document in the docs folder with 
information on how this should be used.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2241
@@ +2240,3 @@
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
+
+// Mark the index symbol of any ElementRegion key as live.

Please, remove unnecessary spacing here and in a couple of other places.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2247
@@ +2246,3 @@
+  if (auto elemR = dyn_cast(subR))
+if (SymbolRef Sym = elemR->getIndex().getAsSymbol())
+  SymReaper.markLive(Sym);

Why symbol_iterator is not used here?


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2249
@@ +2248,3 @@
+  SymReaper.markLive(Sym);
+  subR = dyn_cast(subR->getSuperRegion());
+}

Could you add test cases that explain why we need the while loop here?


http://reviews.llvm.org/D12726



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


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r249751


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


r249751 - Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Thu Oct  8 16:21:44 2015
New Revision: 249751

URL: http://llvm.org/viewvc/llvm-project?rev=249751&view=rev
Log:
Use Triple.isAndroid() where possible.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 16:21:44 2015
@@ -383,7 +383,7 @@ protected:
 DefineStd(Builder, "linux", Opts);
 Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
-if (Triple.getEnvironment() == llvm::Triple::Android) {
+if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
   unsigned Maj, Min, Rev;
   Triple.getEnvironmentVersion(Maj, Min, Rev);

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Oct  8 16:21:44 2015
@@ -495,10 +495,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
 
   if (AllAddedKinds & Address) {
 AsanSharedRuntime =
-Args.hasArg(options::OPT_shared_libasan) ||
-(TC.getTriple().getEnvironment() == llvm::Triple::Android);
-AsanZeroBaseShadow =
-(TC.getTriple().getEnvironment() == llvm::Triple::Android);
+Args.hasArg(options::OPT_shared_libasan) || TC.getTriple().isAndroid();
+AsanZeroBaseShadow = TC.getTriple().isAndroid();
 if (Arg *A =
 Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
 StringRef S = A->getValue();

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Oct  8 16:21:44 2015
@@ -284,8 +284,7 @@ static StringRef getArchNameForCompilerR
 std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
  bool Shared) const {
   const llvm::Triple &TT = getTriple();
-  const char *Env =
-  (TT.getEnvironment() == llvm::Triple::Android) ? "-android" : "";
+  const char *Env = TT.isAndroid() ? "-android" : "";
   bool IsITANMSVCWindows =
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct  8 16:21:44 2015
@@ -1823,7 +1823,7 @@ static bool findMIPSMultilibs(const llvm
   addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
   addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
 
-  if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
+  if (TargetTriple.isAndroid()) {
 // Select Android toolchain. It's the only choice in that case.
 if (AndroidMipsMultilibs.select(Flags, Result.SelectedMultilib)) {
   Result.Multilibs = AndroidMipsMultilibs;
@@ -2174,8 +2174,7 @@ void Generic_ELF::addClangTargetOptions(
   getTriple().getArch() == llvm::Triple::aarch64 ||
   getTriple().getArch() == llvm::Triple::aarch64_be ||
   (getTriple().getOS() == llvm::Triple::Linux &&
-   (!V.isOlderThan(4, 7, 0) ||
-getTriple().getEnvironment() == llvm::Triple::Android)) ||
+   (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
   getTriple().getOS() == llvm::Triple::NaCl;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
@@ -3329,7 +3328,7 @@ Linux::Linux(const Driver &D, const llvm
   if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
 ExtraOpts.push_back("-X");
 
-  const bool IsAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+  const bool IsAndroid = Triple.isAndroid();
   const bool IsMips = isMipsArch(Arch);
 
   if (IsMips && !SysRoot.empty())

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct  8 16:21:44 2015
@@ -989,7 +989,7 @@ void Clan

[libcxx] r249749 - Fix incorrect file header. This is not .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 16:17:21 2015
New Revision: 249749

URL: http://llvm.org/viewvc/llvm-project?rev=249749&view=rev
Log:
Fix incorrect file header. This is  not .

Modified:
libcxx/trunk/include/cfenv

Modified: libcxx/trunk/include/cfenv
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cfenv?rev=249749&r1=249748&r2=249749&view=diff
==
--- libcxx/trunk/include/cfenv (original)
+++ libcxx/trunk/include/cfenv Thu Oct  8 16:17:21 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//=== cctype 
--===//
+//=== cfenv 
---===//
 //
 // The LLVM Compiler Infrastructure
 //


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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> You are right, my bad, I thought this if covers all the cases, but 
> part could be empty.
>
> Here is the fix
>

Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
maybe?).

The '&&' should go at the end of the previous line.

Adrian
> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> wrote:
> >
> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> wrote:
> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
> >> wrote:
> >>>
> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
> >>> wrote:
>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>   wrote:
> >
> > Author: aaronballman
> > Date: Thu Oct  8 14:24:08 2015
> > New Revision: 249721
> >
> > URL:
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> > Log:
> > When mapping no_sanitize_* attributes to no_sanitize attributes,
> handle
> > GNU-style formatting that involves prefix and suffix underscores.
> > Cleans up
> > other usages of similar functionality.
> >
> > Patch by Adrian Zgorzalek!
> >
> > Modified:
> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > URL:
> >
> >
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
> >
> >
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> > AssumeAlignedAttr(AttrRange, Context, E, OE,
> > SpellingListIndex));
> > }
> >
> > +/// Normalize the attribute, __foo__ becomes foo.
> > +/// Returns true if normalization was applied.
> > +static bool normalizeName(StringRef &AttrName) {
> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> > +assert(AttrName.size() > 4 && "Name too short");
> 
> 
>  This assert will fire on the strings __, ___, and , which are
> valid
>  in
>  some of the below cases.
> >>>
> >>> That assert won't fire on anything but  because it's &&, not ||.
> >>
> >>
> >> I disagree. __ starts with __ and ends with __. The right thing to do
> here
> >> is remove the assert and put back the AttrName.size() > 4 check that the
> >> callers used to have.
> >
> > Hah, you are correct. I hadn't considered that point. I agree with you.
> :-)
> >
> > ~Aaron
> >
> >>
> >>> I
> >>> don't think these names were intended to be valid in their uses.
> >>> However, you are correct that this will trigger assertions instead of
> >>> diagnostics. Adrian, can you investigate?
> >>>
> 
> >
> > +AttrName = AttrName.drop_front(2).drop_back(2);
> > +return true;
> > +  }
> > +  return false;
> > +}
> > +
> > static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> > &AL) {
> >   // This attribute must be applied to a function declaration. The
> > first
> >   // argument to the attribute must be an identifier, the name of the
> > resource,
> > @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
> >
> >   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
> >
> > -  // Normalize the argument, __foo__ becomes foo.
> >   StringRef ModuleName = Module->getName();
> > -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> > -  ModuleName.size() > 4) {
> > -ModuleName = ModuleName.drop_front(2).drop_back(2);
> > +  if (normalizeName(ModuleName)) {
> > Module = &S.PP.getIdentifierTable().get(ModuleName);
> >   }
> >
> > @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
> >   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
> >   StringRef Format = II->getName();
> >
> > -  // Normalize the argument, __foo__ becomes foo.
> > -  if (Format.startswith("__") && Format.endswith("__")) {
> > -Format = Format.substr(2, Format.size() - 4);
> > +  if (normalizeName(Format)) {

r249748 - [WinEH] Push cleanupendpad scopes around exceptional cleanups

2015-10-08 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct  8 16:14:56 2015
New Revision: 249748

URL: http://llvm.org/viewvc/llvm-project?rev=249748&view=rev
Log:
[WinEH] Push cleanupendpad scopes around exceptional cleanups

We were only doing this for SEH as a special case. Generalize it to all
cleanups.

Modified:
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=249748&r1=249747&r2=249748&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Thu Oct  8 16:14:56 2015
@@ -521,15 +521,6 @@ static void EmitCleanup(CodeGenFunction
 EHScopeStack::Cleanup *Fn,
 EHScopeStack::Cleanup::Flags flags,
 Address ActiveFlag) {
-  // Itanium EH cleanups occur within a terminate scope. Microsoft SEH doesn't
-  // have this behavior, and the Microsoft C++ runtime will call terminate for
-  // us if the cleanup throws.
-  bool PushedTerminate = false;
-  if (flags.isForEHCleanup() && !CGF.getTarget().getCXXABI().isMicrosoft()) {
-CGF.EHStack.pushTerminate();
-PushedTerminate = true;
-  }
-
   // If there's an active flag, load it and skip the cleanup if it's
   // false.
   llvm::BasicBlock *ContBB = nullptr;
@@ -549,10 +540,6 @@ static void EmitCleanup(CodeGenFunction
   // Emit the continuation block if there was an active flag.
   if (ActiveFlag.isValid())
 CGF.EmitBlock(ContBB);
-
-  // Leave the terminate scope.
-  if (PushedTerminate)
-CGF.EHStack.popTerminate();
 }
 
 static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit,
@@ -931,11 +918,29 @@ void CodeGenFunction::PopCleanupBlock(bo
 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
 
 EmitBlock(EHEntry);
+
+// Push terminate scopes around the potentially throwing destructor calls.
+// We don't emit these when using funclets, because the runtime does it for
+// us as part of unwinding out of a cleanuppad.
+bool PushedTerminate = false;
+if (!EHPersonality::get(*this).usesFuncletPads()) {
+  EHStack.pushTerminate();
+  PushedTerminate = true;
+}
+
 llvm::CleanupPadInst *CPI = nullptr;
+llvm::BasicBlock *CleanupEndBB = nullptr;
 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
-if (EHPersonality::get(*this).usesFuncletPads())
+if (EHPersonality::get(*this).usesFuncletPads()) {
   CPI = Builder.CreateCleanupPad({});
 
+  // Build a cleanupendpad to unwind through. Our insertion point should be
+  // in the cleanuppad block.
+  CleanupEndBB = createBasicBlock("ehcleanup.end");
+  CGBuilderTy(*this, CleanupEndBB).CreateCleanupEndPad(CPI, NextAction);
+  EHStack.pushPadEnd(CleanupEndBB);
+}
+
 // We only actually emit the cleanup code if the cleanup is either
 // active or was used before it was deactivated.
 if (EHActiveFlag.isValid() || IsActive) {
@@ -948,6 +953,21 @@ void CodeGenFunction::PopCleanupBlock(bo
 else
   Builder.CreateBr(NextAction);
 
+// Insert the cleanupendpad block here, if it has any uses.
+if (CleanupEndBB) {
+  EHStack.popPadEnd();
+  if (CleanupEndBB->hasNUsesOrMore(1)) {
+CurFn->getBasicBlockList().insertAfter(Builder.GetInsertBlock(),
+   CleanupEndBB);
+  } else {
+delete CleanupEndBB;
+  }
+}
+
+// Leave the terminate scope.
+if (PushedTerminate)
+  EHStack.popTerminate();
+
 Builder.restoreIP(SavedIP);
 
 SimplifyCleanupEntry(*this, EHEntry);

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=249748&r1=249747&r2=249748&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Oct  8 16:14:56 2015
@@ -1410,10 +1410,8 @@ void CodeGenFunction::EmitSEHTryStmt(con
 namespace {
 struct PerformSEHFinally final : EHScopeStack::Cleanup {
   llvm::Function *OutlinedFinally;
-  EHScopeStack::stable_iterator EnclosingScope;
-  PerformSEHFinally(llvm::Function *OutlinedFinally,
-EHScopeStack::stable_iterator EnclosingScope)
-  : OutlinedFinally(OutlinedFinally), EnclosingScope(EnclosingScope) {}
+  PerformSEHFinally(llvm::Function *OutlinedFinally)
+  : OutlinedFinally(OutlinedFinally) {}
 
   void Emit(CodeGenFunction &CGF, Flags F) override {
 ASTContext &Context = CGF.getContext();
@@ -1438,28 +1436,7 @@ struct PerformSEHFinally final : EHScope
 CGM.getTypes().arrangeFreeFunctionCall(Args, FPT,
/*chainCall=*/false)

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix:



Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith  wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
  wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>   // This attribute must be applied to a function declaration. The
> first
>   // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>   StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
> Module = &S.PP.getIdentifierTable().get(ModuleName);
>   }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>   StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeName(Format)) {
> // If we've modified the string name, we need a new identifier for
> it.
> II = &S.Context.Idents.get(Format);
>   }
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>   StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2,

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 9:54 AM,  wrote:

> > I think this actually makes it less general. You would presumably perform
> > different inlining for:
> >
> >   throw f(x, y);
> >
> > versus
> >
> >   auto k = f(x, y);
> >   throw k;
>
> We need to differentiate between these two. For the second case, we should
> not add any attribute because it’s not invoked in the EH region and it
> could have any other purposes other than exception handling. I believe we
> need to specifically handle only the case where we can guarantee that the
> call is invoked only in exception handling context.


Modulo copying the value returned by f, those two are equivalent, and it's
entirely reasonable to want to refactor one into the other. Such
refactoring should not affect the optimizer's behavior on this code. Why do
you think they should be treated differently?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Pending naming from llvm review, LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Eric Christopher via cfe-commits
Pending naming from llvm review, LGTM.

On Thu, Oct 8, 2015 at 1:55 PM Stephen Hines  wrote:

> srhines added a comment.
>
> LGTM
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D13572
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-08 Thread Alexey Bataev via cfe-commits
ABataev marked 2 inline comments as done.


Comment at: lib/AST/DeclPrinter.cpp:197
@@ -196,3 +196,3 @@
 
-void DeclPrinter::prettyPrintAttributes(Decl *D) {
+void DeclPrinter::prettyPrintAttributes(Decl *D, bool PrintPragmas) {
   if (Policy.PolishForDeclaration)

aaron.ballman wrote:
> Would it make more sense to add a prettyPrintPragmas(Decl *D) function 
> instead?
Ok, will do


Comment at: test/SemaCXX/pragma-init_seg.cpp:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32 -ast-print | FileCheck %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
i386-apple-darwin13.3.0

aaron.ballman wrote:
> I think this should be a new test under Misc\. We have ast-print-pragmas.cpp 
> that looks like a good place for it to go.
Ok


http://reviews.llvm.org/D13546



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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith  wrote:
> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
> wrote:
>>
>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>> wrote:
>> > On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>> >  wrote:
>> >>
>> >> Author: aaronballman
>> >> Date: Thu Oct  8 14:24:08 2015
>> >> New Revision: 249721
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
>> >> Log:
>> >> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>> >> GNU-style formatting that involves prefix and suffix underscores.
>> >> Cleans up
>> >> other usages of similar functionality.
>> >>
>> >> Patch by Adrian Zgorzalek!
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>> >>
>> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> >> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> >> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>> >>  AssumeAlignedAttr(AttrRange, Context, E, OE,
>> >> SpellingListIndex));
>> >>  }
>> >>
>> >> +/// Normalize the attribute, __foo__ becomes foo.
>> >> +/// Returns true if normalization was applied.
>> >> +static bool normalizeName(StringRef &AttrName) {
>> >> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> >> +assert(AttrName.size() > 4 && "Name too short");
>> >
>> >
>> > This assert will fire on the strings __, ___, and , which are valid
>> > in
>> > some of the below cases.
>>
>> That assert won't fire on anything but  because it's &&, not ||.
>
>
> I disagree. __ starts with __ and ends with __. The right thing to do here
> is remove the assert and put back the AttrName.size() > 4 check that the
> callers used to have.

Hah, you are correct. I hadn't considered that point. I agree with you. :-)

~Aaron

>
>> I
>> don't think these names were intended to be valid in their uses.
>> However, you are correct that this will trigger assertions instead of
>> diagnostics. Adrian, can you investigate?
>>
>> >
>> >>
>> >> +AttrName = AttrName.drop_front(2).drop_back(2);
>> >> +return true;
>> >> +  }
>> >> +  return false;
>> >> +}
>> >> +
>> >>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>> >> &AL) {
>> >>// This attribute must be applied to a function declaration. The
>> >> first
>> >>// argument to the attribute must be an identifier, the name of the
>> >> resource,
>> >> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>> >>
>> >>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>> >>
>> >> -  // Normalize the argument, __foo__ becomes foo.
>> >>StringRef ModuleName = Module->getName();
>> >> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> >> -  ModuleName.size() > 4) {
>> >> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> >> +  if (normalizeName(ModuleName)) {
>> >>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>> >>}
>> >>
>> >> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>> >>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>> >>StringRef Format = II->getName();
>> >>
>> >> -  // Normalize the argument, __foo__ becomes foo.
>> >> -  if (Format.startswith("__") && Format.endswith("__")) {
>> >> -Format = Format.substr(2, Format.size() - 4);
>> >> +  if (normalizeName(Format)) {
>> >>  // If we've modified the string name, we need a new identifier for
>> >> it.
>> >>  II = &S.Context.Idents.get(Format);
>> >>}
>> >> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>> >>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>> >>StringRef Str = Name->getName();
>> >>
>> >> -  // Normalize the attribute name, __foo__ becomes foo.
>> >> -  if (Str.startswith("__") && Str.endswith("__"))
>> >> -Str = Str.substr(2, Str.size() - 4);
>> >> +  normalizeName(Str);
>> >>
>> >>unsigned DestWidth = 0;
>> >>bool IntegerMode = true;
>> >> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>> >>
>> >>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>> >>   const AttributeList &Attr) {
>> >> +  StringRef AttrName = Attr.getName()->getName();
>> >> +  normalizeName(AttrName);
>> >>std::string SanitizerName =
>> >> -  llvm::StringSwitch(Attr.getName()->getName())
>> >> +  llvm::StringSwitch(AttrName)
>> >>.Case("no_address_safety_analysis", "address")
>> >>.Case("no_sanitize_addres

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
wrote:

> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
> wrote:
> > On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Thu Oct  8 14:24:08 2015
> >> New Revision: 249721
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
> >> Log:
> >> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> >> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> >> other usages of similar functionality.
> >>
> >> Patch by Adrian Zgorzalek!
> >>
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> >> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> >>  AssumeAlignedAttr(AttrRange, Context, E, OE,
> >> SpellingListIndex));
> >>  }
> >>
> >> +/// Normalize the attribute, __foo__ becomes foo.
> >> +/// Returns true if normalization was applied.
> >> +static bool normalizeName(StringRef &AttrName) {
> >> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> >> +assert(AttrName.size() > 4 && "Name too short");
> >
> >
> > This assert will fire on the strings __, ___, and , which are valid
> in
> > some of the below cases.
>
> That assert won't fire on anything but  because it's &&, not ||.


I disagree. __ starts with __ and ends with __. The right thing to do here
is remove the assert and put back the AttrName.size() > 4 check that the
callers used to have.

I
> don't think these names were intended to be valid in their uses.
> However, you are correct that this will trigger assertions instead of
> diagnostics. Adrian, can you investigate?
>
> >
> >>
> >> +AttrName = AttrName.drop_front(2).drop_back(2);
> >> +return true;
> >> +  }
> >> +  return false;
> >> +}
> >> +
> >>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> >> &AL) {
> >>// This attribute must be applied to a function declaration. The
> first
> >>// argument to the attribute must be an identifier, the name of the
> >> resource,
> >> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
> >>
> >>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
> >>
> >> -  // Normalize the argument, __foo__ becomes foo.
> >>StringRef ModuleName = Module->getName();
> >> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> >> -  ModuleName.size() > 4) {
> >> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> >> +  if (normalizeName(ModuleName)) {
> >>  Module = &S.PP.getIdentifierTable().get(ModuleName);
> >>}
> >>
> >> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
> >>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
> >>StringRef Format = II->getName();
> >>
> >> -  // Normalize the argument, __foo__ becomes foo.
> >> -  if (Format.startswith("__") && Format.endswith("__")) {
> >> -Format = Format.substr(2, Format.size() - 4);
> >> +  if (normalizeName(Format)) {
> >>  // If we've modified the string name, we need a new identifier for
> >> it.
> >>  II = &S.Context.Idents.get(Format);
> >>}
> >> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
> >>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
> >>StringRef Str = Name->getName();
> >>
> >> -  // Normalize the attribute name, __foo__ becomes foo.
> >> -  if (Str.startswith("__") && Str.endswith("__"))
> >> -Str = Str.substr(2, Str.size() - 4);
> >> +  normalizeName(Str);
> >>
> >>unsigned DestWidth = 0;
> >>bool IntegerMode = true;
> >> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
> >>
> >>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
> >>   const AttributeList &Attr) {
> >> +  StringRef AttrName = Attr.getName()->getName();
> >> +  normalizeName(AttrName);
> >>std::string SanitizerName =
> >> -  llvm::StringSwitch(Attr.getName()->getName())
> >> +  llvm::StringSwitch(AttrName)
> >>.Case("no_address_safety_analysis", "address")
> >>.Case("no_sanitize_address", "address")
> >>.Case("no_sanitize_thread", "thread")
> >
> >
> > Is there any way we could use the spelling list index in this case rather
> > than repeating the attribute names and __-stripping here?
>
> The spelling list index isn't exposed in a meaningful way (and I t

[libcxx] r249743 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:41:26 2015
New Revision: 249743

URL: http://llvm.org/viewvc/llvm-project?rev=249743&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/setjmp.h
  - copied, changed from r249736, libcxx/trunk/include/csetjmp
Modified:
libcxx/trunk/include/csetjmp
libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp

Modified: libcxx/trunk/include/csetjmp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/csetjmp?rev=249743&r1=249742&r2=249743&view=diff
==
--- libcxx/trunk/include/csetjmp (original)
+++ libcxx/trunk/include/csetjmp Thu Oct  8 15:41:26 2015
@@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val);
 #pragma GCC system_header
 #endif
 
-#ifndef setjmp
-#define setjmp(env) setjmp(env)
-#endif
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::jmp_buf;

Copied: libcxx/trunk/include/setjmp.h (from r249736, 
libcxx/trunk/include/csetjmp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/setjmp.h?p2=libcxx/trunk/include/setjmp.h&p1=libcxx/trunk/include/csetjmp&r1=249736&r2=249743&rev=249743&view=diff
==
--- libcxx/trunk/include/csetjmp (original)
+++ libcxx/trunk/include/setjmp.h Thu Oct  8 15:41:26 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- csetjmp 
--===//
+//===--- setjmp.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,31 +8,26 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSETJMP
-#define _LIBCPP_CSETJMP
+#ifndef _LIBCPP_SETJMP_H
+#define _LIBCPP_SETJMP_H
 
 /*
-csetjmp synopsis
+setjmp.h synopsis
 
 Macros:
 
 setjmp
 
-namespace std
-{
-
 Types:
 
 jmp_buf
 
 void longjmp(jmp_buf env, int val);
 
-}  // std
-
 */
 
 #include <__config>
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -42,11 +37,4 @@ void longjmp(jmp_buf env, int val);
 #define setjmp(env) setjmp(env)
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::jmp_buf;
-using ::longjmp;
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif  // _LIBCPP_CSETJMP
+#endif  // _LIBCPP_SETJMP_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp?rev=249743&r1=249742&r2=249743&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp Thu Oct  8 
15:41:26 2015
@@ -12,6 +12,10 @@
 #include 
 #include 
 
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
 int main()
 {
 jmp_buf jb;


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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Hey!

I think you are right. This will not regress any of the cases, because previous 
behaviour either checked str.size() >= 4 OR didn’t check it at all, but then 
called .substr(2, str.size() - 4), which would crash. I think, though, that 
explicitly checking str.size() >= 4 makes sense. See comments below.
I will have a patch to fix it up. See comments below.

Adrian
> On Oct 8, 2015, at 1:21 PM, Aaron Ballman  wrote:
> 
> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith  wrote:
>> On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>>  wrote:
>>> 
>>> Author: aaronballman
>>> Date: Thu Oct  8 14:24:08 2015
>>> New Revision: 249721
>>> 
>>> URL: 
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=I7JuuiH4eEYBv1meYlgoiyDdl9yvM1r3kGhI0NE1f2g%3D%0A&s=4eae7d09ce0f4330138bcb73d7c5b39ae009250829081e6ef41033dc71e8bfc4
>>> Log:
>>> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>>> GNU-style formatting that involves prefix and suffix underscores. Cleans up
>>> other usages of similar functionality.
>>> 
>>> Patch by Adrian Zgorzalek!
>>> 
>>> Modified:
>>>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>>> 
>>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> URL:
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=I7JuuiH4eEYBv1meYlgoiyDdl9yvM1r3kGhI0NE1f2g%3D%0A&s=d7e208b0f19fa5d62b635aab96f22ed209d3ffb85762228e4cd2f87ff1cf1983
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>>> AssumeAlignedAttr(AttrRange, Context, E, OE,
>>> SpellingListIndex));
>>> }
>>> 
>>> +/// Normalize the attribute, __foo__ becomes foo.
>>> +/// Returns true if normalization was applied.
>>> +static bool normalizeName(StringRef &AttrName) {
>>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {

I will make it:
+  if (AttrName.size() >= 4 && AttrName.startswith("__") && 
AttrName.endswith("__”)) {

>>> 
>>> +assert(AttrName.size() > 4 && "Name too short");
>> 
>> 
>> This assert will fire on the strings __, ___, and , which are valid in
>> some of the below cases.
> 
> That assert won't fire on anything but  because it's &&, not ||. I
> don't think these names were intended to be valid in their uses.
> However, you are correct that this will trigger assertions instead of
> diagnostics. Adrian, can you investigate?
> 
>> 
>>> 
>>> +AttrName = AttrName.drop_front(2).drop_back(2);
>>> +return true;
>>> +  }
>>> +  return false;
>>> +}
>>> +
>>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>>> &AL) {
>>>   // This attribute must be applied to a function declaration. The first
>>>   // argument to the attribute must be an identifier, the name of the
>>> resource,
>>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>>> 
>>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>> 
>>> -  // Normalize the argument, __foo__ becomes foo.
>>>   StringRef ModuleName = Module->getName();
>>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>>> -  ModuleName.size() > 4) {
Checks size, so is fine.
>>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>>> +  if (normalizeName(ModuleName)) {
>>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>>   }
>>> 
>>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Format = II->getName();
>>> 
>>> -  // Normalize the argument, __foo__ becomes foo.
>>> -  if (Format.startswith("__") && Format.endswith("__")) {
>>> -Format = Format.substr(2, Format.size() - 4);
- 4, so it would crash if shorter than 4 chars
>> 
>>> +  if (normalizeName(Format)) {
>>> // If we've modified the string name, we need a new identifier for
>>> it.
>>> II = &S.Context.Idents.get(Format);
>>>   }
>>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Str = Name->getName();
>>> 
>>> -  // Normalize the attribute name, __foo__ becomes foo.
>>> -  if (Str.startswith("__") && Str.endswith("__"))
>>> -Str = Str.substr(2, Str.size() - 4);
>>> +  normalizeName(Str);
>>> 
- 4, so it would crash if shorter than 4 chars
>>>   unsigned DestWidth = 0;
>>>   bool IntegerMode = true;
>>> @@ -4533,

[PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added a reviewer: echristo.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.

Depends on http://reviews.llvm.org/D13571

Repository:
  rL LLVM

http://reviews.llvm.org/D13572

Files:
  lib/Basic/Targets.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -989,7 +989,7 @@
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
 else
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=0");
-  } else if (Triple.getEnvironment() == llvm::Triple::Android) {
+  } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
 CmdArgs.push_back("-backend-option");
 CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
@@ -1022,7 +1022,7 @@
   }
 
   // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android).
-  if (Triple.getEnvironment() == llvm::Triple::Android)
+  if (Triple.isAndroid())
 DefMips64CPU = "mips64r6";
 
   // MIPS3 is the default for mips64*-unknown-openbsd.
@@ -1527,7 +1527,7 @@
 return "btver2";
 
   // On Android use targets compatible with gcc
-  if (Triple.getEnvironment() == llvm::Triple::Android)
+  if (Triple.isAndroid())
 return Is64Bit ? "x86-64" : "i686";
 
   // Everything else goes to x86-64 in 64-bit mode.
@@ -1824,7 +1824,7 @@
 
   const llvm::Triple::ArchType ArchType = Triple.getArch();
   // Add features to be compatible with gcc for Android.
-  if (Triple.getEnvironment() == llvm::Triple::Android) {
+  if (Triple.isAndroid()) {
 if (ArchType == llvm::Triple::x86_64) {
   Features.push_back("+sse4.2");
   Features.push_back("+popcnt");
@@ -2593,8 +2593,7 @@
   }
 
   // Collect static runtimes.
-  if (Args.hasArg(options::OPT_shared) ||
-  (TC.getTriple().getEnvironment() == llvm::Triple::Android)) {
+  if (Args.hasArg(options::OPT_shared) || TC.getTriple().isAndroid()) {
 // Don't link static runtimes into DSOs or if compiling for Android.
 return;
   }
@@ -3042,7 +3041,7 @@
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
 
   // Android-specific defaults for PIC/PIE
-  if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
+  if (ToolChain.getTriple().isAndroid()) {
 switch (ToolChain.getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::armeb:
@@ -4241,7 +4240,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   // Emulated TLS is enabled by default on Android, and can be enabled manually
   // with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.getEnvironment() == llvm::Triple::Android;
+  bool EmulatedTLSDefault = Triple.isAndroid();
   if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
EmulatedTLSDefault))
 CmdArgs.push_back("-femulated-tls");
@@ -8170,7 +8169,7 @@
 
 static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
   ArgStringList &CmdArgs, const ArgList &Args) {
-  bool isAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+  bool isAndroid = Triple.isAndroid();
   bool isCygMing = Triple.isOSCygMing();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
   Args.hasArg(options::OPT_static);
@@ -8206,7 +8205,7 @@
  const toolchains::Linux &ToolChain) {
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
 
-  if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
+  if (ToolChain.getTriple().isAndroid()) {
 if (ToolChain.getTriple().isArch64Bit())
   return "/system/bin/linker64";
 else
@@ -8354,8 +8353,7 @@
   llvm::Triple Triple = llvm::Triple(TripleStr);
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
-  const bool isAndroid =
-  ToolChain.getTriple().getEnvironment() == llvm::Triple::Android;
+  const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsPIE =
   !Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
   (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1823,7 +1823,7 @@
   addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
   addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
 
-  if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
+  if (TargetTriple.isAndroid()) {
 // Select Android toolchain. It's the only choice in that case.
 if (AndroidMipsMultilibs.select(Flags, Result.SelectedMultilib)) {
   Result.Multilibs = AndroidMipsMultilibs;
@@ -2174,8 +2174,7 @@
   

[libcxx] r249741 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:38:53 2015
New Revision: 249741

URL: http://llvm.org/viewvc/llvm-project?rev=249741&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/inttypes.h
  - copied, changed from r249736, libcxx/trunk/include/cinttypes
Modified:
libcxx/trunk/include/cinttypes
libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp

Modified: libcxx/trunk/include/cinttypes
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cinttypes?rev=249741&r1=249740&r2=249741&view=diff
==
--- libcxx/trunk/include/cinttypes (original)
+++ libcxx/trunk/include/cinttypes Thu Oct  8 15:38:53 2015
@@ -246,10 +246,7 @@ uintmax_t wcstoumax(const wchar_t* restr
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using::imaxdiv_t;
-
-#undef imaxabs
 using::imaxabs;
-#undef imaxdiv
 using::imaxdiv;
 using::strtoimax;
 using::strtoumax;

Copied: libcxx/trunk/include/inttypes.h (from r249736, 
libcxx/trunk/include/cinttypes)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/inttypes.h?p2=libcxx/trunk/include/inttypes.h&p1=libcxx/trunk/include/cinttypes&r1=249736&r2=249741&rev=249741&view=diff
==
--- libcxx/trunk/include/cinttypes (original)
+++ libcxx/trunk/include/inttypes.h Thu Oct  8 15:38:53 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cinttypes 
===//
+//===--- inttypes.h 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,15 +8,15 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CINTTYPES
-#define _LIBCPP_CINTTYPES
+#ifndef _LIBCPP_INTTYPES_H
+#define _LIBCPP_INTTYPES_H
 
 /*
-cinttypes synopsis
+inttypes.h synopsis
 
 This entire header is C99 / C++0X
 
-#include   //  includes 
+#include   //  includes 
 
 Macros:
 
@@ -218,9 +218,6 @@ Macros:
 SCNxMAX
 SCNxPTR
 
-namespace std
-{
-
 Types:
 
 imaxdiv_t
@@ -232,30 +229,22 @@ uintmax_t strtoumax(const char* restrict
 intmax_t  wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, 
int base);
 uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, 
int base);
 
-}  // std
 */
 
 #include <__config>
-#include 
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#ifdef __cplusplus
 
-using::imaxdiv_t;
+#include 
 
 #undef imaxabs
-using::imaxabs;
 #undef imaxdiv
-using::imaxdiv;
-using::strtoimax;
-using::strtoumax;
-using::wcstoimax;
-using::wcstoumax;
 
-_LIBCPP_END_NAMESPACE_STD
+#endif
 
-#endif  // _LIBCPP_CINTTYPES
+#endif  // _LIBCPP_INTTYPES_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp?rev=249741&r1=249740&r2=249741&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp Thu Oct  8 
15:38:53 2015
@@ -12,6 +12,250 @@
 #include 
 #include 
 
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined

[libcxx] r249739 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:37:11 2015
New Revision: 249739

URL: http://llvm.org/viewvc/llvm-project?rev=249739&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/errno.h
  - copied, changed from r249736, libcxx/trunk/include/cerrno
Modified:
libcxx/trunk/include/cerrno

Modified: libcxx/trunk/include/cerrno
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cerrno?rev=249739&r1=249738&r2=249739&view=diff
==
--- libcxx/trunk/include/cerrno (original)
+++ libcxx/trunk/include/cerrno Thu Oct  8 15:37:11 2015
@@ -30,364 +30,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-#ifdef ELAST
-
-const int __elast1 = ELAST+1;
-const int __elast2 = ELAST+2;
-
-#else
-
-const int __elast1 = 104;
-const int __elast2 = 105;
-
-#endif
-
-#ifdef ENOTRECOVERABLE
-
-#define EOWNERDEAD __elast1
-
-#ifdef ELAST
-#undef ELAST
-#define ELAST EOWNERDEAD
-#endif
-
-#elif defined(EOWNERDEAD)
-
-#define ENOTRECOVERABLE __elast1
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#else  // defined(EOWNERDEAD)
-
-#define EOWNERDEAD __elast1
-#define ENOTRECOVERABLE __elast2
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#endif  // defined(EOWNERDEAD)
-
-#endif  // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-//  supply errno values likely to be missing, particularly on Windows
-
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT 9901
-#endif
-
-#ifndef EADDRINUSE
-#define EADDRINUSE 9902
-#endif
-
-#ifndef EADDRNOTAVAIL
-#define EADDRNOTAVAIL 9903
-#endif
-
-#ifndef EISCONN
-#define EISCONN 9904
-#endif
-
-#ifndef EBADMSG
-#define EBADMSG 9905
-#endif
-
-#ifndef ECONNABORTED
-#define ECONNABORTED 9906
-#endif
-
-#ifndef EALREADY
-#define EALREADY 9907
-#endif
-
-#ifndef ECONNREFUSED
-#define ECONNREFUSED 9908
-#endif
-
-#ifndef ECONNRESET
-#define ECONNRESET 9909
-#endif
-
-#ifndef EDESTADDRREQ
-#define EDESTADDRREQ 9910
-#endif
-
-#ifndef EHOSTUNREACH
-#define EHOSTUNREACH 9911
-#endif
-
-#ifndef EIDRM
-#define EIDRM 9912
-#endif
-
-#ifndef EMSGSIZE
-#define EMSGSIZE 9913
-#endif
-
-#ifndef ENETDOWN
-#define ENETDOWN 9914
-#endif
-
-#ifndef ENETRESET
-#define ENETRESET 9915
-#endif
-
-#ifndef ENETUNREACH
-#define ENETUNREACH 9916
-#endif
-
-#ifndef ENOBUFS
-#define ENOBUFS 9917
-#endif
-
-#ifndef ENOLINK
-#define ENOLINK 9918
-#endif
-
-#ifndef ENODATA
-#define ENODATA 9919
-#endif
-
-#ifndef ENOMSG
-#define ENOMSG 9920
-#endif
-
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT 9921
-#endif
-
-#ifndef ENOSR
-#define ENOSR 9922
-#endif
-
-#ifndef ENOTSOCK
-#define ENOTSOCK 9923
-#endif
-
-#ifndef ENOSTR
-#define ENOSTR 9924
-#endif
-
-#ifndef ENOTCONN
-#define ENOTCONN 9925
-#endif
-
-#ifndef ENOTSUP
-#define ENOTSUP 9926
-#endif
-
-#ifndef ECANCELED
-#define ECANCELED 9927
-#endif
-
-#ifndef EINPROGRESS
-#define EINPROGRESS 9928
-#endif
-
-#ifndef EOPNOTSUPP
-#define EOPNOTSUPP 9929
-#endif
-
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK 9930
-#endif
-
-#ifndef EOWNERDEAD
-#define EOWNERDEAD  9931
-#endif
-
-#ifndef EPROTO
-#define EPROTO 9932
-#endif
-
-#ifndef EPROTONOSUPPORT
-#define EPROTONOSUPPORT 9933
-#endif
-
-#ifndef ENOTRECOVERABLE
-#define ENOTRECOVERABLE 9934
-#endif
-
-#ifndef ETIME
-#define ETIME 9935
-#endif
-
-#ifndef ETXTBSY
-#define ETXTBSY 9936
-#endif
-
-#ifndef ETIMEDOUT
-#define ETIMEDOUT 9938
-#endif
-
-#ifndef ELOOP
-#define ELOOP 9939
-#endif
-
-#ifndef EOVERFLOW
-#define EOVERFLOW 9940
-#endif
-
-#ifndef EPROTOTYPE
-#define EPROTOTYPE 9941
-#endif
-
-#ifndef ENOSYS
-#define ENOSYS 9942
-#endif
-
-#ifndef EINVAL
-#define EINVAL 9943
-#endif
-
-#ifndef ERANGE
-#define ERANGE 9944
-#endif
-
-#ifndef EILSEQ
-#define EILSEQ 9945
-#endif
-
-//  Windows Mobile doesn't appear to define these:
-
-#ifndef E2BIG
-#define E2BIG 9946
-#endif
-
-#ifndef EDOM
-#define EDOM 9947
-#endif
-
-#ifndef EFAULT
-#define EFAULT 9948
-#endif
-
-#ifndef EBADF
-#define EBADF 9949
-#endif
-
-#ifndef EPIPE
-#define EPIPE 9950
-#endif
-
-#ifndef EXDEV
-#define EXDEV 9951
-#endif
-
-#ifndef EBUSY
-#define EBUSY 9952
-#endif
-
-#ifndef ENOTEMPTY
-#define ENOTEMPTY 9953
-#endif
-
-#ifndef ENOEXEC
-#define ENOEXEC 9954
-#endif
-
-#ifndef EEXIST
-#define EEXIST 9955
-#endif
-
-#ifndef EFBIG
-#define EFBIG 9956
-#endif
-
-#ifndef ENAMETOOLONG
-#define ENAMETOOLONG 9957
-#endif
-
-#ifndef ENOTTY
-#define ENOTTY 9958
-#endif
-
-#ifndef EINTR
-#define EINTR 9959
-#endif
-
-#ifndef ESPIPE
-#define ESPIPE 9960
-#endif
-
-#ifndef EIO
-#define EIO 9961
-#endif
-
-#ifndef EISDIR
-#define EISDIR 9962
-#endif
-
-#ifndef ECHILD
-#define ECHILD 9963
-#endif
-
-#ifndef ENOLCK
-#define ENOLCK 9964
-#endif
-
-#ifndef ENOSPC
-#define ENOSPC 9965
-#endif
-
-#ifndef ENXIO
-#define ENXIO 9966
-#endif
-
-#ifndef ENODEV
-#define ENODEV 9967
-#endif
-
-#ifndef ENOENT
-#define ENOENT 9968
-#endif
-
-#ifndef ESRCH
-#define ESRCH 9969
-#endif
-
-#ifndef ENOTDIR
-#def

[libcxx] r249740 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:37:44 2015
New Revision: 249740

URL: http://llvm.org/viewvc/llvm-project?rev=249740&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/float.h
  - copied, changed from r249736, libcxx/trunk/include/cfloat
Modified:
libcxx/trunk/include/cfloat

Modified: libcxx/trunk/include/cfloat
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cfloat?rev=249740&r1=249739&r2=249740&view=diff
==
--- libcxx/trunk/include/cfloat (original)
+++ libcxx/trunk/include/cfloat Thu Oct  8 15:37:44 2015
@@ -67,12 +67,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#ifndef FLT_EVAL_METHOD
-#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#endif
-
-#ifndef DECIMAL_DIG
-#define DECIMAL_DIG __DECIMAL_DIG__
-#endif
-
 #endif  // _LIBCPP_CFLOAT

Copied: libcxx/trunk/include/float.h (from r249736, libcxx/trunk/include/cfloat)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/float.h?p2=libcxx/trunk/include/float.h&p1=libcxx/trunk/include/cfloat&r1=249736&r2=249740&rev=249740&view=diff
==
--- libcxx/trunk/include/cfloat (original)
+++ libcxx/trunk/include/float.h Thu Oct  8 15:37:44 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cfloat 
---===//
+//===--- float.h 
--===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,11 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CFLOAT
-#define _LIBCPP_CFLOAT
+#ifndef _LIBCPP_FLOAT_H
+#define _LIBCPP_FLOAT_H
 
 /*
-cfloat synopsis
+float.h synopsis
 
 Macros:
 
@@ -61,7 +61,7 @@ Macros:
 */
 
 #include <__config>
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -75,4 +75,4 @@ Macros:
 #define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
-#endif  // _LIBCPP_CFLOAT
+#endif  // _LIBCPP_FLOAT_H


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


[libcxx] r249738 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:36:30 2015
New Revision: 249738

URL: http://llvm.org/viewvc/llvm-project?rev=249738&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/ctype.h
  - copied, changed from r249736, libcxx/trunk/include/cctype
Modified:
libcxx/trunk/include/cctype
libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp

Modified: libcxx/trunk/include/cctype
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cctype?rev=249738&r1=249737&r2=249738&view=diff
==
--- libcxx/trunk/include/cctype (original)
+++ libcxx/trunk/include/cctype Thu Oct  8 15:36:30 2015
@@ -37,10 +37,6 @@ int toupper(int c);
 
 #include <__config>
 #include 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -48,33 +44,19 @@ int toupper(int c);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#undef isalnum
 using ::isalnum;
-#undef isalpha
 using ::isalpha;
-#undef isblank
 using ::isblank;
-#undef iscntrl
 using ::iscntrl;
-#undef isdigit
 using ::isdigit;
-#undef isgraph
 using ::isgraph;
-#undef islower
 using ::islower;
-#undef isprint
 using ::isprint;
-#undef ispunct
 using ::ispunct;
-#undef isspace
 using ::isspace;
-#undef isupper
 using ::isupper;
-#undef isxdigit
 using ::isxdigit;
-#undef tolower
 using ::tolower;
-#undef toupper
 using ::toupper;
 
 _LIBCPP_END_NAMESPACE_STD

Copied: libcxx/trunk/include/ctype.h (from r249736, libcxx/trunk/include/cctype)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?p2=libcxx/trunk/include/ctype.h&p1=libcxx/trunk/include/cctype&r1=249736&r2=249738&rev=249738&view=diff
==
--- libcxx/trunk/include/cctype (original)
+++ libcxx/trunk/include/ctype.h Thu Oct  8 15:36:30 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//=== cctype 
--===//
+//=== ctype.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,14 +8,11 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CCTYPE
-#define _LIBCPP_CCTYPE
+#ifndef _LIBCPP_CTYPE_H
+#define _LIBCPP_CTYPE_H
 
 /*
-cctype synopsis
-
-namespace std
-{
+ctype.h synopsis
 
 int isalnum(int c);
 int isalpha(int c);
@@ -31,52 +28,41 @@ int isupper(int c);
 int isxdigit(int c);
 int tolower(int c);
 int toupper(int c);
-
-}  // std
 */
 
 #include <__config>
-#include 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#ifdef __cplusplus
+
+#if defined(_LIBCPP_MSVCRT)
+// We support including .h headers inside 'extern "C"' contexts, so switch
+// back to C++ linkage before including these C++ headers.
+extern "C++" {
+  #include "support/win32/support.h"
+  #include "support/win32/locale_win32.h"
+}
+#endif // _LIBCPP_MSVCRT
 
 #undef isalnum
-using ::isalnum;
 #undef isalpha
-using ::isalpha;
 #undef isblank
-using ::isblank;
 #undef iscntrl
-using ::iscntrl;
 #undef isdigit
-using ::isdigit;
 #undef isgraph
-using ::isgraph;
 #undef islower
-using ::islower;
 #undef isprint
-using ::isprint;
 #undef ispunct
-using ::ispunct;
 #undef isspace
-using ::isspace;
 #undef isupper
-using ::isupper;
 #undef isxdigit
-using ::isxdigit;
 #undef tolower
-using ::tolower;
 #undef toupper
-using ::toupper;
 
-_LIBCPP_END_NAMESPACE_STD
+#endif
 
-#endif  // _LIBCPP_CCTYPE
+#endif  // _LIBCPP_CTYPE_H

Modified: libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=249738&r1=249737&r2=249738&view=diff
==
--- libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp Thu Oct  8 15:36:30 
2015
@@ -86,18 +86,18 @@ int main()
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 
-assert(isalnum('a'));
-assert(isalpha('a'));
-assert(isblank(' '));
-assert(!iscntrl(' '));
-assert(!isdigit('a'));
-assert(isgraph('a'));
-assert(islower('a'));
-assert(isprint('a'));
-assert(!ispunct('a'));
-assert(!isspace('a'));
-assert(!isupper('a'));
-assert(isxdigit('a'));
-assert(tolower('A') == 'a');
-assert(toupper('a') == 'A');
+assert(std::isalnum('a'));
+assert(std::isalpha('a'));
+assert(std::isblank(' '));
+assert(!std::iscntrl(' '));
+assert(!std::isdig

[libcxx] r249737 - Factor definition of std::nullptr_t out of into a header that can also be used by .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:34:11 2015
New Revision: 249737

URL: http://llvm.org/viewvc/llvm-project?rev=249737&view=rev
Log:
Factor definition of std::nullptr_t out of  into a header that can 
also be used by .

Added:
libcxx/trunk/include/__nullptr
  - copied, changed from r249736, libcxx/trunk/include/cstddef
Modified:
libcxx/trunk/include/cstddef

Copied: libcxx/trunk/include/__nullptr (from r249736, 
libcxx/trunk/include/cstddef)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__nullptr?p2=libcxx/trunk/include/__nullptr&p1=libcxx/trunk/include/cstddef&r1=249736&r2=249737&rev=249737&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/__nullptr Thu Oct  8 15:34:11 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cstddef 
--===//
+//===--- __nullptr 
===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,53 +8,19 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSTDDEF
-#define _LIBCPP_CSTDDEF
-
-/*
-cstddef synopsis
-
-Macros:
-
-offsetof(type,member-designator)
-NULL
-
-namespace std
-{
-
-Types:
-
-ptrdiff_t
-size_t
-max_align_t
-nullptr_t
-
-}  // std
-
-*/
+#ifndef _LIBCPP_NULLPTR
+#define _LIBCPP_NULLPTR
 
 #include <__config>
 
-#include 
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::ptrdiff_t;
-using ::size_t;
-
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
-// Re-use the compiler's  max_align_t where possible.
-using ::max_align_t;
-#else
-typedef long double max_align_t;
-#endif
-
 #ifdef _LIBCPP_HAS_NO_NULLPTR
 
+_LIBCPP_BEGIN_NAMESPACE_STD
+
 struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
 {
 void* __lx;
@@ -86,11 +52,9 @@ inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CON
 
 #define nullptr _VSTD::__get_nullptr_t()
 
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 _LIBCPP_END_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_NULLPTR
+#else  // _LIBCPP_HAS_NO_NULLPTR
 
 namespace std
 {
@@ -99,4 +63,4 @@ namespace std
 
 #endif  // _LIBCPP_HAS_NO_NULLPTR
 
-#endif  // _LIBCPP_CSTDDEF
+#endif  // _LIBCPP_NULLPTR

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=249737&r1=249736&r2=249737&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Oct  8 15:34:11 2015
@@ -34,6 +34,7 @@ Types:
 */
 
 #include <__config>
+#include <__nullptr>
 
 #include 
 
@@ -53,50 +54,6 @@ using ::max_align_t;
 typedef long double max_align_t;
 #endif
 
-#ifdef _LIBCPP_HAS_NO_NULLPTR
-
-struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
-{
-void* __lx;
-
-struct __nat {int __for_bool_;};
-
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) 
{}
-
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const 
{return 0;}
-
-template 
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
-operator _Tp* () const {return 0;}
-
-template 
-_LIBCPP_ALWAYS_INLINE
-operator _Tp _Up::* () const {return 0;}
-
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, 
nullptr_t) {return true;}
-};
-
-inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() 
{return nullptr_t(0);}
-
-#define nullptr _VSTD::__get_nullptr_t()
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 _LIBCPP_END_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_NULLPTR
-
-namespace std
-{
-typedef decltype(nullptr) nullptr_t;
-}
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 #endif  // _LIBCPP_CSTDDEF


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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 7:23 AM, Marshall Clow  wrote:

> On Tue, Oct 6, 2015 at 3:36 PM, Richard Smith 
> wrote:
>
>> Split  out of . This is a big change, but the same pattern
>> as the prior ones.
>>
>> In this patch, you replicate the #ifdef XXX, __libcpp_XXX, #undef XXX
> dance for all the isXXX functions. Is that because they're not required to
> be actual functions in a C library?
>

Yes. Per C11 7.12.3, the following are defined as type-generic macros that
take any real floating-point type:

  fpclassify, isfinite, isinf, isnan, isnormal, signbit

Per C11 7.12.14, the following are defined as type-generic macros that take
any pair of real floating-point types:

  isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered

Per [c.math]p10, we are required to remove those macros and replace them
with a set of overloaded functions. For those cases (and *only* those
cases), we define a function template to capture the contents of the macro,
then undefine the macro.

Note that libc++'s behavior here is non-conforming (both before and after
this change) because it's required to provide a specific set of overloads,
but instead only provides a template. This patch series neither improves
nor regresses libc++'s conformance in that area.


> Other than that Q, LGTM. Like the extended tests.
>
> -- Marshall
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13525: [CodeGen] Attach function attributes to functions created in CGBlocks.cpp.

2015-10-08 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249735: [CodeGen] [CodeGen] Attach function attributes to 
functions created in (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D13525?vs=36886&id=36891#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13525

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenObjC/arc-blocks.m

Index: cfe/trunk/test/CodeGenObjC/arc-blocks.m
===
--- cfe/trunk/test/CodeGenObjC/arc-blocks.m
+++ cfe/trunk/test/CodeGenObjC/arc-blocks.m
@@ -43,7 +43,7 @@
   extern void test2_helper(id (^)(void));
   test2_helper(^{ return x; });
 
-// CHECK-LABEL:define internal void @__copy_helper_block_
+// CHECK-LABEL:define internal void @__copy_helper_block_(i8*, i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8**
@@ -53,7 +53,7 @@
 // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) [[NUW]]
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL:define internal void @__destroy_helper_block_
+// CHECK-LABEL:define internal void @__destroy_helper_block_(i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5
@@ -134,16 +134,16 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[T1]]
   // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
   // CHECK-NEXT: store i8* null, i8** [[T1]]
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]]
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
@@ -155,10 +155,10 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
 }
 
@@ -221,27 +221,27 @@
   // CHECK-NEXT: call void @llvm.lifetime.end(i64 48, i8* [[VARPTR2]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
 
   // CHECK-LABEL:define internal void @__test6_block_invoke
   // CHECK:  [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // 0x8 - F

r249735 - [CodeGen] [CodeGen] Attach function attributes to functions created in

2015-10-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Oct  8 15:26:34 2015
New Revision: 249735

URL: http://llvm.org/viewvc/llvm-project?rev=249735&view=rev
Log:
[CodeGen] [CodeGen] Attach function attributes to functions created in
CGBlocks.cpp.

This commit fixes a bug in clang's code-gen where it creates the
following functions but doesn't attach function attributes to them:

__copy_helper_block_
__destroy_helper_block_
__Block_byref_object_copy_
__Block_byref_object_dispose_

rdar://problem/20828324

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenObjC/arc-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct  8 15:26:34 2015
@@ -1345,6 +1345,9 @@ CodeGenFunction::GenerateCopyHelperFunct
   nullptr, SC_Static,
   false,
   false);
+
+  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   // Create a scope with an artificial location for the body of this function.
@@ -1516,6 +1519,9 @@ CodeGenFunction::GenerateDestroyHelperFu
   SourceLocation(), II, C.VoidTy,
   nullptr, SC_Static,
   false, false);
+
+  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   // Create a scope with an artificial location for the body of this function.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
@@ -1798,6 +1804,8 @@ generateByrefCopyHelper(CodeGenFunction
   SC_Static,
   false, false);
 
+  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   CGF.StartFunction(FD, R, Fn, FI, args);
 
   if (generator.needsCopy()) {
@@ -1869,6 +1877,9 @@ generateByrefDisposeHelper(CodeGenFuncti
   SourceLocation(), II, R, nullptr,
   SC_Static,
   false, false);
+
+  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   CGF.StartFunction(FD, R, Fn, FI, args);
 
   if (generator.needsDispose()) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct  8 15:26:34 2015
@@ -867,12 +867,12 @@ void CodeGenModule::SetLLVMFunctionAttri
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
-  if (const auto *ND = dyn_cast(D))
+  if (const auto *ND = dyn_cast_or_null(D))
 setGlobalVisibility(GV, ND);
   else
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
-  if (D->hasAttr())
+  if (D && D->hasAttr())
 addUsedGlobal(GV);
 }
 
@@ -890,8 +890,9 @@ void CodeGenModule::setNonAliasAttribute
   llvm::GlobalObject *GO) {
   SetCommonAttributes(D, GO);
 
-  if (const SectionAttr *SA = D->getAttr())
-GO->setSection(SA->getName());
+  if (D)
+if (const SectionAttr *SA = D->getAttr())
+  GO->setSection(SA->getName());
 
   getTargetCodeGenInfo().setTargetAttributes(D, GO, *this);
 }

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Oct  8 15:26:34 2015
@@ -1528,7 +1528,7 @@ bool X86_32TargetCodeGenInfo::isStructRe
 void X86_32TargetCodeGenInfo::setTargetAttributes(const Decl *D,
   llvm::GlobalValue *GV,
 CodeGen::CodeGenModule &CGM) const 
{
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
   // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
@@ -1898,7 +1898,7 @@ public:
 static void addStackProbeSizeTargetAttribute(const Decl *D,
  llvm::GlobalValue *GV,
   

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith  wrote:
> On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Thu Oct  8 14:24:08 2015
>> New Revision: 249721
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
>> Log:
>> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>> GNU-style formatting that involves prefix and suffix underscores. Cleans up
>> other usages of similar functionality.
>>
>> Patch by Adrian Zgorzalek!
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>>  AssumeAlignedAttr(AttrRange, Context, E, OE,
>> SpellingListIndex));
>>  }
>>
>> +/// Normalize the attribute, __foo__ becomes foo.
>> +/// Returns true if normalization was applied.
>> +static bool normalizeName(StringRef &AttrName) {
>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> +assert(AttrName.size() > 4 && "Name too short");
>
>
> This assert will fire on the strings __, ___, and , which are valid in
> some of the below cases.

That assert won't fire on anything but  because it's &&, not ||. I
don't think these names were intended to be valid in their uses.
However, you are correct that this will trigger assertions instead of
diagnostics. Adrian, can you investigate?

>
>>
>> +AttrName = AttrName.drop_front(2).drop_back(2);
>> +return true;
>> +  }
>> +  return false;
>> +}
>> +
>>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>> &AL) {
>>// This attribute must be applied to a function declaration. The first
>>// argument to the attribute must be an identifier, the name of the
>> resource,
>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>>
>>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>>StringRef ModuleName = Module->getName();
>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> -  ModuleName.size() > 4) {
>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> +  if (normalizeName(ModuleName)) {
>>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>>}
>>
>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>StringRef Format = II->getName();
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>> -  if (Format.startswith("__") && Format.endswith("__")) {
>> -Format = Format.substr(2, Format.size() - 4);
>> +  if (normalizeName(Format)) {
>>  // If we've modified the string name, we need a new identifier for
>> it.
>>  II = &S.Context.Idents.get(Format);
>>}
>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>StringRef Str = Name->getName();
>>
>> -  // Normalize the attribute name, __foo__ becomes foo.
>> -  if (Str.startswith("__") && Str.endswith("__"))
>> -Str = Str.substr(2, Str.size() - 4);
>> +  normalizeName(Str);
>>
>>unsigned DestWidth = 0;
>>bool IntegerMode = true;
>> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>>
>>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>>   const AttributeList &Attr) {
>> +  StringRef AttrName = Attr.getName()->getName();
>> +  normalizeName(AttrName);
>>std::string SanitizerName =
>> -  llvm::StringSwitch(Attr.getName()->getName())
>> +  llvm::StringSwitch(AttrName)
>>.Case("no_address_safety_analysis", "address")
>>.Case("no_sanitize_address", "address")
>>.Case("no_sanitize_thread", "thread")
>
>
> Is there any way we could use the spelling list index in this case rather
> than repeating the attribute names and __-stripping here?

The spelling list index isn't exposed in a meaningful way (and I think
that would be an abuse of it; I want to someday remove that
implementation detail to something far more private).

I was hoping there would be a way to use the semantic spelling, but
the issue is that this particular attribute doesn't have semantic
spellings. The NoSanitizeSpecificAttr would have one, but it has no
AST node to hang those off of. Since we explicitly document that we do
not want any additional names added to this list (see Attr.td line
1500), I 

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 6:27 AM, Marshall Clow  wrote:

> On Wed, Oct 7, 2015 at 2:38 PM, Richard Smith 
> wrote:
>
>> Marshall: ping, does the below satisfy your concerns about the direction
>> here?
>>
>
> No, not really, because I'm worried about behavior changes with this
> approach.
>
> #include 
>isdigit(c);
>
> will call different code before and after this patch.
> Before the patch, it will use the macro version.
>

That was non-conforming behaviour, per [headers]/6:

  "Names that are defined as functions in C shall be defined as functions
in the C++ standard library. [Footnote: This disallows the practice,
allowed in C, of providing a masking macro in addition to the function
prototype.]"

After, it will use the built-in function.
>
> However, since other standard libraries use this approach, this is
> probably a baseless concern.
>
> Assuming that my concerns are unfounded, the first six patches
> (remove-macros, nullptr, ctype, errno and float) look fine to me.
>
> Working on the rest.
>
> -- Marshall
>
>
>
>> On Wed, Sep 16, 2015 at 2:04 PM, Richard Smith 
>> wrote:
>>
>>> On Mon, Sep 14, 2015 at 7:07 AM, Marshall Clow 
>>> wrote:
>>>
 mclow.lists added a comment.

 I have two concerns about this patch (w/o commenting on the actual
 code).

 1. Until very recently, I was under the impression that C libraries
 _either_ defined a macro, or had a function. I was quite surprised to find
 that glibc did both.
>>>
>>>
>>> Yes, this is required by the C standard. C11 7.1.4/1 says:
>>>
>>> "Any function declared in a header may be additionally implemented as a
>>> function-like macro defined in the header [...]. Any macro definition of a
>>> function can be suppressed locally by enclosing the name of the function in
>>> parentheses, because the name is then not followed by the left parenthesis
>>> that indicates expansion of a macro function name. For the same syntactic
>>> reason, it is permitted to take the address of a library function even if
>>> it is also defined as a macro. [Footnote: This means that an implementation
>>> shall provide an actual function for each library function, even if it also
>>> provides a macro for that function.]"
>>>
>>> Have you checked other C libraries (Apple, FreeBSD, Android, Windows) to
 see if they also define both?
>>>
>>>
>>> No, but libstdc++ does the same #undef thing, so any platform it
>>> supports must have a non-broken C standard library.
>>>
>>>
 2. This adds a lot of header files. Each header file slows down
 compilation, and standard library header files get included *a lot*. We may
 not be able to avoid this, but we should think about the costs here.
>>>
>>>
>>> I created a .cpp file that includes all of the <*.h> headers and does
>>> nothing else (which should maximize the performance difference), and built
>>> it with and without this change. I could not measure any difference (the
>>> average compile time with this change was slightly lower, but that is
>>> almost certainly noise).
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores. Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>  AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
>  }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");
>

This assert will fire on the strings __, ___, and , which are valid in
some of the below cases.


> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>// This attribute must be applied to a function declaration. The first
>// argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>}
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeName(Format)) {
>  // If we've modified the string name, we need a new identifier for it.
>  II = &S.Context.Idents.get(Format);
>}
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2, Str.size() - 4);
> +  normalizeName(Str);
>
>unsigned DestWidth = 0;
>bool IntegerMode = true;
> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>
>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>   const AttributeList &Attr) {
> +  StringRef AttrName = Attr.getName()->getName();
> +  normalizeName(AttrName);
>std::string SanitizerName =
> -  llvm::StringSwitch(Attr.getName()->getName())
> +  llvm::StringSwitch(AttrName)
>.Case("no_address_safety_analysis", "address")
>.Case("no_sanitize_address", "address")
>.Case("no_sanitize_thread", "thread")
>

Is there any way we could use the spelling list index in this case rather
than repeating the attribute names and __-stripping here?

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev=249721&r1=249720&r2=249721&view=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp Thu Oct  8
> 14:24:08 2015
> @@ -5,12 +5,14 @@
>  #if !__has_attribute(no_sanitize_address)
>  #error "Should support no_sanitize_address"
>  #endif
> -
> -void noanal_fun() NO_SANITIZE_ADDRESS;
> -
> -void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
> -  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
> -
> +
> +void noanal_fun() NO_SANITIZE_ADDRESS;
> +
> +void noanal_fun_alt() __attribute__((__no_sanitize_address__));
> +
> +void noanal_fun_args() __attribute__((

r249732 - Migrate most feature map inclusion to initFeatureMap for the x86 target so

2015-10-08 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Oct  8 15:10:14 2015
New Revision: 249732

URL: http://llvm.org/viewvc/llvm-project?rev=249732&view=rev
Log:
Migrate most feature map inclusion to initFeatureMap for the x86 target so
that we can build up an accurate set of features rather than relying on
TargetInfo initialization via handleTargetFeatures to munge the list
of features.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249732&r1=249731&r2=249732&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 15:10:14 2015
@@ -2705,7 +2705,27 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
   }
-  return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec))
+return false;
+
+  // Can't do this earlier because we need to be able to explicitly enable
+  // or disable these features and the things that they depend upon.
+
+  // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
+  auto I = Features.find("sse4.2");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-popcnt") ==
+  FeaturesVec.end())
+Features["popcnt"] = true;
+
+  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
+  I = Features.find("3dnow");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-prfchw") ==
+  FeaturesVec.end())
+Features["prfchw"] = true;
+
+  return true;
 }
 
 void X86TargetInfo::setSSELevel(llvm::StringMap &Features,
@@ -2974,22 +2994,6 @@ bool X86TargetInfo::handleTargetFeatures
 XOPLevel = std::max(XOPLevel, XLevel);
   }
 
-  // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
-  // Can't do this earlier because we need to be able to explicitly enable
-  // popcnt and still disable sse4.2.
-  if (!HasPOPCNT && SSELevel >= SSE42 &&
-  std::find(Features.begin(), Features.end(), "-popcnt") == 
Features.end()){
-HasPOPCNT = true;
-Features.push_back("+popcnt");
-  }
-
-  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
-  if (!HasPRFCHW && MMX3DNowLevel >= AMD3DNow &&
-  std::find(Features.begin(), Features.end(), "-prfchw") == 
Features.end()){
-HasPRFCHW = true;
-Features.push_back("+prfchw");
-  }
-
   // LLVM doesn't have a separate switch for fpmath, so only accept it if it
   // matches the selected sse level.
   if (FPMath == FP_SSE && SSELevel < SSE1) {

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=249732&r1=249731&r2=249732&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Oct  8 15:10:14 2015
@@ -29,7 +29,7 @@ int __attribute__((target("no-aes, arch=
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
 // CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"


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


r249733 - Handle sse turning on mmx, but no -mmx not turning off SSE.

2015-10-08 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Oct  8 15:10:18 2015
New Revision: 249733

URL: http://llvm.org/viewvc/llvm-project?rev=249733&view=rev
Log:
Handle sse turning on mmx, but no -mmx not turning off SSE.

Rationale :

// sse3
__m128d test_mm_addsub_pd(__m128d A, __m128d B) {
  return _mm_addsub_pd(A, B);
}

// mmx
void shift(__m64 a, __m64 b, int c) {
  _mm_slli_pi16(a, c);
  _mm_slli_pi32(a, c);
  _mm_slli_si64(a, c);
  _mm_srli_pi16(a, c);
  _mm_srli_pi32(a, c);
  _mm_srli_si64(a, c);
  _mm_srai_pi16(a, c);
  _mm_srai_pi32(a, c);
}

clang -msse3 -mno-mmx file.c -c

For this code we should be able to explicitly turn off MMX
without affecting the compilation of the SSE3 function and then
diagnose and error on compiling the MMX function.

This is a preparatory patch to the actual diagnosis code which is
coming in a future patch. This sets us up to have the correct information
where we need it and verifies that it's being emitted for the backend
to handle.

Added:
cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249733&r1=249732&r2=249733&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 15:10:18 2015
@@ -2725,6 +2725,14 @@ bool X86TargetInfo::initFeatureMap(
   FeaturesVec.end())
 Features["prfchw"] = true;
 
+  // Additionally, if SSE is enabled and mmx is not explicitly disabled,
+  // then enable MMX.
+  I = Features.find("sse");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-mmx") ==
+  FeaturesVec.end())
+Features["mmx"] = true;
+
   return true;
 }
 
@@ -3004,17 +3012,6 @@ bool X86TargetInfo::handleTargetFeatures
 return false;
   }
 
-  // Don't tell the backend if we're turning off mmx; it will end up disabling
-  // SSE, which we don't want.
-  // Additionally, if SSE is enabled and mmx is not explicitly disabled,
-  // then enable MMX.
-  std::vector::iterator it;
-  it = std::find(Features.begin(), Features.end(), "-mmx");
-  if (it != Features.end())
-Features.erase(it);
-  else if (SSELevel > NoSSE)
-MMX3DNowLevel = std::max(MMX3DNowLevel, MMX);
-
   SimdDefaultAlign =
   hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
   return true;

Added: cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86-mmx.c?rev=249733&view=auto
==
--- cfe/trunk/test/CodeGen/attr-target-x86-mmx.c (added)
+++ cfe/trunk/test/CodeGen/attr-target-x86-mmx.c Thu Oct  8 15:10:18 2015
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// Picking a cpu that doesn't have mmx or sse by default so we can enable it 
later.
+
+#define __MM_MALLOC_H
+
+#include 
+
+// Verify that when we turn on sse that we also turn on mmx.
+void __attribute__((target("sse"))) shift(__m64 a, __m64 b, int c) {
+  _mm_slli_pi16(a, c);
+  _mm_slli_pi32(a, c);
+  _mm_slli_si64(a, c);
+
+  _mm_srli_pi16(a, c);
+  _mm_srli_pi32(a, c);
+  _mm_srli_si64(a, c);
+
+  _mm_srai_pi16(a, c);
+  _mm_srai_pi32(a, c);
+}
+
+// CHECK: "target-features"="+mmx,+sse"

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=249733&r1=249732&r2=249733&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Oct  8 15:10:18 2015
@@ -16,6 +16,8 @@ int bar(int a) { return baz(a) + foo(a);
 int __attribute__((target("avx,  sse4.2,  arch=   ivybridge"))) 
qux(int a) { return 4; }
 int __attribute__((target("no-aes, arch=ivybridge"))) qax(int a) { return 4; }
 
+int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
+
 // Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -28,8 +30,10 @@ int __attribute__((target("no-aes, arch=
 // CHECK: bar{{.*}} #0
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-featur

[clang-tools-extra] r249727 - Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/con

2015-10-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Oct  8 14:54:43 2015
New Revision: 249727

URL: http://llvm.org/viewvc/llvm-project?rev=249727&view=rev
Log:
Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ 
code. Corresponds to the CERT C++ secure coding rule: 
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834

Added:
clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-setlongjmp.rst
clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=249727&r1=249726&r2=249727&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Thu Oct  8 
14:54:43 2015
@@ -15,6 +15,7 @@
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
+#include "SetLongJmpCheck.h"
 #include "VariadicFunctionDefCheck.h"
 
 namespace clang {
@@ -35,6 +36,9 @@ public:
 // OOP
 CheckFactories.registerCheck(
 "cert-oop11-cpp");
+// ERR
+CheckFactories.registerCheck(
+"cert-err52-cpp");
 
 // C checkers
 // DCL

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=249727&r1=249726&r2=249727&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Thu Oct  8 14:54:43 
2015
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
+  SetLongJmpCheck.cpp
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS

Added: clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp?rev=249727&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp Thu Oct  8 
14:54:43 2015
@@ -0,0 +1,77 @@
+//===--- SetLongJmpCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "SetLongJmpCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+const char SetLongJmpCheck::DiagWording[] =
+"do not call %0; consider using exception handling instead";
+
+namespace {
+class SetJmpMacroCallbacks : public PPCallbacks {
+  SetLongJmpCheck &Check;
+
+public:
+  explicit SetJmpMacroCallbacks(SetLongJmpCheck &Check) : Check(Check) {}
+
+  void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
+SourceRange Range, const MacroArgs *Args) override {
+const auto *II = MacroNameTok.getIdentifierInfo();
+if (!II)
+  return;
+
+if (II->getName() == "setjmp")
+  Check.diag(Range.getBegin(), Check.DiagWording) << II;
+  }
+};
+} // namespace
+
+void SetLongJmpCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+  // This checker only applies to C++, where exception handling is a superior
+  // solution to setjmp/longjmp calls.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // Per [headers]p5, setjmp must be exposed as a macro instead of a function,
+  // despite the allowance in C for setjmp to also be an extern function.
+  Compiler.getPreprocessor().addPPCallbacks(
+  llvm::make_unique(*this));
+}
+
+void SetLongJmpCheck::registerMatchers(MatchFinder *Finder) {
+  // This checker only applies to C++, where exception handling is a superior
+  // solution to setjmp/longjmp calls.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // In case there is an implementation that happens to define setjmp as a
+  // function instead of a macro, this will also catch use of it. However, we
+  // are primarily searching for 

Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the fast turn-around! I've commit in r249727.

~Aaron


http://reviews.llvm.org/D13567



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


Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 36890.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Corrected a simple copy-paste error.


http://reviews.llvm.org/D13567

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/SetLongJmpCheck.cpp
  clang-tidy/cert/SetLongJmpCheck.h
  docs/clang-tidy/checks/cert-setlongjmp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-setlongjmp.cpp

Index: test/clang-tidy/cert-setlongjmp.cpp
===
--- test/clang-tidy/cert-setlongjmp.cpp
+++ test/clang-tidy/cert-setlongjmp.cpp
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s cert-err52-cpp %t -- -std=c++11
+
+typedef void *jmp_buf;
+extern int __setjmpimpl(jmp_buf);
+#define setjmp(x) __setjmpimpl(x)
+[[noreturn]] extern void longjmp(jmp_buf, int);
+
+namespace std {
+using ::jmp_buf;
+using ::longjmp;
+}
+
+static jmp_buf env;
+void g() {
+  std::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead [cert-err52-cpp]
+  ::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+  longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+}
+
+void f() {
+  (void)setjmp(env);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cert-setlongjmp
cert-variadic-function-def
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
Index: docs/clang-tidy/checks/cert-setlongjmp.rst
===
--- docs/clang-tidy/checks/cert-setlongjmp.rst
+++ docs/clang-tidy/checks/cert-setlongjmp.rst
@@ -0,0 +1,11 @@
+cert-err52-cpp
+==
+
+The C standard library facilities setjmp() and longjmp() can be used to
+simulate throwing and catching exceptions. However, these facilities bypass
+automatic resource management and can result in undefined behavior, commonly
+including resource leaks, and denial-of-service attacks.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR52-CPP. Do not use setjmp() or longjmp()
+`_.
Index: clang-tidy/cert/SetLongJmpCheck.h
===
--- clang-tidy/cert/SetLongJmpCheck.h
+++ clang-tidy/cert/SetLongJmpCheck.h
@@ -0,0 +1,37 @@
+//===--- SetLongJmpCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Guards against use of setjmp/longjmp in C++ code
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-setlongjmp.html
+class SetLongJmpCheck : public ClangTidyCheck {
+public:
+  SetLongJmpCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+
+  static const char DiagWording[];
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
Index: clang-tidy/cert/SetLongJmpCheck.cpp
===
--- clang-tidy/cert/SetLongJmpCheck.cpp
+++ clang-tidy/cert/SetLongJmpCheck.cpp
@@ -0,0 +1,77 @@
+//===--- SetLongJmpCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "SetLongJmpCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace 

Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 3:47 PM, Samuel Benzaquen  wrote:
> sbenza added inline comments.
>
> 
> Comment at: clang-tidy/cert/SetLongJmpCheck.cpp:31
> @@ +30,3 @@
> +public:
> +  explicit SetJmpMacroCallbacks(Preprocessor *PP, SetLongJmpCheck &Check)
> +  : PP(PP), Check(Check) {}
> 
> Why do you pass one as a pointer and one as a reference?

Bad copy-pasta. I don't even need PP. Good catch! I will remove that.

~Aaron

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


Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/cert/SetLongJmpCheck.cpp:31
@@ +30,3 @@
+public:
+  explicit SetJmpMacroCallbacks(Preprocessor *PP, SetLongJmpCheck &Check)
+  : PP(PP), Check(Check) {}

Why do you pass one as a pointer and one as a reference?


http://reviews.llvm.org/D13567



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


r249722 - [CodeGen] Check if the Decl pointer passed is null, and if so, return

2015-10-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Oct  8 14:30:57 2015
New Revision: 249722

URL: http://llvm.org/viewvc/llvm-project?rev=249722&view=rev
Log:
[CodeGen] Check if the Decl pointer passed is null, and if so, return
early.

This is needed in a patch I plan to commit later, in which a null Decl
pointer is passed to SetLLVMFunctionAttributesForDefinition.

Relevant discussion is in http://reviews.llvm.org/D13525.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=249722&r1=249721&r2=249722&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct  8 14:30:57 2015
@@ -786,6 +786,21 @@ void CodeGenModule::SetLLVMFunctionAttri
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
+  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+B.addAttribute(llvm::Attribute::StackProtect);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+B.addAttribute(llvm::Attribute::StackProtectStrong);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
+B.addAttribute(llvm::Attribute::StackProtectReq);
+
+  if (!D) {
+F->addAttributes(llvm::AttributeSet::FunctionIndex,
+ llvm::AttributeSet::get(
+ F->getContext(),
+ llvm::AttributeSet::FunctionIndex, B));
+return;
+  }
+
   if (D->hasAttr()) {
 // Naked implies noinline: we should not be inlining such functions.
 B.addAttribute(llvm::Attribute::Naked);
@@ -810,13 +825,6 @@ void CodeGenModule::SetLLVMFunctionAttri
   if (D->hasAttr())
 B.addAttribute(llvm::Attribute::MinSize);
 
-  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-B.addAttribute(llvm::Attribute::StackProtect);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-B.addAttribute(llvm::Attribute::StackProtectStrong);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-B.addAttribute(llvm::Attribute::StackProtectReq);
-
   F->addAttributes(llvm::AttributeSet::FunctionIndex,
llvm::AttributeSet::get(
F->getContext(), llvm::AttributeSet::FunctionIndex, B));


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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 2:50 PM, Adrian Zgorzalek  wrote:
> Run clang-format, diff is in SVN format.
>
> Please, can you commit on behalf of me unless you are willing to grant me
> write permission to the repo ;-)

Thanks! I've commit in r249721. As for repo permissions, if you are
intending to contribute with some frequency, you can talk to Chris
Lattner about the process of getting an svn login.

~Aaron

>
> Adrian
>
>
>> On Oct 8, 2015, at 11:40 AM, Aaron Ballman  wrote:
>>
>> On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
>>> I so much like this fast review cycle :)
>>
>> I aim to please. ;-)
>>
>>>
>>> Comments applied.
>>
>> LGTM with one nit:
>>
>> +static bool normalizeName(StringRef& AttrName) {
>>
>> Should be (StringRef &AttrName) per style guidelines. A good idea is
>> to run clang-format over the patch or modified code, that fixes these
>> sort of things handily.
>>
>> Thanks!
>>
>> ~Aaron
>>
>>>
>>> Adrian
>>>
>>>
 On Oct 8, 2015, at 11:24 AM, Aaron Ballman 
 wrote:

 On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
> Feedback applied, new patch in the attachment.

 Thank you for working on this! A few comments:

> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
> Date: Wed, 7 Oct 2015 15:55:53 -0700
> Subject: [PATCH] Fix ICE in Clang when dealing with
> attribute(__no_sanitize_*__)
>
> Summary:
>
> Both syntaxes: __attribute__((no_sanitize_address)) and
> __attribute__((__no_sanitize__address__)) are valid, following
> documentation:
>
>> The attribute identifier (but not scope) can also be specified with a
>> preceding and following __ (double underscore) to avoid interference
>> from a macro with the same name. For instance, gnu::__const__ can be
>> used instead of gnu::const.
>
> This patch is fixing ICE when __const__ syntax is used.
>
> Test Plan:
>
> Added unittests in the patch which cover these cases. After applying
> this patch they don't crash anymore.
> ---
> lib/Sema/SemaDeclAttr.cpp | 28
> +---
> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
> 4 files changed, 23 insertions(+), 11 deletions(-)

 FWIW, it's usually better to supply svn patches instead of git patches
 (my vcs has troubles applying patches like this).

>
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index 3cf9567..b2f2cff 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
> AttrRange, Decl *D, Expr *E,
>AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeAttrName(StringRef& AttrName) {

 I would prefer this be called normalizeName since it doesn't just
 normalize attribute names (for instance, this is used to normalize
 attribute arguments as well).

> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Too short attribute name");

 "Name too short" instead.

> +AttrName = AttrName.substr(2, AttrName.size() - 4);

 I prefer: drop_front() and drop_back() instead.

> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>  // This attribute must be applied to a function declaration. The first
>  // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl
> *D,
> const AttributeList &AL) {
>
>  IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>  StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeAttrName(ModuleName)) {
>Module = &S.PP.getIdentifierTable().get(ModuleName);
>  }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
>  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>  StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeAttrN

r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Oct  8 14:24:08 2015
New Revision: 249721

URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
Log:
When mapping no_sanitize_* attributes to no_sanitize attributes, handle 
GNU-style formatting that involves prefix and suffix underscores. Cleans up 
other usages of similar functionality.

Patch by Adrian Zgorzalek!

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
@@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
 AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
 }
 
+/// Normalize the attribute, __foo__ becomes foo.
+/// Returns true if normalization was applied.
+static bool normalizeName(StringRef &AttrName) {
+  if (AttrName.startswith("__") && AttrName.endswith("__")) {
+assert(AttrName.size() > 4 && "Name too short");
+AttrName = AttrName.drop_front(2).drop_back(2);
+return true;
+  }
+  return false;
+}
+
 static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // This attribute must be applied to a function declaration. The first
   // argument to the attribute must be an identifier, the name of the resource,
@@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
 
   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
 
-  // Normalize the argument, __foo__ becomes foo.
   StringRef ModuleName = Module->getName();
-  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
-  ModuleName.size() > 4) {
-ModuleName = ModuleName.drop_front(2).drop_back(2);
+  if (normalizeName(ModuleName)) {
 Module = &S.PP.getIdentifierTable().get(ModuleName);
   }
 
@@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
   StringRef Format = II->getName();
 
-  // Normalize the argument, __foo__ becomes foo.
-  if (Format.startswith("__") && Format.endswith("__")) {
-Format = Format.substr(2, Format.size() - 4);
+  if (normalizeName(Format)) {
 // If we've modified the string name, we need a new identifier for it.
 II = &S.Context.Idents.get(Format);
   }
@@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
   StringRef Str = Name->getName();
 
-  // Normalize the attribute name, __foo__ becomes foo.
-  if (Str.startswith("__") && Str.endswith("__"))
-Str = Str.substr(2, Str.size() - 4);
+  normalizeName(Str);
 
   unsigned DestWidth = 0;
   bool IntegerMode = true;
@@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
 
 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
  const AttributeList &Attr) {
+  StringRef AttrName = Attr.getName()->getName();
+  normalizeName(AttrName);
   std::string SanitizerName =
-  llvm::StringSwitch(Attr.getName()->getName())
+  llvm::StringSwitch(AttrName)
   .Case("no_address_safety_analysis", "address")
   .Case("no_sanitize_address", "address")
   .Case("no_sanitize_thread", "thread")

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp Thu Oct  8 14:24:08 2015
@@ -5,12 +5,14 @@
 #if !__has_attribute(no_sanitize_address)
 #error "Should support no_sanitize_address"
 #endif
-
-void noanal_fun() NO_SANITIZE_ADDRESS;
-
-void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
-  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
-
+
+void noanal_fun() NO_SANITIZE_ADDRESS;
+
+void noanal_fun_alt() __attribute__((__no_sanitize_address__));
+
+void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
+  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
+
 int noanal_testfn(int y) NO_SANITIZE_ADDRESS;
 
 int noanal_testfn(int y) {

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp (original)
+++ cfe/trunk/test/Sem

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Run clang-format, diff is in SVN format.

Please, can you commit on behalf of me unless you are willing to grant me write 
permission to the repo ;-)

Adrian


> On Oct 8, 2015, at 11:40 AM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
>> I so much like this fast review cycle :)
>
> I aim to please. ;-)
>
>>
>> Comments applied.
>
> LGTM with one nit:
>
> +static bool normalizeName(StringRef& AttrName) {
>
> Should be (StringRef &AttrName) per style guidelines. A good idea is
> to run clang-format over the patch or modified code, that fixes these
> sort of things handily.
>
> Thanks!
>
> ~Aaron
>
>>
>> Adrian
>>
>>
>>> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>>>
>>> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
 Feedback applied, new patch in the attachment.
>>>
>>> Thank you for working on this! A few comments:
>>>
 From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
 Date: Wed, 7 Oct 2015 15:55:53 -0700
 Subject: [PATCH] Fix ICE in Clang when dealing with
 attribute(__no_sanitize_*__)

 Summary:

 Both syntaxes: __attribute__((no_sanitize_address)) and
 __attribute__((__no_sanitize__address__)) are valid, following
 documentation:

> The attribute identifier (but not scope) can also be specified with a
> preceding and following __ (double underscore) to avoid interference
> from a macro with the same name. For instance, gnu::__const__ can be
> used instead of gnu::const.

 This patch is fixing ICE when __const__ syntax is used.

 Test Plan:

 Added unittests in the patch which cover these cases. After applying
 this patch they don't crash anymore.
 ---
 lib/Sema/SemaDeclAttr.cpp | 28
 +---
 test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
 test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
 test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
 4 files changed, 23 insertions(+), 11 deletions(-)
>>>
>>> FWIW, it's usually better to supply svn patches instead of git patches
>>> (my vcs has troubles applying patches like this).
>>>

 diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
 index 3cf9567..b2f2cff 100644
 --- a/lib/Sema/SemaDeclAttr.cpp
 +++ b/lib/Sema/SemaDeclAttr.cpp
 @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
 AttrRange, Decl *D, Expr *E,
AssumeAlignedAttr(AttrRange, Context, E, OE,
 SpellingListIndex));
 }

 +/// Normalize the attribute, __foo__ becomes foo.
 +/// Returns true if normalization was applied.
 +static bool normalizeAttrName(StringRef& AttrName) {
>>>
>>> I would prefer this be called normalizeName since it doesn't just
>>> normalize attribute names (for instance, this is used to normalize
>>> attribute arguments as well).
>>>
 +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
 +assert(AttrName.size() > 4 && "Too short attribute name");
>>>
>>> "Name too short" instead.
>>>
 +AttrName = AttrName.substr(2, AttrName.size() - 4);
>>>
>>> I prefer: drop_front() and drop_back() instead.
>>>
 +return true;
 +  }
 +  return false;
 +}
 +
 static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
 &AL) {
  // This attribute must be applied to a function declaration. The first
  // argument to the attribute must be an identifier, the name of the
 resource,
 @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D,
 const AttributeList &AL) {

  IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;

 -  // Normalize the argument, __foo__ becomes foo.
  StringRef ModuleName = Module->getName();
 -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
 -  ModuleName.size() > 4) {
 -ModuleName = ModuleName.drop_front(2).drop_back(2);
 +  if (normalizeAttrName(ModuleName)) {
Module = &S.PP.getIdentifierTable().get(ModuleName);
  }

 @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
  StringRef Format = II->getName();

 -  // Normalize the argument, __foo__ becomes foo.
 -  if (Format.startswith("__") && Format.endswith("__")) {
 -Format = Format.substr(2, Format.size() - 4);
 +  if (normalizeAttrName(Format)) {
// If we've modified the string name, we need a new identifier for
 it.
II = &S.Context.Idents.get(Format);
  }
 @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const
 AttributeList &Attr) {
  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
  StringRef Str = Name->getName();

 -  // Normalize the attribute name, __

Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 36889.
hintonda added a comment.

- add back check for standalone and add cmake version


http://reviews.llvm.org/D13453

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, 
but
   # the usual CMake convention seems to be ${Project}Targets.cmake.


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, but
   # the usual CMake convention seems to be ${Project}Targets.cmake.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13525: [CodeGen] Attach function attributes to functions created in CGBlocks.cpp.

2015-10-08 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 36886.
ahatanak added a comment.

Changed CodeGenModule::SetLLVMFunctionAttributesForDefinition to use early 
return.

I'll first commit the NFC patch to fix 
CodeGenModule::SetLLVMFunctionAttributesForDefinition and commit the rest after 
that.


http://reviews.llvm.org/D13525

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenObjC/arc-blocks.m

Index: test/CodeGenObjC/arc-blocks.m
===
--- test/CodeGenObjC/arc-blocks.m
+++ test/CodeGenObjC/arc-blocks.m
@@ -43,7 +43,7 @@
   extern void test2_helper(id (^)(void));
   test2_helper(^{ return x; });
 
-// CHECK-LABEL:define internal void @__copy_helper_block_
+// CHECK-LABEL:define internal void @__copy_helper_block_(i8*, i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8**
@@ -53,7 +53,7 @@
 // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) [[NUW]]
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL:define internal void @__destroy_helper_block_
+// CHECK-LABEL:define internal void @__destroy_helper_block_(i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5
@@ -134,16 +134,16 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[T1]]
   // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
   // CHECK-NEXT: store i8* null, i8** [[T1]]
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]]
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
@@ -155,10 +155,10 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
 }
 
@@ -221,27 +221,27 @@
   // CHECK-NEXT: call void @llvm.lifetime.end(i64 48, i8* [[VARPTR2]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
 
   // CHECK-LABEL:define internal void @__test6_block_invoke
   // CHECK:  [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Marshall Clow via cfe-commits
On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith  wrote:

> . This one is tricky:
>
> 1) There's an (undocumented) interface between the C standard library and
> this header, where the macros __need_ptrdiff_t, __need_size_t,
> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
> header rather than the whole thing. If we see any of those, just go
> straight to the underlying header.
>

Ok, but in that case we don't get nullptr.  I suspect that's OK.


> 2) We probably don't want  to include  (for consistency
> with other headers)
>

No, we do not! :-)


> , but  must provide a ::nullptr_t (which we don't want 
> to provide). So neither header includes the other. Instead, both include
> <__nullptr> for std::nullptr_t, and we duplicate the definition of
> max_align_t between them, in the case where the compiler's 
> doesn't provide it.
>
> If you prefer, I could make  include  to avoid the
> duplication of the max_align_t logic.
>

No; this is a minor annoyance, and layer jumping ( including
) is a major annoyance - and I'm pretty sure that that would come
back to bite us in the future.

Looks ok to me.

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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
I so much like this fast review cycle :)

Comments applied.

Adrian


> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
>> Feedback applied, new patch in the attachment.
>
> Thank you for working on this! A few comments:
>
>> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
>> Date: Wed, 7 Oct 2015 15:55:53 -0700
>> Subject: [PATCH] Fix ICE in Clang when dealing with
>> attribute(__no_sanitize_*__)
>>
>> Summary:
>>
>> Both syntaxes: __attribute__((no_sanitize_address)) and
>> __attribute__((__no_sanitize__address__)) are valid, following
>> documentation:
>>
>>> The attribute identifier (but not scope) can also be specified with a
>>> preceding and following __ (double underscore) to avoid interference
>>> from a macro with the same name. For instance, gnu::__const__ can be
>>> used instead of gnu::const.
>>
>> This patch is fixing ICE when __const__ syntax is used.
>>
>> Test Plan:
>>
>> Added unittests in the patch which cover these cases. After applying
>> this patch they don't crash anymore.
>> ---
>> lib/Sema/SemaDeclAttr.cpp | 28 +---
>> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>> 4 files changed, 23 insertions(+), 11 deletions(-)
>
> FWIW, it's usually better to supply svn patches instead of git patches
> (my vcs has troubles applying patches like this).
>
>>
>> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
>> index 3cf9567..b2f2cff 100644
>> --- a/lib/Sema/SemaDeclAttr.cpp
>> +++ b/lib/Sema/SemaDeclAttr.cpp
>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange 
>> AttrRange, Decl *D, Expr *E,
>> AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
>> }
>>
>> +/// Normalize the attribute, __foo__ becomes foo.
>> +/// Returns true if normalization was applied.
>> +static bool normalizeAttrName(StringRef& AttrName) {
>
> I would prefer this be called normalizeName since it doesn't just
> normalize attribute names (for instance, this is used to normalize
> attribute arguments as well).
>
>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> +assert(AttrName.size() > 4 && "Too short attribute name");
>
> "Name too short" instead.
>
>> +AttrName = AttrName.substr(2, AttrName.size() - 4);
>
> I prefer: drop_front() and drop_back() instead.
>
>> +return true;
>> +  }
>> +  return false;
>> +}
>> +
>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
>>   // This attribute must be applied to a function declaration. The first
>>   // argument to the attribute must be an identifier, the name of the 
>> resource,
>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D, 
>> const AttributeList &AL) {
>>
>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>>   StringRef ModuleName = Module->getName();
>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> -  ModuleName.size() > 4) {
>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> +  if (normalizeAttrName(ModuleName)) {
>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>   }
>>
>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const 
>> AttributeList &Attr) {
>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>   StringRef Format = II->getName();
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>> -  if (Format.startswith("__") && Format.endswith("__")) {
>> -Format = Format.substr(2, Format.size() - 4);
>> +  if (normalizeAttrName(Format)) {
>> // If we've modified the string name, we need a new identifier for it.
>> II = &S.Context.Idents.get(Format);
>>   }
>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const 
>> AttributeList &Attr) {
>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>   StringRef Str = Name->getName();
>>
>> -  // Normalize the attribute name, __foo__ becomes foo.
>> -  if (Str.startswith("__") && Str.endswith("__"))
>> -Str = Str.substr(2, Str.size() - 4);
>> +  static_cast(normalizeAttrName(Str));
>
> No need for the static_cast to void here; we're okay ignoring this
> return value implicitly.
>
>>
>>   unsigned DestWidth = 0;
>>   bool IntegerMode = true;
>> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, 
>> const AttributeList &Attr) {
>>
>> static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>>  const AttributeList &Attr) {
>> +  StringRef AttrName = Attr.getName()->getName();
>> +  static_cast(normalizeAttrName(AttrName));
>
> No need for the static_cast here either.
>
> ~Aaron
>
>>   std::string SanitizerName =
>> -  llvm::StringSwitch(Attr.getName()-

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
> I so much like this fast review cycle :)

I aim to please. ;-)

>
> Comments applied.

LGTM with one nit:

+static bool normalizeName(StringRef& AttrName) {

Should be (StringRef &AttrName) per style guidelines. A good idea is
to run clang-format over the patch or modified code, that fixes these
sort of things handily.

Thanks!

~Aaron

>
> Adrian
>
>
>> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>>
>> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
>>> Feedback applied, new patch in the attachment.
>>
>> Thank you for working on this! A few comments:
>>
>>> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
>>> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
>>> Date: Wed, 7 Oct 2015 15:55:53 -0700
>>> Subject: [PATCH] Fix ICE in Clang when dealing with
>>> attribute(__no_sanitize_*__)
>>>
>>> Summary:
>>>
>>> Both syntaxes: __attribute__((no_sanitize_address)) and
>>> __attribute__((__no_sanitize__address__)) are valid, following
>>> documentation:
>>>
 The attribute identifier (but not scope) can also be specified with a
 preceding and following __ (double underscore) to avoid interference
 from a macro with the same name. For instance, gnu::__const__ can be
 used instead of gnu::const.
>>>
>>> This patch is fixing ICE when __const__ syntax is used.
>>>
>>> Test Plan:
>>>
>>> Added unittests in the patch which cover these cases. After applying
>>> this patch they don't crash anymore.
>>> ---
>>> lib/Sema/SemaDeclAttr.cpp | 28
>>> +---
>>> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>>> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>>> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>>> 4 files changed, 23 insertions(+), 11 deletions(-)
>>
>> FWIW, it's usually better to supply svn patches instead of git patches
>> (my vcs has troubles applying patches like this).
>>
>>>
>>> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
>>> index 3cf9567..b2f2cff 100644
>>> --- a/lib/Sema/SemaDeclAttr.cpp
>>> +++ b/lib/Sema/SemaDeclAttr.cpp
>>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
>>> AttrRange, Decl *D, Expr *E,
>>> AssumeAlignedAttr(AttrRange, Context, E, OE,
>>> SpellingListIndex));
>>> }
>>>
>>> +/// Normalize the attribute, __foo__ becomes foo.
>>> +/// Returns true if normalization was applied.
>>> +static bool normalizeAttrName(StringRef& AttrName) {
>>
>> I would prefer this be called normalizeName since it doesn't just
>> normalize attribute names (for instance, this is used to normalize
>> attribute arguments as well).
>>
>>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>>> +assert(AttrName.size() > 4 && "Too short attribute name");
>>
>> "Name too short" instead.
>>
>>> +AttrName = AttrName.substr(2, AttrName.size() - 4);
>>
>> I prefer: drop_front() and drop_back() instead.
>>
>>> +return true;
>>> +  }
>>> +  return false;
>>> +}
>>> +
>>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>>> &AL) {
>>>   // This attribute must be applied to a function declaration. The first
>>>   // argument to the attribute must be an identifier, the name of the
>>> resource,
>>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D,
>>> const AttributeList &AL) {
>>>
>>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>>
>>> -  // Normalize the argument, __foo__ becomes foo.
>>>   StringRef ModuleName = Module->getName();
>>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>>> -  ModuleName.size() > 4) {
>>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>>> +  if (normalizeAttrName(ModuleName)) {
>>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>>   }
>>>
>>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
>>> const AttributeList &Attr) {
>>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Format = II->getName();
>>>
>>> -  // Normalize the argument, __foo__ becomes foo.
>>> -  if (Format.startswith("__") && Format.endswith("__")) {
>>> -Format = Format.substr(2, Format.size() - 4);
>>> +  if (normalizeAttrName(Format)) {
>>> // If we've modified the string name, we need a new identifier for
>>> it.
>>> II = &S.Context.Idents.get(Format);
>>>   }
>>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const
>>> AttributeList &Attr) {
>>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Str = Name->getName();
>>>
>>> -  // Normalize the attribute name, __foo__ becomes foo.
>>> -  if (Str.startswith("__") && Str.endswith("__"))
>>> -Str = Str.substr(2, Str.size() - 4);
>>> +  static_cast(normalizeAttrName(Str));
>>
>> No need for the static_cast to void here; we're okay ignoring this
>> return value implicitly.
>>
>>>
>>>   unsigned DestWidth = 0;
>>>   bool IntegerMode = true;
>>> @@ -4533,

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
> Feedback applied, new patch in the attachment.

Thank you for working on this! A few comments:

> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
> Date: Wed, 7 Oct 2015 15:55:53 -0700
> Subject: [PATCH] Fix ICE in Clang when dealing with
>  attribute(__no_sanitize_*__)
>
> Summary:
>
> Both syntaxes: __attribute__((no_sanitize_address)) and
> __attribute__((__no_sanitize__address__)) are valid, following
> documentation:
>
> > The attribute identifier (but not scope) can also be specified with a
> > preceding and following __ (double underscore) to avoid interference
> > from a macro with the same name. For instance, gnu::__const__ can be
> > used instead of gnu::const.
>
> This patch is fixing ICE when __const__ syntax is used.
>
> Test Plan:
>
> Added unittests in the patch which cover these cases. After applying
> this patch they don't crash anymore.
> ---
>  lib/Sema/SemaDeclAttr.cpp | 28 +---
>  test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>  test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>  test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>  4 files changed, 23 insertions(+), 11 deletions(-)

FWIW, it's usually better to supply svn patches instead of git patches
(my vcs has troubles applying patches like this).

>
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index 3cf9567..b2f2cff 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange AttrRange, 
> Decl *D, Expr *E,
>  AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
>  }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeAttrName(StringRef& AttrName) {

I would prefer this be called normalizeName since it doesn't just
normalize attribute names (for instance, this is used to normalize
attribute arguments as well).

> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Too short attribute name");

"Name too short" instead.

> +AttrName = AttrName.substr(2, AttrName.size() - 4);

I prefer: drop_front() and drop_back() instead.

> +return true;
> +  }
> +  return false;
> +}
> +
>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
>// This attribute must be applied to a function declaration. The first
>// argument to the attribute must be an identifier, the name of the 
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D, 
> const AttributeList &AL) {
>
>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeAttrName(ModuleName)) {
>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>}
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const 
> AttributeList &Attr) {
>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeAttrName(Format)) {
>  // If we've modified the string name, we need a new identifier for it.
>  II = &S.Context.Idents.get(Format);
>}
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const 
> AttributeList &Attr) {
>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2, Str.size() - 4);
> +  static_cast(normalizeAttrName(Str));

No need for the static_cast to void here; we're okay ignoring this
return value implicitly.

>
>unsigned DestWidth = 0;
>bool IntegerMode = true;
> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, 
> const AttributeList &Attr) {
>
>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>   const AttributeList &Attr) {
> +  StringRef AttrName = Attr.getName()->getName();
> +  static_cast(normalizeAttrName(AttrName));

No need for the static_cast here either.

~Aaron

>std::string SanitizerName =
> -  llvm::StringSwitch(Attr.getName()->getName())
> +  llvm::StringSwitch(AttrName)
>.Case("no_address_safety_analysis", "address")
>.Case("no_sanitize_address", "address")
>.Case("no_sanitize_thread", "thread")
> diff --git a/test/Sem

Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-10-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Thanks for the comments!



Comment at: lib/CodeGen/CGOpenMPRuntime.h:323
@@ +322,3 @@
+  /// far.
+  struct OffloadEntriesInfoManagerTy {
+CodeGenModule &CGM;

ABataev wrote:
> Maybe it is better to make it a class if it has some non-public members?
Ok, replaced struct by class in `OffloadEntriesInfoManagerTy` and the other 
subtypes that have either private or protected fields.



http://reviews.llvm.org/D12614



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


Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-10-08 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 36880.
sfantao added a comment.

Use class instead of structs if aggregate have private or protected fields.


http://reviews.llvm.org/D12614

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/LangOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_global_capture.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_messages.cpp

Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -omptargets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s
+// CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
 
 void foo() {
 }
Index: test/OpenMP/target_codegen_registration.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_registration.cpp
@@ -0,0 +1,437 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+
+// Check that no target code is emmitted if no omptests flag was provided.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NTARGET
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SA:%.+]] = type { [4 x i32] }
+// CHECK-DAG: [[SB:%.+]] = type { [8 x i32] }
+// CHECK-DAG: [[SC:%.+]] = type { [16 x i32] }
+// CHECK-DAG: [[SD:%.+]] = type { [32 x i32] }
+// CHECK-DAG: [[SE:%.+]] = type { [64 x i32] }
+// CHECK-DAG: [[ST1:%.+]] = type { [228 x i32] }
+// CHECK-DAG: [[ST2:%.+]] = type { [1128 x i32] }
+// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+// CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
+// CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* }
+
+// TCHECK:[[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+
+// CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
+// CHECK-DAG: [[A2:@.+]] = glob

[PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.

setjmp and longjmp facilities in C++ are unsafe due to the likelihood of 
triggering undefined behavior with nontrivial type destruction, etc. Instead, 
exception handling facilities are a better choice. This patch adds a checker 
that discourages the use of setjmp and longjmp in C++.

This patch corresponds to CERT C++ Coding Standard rule: 
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834

http://reviews.llvm.org/D13567

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/SetLongJmpCheck.cpp
  clang-tidy/cert/SetLongJmpCheck.h
  docs/clang-tidy/checks/cert-setlongjmp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-setlongjmp.cpp

Index: test/clang-tidy/cert-setlongjmp.cpp
===
--- test/clang-tidy/cert-setlongjmp.cpp
+++ test/clang-tidy/cert-setlongjmp.cpp
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s cert-err52-cpp %t -- -std=c++11
+
+typedef void *jmp_buf;
+extern int __setjmpimpl(jmp_buf);
+#define setjmp(x) __setjmpimpl(x)
+[[noreturn]] extern void longjmp(jmp_buf, int);
+
+namespace std {
+using ::jmp_buf;
+using ::longjmp;
+}
+
+static jmp_buf env;
+void g() {
+  std::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead [cert-err52-cpp]
+  ::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+  longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+}
+
+void f() {
+  (void)setjmp(env);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cert-setlongjmp
cert-variadic-function-def
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
Index: docs/clang-tidy/checks/cert-setlongjmp.rst
===
--- docs/clang-tidy/checks/cert-setlongjmp.rst
+++ docs/clang-tidy/checks/cert-setlongjmp.rst
@@ -0,0 +1,11 @@
+cert-err52-cpp
+==
+
+The C standard library facilities setjmp() and longjmp() can be used to
+simulate throwing and catching exceptions. However, these facilities bypass
+automatic resource management and can result in undefined behavior, commonly
+including resource leaks, and denial-of-service attacks.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR52-CPP. Do not use setjmp() or longjmp()
+`_.
Index: clang-tidy/cert/SetLongJmpCheck.h
===
--- clang-tidy/cert/SetLongJmpCheck.h
+++ clang-tidy/cert/SetLongJmpCheck.h
@@ -0,0 +1,37 @@
+//===--- SetLongJmpCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Guards against use of setjmp/longjmp in C++ code
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-setlongjmp.html
+class SetLongJmpCheck : public ClangTidyCheck {
+public:
+  SetLongJmpCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+
+  static const char DiagWording[];
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
Index: clang-tidy/cert/SetLongJmpCheck.cpp
===
--- clang-tidy/cert/SetLongJmpCheck.cpp
+++ clang-tidy/cert/SetLongJmpCheck.cpp
@@ -0,0 +1,80 @@
+//===--- SetLongJmpCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-08 Thread Chris Bieneman via cfe-commits
beanz added inline comments.


Comment at: runtime/CMakeLists.txt:41
@@ +40,3 @@
+
+  add_custom_target(compiler-rt-clear
+DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared

samsonov wrote:
> So, that's the target that you can invoke manually to clean compiler-rt build?
Yes.


Comment at: runtime/CMakeLists.txt:46
@@ +45,3 @@
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+DEPENDS clang llvm-config
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}

samsonov wrote:
> Hm? But "compiler-rt" target also depends on clang and llvm-config.
It should. We need it to rebuild whenever clang and llvm-config change.

Although it just occurred to me that I also need to make sure that the clearing 
happens before compiler-rt gets built, so there will need to be a dependency on 
that too... I'll figure that out.


Comment at: runtime/CMakeLists.txt:69
@@ -47,3 +68,3 @@
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""

samsonov wrote:
> I thought we only refer to COMPILER_RT_INSTALL_PATH in compiler-rt's CMake. 
> Do we actually need CMAKE_INSTALL_PREFIX there as well?
I don't think we're actually using it in compiler-rt today, but I think that 
passing it through is a good idea so that if in the future compiler-rt ever 
uses CMAKE_INSTALL_PREFIX it will be properly populated.


Comment at: runtime/CMakeLists.txt:70
@@ -49,2 +69,3 @@
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build

samsonov wrote:
> Disagree - we can't set COMPILER_RT_ENABLE_WERROR in compiler-rt's CMake, 
> because standalone compiler-rt can be built with any compiler in the world, 
> which we don't control. OTOH, if we *know* we're building it with trunk 
> Clang, having it -Werror-clean is smth. we can enforce. It's also consistent 
> with what autoconf did previously.
At the very least if we do that it should be tied to LLVM_ENABLE_WERROR, not 
just defaulted to On. None of our projects default WERROR to On anywhere. While 
I agree building with Werror is desirable, we shouldn't be defaulting it on, 
and we certainly shouldn't be doing it in a way that makes it so the user has 
to edit the build files in order to turn it off.


Comment at: runtime/CMakeLists.txt:78
@@ -62,11 +77,3 @@
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
-
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt

samsonov wrote:
> This is also convenience target, right?
Yes.


http://reviews.llvm.org/D13399



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


Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I added this conditional check in r221415, with this message:

  cmake: Only export targets in the standalone build
  
  Trying to fix bots that didn't like the fact that I exported targets
  that depended on LLVM without exporting targets from LLVM.

I assume this has already been addressed in LLVM? We now export targets there 
so we can depend on them in clang's exported targets file? If so, I'm happy to 
make this check simply conditional on the CMake version like you suggest.

I'm not actually a good reviewer for these kinds of things, I know very little 
about cmake package exports. =/ When I made this code change, I was just trying 
to hack the standalone build into shape. I haven't really used it since.


http://reviews.llvm.org/D13453



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


Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)

2015-10-08 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> Even if you do not deal with this case I think it would be great to have an 
> XFAIL test with a fixme that describes this limitation.


Yes! Every time we have a test case that shows known limitations, we should add 
it to the regression tests with a TODO explaining the issue. (I would not add 
it as a separate test that is XFAILed but rather add to an existing test file 
at the very end in the TODO or FIXME section. )


http://reviews.llvm.org/D13099



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


r249704 - [clang-cl] Make /EHs turn on C++ EH once again

2015-10-08 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct  8 12:29:07 2015
New Revision: 249704

URL: http://llvm.org/viewvc/llvm-project?rev=249704&view=rev
Log:
[clang-cl] Make /EHs turn on C++ EH once again

C++ exceptions are still off by default, which is similar to how C++
cleanups are off by default in MSVC.

If you use clang instead of clang-cl, exceptions are also still off by
default. In the future, when C++ EH is proven to be stable, we may flip
the default for that driver to be consistent with other platforms.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-eh.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249704&r1=249703&r2=249704&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct  8 12:29:07 2015
@@ -5392,10 +5392,6 @@ static EHFlags parseClangCLEHFlags(const
 }
   }
 
-  // FIXME: Disable C++ EH completely, until it becomes more reliable. Users
-  // can use -Xclang to manually enable C++ EH until then.
-  EH = EHFlags();
-
   return EH;
 }
 

Modified: cfe/trunk/test/Driver/cl-eh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-eh.cpp?rev=249704&r1=249703&r2=249704&view=diff
==
--- cfe/trunk/test/Driver/cl-eh.cpp (original)
+++ cfe/trunk/test/Driver/cl-eh.cpp Thu Oct  8 12:29:07 2015
@@ -1,11 +1,9 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
-// FIXME: When C++ EH works, we can make this flag turn things back on.
-
 // RUN: %clang_cl /c /EHsc -### -- %s 2>&1 | FileCheck -check-prefix=EHsc %s
-// EHsc-NOT: "-fcxx-exceptions"
-// EHsc-NOT: "-fexceptions"
+// EHsc: "-fcxx-exceptions"
+// EHsc: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs-c- -### -- %s 2>&1 | FileCheck -check-prefix=EHs_c_ 
%s
 // EHs_c_-NOT: "-fcxx-exceptions"
@@ -16,12 +14,12 @@
 // EHs_EHc_-NOT: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs- /EHs -### -- %s 2>&1 | FileCheck 
-check-prefix=EHs_EHs %s
-// EHs_EHs-NOT: "-fcxx-exceptions"
-// EHs_EHs-NOT: "-fexceptions"
+// EHs_EHs: "-fcxx-exceptions"
+// EHs_EHs: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs- /EHsa -### -- %s 2>&1 | FileCheck 
-check-prefix=EHs_EHa %s
-// EHs_EHa-NOT: "-fcxx-exceptions"
-// EHs_EHa-NOT: "-fexceptions"
+// EHs_EHa: "-fcxx-exceptions"
+// EHs_EHa: "-fexceptions"
 
 // RUN: %clang_cl /c /EHinvalid -### -- %s 2>&1 | FileCheck 
-check-prefix=EHinvalid %s
 // EHinvalid: error: invalid value 'invalid' in '/EH'


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


Re: [PATCH] D12832: [Driver] Add support for Windows 10 SDK

2015-10-08 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Looks like this got committed. Sorry for the delay, I was travelling.


http://reviews.llvm.org/D12832



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


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread via cfe-commits
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;

We need to differentiate between these two. For the second case, we should
not add any attribute because it’s not invoked in the EH region and it
could have any other purposes other than exception handling. I believe we
need to specifically handle only the case where we can guarantee that the
call is invoked only in exception handling context.


> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.

I agree. If we need to add check for callee size, doing this in frontend
may not be the good idea. But it should be done before inliner.


> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.

Basically, current Inliner doesn't have any impact with Attribute::Cold
because ColdThreshold and InlineLimit are the same by default. I
understand noinline looks somewhat strong decision. But, even with
noinline, I believe we could expect more pros than cons.

In performance perspective, by avoiding inlining in throw statement, we
could open up more inline opportunities for functions containing throw
statements. For example, below small function could not be inlined in its
many callsites if the constructor of IndexOutOfBoundsException is
non-trivial and inlined first in elementAt().

  int elementAt(int idx) {
if (idx >= limit)
  throw IndexOutOfBoundsException(idx, limit);
return Array[idx];
  }
Pretty much same thing could actually happen in many c++ programs, and I
found the actual cases in spec2006/xalancbmk.

In most case we also don't need to increase code size by inlining
constructors invoked in throw statement, especially when there is a
hierarchy of exception handling classes.

The only downsides I can think of is the case where the constructor is
very small so that inlining it is profitable for size. My suggestion for
this is to move this implementation back to PruneEH.cpp so that we can
check the callee size right before the inliner. I may add the noinline
only when the constructor is large enough.




> On Wed, Oct 7, 2015 at 3:10 PM, Jun Bum Lim via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> junbuml added a comment.
>>
>> Thanks Richard for the comment.
>>
>> Initially, I intended to implement this in inliner by checking if a
>> callsite is in exception handling regions. However, I decided not to
>> implement this in inliner because this kind of check should be performed
>> for all callsites if we implement it in inliner.
>>
>> Instead of directly adding complexity in inliner, I implemented this in
>> PruneEH.cpp (http://reviews.llvm.org/D12979) because this is very
>> specific to exception handling regions. In this patch, I tried to mark
>> all
>> callsites invoked from throw statements as cold (noinline) by looking up
>> users of __cxa_throw() and __cxa_allocate_exception(). We had many
>> discussions and finally ended up to implement the same thing in clang to
>> be
>> more general and simpler as Hal suggested in
>> http://reviews.llvm.org/D12979.
>>
>
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;
>
> which doesn't really seem defensible.
>
>
>> As you point out, it should be done by influencing inline cost heurisic,
>> so I believe Attribute::Cold is the right attribute to be added here.
>> However, as I FIXMEed, the current ColdThreshold is not tuned yet
>> (r200898). So for now, I add both cold and noinline.
>>
>> Regarding code size, I believe not inlining contractor calls in throw
>> statements could be potentially more helpful for code size in many
>> cases.
>> If inlining very small callsites in throw statements could be issue,
>> then
>> we may be able to  check if callee is smaller than some threshold to
>> avoid
>> adding the attributes (cold and noinline).
>
>
> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.
>
> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.
>

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


r249699 - Simplify DefaultCPU in ARMTargetInfo

2015-10-08 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Oct  8 11:43:26 2015
New Revision: 249699

URL: http://llvm.org/viewvc/llvm-project?rev=249699&view=rev
Log:
Simplify DefaultCPU in ARMTargetInfo

Simplifying the convoluted CPU handling in ARMTargetInfo.

The default base CPU on ARM is ARM7TDMI, arch ARMv4T, and
ARMTargetInfo had a different one. This wasn't visible from
Clang because the driver selects the defaults and sets the
Arch/CPU features directly, but the constructor depended
on the CPU, which was never used.

This patch corrects the mistake and greatly simplifies
how CPU is dealt with (essentially by removing the duplicated
DefaultCPU field).

Tests updated.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249699&r1=249698&r2=249699&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 11:43:26 2015
@@ -4086,7 +4086,6 @@ class ARMTargetInfo : public TargetInfo
 
   std::string ABI, CPU;
 
-  StringRef DefaultCPU;
   StringRef CPUProfile;
   StringRef CPUAttr;
 
@@ -4097,7 +4096,7 @@ class ARMTargetInfo : public TargetInfo
   } FPMath;
 
   unsigned ArchISA;
-  unsigned ArchKind;
+  unsigned ArchKind = llvm::ARM::AK_ARMV4T;
   unsigned ArchProfile;
   unsigned ArchVersion;
 
@@ -4235,13 +4234,11 @@ class ARMTargetInfo : public TargetInfo
   void setArchInfo() {
 StringRef ArchName = getTriple().getArchName();
 
-ArchISA= llvm::ARM::parseArchISA(ArchName);
-DefaultCPU = getDefaultCPU(ArchName);
-
-unsigned ArchKind = llvm::ARM::parseArch(ArchName);
-if (ArchKind == llvm::ARM::AK_INVALID)
-  // set arch of the CPU, either provided explicitly or hardcoded default
-  ArchKind = llvm::ARM::parseCPUArch(CPU);
+ArchISA = llvm::ARM::parseArchISA(ArchName);
+CPU = llvm::ARM::getDefaultCPU(ArchName);
+unsigned AK = llvm::ARM::parseArch(ArchName);
+if (AK != llvm::ARM::AK_INVALID)
+  ArchKind = AK;
 setArchInfo(ArchKind);
   }
 
@@ -4262,8 +4259,7 @@ class ARMTargetInfo : public TargetInfo
   void setAtomic() {
 // when triple does not specify a sub arch, 
 // then we are not using inline atomics
-bool ShouldUseInlineAtomic = DefaultCPU.empty() ? 
- false :
+bool ShouldUseInlineAtomic =
(ArchISA == llvm::ARM::IK_ARM   && ArchVersion >= 6) ||
(ArchISA == llvm::ARM::IK_THUMB && ArchVersion >= 7);
 // Cortex M does not support 8 byte atomics, while general Thumb2 does. 
@@ -4291,10 +4287,6 @@ class ARMTargetInfo : public TargetInfo
 return CPUAttr.equals("6T2") || ArchVersion >= 7;
   }
 
-  StringRef getDefaultCPU(StringRef ArchName) const {
-return llvm::ARM::getDefaultCPU(ArchName);
-  }
-
   StringRef getCPUAttr() const {
 // For most sub-arches, the build attribute CPU name is enough.
 // For Cortex variants, it's slightly different.
@@ -4340,7 +4332,7 @@ class ARMTargetInfo : public TargetInfo
 
 public:
   ARMTargetInfo(const llvm::Triple &Triple, bool IsBigEndian)
-  : TargetInfo(Triple), CPU("arm1136j-s"), FPMath(FP_Default),
+  : TargetInfo(Triple), FPMath(FP_Default),
 IsAAPCS(true), LDREX(0), HW_FP(0) {
 BigEndian = IsBigEndian;
 
@@ -4353,7 +4345,7 @@ public:
   break;
 }
 
-// cache arch related info
+// Cache arch related info.
 setArchInfo();
 
 // {} in inline assembly are neon specifiers, not assembly variant
@@ -4389,8 +4381,8 @@ public:
 setABI("aapcs");
 break;
   case llvm::Triple::GNU:
-   setABI("apcs-gnu");
-   break;
+setABI("apcs-gnu");
+  break;
   default:
 if (Triple.getOS() == llvm::Triple::NetBSD)
   setABI("apcs-gnu");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=249699&r1=249698&r2=249699&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Oct  8 11:43:26 2015
@@ -1198,7 +1198,7 @@
 // ARM:#define __APCS_32__ 1
 // ARM-NOT:#define __ARMEB__ 1
 // ARM:#define __ARMEL__ 1
-// ARM:#define __ARM_ARCH_6J__ 1
+// ARM:#define __ARM_ARCH_4T__ 1
 // ARM-NOT:#define __ARM_BIG_ENDIAN 1
 // ARM:#define __BIGGEST_ALIGNMENT__ 8
 // ARM:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
@@ -1338,7 +1338,6 @@
 // ARM:#define __SIZE_MAX__ 4294967295U
 // ARM:#define __SIZE_TYPE__ unsigned int
 // ARM:#define __SIZE_WIDTH__ 32
-// ARM:#define __THUMB_INTERWORK__ 1
 // ARM:#define __UINT16_C_SUFFIX__ {{$}}
 // ARM:#define __UINT16_MAX__ 65535
 // ARM:#define __UINT16_TYPE__ unsigned short
@@ -1389,7 +1388,7 @@
 // ARM-BE:#define __APCS_32__ 1
 // ARM-BE:#defi

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Feedback applied, new patch in the attachment.

Adrian


> On Oct 8, 2015, at 8:48 AM, Adrian Zgorzalek  wrote:
>
> Great! I did not notice, that we already have exactly the same logic in 
> SemaDeclAttr.cpp.
> Maybe it would be possible even to refactor it in such a way that this code 
> is written only once.
>
> Adrian
>> On Oct 8, 2015, at 6:53 AM, Aaron Ballman  wrote:
>>
>> (Removing llvm-commits, adding cfe-commits)
>>
>> On Wed, Oct 7, 2015 at 8:07 PM, Adrian Zgorzalek via llvm-commits
>>  wrote:
>>> Hey,
>>>
>>> Here is an attempt to fix 
>>> https://urldefense.proofpoint.com/v1/url?u=https://llvm.org/bugs/show_bug.cgi?id%3D25067&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=8P8ApMVHowVMPUxNPT7LA63ve6JJvA38Hc1rN4zEYvw%3D%0A&s=129aedfc04dd18acb23e1369c5712b619076e282e0a4e07452ac187e4d37d43a.
>>
>> Thank you for working on this!
>>
>>>
>>> Summary:
>>>
>>> After introducing no_sanitize, we try to map no_sanitize_* into a
>>> no_sanitize(“*”), the switch in code, however doesn’t handle cases when
>>> attribute is surrounded by two underscores on each of the ends. In this
>>> patch I am trying to utilize existing normalizeAttrName function, by
>>> exposing it to outside world and using it before feeding input to the
>>> switch.
>>>
>>> Added unit tests for the crashes I encountered and patched.
>>
>> I am hesitant to expose a normalized attribute name API like that
>> because very little should ever care about the actual spelling string
>> of the attribute; instead, it should be looking at the semantic
>> spelling or the (parsed) attribute kind. However, the no sanitize
>> attributes are a bit strange in that they don't have different
>> semantic spellings, but instead use the list of sanitizers, so that
>> approach won't work.
>>
>> I think the better way to handle this is to refactor SemaDeclAttr.cpp
>> to have a helper function named normalizeName() and use it in
>> handleOwnershipAttr, handleFormatAttr, handleModeAttr, and
>> handleNoSanitizeSpecificAttr. It can be used for normalizing attribute
>> names as well as attribute argument names.
>>
>> ~Aaron
>



0001-Fix-ICE-in-Clang-when-dealing-with-attribute-__no_sa.patch
Description: 0001-Fix-ICE-in-Clang-when-dealing-with-attribute-__no_sa.patch
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris abandoned this revision.
vkalintiris added a comment.

In http://reviews.llvm.org/D13557#262801, @jroelofs wrote:

> Unfortunately, Musl intentionally doesn't provide that sort of macro [1], so 
> to provide support for Musl in libc++, we need to make note of it at 
> configure-time via something like a _LIBCXX_LIBC_IS_MUSL macro via 
> http://reviews.llvm.org/D13407.


Agreed. That would be much more elegant. I had to write another patch to test 
for the existence of *each* extended locale functions during 
configuration-time. It was generic but an ugly hack. Offering a 
_LIBCXX_LIBC_IS_MUSL option/macro would make things quite simpler. I'll abandon 
this review request and I'll wait until http://reviews.llvm.org/D13407 is 
committed.


http://reviews.llvm.org/D13557



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


r249698 - CGStmtOpenMP.cpp: Prune redundant \param. [-Wdocumentation]

2015-10-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Oct  8 11:41:42 2015
New Revision: 249698

URL: http://llvm.org/viewvc/llvm-project?rev=249698&view=rev
Log:
CGStmtOpenMP.cpp: Prune redundant \param. [-Wdocumentation]

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=249698&r1=249697&r2=249698&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Oct  8 11:41:42 2015
@@ -213,7 +213,6 @@ void CodeGenFunction::EmitOMPAggregateAs
 }
 
 /// \brief Emit initialization of arrays of complex types.
-/// \param Type Type of array.
 /// \param DestAddr Address of the array.
 /// \param Type Type of array.
 /// \param Init Initial expression of array.


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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Great! I did not notice, that we already have exactly the same logic in 
SemaDeclAttr.cpp.
Maybe it would be possible even to refactor it in such a way that this code is 
written only once.

Adrian
> On Oct 8, 2015, at 6:53 AM, Aaron Ballman  wrote:
> 
> (Removing llvm-commits, adding cfe-commits)
> 
> On Wed, Oct 7, 2015 at 8:07 PM, Adrian Zgorzalek via llvm-commits
>  wrote:
>> Hey,
>> 
>> Here is an attempt to fix 
>> https://urldefense.proofpoint.com/v1/url?u=https://llvm.org/bugs/show_bug.cgi?id%3D25067&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=8P8ApMVHowVMPUxNPT7LA63ve6JJvA38Hc1rN4zEYvw%3D%0A&s=129aedfc04dd18acb23e1369c5712b619076e282e0a4e07452ac187e4d37d43a.
> 
> Thank you for working on this!
> 
>> 
>> Summary:
>> 
>> After introducing no_sanitize, we try to map no_sanitize_* into a
>> no_sanitize(“*”), the switch in code, however doesn’t handle cases when
>> attribute is surrounded by two underscores on each of the ends. In this
>> patch I am trying to utilize existing normalizeAttrName function, by
>> exposing it to outside world and using it before feeding input to the
>> switch.
>> 
>> Added unit tests for the crashes I encountered and patched.
> 
> I am hesitant to expose a normalized attribute name API like that
> because very little should ever care about the actual spelling string
> of the attribute; instead, it should be looking at the semantic
> spelling or the (parsed) attribute kind. However, the no sanitize
> attributes are a bit strange in that they don't have different
> semantic spellings, but instead use the list of sanitizers, so that
> approach won't work.
> 
> I think the better way to handle this is to refactor SemaDeclAttr.cpp
> to have a helper function named normalizeName() and use it in
> handleOwnershipAttr, handleFormatAttr, handleModeAttr, and
> handleNoSanitizeSpecificAttr. It can be used for normalizing attribute
> names as well as attribute argument names.
> 
> ~Aaron

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


Re: [PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs added a comment.

I don't think it's correct to say that `!defined(__GLIBC__) && 
defined(__linux__) ==> Musl` (nor is the converse true).  Unfortunately, Musl 
intentionally doesn't provide that sort of macro [1], so to provide support for 
Musl in libc++, we need to make note of it at configure-time via something like 
a _LIBCXX_LIBC_IS_MUSL macro via http://reviews.llvm.org/D13407.

1: http://www.openwall.com/lists/musl/2013/02/08/9


http://reviews.llvm.org/D13557



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


Re: [PATCH] D13407: [libcxx] Capture configuration information when installing the libc++ headers

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added a subscriber: vkalintiris.


Comment at: include/CMakeLists.txt:9
@@ -7,2 +8,3 @@
   PATTERN ".svn" EXCLUDE
+  PATTERN "__config_site.in" EXCLUDE
   ${LIBCXX_SUPPORT_HEADER_PATTERN}

Kind of silly but I believe that the files used for auto-generated config 
headers in LLVM have the extesions `.cmake` and `.in`, for cmake and autoconf, 
respectively.


http://reviews.llvm.org/D13407



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


[PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris created this revision.
vkalintiris added a reviewer: mclow.lists.
vkalintiris added a subscriber: cfe-commits.

Most of the #ifdefs in the locale code would check for the existence of
GLIBC or for operating systems other than Linux. This patch considers the
case where GLIBC isn't available on Linux, and allows the libcxx
library to build successfully when using the musl C library (with a
small patch for the extended locale functions strtoll_l() and
strtoull_l()).

http://reviews.llvm.org/D13557

Files:
  include/__locale
  src/locale.cpp

Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -812,7 +812,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 return isascii(c) ? ctype::__classic_upper_table()[c] : c;
 #else
 return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
@@ -825,7 +826,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 *low = isascii(*low) ? ctype::__classic_upper_table()[*low]
  : *low;
 #else
@@ -839,7 +841,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 return isascii(c) ? ctype::__classic_lower_table()[c] : c;
 #else
 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
@@ -852,7 +855,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 *low = isascii(*low) ? ctype::__classic_lower_table()[*low]
  : *low;
 #else
@@ -921,8 +925,8 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_upper_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
-return isascii(c) ? 
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
+return isascii(c) ?
   static_cast(__classic_upper_table()[static_cast(c)]) : c;
 #else
 return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
@@ -938,7 +942,7 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_upper_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 *low = isascii(*low) ?
   static_cast(__classic_upper_table()[static_cast(*low)]) : *low;
 #else
@@ -955,7 +959,7 @@
   static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_lower_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 return isascii(c) ?
   static_cast(__classic_lower_table()[static_cast(c)]) : c;
 #else
@@ -971,7 +975,7 @@
 *low = isascii(*low) ? static_cast(_DefaultRuneLocale.__maplower[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_lower_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low;
 #else
 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
@@ -1012,7 +1016,7 @@
 return low;
 }
 
-#ifdef __EMSCRIPTEN__
+#if !defined(__GLIBC__) && (defined(__linux__) || defined(__EMSCRIPTEN__))
 extern "C" const unsigned short ** __ctype_b_loc();
 extern "C" const int ** __ctype_tolower_loc();
 extern "C" const int ** __ctype_toupper_loc();
@@ -1114,7 +1118,7 @@
 return _ctype+1; // internal ctype mask table defined in msvcrt.dll
 // This is assumed to be safe, which is a nonsense assumption because we're
 // going to end up dereferencing it later...
-#elif defined(__EM

  1   2   >