Re: [PATCH] D14804: [clang] Disable Unicode in asm files

2015-11-19 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM, too. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D14804



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


Re: [PATCH] D13351: [Power PC] add soft float support for ppc32

2015-11-19 Thread Strahinja Petrovic via cfe-commits
spetrovic added a comment.

ping


http://reviews.llvm.org/D13351



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


Re: [PATCH] D14744: PR10235: support for vector mode attributes + warning

2015-11-19 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253551: PR10235: support for vector mode attributes + 
warning, by Dmitry Polukhin. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D14744?vs=40506&id=40618#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14744

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-mode-vector-types.c

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3234,38 +3234,31 @@
   return true;
 }
 
-/// handleModeAttr - This attribute modifies the width of a decl with primitive
-/// type.
-///
-/// Despite what would be logical, the mode attribute is a decl attribute, not a
-/// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
-/// HImode, not an intermediate pointer.
-static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  // This attribute isn't documented, but glibc uses it.  It changes
-  // the width of an int or unsigned int to the specified size.
-  if (!Attr.isArgIdent(0)) {
-S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
-  << AANT_ArgumentIdentifier;
-return;
-  }
-  
-  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
-  StringRef Str = Name->getName();
-
-  normalizeName(Str);
-
-  unsigned DestWidth = 0;
-  bool IntegerMode = true;
-  bool ComplexMode = false;
+/// parseModeAttrArg - Parses attribute mode string and returns parsed type
+/// attribute.
+static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
+ bool &IntegerMode, bool &ComplexMode) {
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
-case 'Q': DestWidth = 8; break;
-case 'H': DestWidth = 16; break;
-case 'S': DestWidth = 32; break;
-case 'D': DestWidth = 64; break;
-case 'X': DestWidth = 96; break;
-case 'T': DestWidth = 128; break;
+case 'Q':
+  DestWidth = 8;
+  break;
+case 'H':
+  DestWidth = 16;
+  break;
+case 'S':
+  DestWidth = 32;
+  break;
+case 'D':
+  DestWidth = 64;
+  break;
+case 'X':
+  DestWidth = 96;
+  break;
+case 'T':
+  DestWidth = 128;
+  break;
 }
 if (Str[1] == 'F') {
   IntegerMode = false;
@@ -3293,6 +3286,52 @@
   DestWidth = S.Context.getTargetInfo().getUnwindWordWidth();
 break;
   }
+}
+
+/// handleModeAttr - This attribute modifies the width of a decl with primitive
+/// type.
+///
+/// Despite what would be logical, the mode attribute is a decl attribute, not a
+/// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
+/// HImode, not an intermediate pointer.
+static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  // This attribute isn't documented, but glibc uses it.  It changes
+  // the width of an int or unsigned int to the specified size.
+  if (!Attr.isArgIdent(0)) {
+S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
+  << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
+  StringRef Str = Name->getName();
+
+  normalizeName(Str);
+
+  unsigned DestWidth = 0;
+  bool IntegerMode = true;
+  bool ComplexMode = false;
+  llvm::APInt VectorSize(64, 0);
+  if (Str.size() >= 4 && Str[0] == 'V') {
+// Minimal length of vector mode is 4: 'V' + NUMBER(>=1) + TYPE(>=2).
+size_t StrSize = Str.size();
+size_t VectorStringLength = 0;
+while ((VectorStringLength + 1) < StrSize &&
+   isdigit(Str[VectorStringLength + 1]))
+  ++VectorStringLength;
+if (VectorStringLength &&
+!Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
+VectorSize.isPowerOf2()) {
+  parseModeAttrArg(S, Str.substr(VectorStringLength + 1), DestWidth,
+   IntegerMode, ComplexMode);
+  S.Diag(Attr.getLoc(), diag::warn_vector_mode_deprecated);
+} else {
+  VectorSize = 0;
+}
+  }
+
+  if (!VectorSize)
+parseModeAttrArg(S, Str, DestWidth, IntegerMode, ComplexMode);
 
   QualType OldTy;
   if (TypedefNameDecl *TD = dyn_cast(D))
@@ -3351,7 +3390,10 @@
   }
 
   QualType NewTy = NewElemTy;
-  if (const VectorType *OldVT = OldTy->getAs()) {
+  if (VectorSize.getBoolValue()) {
+NewTy = S.Context.getVectorType(NewTy, VectorSize.getZExtValue(),
+VectorType::GenericVector);
+  } else if (const VectorType *OldVT = OldTy->getAs()) {
 // Complex machine mode does not support base vector types.
 if (ComplexMode) {
   S.Diag(Attr.getLoc(), diag::err_complex_mode_vector_type);
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
==

r253551 - PR10235: support for vector mode attributes + warning, by Dmitry Polukhin.

2015-11-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov 19 04:13:11 2015
New Revision: 253551

URL: http://llvm.org/viewvc/llvm-project?rev=253551&view=rev
Log:
PR10235: support for vector mode attributes + warning, by Dmitry Polukhin.
Add support for vector mode attributes like "attribute((mode(V4SF)))". Also add 
warning about deprecated vector modes like GCC does.
Differential Revision: http://reviews.llvm.org/D14744

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-mode-vector-types.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=253551&r1=253550&r2=253551&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 19 04:13:11 2015
@@ -83,6 +83,7 @@ def AbstractFinalClass : DiagGroup<"abst
 def CXX11CompatDeprecatedWritableStr :
   DiagGroup<"c++11-compat-deprecated-writable-strings">;
 
+def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def PartialAvailability : DiagGroup<"partial-availability">;
@@ -92,7 +93,8 @@ def DeprecatedRegister : DiagGroup<"depr
 def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings",
   [CXX11CompatDeprecatedWritableStr]>;
 // FIXME: Why is DeprecatedImplementations not in this group?
-def Deprecated : DiagGroup<"deprecated", [DeprecatedDeclarations,
+def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
+  DeprecatedDeclarations,
   DeprecatedIncrementBool,
   DeprecatedRegister,
   DeprecatedWritableStr]>,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253551&r1=253550&r2=253551&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 19 04:13:11 
2015
@@ -2823,6 +2823,10 @@ def err_mode_not_primitive : Error<
   "mode attribute only supported for integer and floating-point types">;
 def err_mode_wrong_type : Error<
   "type of machine mode does not match type of base type">;
+def warn_vector_mode_deprecated : Warning<
+  "specifying vector types with the 'mode' attribute is deprecated; "
+  "use the 'vector_size' attribute instead">,
+  InGroup;
 def err_complex_mode_vector_type : Error<
   "type of machine mode does not support base vector types">;
 def err_attr_wrong_decl : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=253551&r1=253550&r2=253551&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Nov 19 04:13:11 2015
@@ -3234,38 +3234,31 @@ bool Sema::checkMSInheritanceAttrOnDefin
   return true;
 }
 
-/// handleModeAttr - This attribute modifies the width of a decl with primitive
-/// type.
-///
-/// Despite what would be logical, the mode attribute is a decl attribute, not 
a
-/// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
-/// HImode, not an intermediate pointer.
-static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  // This attribute isn't documented, but glibc uses it.  It changes
-  // the width of an int or unsigned int to the specified size.
-  if (!Attr.isArgIdent(0)) {
-S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
-  << AANT_ArgumentIdentifier;
-return;
-  }
-  
-  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
-  StringRef Str = Name->getName();
-
-  normalizeName(Str);
-
-  unsigned DestWidth = 0;
-  bool IntegerMode = true;
-  bool ComplexMode = false;
+/// parseModeAttrArg - Parses attribute mode string and returns parsed type
+/// attribute.
+static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
+ bool &IntegerMode, bool &ComplexMode) {
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
-case 'Q': DestWidth = 8; break;
-case 'H': DestWidth = 16; break;
-case 'S': DestWidth = 32; break;
-case 'D': DestWidth = 64; break;
-case 'X': DestWidth = 96; break;
-case 'T': DestWidth = 128; break;
+case 'Q':
+  DestWidth = 8;
+  break;
+cas

Re: [PATCH] D14629: [analyzer] Configuration file for scan-build.

2015-11-19 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added a comment.

I think the `scan-build` user experience would be improved by config file! And 
I really like how the `clang-tidy` guys were doing it. (In case if you are not 
familiar with it, copy from the help output)

  Configuration files:
clang-tidy attempts to read configuration for each source file from a
.clang-tidy file located in the closest parent directory of the source
file. If any configuration options have a corresponding command-line
option, command-line option takes precedence. The effective
configuration can be inspected using -dump-config:
  
$ clang-tidy -dump-config - --
  ---
  Checks:  '-*,some-check'
  HeaderFilterRegex: ''
  AnalyzeTemporaryDtors: false
  User:user
  CheckOptions:
- key: some-check.SomeOption
  value:   'some value'
  ...

So the major difference from the current patch would be:

- It's not a windows .ini file, but YAML/JSON syntax.
- No need to provide default config file and check into the source repository.
- Loading of the config file is a bit more complex logic, than taking value 
from a specific location.

Benefit for the user to have common usage pattern of the clang related analyzer 
tools. What do you think?


http://reviews.llvm.org/D14629



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


Re: [PATCH] D14760: Resolve build problem on NetBSD

2015-11-19 Thread NAKAMURA Takumi via cfe-commits
chapuni accepted this revision.
chapuni added a comment.
This revision is now accepted and ready to land.

It is obviously missing dependency.
How to reproduce;

  $ ninja -t clean
  $ ninja clangFrontend

FYI, this is reported also in; https://llvm.org/bugs/show_bug.cgi?id=25565

Sorry for the delay. I had an issue in my network.


Repository:
  rL LLVM

http://reviews.llvm.org/D14760



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


r253554 - clangFrontend: [PR25565] Quick fix for dependencies on Attributes.inc.

2015-11-19 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Nov 19 04:59:48 2015
New Revision: 253554

URL: http://llvm.org/viewvc/llvm-project?rev=253554&view=rev
Log:
clangFrontend: [PR25565] Quick fix for dependencies on Attributes.inc.

FIXME: Attributes.inc may be an independent target.

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

Modified:
cfe/trunk/lib/Frontend/CMakeLists.txt

Modified: cfe/trunk/lib/Frontend/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CMakeLists.txt?rev=253554&r1=253553&r2=253554&view=diff
==
--- cfe/trunk/lib/Frontend/CMakeLists.txt (original)
+++ cfe/trunk/lib/Frontend/CMakeLists.txt Thu Nov 19 04:59:48 2015
@@ -43,6 +43,7 @@ add_clang_library(clangFrontend
 
   DEPENDS
   ClangDriverOptions
+  intrinsics_gen
 
   LINK_LIBS
   clangAST


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


Re: [PATCH] D14760: Resolve build problem on NetBSD

2015-11-19 Thread NAKAMURA Takumi via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253554: clangFrontend: [PR25565] Quick fix for dependencies 
on Attributes.inc. (authored by chapuni).

Changed prior to commit:
  http://reviews.llvm.org/D14760?vs=40439&id=40623#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14760

Files:
  cfe/trunk/lib/Frontend/CMakeLists.txt

Index: cfe/trunk/lib/Frontend/CMakeLists.txt
===
--- cfe/trunk/lib/Frontend/CMakeLists.txt
+++ cfe/trunk/lib/Frontend/CMakeLists.txt
@@ -43,6 +43,7 @@
 
   DEPENDS
   ClangDriverOptions
+  intrinsics_gen
 
   LINK_LIBS
   clangAST


Index: cfe/trunk/lib/Frontend/CMakeLists.txt
===
--- cfe/trunk/lib/Frontend/CMakeLists.txt
+++ cfe/trunk/lib/Frontend/CMakeLists.txt
@@ -43,6 +43,7 @@
 
   DEPENDS
   ClangDriverOptions
+  intrinsics_gen
 
   LINK_LIBS
   clangAST
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14814: [libcxx] Use __make_integer_seq builtin when available

2015-11-19 Thread Agustín Bergé via cfe-commits
K-ballo created this revision.
K-ballo added reviewers: mclow.lists, EricWF, majnemer, rsmith.
K-ballo added a subscriber: cfe-commits.

Use the `__make_integer_seq` builtin, introduced by r252036, when available. 
This allows for an incredibly fast `std::make_integer_sequence` implementation.

http://reviews.llvm.org/D14814

Files:
  include/utility

Index: include/utility
===
--- include/utility
+++ include/utility
@@ -680,6 +680,16 @@
 template
 using index_sequence = integer_sequence;
 
+#if __has_builtin(__make_integer_seq)
+
+template 
+struct __make_integer_sequence
+{
+typedef __make_integer_seq type;
+};
+
+#else
+
 namespace __detail {
 
 template struct __repeat;
@@ -737,6 +747,8 @@
 typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
 };
 
+#endif
+
 template
 using make_integer_sequence = typename __make_integer_sequence<_Tp, 
_Np>::type;
 


Index: include/utility
===
--- include/utility
+++ include/utility
@@ -680,6 +680,16 @@
 template
 using index_sequence = integer_sequence;
 
+#if __has_builtin(__make_integer_seq)
+
+template 
+struct __make_integer_sequence
+{
+typedef __make_integer_seq type;
+};
+
+#else
+
 namespace __detail {
 
 template struct __repeat;
@@ -737,6 +747,8 @@
 typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
 };
 
+#endif
+
 template
 using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14800: Honor system specific paths of MAN pages

2015-11-19 Thread Kamil Rytarowski via cfe-commits
krytarowski created this revision.
krytarowski added a reviewer: beanz.
krytarowski added subscribers: joerg, cfe-commits.
krytarowski set the repository for this revision to rL LLVM.

Caught on NetBSD.

Repository:
  rL LLVM

http://reviews.llvm.org/D14800

Files:
  INSTALL.txt
  tools/scan-build/CMakeLists.txt

Index: tools/scan-build/CMakeLists.txt
===
--- tools/scan-build/CMakeLists.txt
+++ tools/scan-build/CMakeLists.txt
@@ -1,5 +1,7 @@
 option(CLANG_INSTALL_SCANBUILD "Install the scan-build tool" ON)
 
+include(GNUInstallDirs)
+
 if (WIN32 AND NOT CYGWIN)
   set(BinFiles
 scan-build.bat)
@@ -52,15 +54,15 @@
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/man/man1/${ManPage}
+add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/share/man/man1
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
- ${CMAKE_BINARY_DIR}/share/man/man1/
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends ${CMAKE_BINARY_DIR}/share/man/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION share/man/man1)
+list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -78,4 +80,3 @@
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
 endif()
-
Index: INSTALL.txt
===
--- INSTALL.txt
+++ INSTALL.txt
@@ -45,5 +45,4 @@
 configured.
 
 The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc 
like
-command line interface. See the man page for clang (installed into
-$prefix/share/man/man1) for more information.
+command line interface. See the man page for clang for more information.


Index: tools/scan-build/CMakeLists.txt
===
--- tools/scan-build/CMakeLists.txt
+++ tools/scan-build/CMakeLists.txt
@@ -1,5 +1,7 @@
 option(CLANG_INSTALL_SCANBUILD "Install the scan-build tool" ON)
 
+include(GNUInstallDirs)
+
 if (WIN32 AND NOT CYGWIN)
   set(BinFiles
 scan-build.bat)
@@ -52,15 +54,15 @@
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/man/man1/${ManPage}
+add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/share/man/man1
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
- ${CMAKE_BINARY_DIR}/share/man/man1/
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends ${CMAKE_BINARY_DIR}/share/man/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION share/man/man1)
+list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -78,4 +80,3 @@
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
 endif()
-
Index: INSTALL.txt
===
--- INSTALL.txt
+++ INSTALL.txt
@@ -45,5 +45,4 @@
 configured.
 
 The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like
-command line interface. See the man page for clang (installed into
-$prefix/share/man/man1) for more information.
+command line interface. See the man page for clang for more information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14616: [libcxx] Replace TEST_HAS_NO_EXCEPTIONS with _LIBCPP_NO_EXCEPTIONS [NFC]

2015-11-19 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Makes sense. Thanks.


http://reviews.llvm.org/D14616



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


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D14779#292513, @zaks.anna wrote:

> This is a partial review. I did not look at the padding calculations closely.
>
> Have you run this over codebases other than clang? Are there any false 
> positives?


I ran this over a large C code base, then spot checked the top dozen of so 
issues.  I haven't seen a "real" false positive with the current 
implementation.  I have seen plenty of structures where the specific layout was 
important and couldn't be changed.  I haven't seen any cases where the checker 
reported excess padding when it wasn't true.

One of the reasons that I do not attempt to handle base classes is because of 
the fear of false positives.

> > Even with the default of 8, this checker is too noisy to justify turning on 
> > by default. Clang+LLVM has 

> 

> >  hundreds of violations.

> 

> 

> How did you pick the default? Should it be higher? 

>  My main concern is that if the checker is too noisy on most codebases, 
> people might just try it once and keep it turned off. Having a higher default 
> will report less issues but they will be more interesting.


The number was picked by looking at the data.  A huge portion of the results 
were in the general area of 8 bytes or lower.  These generally felt like noisy 
reports unless I had more specific justification for them (like evidence of an 
array of the elements).

Should it be higher?  As I get better at detecting arrays, then I think it 
makes sense to bump the raw value higher.

I think I'm fine with people only running this checker on occasion.  It feels 
like a profiler in many ways, and the information doesn't go stale.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:56
@@ +55,3 @@
+  : Self(Self), BR(BR), AllowedPad(AllowedPad) {}
+  bool VisitRecordDecl(const RecordDecl *RD) {
+Self->visitRecord(RD, BR, AllowedPad);

zaks.anna wrote:
> Why do we need to implement the visitation here? Can PaddingChecker just 
> implement checkASTDecl(const RecordDecl *RD, ...) and checkASTDecl(const 
> VarDecl *RD, ...)?
I wanted to be able to visit template instantiations and the class portion of a 
lambda, and the AnalysisConsumer class that calls the varios checkAST* 
functions doesn't do that.  Once I added this custom visitor, I stuck with it 
for the VarDecl.

I will add a comment mentioning my rationale.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:71
@@ +70,3 @@
+
+  void visitRecord(const RecordDecl *RD, BugReporter &BR,
+   int64_t AllowedPad) const {

zaks.anna wrote:
> I'd just make the BugReporter and AllowedPad members to avoid passing them 
> around.
I'm fine doing that, but I was under the impression that the checker was 
supposed to be as close to stateless as possible.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:114
@@ +113,3 @@
+  return;
+auto &ASTContext = RD->getASTContext();
+const ASTRecordLayout &RL = ASTContext.getASTRecordLayout(RD);

zaks.anna wrote:
> Should the rest of the function implementation be moved into a subroutine? 
> Looks like copy and paste from visitRecord.
I'll make an attempt to do that.  The two functions use BaselinePad and 
OptimalPad a little differently, which complicates things.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:144
@@ +143,3 @@
+BR.getSourceManager().getFileCharacteristic(Location);
+// Throw out all records that come from system headers.
+if (Kind != SrcMgr::C_User)

zaks.anna wrote:
> Do you get reports from system headers without this check?
> 
Yes.  Turns out the structures for flock and flock64 have extra padding.  And 
since those are in commonly included headers, you get that message a lot...


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:209
@@ +208,3 @@
+  std::tie(Info.Size, std::ignore) =
+  ASTContext.getTypeInfoInChars(FD->getType());
+

zaks.anna wrote:
> Are you intentionally not using getTypeInfoDataSizeInChars? Can this lead to 
> false positives? A comment would be helpful.
It is intentional, and I will add a comment.

In most cases, it doesn't matter what the data size of a field is, just what 
the aligned size is.  In general, you can't put one object in another's tail 
padding.  Note that my goal isn't to say how much padding there is in a 
structure, but how much you can reduce the padding by reordering the fields.  
Knowing the tail padding of a structure doesn't further that goal.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:325
@@ +324,3 @@
+
+Os << " (" << BaselinePad.getQuantity() << " padding bytes, where "
+   << TargetPad.getQuantity() << " is optimal)";

zaks.anna wrote:
> Why are you not testing for the full message in the tests? It is impor

Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-19 Thread Andrey Turetskiy via cfe-commits
aturetsk updated this revision to Diff 40645.
aturetsk added a comment.

Do not enable X87 for i386


http://reviews.llvm.org/D13980

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/attr-target-x86-mmx.c
  test/CodeGen/attr-target-x86.c

Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -18,6 +18,8 @@
 
 int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
 
+int __attribute__((target("arch=i386"))) qix(int a) { return 4; }
+
 // Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -31,9 +33,11 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+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,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: qix{{.*}} #6
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
+// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
+// CHECK: #6 = {{.*}}"target-cpu"="i386" "target-features"="+mmx,+sse,+sse2"
Index: test/CodeGen/attr-target-x86-mmx.c
===
--- test/CodeGen/attr-target-x86-mmx.c
+++ test/CodeGen/attr-target-x86-mmx.c
@@ -19,4 +19,4 @@
   _mm_srai_pi32(a, c);
 }
 
-// CHECK: "target-features"="+mmx,+sse"
+// CHECK: "target-features"="+mmx,+sse,+x87"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2535,6 +2535,10 @@
   if (getTriple().getArch() == llvm::Triple::x86_64)
 setFeatureEnabledImpl(Features, "sse2", true);
 
+  // All X86 processors but i386 have X87.
+  if (getCPUKind(CPU) != CK_i386)
+setFeatureEnabledImpl(Features, "x87", true);
+
   switch (getCPUKind(CPU)) {
   case CK_Generic:
   case CK_i386:


Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -18,6 +18,8 @@
 
 int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
 
+int __attribute__((target("arch=i386"))) qix(int a) { return 4; }
+
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -31,9 +33,11 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+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,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,

Re: [PATCH] D14796: Preserve exceptions information during calls code generation.

2015-11-19 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 40646.
sfantao added a comment.

Update comment as suggested by John.


http://reviews.llvm.org/D14796

Files:
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/observe-noexcept.cpp

Index: test/CodeGenCXX/observe-noexcept.cpp
===
--- /dev/null
+++ test/CodeGenCXX/observe-noexcept.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple  powerpc64le-unknown-unknown -std=c++11 -fopenmp -fexceptions -fcxx-exceptions -O0 -emit-llvm %s -o - | FileCheck %s
+
+// Check that regions that install a terminate scope in the exception stack can
+// correctly generate complex arithmetic.
+
+// CHECK-LABEL: ffcomplex
+void ffcomplex (int a) {
+  double _Complex dc = (double)a;
+
+  // CHECK: call { double, double } @__muldc3(double %{{.+}}, double %{{.+}}, double %{{.+}}, double %{{.+}})
+  dc *= dc;
+  // CHECK: call {{.+}} @__kmpc_fork_call({{.+}} [[REGNAME1:@.*]] to void (i32*, i32*, ...)*), { double, double }* %{{.+}})
+  #pragma omp parallel
+  {
+dc *= dc;
+  }
+  // CHECK: ret void
+}
+
+// CHECK: define internal {{.+}}[[REGNAME1]](
+// CHECK-NOT: invoke
+// CHECK: call { double, double } @__muldc3(double %{{.+}}, double %{{.+}}, double %{{.+}}, double %{{.+}})
+// CHECK-NOT: invoke
+// CHECK: ret void
+
+// Check if we are observing the function pointer attribute regardless what is
+// in the exception specification of the callees.
+void fnoexcp(void) noexcept;
+
+// CHECK-LABEL: foo
+void foo(int a, int b) {
+
+  void (*fptr)(void) noexcept = fnoexcp;
+
+  // CHECK: call {{.+}} @__kmpc_fork_call({{.+}} [[REGNAME2:@.*]] to void (i32*, i32*, ...)*), void ()** %{{.+}})
+  #pragma omp parallel
+  {
+fptr();
+  }
+  // CHECK: ret void
+}
+
+// CHECK: define internal {{.+}}[[REGNAME2]](
+// CHECK-NOT: invoke
+// CHECK: call void %{{[0-9]+}}()
+// CHECK-NOT: invoke
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -968,16 +968,14 @@
   /// function type.
   ///
   /// \param Info - The function type information.
-  /// \param TargetDecl - The decl these attributes are being constructed
-  /// for. If supplied the attributes applied to this decl may contribute to the
-  /// function attributes and calling convention.
+  /// \param CalleeInfo - The callee information these attributes are being
+  /// constructed for. If valid, the attributes applied to this decl may
+  /// contribute to the function attributes and calling convention.
   /// \param PAL [out] - On return, the attribute list to use.
   /// \param CallingConv [out] - On return, the LLVM calling convention to use.
   void ConstructAttributeList(const CGFunctionInfo &Info,
-  const Decl *TargetDecl,
-  AttributeListType &PAL,
-  unsigned &CallingConv,
-  bool AttrOnCallSite);
+  CGCalleeInfo CalleeInfo, AttributeListType &PAL,
+  unsigned &CallingConv, bool AttrOnCallSite);
 
   StringRef getMangledName(GlobalDecl GD);
   StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2624,16 +2624,14 @@
   ///
   /// \param TargetDecl - If given, the decl of the function in a direct call;
   /// used to set attributes on the call (noreturn, etc.).
-  RValue EmitCall(const CGFunctionInfo &FnInfo,
-  llvm::Value *Callee,
-  ReturnValueSlot ReturnValue,
-  const CallArgList &Args,
-  const Decl *TargetDecl = nullptr,
+  RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee,
+  ReturnValueSlot ReturnValue, const CallArgList &Args,
+  CGCalleeInfo CalleeInfo = CGCalleeInfo(),
   llvm::Instruction **callOrInvoke = nullptr);
 
   RValue EmitCall(QualType FnType, llvm::Value *Callee, const CallExpr *E,
   ReturnValueSlot ReturnValue,
-  const Decl *TargetDecl = nullptr,
+  CGCalleeInfo CalleeInfo = CGCalleeInfo(),
   llvm::Value *Chain = nullptr);
   RValue EmitCallExpr(const CallExpr *E,
   ReturnValueSlot ReturnValue = ReturnValueSlot());
Index: lib/CodeGen/CGObjCMac.cpp
===
--- lib/CodeGen/CGObjCMac.cpp
+++ lib/CodeGen/CGObjCMac.cpp
@@ -1947,7 +1947,7 @@
   llvm::Instruction *CallSite;
  

Re: [PATCH] D14796: Preserve exceptions information during calls code generation.

2015-11-19 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/CodeGen/CGExpr.cpp:3751
@@ +3750,3 @@
+  // Preserve the non-canonical function type because things like exception
+  // specifications disappear in the canonical type. That information is useful
+  // to drive the generation of more accurate code for this call later on.

Done!


http://reviews.llvm.org/D14796



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


Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-19 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

Hello Richard,
Thank for the review.



Comment at: lib/Basic/Targets.cpp:2538-2539
@@ -2537,1 +2537,4 @@
 
+  // All X86 processors but i386 have X87.
+  if (getCPUKind(CPU) != CK_i386)
+setFeatureEnabledImpl(Features, "x87", true);

You are right. Fixed.


http://reviews.llvm.org/D13980



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread scott douglass via cfe-commits
scott-0 added a subscriber: scott-0.
scott-0 added a comment.

It would be nice if the no-exceptions library called an intermediate helper, 
for example `__libcxx_noexceptions_abort()`, instead of calling `abort()` 
directly.  Then the user and the tests could provide a replacement for 
`__libcxx_noexceptions_abort()` instead of `abort()` which has other uses.


http://reviews.llvm.org/D14653



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: include/__noexcept:22
@@ +21,3 @@
+template
+inline void throw_helper(T t, const char *msg = nullptr)
+{

We're not allowed to pollute the global namespace. This must be prefixed with 
`__`.


http://reviews.llvm.org/D14653



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


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 40659.
bcraig added a comment.

Addressed the bulk of Anna's review comments.


http://reviews.llvm.org/D14779

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  test/Analysis/padding_c.c
  test/Analysis/padding_cpp.cpp

Index: test/Analysis/padding_cpp.cpp
===
--- /dev/null
+++ test/Analysis/padding_cpp.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -std=c++14 -analyze -analyzer-checker=performance -analyzer-config performance.Padding:AllowedPad=2 -verify %s
+
+// Make sure that the C cases still work fine, even when compiled as C++.
+#include "padding_c.c"
+
+struct BigCharArray2 { // no-warning
+  char c[129];
+};
+
+// xxxexpected-warning@+1{{Excessive padding in 'struct LowAlignmentBase'}}
+struct LowAlignmentBase : public BigCharArray2 {
+  int i;
+  char c;
+};
+
+struct CorrectLowAlignmentBase : public BigCharArray2 { // no-warning
+  char c;
+  int i;
+};
+
+// xxxexpected-warning@+1{{Excessive padding in 'struct LowAlignmentBase2'}}
+struct LowAlignmentBase2 : public BigCharArray2 {
+  char c1;
+  int i;
+  char c2;
+};
+
+class PaddedA { // expected-warning{{Excessive padding in 'class PaddedA'}}
+  char c1;
+  int i;
+  char c2;
+};
+
+class VirtualPaddedA : public PaddedA { // no-warning
+  virtual void foo() {}
+};
+
+class VirtualIntSandwich { // expected-warning{{Excessive padding in 'class VirtualIntSandwich'}}
+  virtual void foo() {}
+  char c1;
+  int i;
+  char c2;
+};
+
+// constructed so as not to have tail padding
+class InnerPaddedB { // expected-warning{{Excessive padding in 'class InnerPaddedB'}}
+  char c1;
+  int i1;
+  char c2;
+  int i2;
+};
+
+class TailPaddedB { // expected-warning{{Excessive padding in 'class TailPaddedB'}}
+  char c1;
+  int i1;
+  char c2;
+};
+
+class SI : public PaddedA { // no-warning
+  char c;
+};
+
+class SI2 : public PaddedA { // xxxexpected-warning{{Excessive padding in 'class SI2'}}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class VirtualSI : virtual public PaddedA { // no-warning
+  char c;
+};
+
+// currently not checked for
+class VirtualSI2 : virtual public PaddedA { // no-warning
+  char c10;
+  int i10;
+  char c11;
+};
+
+class VtblSI : public PaddedA { // no-warning
+  virtual void foo() {}
+  char c;
+};
+
+class VtblSI2 : public PaddedA { // xxxexpected-warning{{Excessive padding in 'class VtblSI2'}}
+  virtual void foo() {}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class VtblSI3 : public VirtualPaddedA { // xxxexpected-warning{{Excessive padding in 'class VtblSI3'}}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class MI : public PaddedA, public InnerPaddedB { // no-warning
+  char c;
+};
+
+class MI2 : public PaddedA, public InnerPaddedB { // xxxexpected-warning{{Excessive padding in 'class MI2'}}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class VtblMI : public PaddedA, public InnerPaddedB { // xxxexpected-warning{{Excessive padding in 'class VtblMI'}}
+  virtual void foo() {}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class VtblMI2 : public VirtualPaddedA, public InnerPaddedB { // xxxexpected-warning{{Excessive padding in 'class VtblMI2'}}
+  char c10;
+  int i10;
+  char c11;
+};
+
+class Empty {}; // no-warning
+
+class LotsOfSpace { // expected-warning{{Excessive padding in 'class LotsOfSpace'}}
+  Empty e1;
+  int i;
+  Empty e2;
+};
+
+class EBO1 : public Empty { // xxxexpected-warning{{Excessive padding in 'class EBO1'}}
+  char c1;
+  int i;
+  char c2;
+};
+
+class EBO2 : public Empty { // xxxexpected-warning{{Excessive padding in 'class EBO2'}}
+  Empty c1;
+  int i;
+  Empty c2;
+};
+
+template 
+class TemplateSandwich { // expected-warning{{Excessive padding in 'class TemplateSandwich' instantiated here}}
+  char c1;
+  T t;
+  char c2;
+};
+
+template 
+class TemplateSandwich { // expected-warning{{Excessive padding in 'class TemplateSandwich' instantiated here}}
+  char c1;
+  T *t;
+  char c2;
+};
+
+template <>
+class TemplateSandwich { // expected-warning{{Excessive padding in 'class TemplateSandwich' (}}
+  char c1;
+  long long t;
+  char c2;
+};
+
+class Holder1 { // no-warning
+  TemplateSandwich t1;
+  TemplateSandwich t2;
+  TemplateSandwich t3;
+};
+
+typedef struct { // expected-warning{{Excessive padding in 'TypedefSandwich2'}}
+  char c1;
+  typedef struct { // expected-warning{{Excessive padding in 'TypedefSandwich2::NestedTypedef'}}
+char c1;
+int i;
+char c2;
+  } NestedTypedef;
+  NestedTypedef t;
+  char c2;
+} TypedefSandwich2;
+
+template 
+struct Foo {
+  // expected-warning@+1{{Excessive padding in 'struct Foo::Nested'}}
+  struct Nested {
+char c1;
+T t;
+char c2;
+  };
+};
+
+struct Holder { // no-warning
+  Foo::Nested t1;
+  Foo::Nested t2;
+};
+
+struct GlobalsForLambda { // no-warning
+  int i;
+  char c1;
+  char c2;
+} G;
+
+// expected-warning@+1{{Excessive padding in 'cl

Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Ben Craig via cfe-commits
bcraig marked 15 inline comments as done.
bcraig added a comment.

http://reviews.llvm.org/D14779



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


[PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

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

Throwing an exception from the constructor of an object being used with static 
or thread_local storage duration is a dangerous operation. The exception thrown 
for an object with static storage duration cannot be caught, even by 
function-try-blocks in main, and the exception thrown for an object with 
thread_local storage duration cannot be caught by a function-try-block of the 
initial thread. This patch adds a checker to flag such constructs.

This check corresponds to the CERT secure coding rule: 
https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions

http://reviews.llvm.org/D14824

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/StaticObjectExceptionCheck.cpp
  clang-tidy/cert/StaticObjectExceptionCheck.h
  docs/clang-tidy/checks/cert-static-object-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-static-object-exception.cpp

Index: test/clang-tidy/cert-static-object-exception.cpp
===
--- test/clang-tidy/cert-static-object-exception.cpp
+++ test/clang-tidy/cert-static-object-exception.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cert-err58-cpp %t
+
+struct S {
+  S() noexcept(false);
+};
+
+struct T {
+  T() noexcept;
+};
+
+struct U {
+  U() {}
+};
+
+struct V {
+  explicit V(const char *) {} // Can throw
+};
+
+
+S s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+T t; // ok
+U u;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
+V v("v");
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
+
+void f(S s1, T t1, U u1, V v1) { // ok, ok, ok, ok
+  S s2; // ok
+  T t2; // ok
+  U u2; // ok
+  V v2("v"); // ok
+
+  thread_local S s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local T t3; // ok
+  thread_local U u3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local V v3("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
+
+  static S s4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 's4' with static storage duration may throw an exception that cannot be caught
+  static T t4; // ok
+  static U u4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'u4' with static storage duration may throw an exception that cannot be caught
+  static V v4("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v4' with static storage duration may throw an exception that cannot be caught
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -1,8 +1,9 @@
 List of clang-tidy Checks
 =
 
-.. toctree::
+.. toctree::   
cert-setlongjmp
+   cert-static-object-exception
cert-thrown-exception-type
cert-variadic-function-def
cppcoreguidelines-pro-bounds-array-to-pointer-decay
Index: docs/clang-tidy/checks/cert-static-object-exception.rst
===
--- docs/clang-tidy/checks/cert-static-object-exception.rst
+++ docs/clang-tidy/checks/cert-static-object-exception.rst
@@ -0,0 +1,9 @@
+cert-err58-cpp
+==
+
+This check flags all static or thread_local variable declarations where the
+constructor for the object may throw an exception.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR58-CPP. Constructors of objects with static or thread storage duration must not throw exceptions
+`_.
Index: clang-tidy/cert/StaticObjectExceptionCheck.h
===
--- clang-tidy/cert/StaticObjectExceptionCheck.h
+++ clang-tidy/cert/StaticObjectExceptionCheck.h
@@ -0,0 +1,34 @@
+//===--- StaticObjectExceptionCheck.h - clang-tidy

r253582 - clang-cl: Make /W4 imply -Wall -Wextra (PR25563)

2015-11-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Nov 19 11:49:59 2015
New Revision: 253582

URL: http://llvm.org/viewvc/llvm-project?rev=253582&view=rev
Log:
clang-cl: Make /W4 imply -Wall -Wextra (PR25563)

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=253582&r1=253581&r2=253582&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Nov 19 11:49:59 2015
@@ -2173,7 +2173,7 @@ Execute ``clang-cl /?`` to see a list of
   /W1Enable -Wall
   /W2Enable -Wall
   /W3Enable -Wall
-  /W4Enable -Wall
+  /W4Enable -Wall and -Wextra
   /Wall  Enable -Wall
   /WX-   Do not treat warnings as errors
   /WXTreat warnings as errors

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=253582&r1=253581&r2=253582&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Nov 19 11:49:59 2015
@@ -115,12 +115,12 @@ def _SLASH_showIncludes : CLFlag<"showIn
   Alias;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
   MetaVarName<"">, Alias;
-def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias;
-def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias;
-def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias;
-def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">, Alias;
-def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall">, Alias;
-def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Wall">, Alias;
+def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">;
+def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">;
+def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">;
+def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">;
+def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall and -Wextra">;
+def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Wall">;
 def _SLASH_WX : CLFlag<"WX">, HelpText<"Treat warnings as errors">,
   Alias, AliasArgs<["error"]>;
 def _SLASH_WX_ : CLFlag<"WX-">, HelpText<"Do not treat warnings as errors">,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253582&r1=253581&r2=253582&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Nov 19 11:49:59 2015
@@ -5684,6 +5684,26 @@ void Clang::AddClangCLArgs(const ArgList
 else
   CmdArgs.push_back("msvc");
   }
+
+  if (Arg *A =
+  Args.getLastArg(options::OPT__SLASH_W0, options::OPT__SLASH_W1,
+  options::OPT__SLASH_W2, options::OPT__SLASH_W3,
+  options::OPT__SLASH_W4, options::OPT__SLASH_Wall)) {
+switch (A->getOption().getID()) {
+case options::OPT__SLASH_W0:
+  CmdArgs.push_back("-w");
+  break;
+case options::OPT__SLASH_W4:
+  CmdArgs.push_back("-Wextra");
+  // Fallthrough.
+case options::OPT__SLASH_W1:
+case options::OPT__SLASH_W2:
+case options::OPT__SLASH_W3:
+case options::OPT__SLASH_Wall:
+  CmdArgs.push_back("-Wall");
+  break;
+}
+  }
 }
 
 visualstudio::Compiler *Clang::getCLFallback() const {

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=253582&r1=253581&r2=253582&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Thu Nov 19 11:49:59 2015
@@ -173,10 +173,15 @@
 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
-// RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
 // W1: -Wall
 
+// RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
+// W4: -Wextra
+// W4: -Wall
+// RUN: %clang_cl /W4 /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W4W1 %s
+// W4W1-NOT: -Wextra
+
 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
 // WX: -Werror
 


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

Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 40669.
rmaprath added a comment.

Addressing review comments:

- Renamed `throw_helper` as `__throw_helper` in order to not pollute the global 
namespace (@jroelofs)
- Made `try_buf` a `thread_local` in order to be able to support those tests 
the launch multiple threads.
- Introduced `__libcxx_noexceptions_abort()` as an intermediary between the 
no-exceptions library and the c library's `abort()` (@scott-0).
  - This had the side-benefit that we now don't have to hack around `assert()` 
in `noexcept.h` test support header; neat!


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/__noexcept
  include/array
  src/noexcept.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// 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.
+//
+//===--===//
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include
+#include
+#include
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+// some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+thread_local jmp_buf try_buf;
+#else
+jmp_buf try_buf;
+#endif
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(void) {
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: src/noexcept.cpp
===
--- /dev/null
+++ src/noexcept.cpp
@@ -0,0 +1,15 @@
+//=== noexcept.cpp ===//
+//
+// 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.
+//
+//===--===//
+
+#include 
+#include <__noexcept>
+
+void __libcxx_noexceptions_abort() {
+  abort();
+}
Index: include/array
===
--- include/array
+++ include/array
@@ -110,6 +110,7 @@
 #if defined(_LIBCPP_NO_EXCEPTIONS)
 #include 
 #endif
+#include <__noexcept>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -201,11 +202,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+   __throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +212,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__noexcept
===
--- /dev/null
+++ include/__noexcept
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//===-- __noexcept ===//
+//
+// 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.
+//
+//===--===//
+
+#ifndef _LIBCPP_NOEXCEPT_H
+#define _LIBCPP_NOEXCEP

Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: include/__noexcept:19
@@ +18,3 @@
+
+void __libcxx_noexceptions_abort();
+#endif // _LIBCPP_NO_EXCEPTIONS

Make this:

void __attribute__((weak)) __libcxx_noexceptions_abort();


Comment at: include/__noexcept:36
@@ +35,3 @@
+  fprintf(stderr, "exception raised, cannot propagate. Aborting.\n");
+__libcxx_noexceptions_abort();
+#endif // _LIBCPP_NO_EXCEPTIONS

Then this should be:

if (__libcxx_noexceptions_abort)
  __libcxx_noexceptions_abort();
else
  abort();


Comment at: src/noexcept.cpp:1
@@ +1,2 @@
+//=== noexcept.cpp 
===//
+//

And delete this whole file.


http://reviews.llvm.org/D14653



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: include/__noexcept:19
@@ +18,3 @@
+
+void __libcxx_noexceptions_abort();
+#endif // _LIBCPP_NO_EXCEPTIONS

jroelofs wrote:
> Make this:
> 
> void __attribute__((weak)) __libcxx_noexceptions_abort();
I meant to write:

void _LIBCPP_WEAK __libcxx_noexceptions_abort();


http://reviews.llvm.org/D14653



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


Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.

2015-11-19 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaPseudoObject.cpp:1627
@@ -1579,1 +1626,3 @@
+cast(Base->IgnoreParens())->getBaseExpr());
+return MSPropertyRefRebuilder(S, BaseOVE->getSourceExpr()).rebuild(E);
   } else {

Hmm.  Just like the ObjCSubscriptRefExpr case, this will need to strip the OVEs 
off the index expressions, or else you'll end up stacking OVEs and asserting in 
IRGen.

The deeper problem here is that we have too much redundancy in all these places 
that have to walk over the different pseudo-object expressions.  We can remove 
some of that by simplifying the design of Rebuilder, which is really 
over-engineered for its task.  It should be fine to make it non-templated, 
merge all of the rebuildSpecific cases into it (and therefore remove all of the 
subclasses), and give it a callback to invoke at all the capture points in 
source order.

I think the callback can just be a llvm::function_ref.  
The second parameter is the position of the capture point in source order, so 
for example in your case the base of the MSPropertyRefExpr will be 0, the index 
of the innermost MSPropertySubscriptExpr will be 1, and so on.  That'll be 
important for callers that care about which capture point is which.

The various rebuildAndCaptureObject implementations should use a callback that 
returns the appropriate captured expression for the position.

stripOpaqueValuesFromPseudoObjectRef should use a callback that returns 
cast(e)->getSourceExpr(); it shouldn't need to split out the 
different cases at all.


http://reviews.llvm.org/D13336



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


Re: [PATCH] D14796: Preserve exceptions information during calls code generation.

2015-11-19 Thread John McCall via cfe-commits
rjmccall added a comment.

Thanks, that's great.  One minor tweak, and feel free to just commit when 
you've done that.



Comment at: lib/CodeGen/CGCall.cpp:1420
@@ +1419,3 @@
+  // If we have information about the function proto type, we can learn
+  // attributes form there.
+  AddAttributesFromFunctionProtoType(getContext(), FuncAttrs,

Minor tweak: "prototype".


http://reviews.llvm.org/D14796



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


r253590 - Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults.

2015-11-19 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Nov 19 13:20:17 2015
New Revision: 253590

URL: http://llvm.org/viewvc/llvm-project?rev=253590&view=rev
Log:
Change the expression evaluation context from Unevaluated to ConstantEvaluated 
while substituting into non-type template argument defaults.

Also address a typo from a prior patch that performed a similar fix during 
Parsing of default non-type template arguments.  I left the RAII 
ExpressionEvaluationContext variable Name as Unevaluated though we had switched 
the context to ConstantEvaluated.

There should be no functionality change here - since when expression evaluation 
context is popped off, for the most part these two contexts currently behave 
similarly in regards to lambda diagnostics and odr-use tracking.

Like its parsing counterpart, this patch presages the advent of constexpr 
lambda patches...

Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=253590&r1=253589&r2=253590&view=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Nov 19 13:20:17 2015
@@ -695,8 +695,8 @@ Parser::ParseNonTypeTemplateParameter(un
 //   end of the template-parameter-list rather than a greater-than
 //   operator.
 GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-EnterExpressionEvaluationContext Unevaluated(Actions,
- Sema::ConstantEvaluated);
+EnterExpressionEvaluationContext ConstantEvaluated(Actions,
+   
Sema::ConstantEvaluated);
 
 DefaultArg = 
Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
 if (DefaultArg.isInvalid())

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=253590&r1=253589&r2=253590&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Nov 19 13:20:17 2015
@@ -3280,7 +3280,8 @@ SubstDefaultTemplateArgument(Sema &SemaR
 TemplateArgLists.addOuterTemplateArguments(None);
 
   Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
-  EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
+  EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+ Sema::ConstantEvaluated);
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 


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


[libcxx] r253592 - Fix some mistakes in the synopsis. No functional change. Thanks to K-ballo for the patch

2015-11-19 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Nov 19 13:41:04 2015
New Revision: 253592

URL: http://llvm.org/viewvc/llvm-project?rev=253592&view=rev
Log:
Fix some mistakes in the  synopsis. No functional change. Thanks to 
K-ballo for the patch

Modified:
libcxx/trunk/include/array

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=253592&r1=253591&r2=253592&view=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Thu Nov 19 13:41:04 2015
@@ -89,12 +89,12 @@ template 
   void swap(array& x, array& y) noexcept(noexcept(x.swap(y)));
 
 template  class tuple_size;
-template  class tuple_element;
+template  class tuple_element;
 template  struct tuple_size>;
-template  struct tuple_element>;
-template  T& get(array&) noexcept; // 
constexpr in C++14
-template  const T& get(const array&) noexcept; 
// constexpr in C++14
-template  T&& get(array&&) noexcept; // 
constexpr in C++14
+template  struct tuple_element>;
+template  T& get(array&) noexcept; // 
constexpr in C++14
+template  const T& get(const array&) 
noexcept; // constexpr in C++14
+template  T&& get(array&&) noexcept; // 
constexpr in C++14
 
 }  // std
 


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


[libcxx] r253593 - Fix some mistakes in the and synopses. No functional change. Thannks to K-ballo for the patch

2015-11-19 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Nov 19 13:45:29 2015
New Revision: 253593

URL: http://llvm.org/viewvc/llvm-project?rev=253593&view=rev
Log:
Fix some mistakes in the  and  synopses. No functional change. 
Thannks to K-ballo for the patch

Modified:
libcxx/trunk/include/tuple
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=253593&r1=253592&r2=253593&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Nov 19 13:45:29 2015
@@ -80,26 +80,26 @@ template  tuple class tuple_size; // undefined
 template  class tuple_size>;
-template  class tuple_element; // undefined
-template  class tuple_element>;
-template 
-  using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
+template  class tuple_element; // undefined
+template  class tuple_element>;
+template 
+  using tuple_element_t = typename tuple_element ::type; // C++14
 
 // 20.4.1.5, element access:
-template 
+template 
 typename tuple_element>::type&
 get(tuple&) noexcept; // constexpr in C++14
-template 
-typename const tuple_element>::type &
+template 
+const typename tuple_element>::type&
 get(const tuple&) noexcept; // constexpr in C++14
-template 
+template 
 typename tuple_element>::type&&
 get(tuple&&) noexcept; // constexpr in C++14
 
 template 
 constexpr T1& get(tuple&) noexcept;  // C++14
 template 
-constexpr T1 const& get(const tuple&) noexcept;   // C++14
+constexpr const T1& get(const tuple&) noexcept;   // C++14
 template 
 constexpr T1&& get(tuple&&) noexcept;   // C++14
 

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=253593&r1=253592&r2=253593&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Thu Nov 19 13:45:29 2015
@@ -113,7 +113,7 @@ template
 get(pair&) noexcept; // constexpr in C++14
 
 template
-const typename const tuple_element >::type&
+const typename tuple_element >::type&
 get(const pair&) noexcept; // constexpr in C++14
 
 template
@@ -124,7 +124,7 @@ template
 constexpr T1& get(pair&) noexcept; // C++14
 
 template
-constexpr T1 const& get(pair const &) noexcept; // C++14
+constexpr const T1& get(const pair&) noexcept; // C++14
 
 template
 constexpr T1&& get(pair&&) noexcept; // C++14


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


r253595 - Update clang tests to accomendate discriminator changes.

2015-11-19 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Nov 19 13:53:16 2015
New Revision: 253595

URL: http://llvm.org/viewvc/llvm-project?rev=253595&view=rev
Log:
Update clang tests to accomendate discriminator changes.

Summary: The discriminator change in http://reviews.llvm.org/D14738 will fail 
these clang tests. Update the test to accomendate the discriminator change.

Reviewers: dblaikie, davidxl, dnovillo

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

Modified:
cfe/trunk/test/CodeGen/debug-info-scope.c
cfe/trunk/test/CodeGenObjC/arc-linetable.m

Modified: cfe/trunk/test/CodeGen/debug-info-scope.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=253595&r1=253594&r2=253595&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-scope.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-scope.c Thu Nov 19 13:53:16 2015
@@ -10,6 +10,7 @@ int main() {
 
 // GMLT-NOT: !DILexicalBlock
 // GMLT: !DILexicalBlockFile({{.*}}, discriminator: 1)
+// GMLT: !DILexicalBlockFile({{.*}}, discriminator: 2)
 // Make sure we don't have any more lexical blocks because we don't need them 
in
 // -gmlt.
 // GMLT-NOT: !DILexicalBlock

Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=253595&r1=253594&r2=253595&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Thu Nov 19 13:53:16 2015
@@ -34,9 +34,9 @@
 
 // CHECK: define {{.*}}testCleanupVoid
 // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
-// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]]
+// CHECK: store i32 0, i32* {{.*}}, !dbg ![[STORE8:[0-9]+]]
 // CHECK: @objc_storeStrong{{.*}}, !dbg ![[ARC8:[0-9]+]]
-// CHECK: ret {{.*}} !dbg ![[RET8]]
+// CHECK: ret {{.*}} !dbg ![[RET8:[0-9]+]]
 
 typedef signed char BOOL;
 
@@ -112,8 +112,9 @@ typedef signed char BOOL;
   [delegate testVoid :s];
 }
   }
-  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+2]], scope:
-  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+1]], scope:
+  // CHECK: ![[STORE8]] = !DILocation(line: [[@LINE+3]], scope:
+  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+2]], scope:
+  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
 }
 
 


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


Re: r253595 - Update clang tests to accomendate discriminator changes.

2015-11-19 Thread David Blaikie via cfe-commits
On Thu, Nov 19, 2015 at 11:53 AM, Dehao Chen via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dehao
> Date: Thu Nov 19 13:53:16 2015
> New Revision: 253595
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253595&view=rev
> Log:
> Update clang tests to accomendate discriminator changes.
>
> Summary: The discriminator change in http://reviews.llvm.org/D14738 will
> fail these clang tests. Update the test to accomendate the discriminator
> change.
>

Do these tests need to be testing discriminators in the frontend? Could we
just -mllvm -disable-llvm-optzns on these tests? (can the functionality be
wholely tested in LLVM, I assume so if it's phrased as an LLVM
transformation pass?)


>
> Reviewers: dblaikie, davidxl, dnovillo
>
> Differential Revision: http://reviews.llvm.org/D14836
>
> Modified:
> cfe/trunk/test/CodeGen/debug-info-scope.c
> cfe/trunk/test/CodeGenObjC/arc-linetable.m
>
> Modified: cfe/trunk/test/CodeGen/debug-info-scope.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=253595&r1=253594&r2=253595&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/debug-info-scope.c (original)
> +++ cfe/trunk/test/CodeGen/debug-info-scope.c Thu Nov 19 13:53:16 2015
> @@ -10,6 +10,7 @@ int main() {
>
>  // GMLT-NOT: !DILexicalBlock
>  // GMLT: !DILexicalBlockFile({{.*}}, discriminator: 1)
> +// GMLT: !DILexicalBlockFile({{.*}}, discriminator: 2)
>  // Make sure we don't have any more lexical blocks because we don't need
> them in
>  // -gmlt.
>  // GMLT-NOT: !DILexicalBlock
>
> Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=253595&r1=253594&r2=253595&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)
> +++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Thu Nov 19 13:53:16 2015
> @@ -34,9 +34,9 @@
>
>  // CHECK: define {{.*}}testCleanupVoid
>  // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
> -// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]]
> +// CHECK: store i32 0, i32* {{.*}}, !dbg ![[STORE8:[0-9]+]]
>  // CHECK: @objc_storeStrong{{.*}}, !dbg ![[ARC8:[0-9]+]]
> -// CHECK: ret {{.*}} !dbg ![[RET8]]
> +// CHECK: ret {{.*}} !dbg ![[RET8:[0-9]+]]
>
>  typedef signed char BOOL;
>
> @@ -112,8 +112,9 @@ typedef signed char BOOL;
>[delegate testVoid :s];
>  }
>}
> -  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+2]], scope:
> -  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+1]], scope:
> +  // CHECK: ![[STORE8]] = !DILocation(line: [[@LINE+3]], scope:
> +  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+2]], scope:
> +  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
>  }
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r253595 - Update clang tests to accomendate discriminator changes.

2015-11-19 Thread Dehao Chen via cfe-commits
Yes, as discriminator is a backend pass, it should *not* affect frontend tests.

On Thu, Nov 19, 2015 at 12:36 PM, David Blaikie  wrote:
>
>
> On Thu, Nov 19, 2015 at 11:53 AM, Dehao Chen via cfe-commits
>  wrote:
>>
>> Author: dehao
>> Date: Thu Nov 19 13:53:16 2015
>> New Revision: 253595
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253595&view=rev
>> Log:
>> Update clang tests to accomendate discriminator changes.
>>
>> Summary: The discriminator change in http://reviews.llvm.org/D14738 will
>> fail these clang tests. Update the test to accomendate the discriminator
>> change.
>
>
> Do these tests need to be testing discriminators in the frontend? Could we
> just -mllvm -disable-llvm-optzns on these tests? (can the functionality be
> wholely tested in LLVM, I assume so if it's phrased as an LLVM
> transformation pass?)
>
>>
>>
>> Reviewers: dblaikie, davidxl, dnovillo
>>
>> Differential Revision: http://reviews.llvm.org/D14836
>>
>> Modified:
>> cfe/trunk/test/CodeGen/debug-info-scope.c
>> cfe/trunk/test/CodeGenObjC/arc-linetable.m
>>
>> Modified: cfe/trunk/test/CodeGen/debug-info-scope.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=253595&r1=253594&r2=253595&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGen/debug-info-scope.c (original)
>> +++ cfe/trunk/test/CodeGen/debug-info-scope.c Thu Nov 19 13:53:16 2015
>> @@ -10,6 +10,7 @@ int main() {
>>
>>  // GMLT-NOT: !DILexicalBlock
>>  // GMLT: !DILexicalBlockFile({{.*}}, discriminator: 1)
>> +// GMLT: !DILexicalBlockFile({{.*}}, discriminator: 2)
>>  // Make sure we don't have any more lexical blocks because we don't need
>> them in
>>  // -gmlt.
>>  // GMLT-NOT: !DILexicalBlock
>>
>> Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=253595&r1=253594&r2=253595&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)
>> +++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Thu Nov 19 13:53:16 2015
>> @@ -34,9 +34,9 @@
>>
>>  // CHECK: define {{.*}}testCleanupVoid
>>  // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
>> -// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]]
>> +// CHECK: store i32 0, i32* {{.*}}, !dbg ![[STORE8:[0-9]+]]
>>  // CHECK: @objc_storeStrong{{.*}}, !dbg ![[ARC8:[0-9]+]]
>> -// CHECK: ret {{.*}} !dbg ![[RET8]]
>> +// CHECK: ret {{.*}} !dbg ![[RET8:[0-9]+]]
>>
>>  typedef signed char BOOL;
>>
>> @@ -112,8 +112,9 @@ typedef signed char BOOL;
>>[delegate testVoid :s];
>>  }
>>}
>> -  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+2]], scope:
>> -  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+1]], scope:
>> +  // CHECK: ![[STORE8]] = !DILocation(line: [[@LINE+3]], scope:
>> +  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+2]], scope:
>> +  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
>>  }
>>
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r253595 - Update clang tests to accomendate discriminator changes.

2015-11-19 Thread David Blaikie via cfe-commits
On Thu, Nov 19, 2015 at 12:42 PM, Dehao Chen  wrote:

> Yes, as discriminator is a backend pass, it should *not* affect frontend
> tests.
>

Could you update these tests to not involve discriminators by passing
-disable-llvm-optzns instead?


>
> On Thu, Nov 19, 2015 at 12:36 PM, David Blaikie 
> wrote:
> >
> >
> > On Thu, Nov 19, 2015 at 11:53 AM, Dehao Chen via cfe-commits
> >  wrote:
> >>
> >> Author: dehao
> >> Date: Thu Nov 19 13:53:16 2015
> >> New Revision: 253595
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=253595&view=rev
> >> Log:
> >> Update clang tests to accomendate discriminator changes.
> >>
> >> Summary: The discriminator change in http://reviews.llvm.org/D14738
> will
> >> fail these clang tests. Update the test to accomendate the discriminator
> >> change.
> >
> >
> > Do these tests need to be testing discriminators in the frontend? Could
> we
> > just -mllvm -disable-llvm-optzns on these tests? (can the functionality
> be
> > wholely tested in LLVM, I assume so if it's phrased as an LLVM
> > transformation pass?)
> >
> >>
> >>
> >> Reviewers: dblaikie, davidxl, dnovillo
> >>
> >> Differential Revision: http://reviews.llvm.org/D14836
> >>
> >> Modified:
> >> cfe/trunk/test/CodeGen/debug-info-scope.c
> >> cfe/trunk/test/CodeGenObjC/arc-linetable.m
> >>
> >> Modified: cfe/trunk/test/CodeGen/debug-info-scope.c
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=253595&r1=253594&r2=253595&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/test/CodeGen/debug-info-scope.c (original)
> >> +++ cfe/trunk/test/CodeGen/debug-info-scope.c Thu Nov 19 13:53:16 2015
> >> @@ -10,6 +10,7 @@ int main() {
> >>
> >>  // GMLT-NOT: !DILexicalBlock
> >>  // GMLT: !DILexicalBlockFile({{.*}}, discriminator: 1)
> >> +// GMLT: !DILexicalBlockFile({{.*}}, discriminator: 2)
> >>  // Make sure we don't have any more lexical blocks because we don't
> need
> >> them in
> >>  // -gmlt.
> >>  // GMLT-NOT: !DILexicalBlock
> >>
> >> Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=253595&r1=253594&r2=253595&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)
> >> +++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Thu Nov 19 13:53:16 2015
> >> @@ -34,9 +34,9 @@
> >>
> >>  // CHECK: define {{.*}}testCleanupVoid
> >>  // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
> >> -// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]]
> >> +// CHECK: store i32 0, i32* {{.*}}, !dbg ![[STORE8:[0-9]+]]
> >>  // CHECK: @objc_storeStrong{{.*}}, !dbg ![[ARC8:[0-9]+]]
> >> -// CHECK: ret {{.*}} !dbg ![[RET8]]
> >> +// CHECK: ret {{.*}} !dbg ![[RET8:[0-9]+]]
> >>
> >>  typedef signed char BOOL;
> >>
> >> @@ -112,8 +112,9 @@ typedef signed char BOOL;
> >>[delegate testVoid :s];
> >>  }
> >>}
> >> -  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+2]], scope:
> >> -  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+1]], scope:
> >> +  // CHECK: ![[STORE8]] = !DILocation(line: [[@LINE+3]], scope:
> >> +  // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+2]], scope:
> >> +  // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
> >>  }
> >>
> >>
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r253598 - Test to ensure the function does not have an unresolved or unevaluated exception specification before testing whether the function throws or not. Fixes PR25574.

2015-11-19 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Nov 19 14:45:35 2015
New Revision: 253598

URL: http://llvm.org/viewvc/llvm-project?rev=253598&view=rev
Log:
Test to ensure the function does not have an unresolved or unevaluated 
exception specification before testing whether the function throws or not. 
Fixes PR25574.

Modified:
clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/cert-throw-exception-type.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp?rev=253598&r1=253597&r2=253598&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp Thu 
Nov 19 14:45:35 2015
@@ -19,9 +19,12 @@ AST_MATCHER(CXXConstructorDecl, isNoThro
   if (!Node.isCopyConstructor())
 return false;
 
-  if (const auto *FnTy = Node.getType()->getAs())
-return FnTy->isNothrow(Node.getASTContext());
-  llvm_unreachable("Copy constructor with no prototype");
+  const auto *FnTy = Node.getType()->getAs();
+  // Assume the best for any unresolved exception specification.
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return true;
+
+  return FnTy->isNothrow(Node.getASTContext());
 }
 } // end namespace
 
@@ -36,7 +39,6 @@ void ThrownExceptionTypeCheck::registerM
   isCopyConstructor(), unless(isNoThrowCopyConstructor()
   .bind("expr"))),
   this);
-
 }
 
 void ThrownExceptionTypeCheck::check(const MatchFinder::MatchResult &Result) {

Modified: clang-tools-extra/trunk/test/clang-tidy/cert-throw-exception-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-throw-exception-type.cpp?rev=253598&r1=253597&r2=253598&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/cert-throw-exception-type.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-throw-exception-type.cpp Thu 
Nov 19 14:45:35 2015
@@ -108,5 +108,20 @@ void f() {
   throw Allocates(); // match, copy constructor throws
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: thrown exception type is not 
nothrow copy constructible
   throw OptionallyAllocates(); // ok
+}
+
+namespace PR25574 {
+struct B {
+  B(const B&) noexcept;
+};
 
+struct D : B {
+  D();
+  virtual ~D() noexcept;
+};
+
+template 
+void f() {
+  throw D();
+}
 }


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


Re: [PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

2015-11-19 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 40695.
aaron.ballman added a comment.

Ensuring unresolved exception specifications are properly handled.


http://reviews.llvm.org/D14824

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/StaticObjectExceptionCheck.cpp
  clang-tidy/cert/StaticObjectExceptionCheck.h
  docs/clang-tidy/checks/cert-static-object-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-static-object-exception.cpp

Index: test/clang-tidy/cert-static-object-exception.cpp
===
--- test/clang-tidy/cert-static-object-exception.cpp
+++ test/clang-tidy/cert-static-object-exception.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cert-err58-cpp %t
+
+struct S {
+  S() noexcept(false);
+};
+
+struct T {
+  T() noexcept;
+};
+
+struct U {
+  U() {}
+};
+
+struct V {
+  explicit V(const char *) {} // Can throw
+};
+
+
+S s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+T t; // ok
+U u;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
+V v("v");
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
+
+void f(S s1, T t1, U u1, V v1) { // ok, ok, ok, ok
+  S s2; // ok
+  T t2; // ok
+  U u2; // ok
+  V v2("v"); // ok
+
+  thread_local S s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local T t3; // ok
+  thread_local U u3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local V v3("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
+
+  static S s4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 's4' with static storage duration may throw an exception that cannot be caught
+  static T t4; // ok
+  static U u4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'u4' with static storage duration may throw an exception that cannot be caught
+  static V v4("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v4' with static storage duration may throw an exception that cannot be caught
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -1,8 +1,9 @@
 List of clang-tidy Checks
 =
 
-.. toctree::
+.. toctree::   
cert-setlongjmp
+   cert-static-object-exception
cert-thrown-exception-type
cert-variadic-function-def
cppcoreguidelines-pro-bounds-array-to-pointer-decay
Index: docs/clang-tidy/checks/cert-static-object-exception.rst
===
--- docs/clang-tidy/checks/cert-static-object-exception.rst
+++ docs/clang-tidy/checks/cert-static-object-exception.rst
@@ -0,0 +1,9 @@
+cert-err58-cpp
+==
+
+This check flags all static or thread_local variable declarations where the
+constructor for the object may throw an exception.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR58-CPP. Constructors of objects with static or thread storage duration must not throw exceptions
+`_.
Index: clang-tidy/cert/StaticObjectExceptionCheck.h
===
--- clang-tidy/cert/StaticObjectExceptionCheck.h
+++ clang-tidy/cert/StaticObjectExceptionCheck.h
@@ -0,0 +1,34 @@
+//===--- StaticObjectExceptionCheck.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_CERT_ERR58_CPP_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_ERR58_CPP_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/CERT-err58-cpp.html
+class 

cfe-commits@lists.llvm.org

2015-11-19 Thread Agustín Bergé via cfe-commits
K-ballo created this revision.
K-ballo added reviewers: mclow.lists, EricWF.
K-ballo added a subscriber: cfe-commits.

Implement LWG2485, `get()` should be overloaded for `const tuple&&`.

http://reviews.llvm.org/D14839

Files:
  include/__tuple
  include/array
  include/tuple
  include/utility
  test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
  test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp

Index: test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
===
--- test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
+++ test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -40,5 +40,13 @@
 assert(std::get<0>(t) == nullptr); // has been moved from
 }
 
+{
+typedef std::unique_ptr upint;
+const std::pair t(upint(new int(4)), 42);
+const upint&& p = std::get<0>(std::move(t)); // get const rvalue
+assert(*p == 4);
+assert(std::get<0>(t) != nullptr);
+}
+
 #endif
 }
Index: test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
===
--- /dev/null
+++ test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
@@ -0,0 +1,32 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  struct pair
+
+// template
+// const typename tuple_element >::type&&
+// get(const pair&&);
+
+#include 
+#include 
+#include 
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+typedef std::pair, short> P;
+const P p(std::unique_ptr(new int(3)), 4);
+const std::unique_ptr&& ptr = std::get<0>(std::move(p));
+assert(*ptr == 3);
+}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -56,5 +56,13 @@
 assert(std::get<0>(t) == nullptr); // has been moved from
 }
 
+{
+typedef std::unique_ptr upint;
+const std::tuple t(upint(new int(4)));
+const upint&& p = std::get(std::move(t)); // get const rvalue
+assert(*p == 4);
+assert(std::get<0>(t) != nullptr);
+}
+
 #endif
 }
Index: test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
@@ -0,0 +1,43 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   const typename tuple_element >::type&&
+//   get(const tuple&& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+#include 
+#include 
+
+struct Empty {};
+
+int main()
+{
+{
+typedef std::tuple T;
+const T t(3);
+int const&& i = std::get<0>(std::move(t));
+assert(i == 3);
+}
+{
+typedef std::tuple T;
+const T t("high", 5);
+std::string const&& s = std::get<0>(std::move(t));
+int const&& i = std::get<1>(std::move(t));
+assert(s == "high");
+assert(i == 5);
+}
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
@@ -0,0 +1,32 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  class tuple;
+
+// template 
+//   const typename tuple_element >::typ

Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> I have seen plenty of structures where the specific layout was important and 
> couldn't be changed.


Can you give specific examples of these? Can we develop heuristics for them?

> These generally felt like noisy reports unless I had more specific 
> justification for them (like evidence of 

>  an array of the elements). Should it be higher? As I get better at detecting 
> arrays, then I think it makes 

>  sense to bump the raw value higher.


I think it's better to report many fewer issues that are real problems to 
"advertise" the checker. Once people see it's value, they can lower the 
threshold. If we report hundreds of issues, it will scare people off.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:72
@@ +71,3 @@
+if (shouldSkipDecl(RD))
+  return;
+

That's true, but it does not matter for the syntactic checkers much.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:145
@@ +144,3 @@
+}
+auto IsTrickyField = [](const FieldDecl *FD) -> bool {
+  // Bitfield layout is hard.

I wonder why the analyzer diagnostic reporting mechanism does not take care of 
this.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:322
@@ +321,2 @@
+  Mgr.registerChecker();
+}

I think it is important to check the numbers to make sure that logic does not 
regress. Maybe you could create one clone for x86 or only test on x86? Is 
testing on each architecture tests the code you wrote?


http://reviews.llvm.org/D14779



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


Re: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-11-19 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: include/clang/AST/Expr.h:631-634
@@ -630,1 +630,6 @@
 
+  /// \brief If the current Expr is either a pointer, this will try to
+  /// statically determine the number of bytes available where the pointer is
+  /// pointing.  Returns true if all of the above holds and we were able to
+  /// figure out the size, false otherwise.
+  ///

rsmith wrote:
> Looks OK, but you have an undesirable "either" in the comment now.
Danke


Comment at: lib/AST/ExprConstant.cpp:6507-6509
@@ -6506,5 +6545,3 @@
 // handle all cases where the expression has side-effects.
-// Likewise, if Type is 3, we must handle this because CodeGen cannot give 
a
-// conservatively correct answer in that case.
-if (E->getArg(0)->HasSideEffects(Info.Ctx) || Type == 3)
   return Success((Type & 2) ? 0 : -1, E);

rsmith wrote:
> I don't disagree, but it seems logically similar to the `HasSideEffects` 
> case, which is still here. Maybe that should be moved to `CodeGen` too.
They seem sufficiently different to me. GCC's docs for `__builtin_object_size` 
say "__builtin_object_size never evaluates its arguments for side-effects. If 
there are any side-effects in them, it returns (size_t) -1 for type 0 or 1 and 
(size_t) 0 for type 2 or 3," so this is more a feature of the builtin itself 
than an artifact of how we generate code. That said, I can't tell if our 
partial relaxation of this restriction is intentional or not. :)

FWIW, the static analyzer also apparently depends on us returning `Success` 
here if there are side-effects; tests fail if I move this check to CodeGen.


Comment at: lib/CodeGen/CGCall.cpp:110
@@ +109,3 @@
+  // pass_object_size. So, we preallocate for the common case.
+  prefix.reserve(FPT->getNumParams());
+

rsmith wrote:
> Given that this appends, `reserve(prefix.size() + FPT->getNumParams())` seems 
> better.
Nice catch -- thanks.


Comment at: lib/Sema/SemaOverload.cpp:8832-8834
@@ +8831,5 @@
+
+  auto HasPassObjSize = std::mem_fn(&ParmVarDecl::hasAttr);
+
+  auto I = std::find_if(FD->param_begin(), FD->param_end(), HasPassObjSize);
+  if (I == FD->param_end()) {

rsmith wrote:
> Any reason why you factor out `HasPassObjSize` here and not in the previous 
> (essentially identical) function? And can you factor this out into a 
> `getPassObjectSizeParamIndex` function or something, to avoid some of the 
> duplication between this and the previous function?
> Any reason why you factor out HasPassObjSize here and not in the previous 
> (essentially identical) function? 

Artifact of not cleaning up completely after playing with different ways to do 
this -- sorry.

> And can you factor this out into a getPassObjectSizeParamIndex function or 
> something, to avoid some of the duplication between this and the previous 
> function?

I tried merging the functions entirely; if we don't like the result, I'm happy 
to go back to the way they were and just factor out the `find_if` bit. :)


http://reviews.llvm.org/D13263



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


Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-19 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Are there any of the intrinsics in the headers that also depend on x87?

One inline comment.

-eric



Comment at: lib/Basic/Targets.cpp:2538-2539
@@ -2537,1 +2537,4 @@
 
+  // All X86 processors but i386 have X87.
+  if (getCPUKind(CPU) != CK_i386)
+setFeatureEnabledImpl(Features, "x87", true);

aturetsk wrote:
> You are right. Fixed.
Mind only doing getCPUKind once here? :)


http://reviews.llvm.org/D13980



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


Re: [PATCH] D14727: [Driver] Adapt Linux::GCCVersion::Parse to match GCC 5 installations

2015-11-19 Thread Thiago Macieira via cfe-commits
thiagomacieira added a comment.

What happens now?


http://reviews.llvm.org/D14727



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


Re: [PATCH] D14800: Honor system specific paths of MAN pages

2015-11-19 Thread Chris Bieneman via cfe-commits
beanz added a reviewer: jroelofs.
beanz added a comment.

This looks fine to me, but looping in jroelofs as he wrote the original patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D14800



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


Re: [PATCH] D14800: Honor system specific paths of MAN pages

2015-11-19 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D14800



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-19 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 40703.
pete added a comment.

Updated with the following changes:

- Removed the -f-objc-X option and made the -fno-objc-X option be codegen only.
- Updated all the comments to be what John suggested.
- Added a method (shouldUseRuntimeFunctionsForAlloc) to single out the alloc 
case with its own checks.
- Added check and test case for IsSuper
- Added test for retain of self.
- The driver test now only checks for whether the flag is forwarded correctly 
as the target checks are done during codegen.
- The CodeGen test now includes all the variants for macos, fragile, iOS, tvos 
and watchOS.

Given we now have 2 runtime methods to check, I tried to reduce duplication by 
splitting alloc out of the switch.  The alternative is to check for 
shouldUseARCFunctionsForRetainRelease() in each of the 
retain/release/autorelease cases.  I'm fine with either solution.

I wasn't able to move the code to CGObjC.  Unfortunately there's no common 
EmitMessageSend method which is shared by CGObjCMac and CGObjCGNU.  I could 
move this to a helper in CGObjC and call the helper from CGObjCMac and 
CGObjCGNU if thats preferable.  Perhaps we should do that in a follow up only 
if the CGObjCGNU valid targets were ever true for the versions being checked in 
shouldUseARCFunctionsForRetainRelease.


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,9 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
+
+
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (id)autorelease;
+@end
+
+@interface NSString : NSObject
+- (void)retain_self;
+- (void)retain_super;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
+
+@implementation NSString
+
+// Make sure we can convert a message to a dynamic receiver to a call
+// CHECK-LABEL: define {{.*}}void @retain_self
+- (void)retain_self {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_retain}}
+  [self retain];
+}
+
+// Make sure we never convert a message to super to a call
+// CHECK-LABEL: define {{.*}}void @retain_super
+- (void)retain_super {
+  // MSGS: {{call.*@objc_msgSend}}

r253610 - AMDGPU: Add support for 's' and 'v' asm constraints

2015-11-19 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Nov 19 16:11:58 2015
New Revision: 253610

URL: http://llvm.org/viewvc/llvm-project?rev=253610&view=rev
Log:
AMDGPU: Add support for 's' and 'v' asm constraints

Summary: 's' is used to specify sgprs and 'v' is used to specify vgprs.

Reviewers: arsenm, echristo

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=253610&r1=253609&r2=253610&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Nov 19 16:11:58 2015
@@ -1826,8 +1826,15 @@ public:
   }
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &info) const override {
-return true;
+ TargetInfo::ConstraintInfo &Info) const override {
+switch (*Name) {
+default: break;
+case 'v': // vgpr
+case 's': // sgpr
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 
   ArrayRef getTargetBuiltins() const override {

Added: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl?rev=253610&view=auto
==
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl (added)
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl Thu Nov 19 16:11:58 2015
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}


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


Re: [PATCH] D14307: AMDGPU: Add support for 's' and 'v' asm constraints

2015-11-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253610: AMDGPU: Add support for 's' and 'v' asm constraints 
(authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D14307?vs=39121&id=40704#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14307

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl

Index: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
===
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1826,8 +1826,15 @@
   }
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &info) const override {
-return true;
+ TargetInfo::ConstraintInfo &Info) const override {
+switch (*Name) {
+default: break;
+case 'v': // vgpr
+case 's': // sgpr
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 
   ArrayRef getTargetBuiltins() const override {


Index: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
===
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1826,8 +1826,15 @@
   }
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &info) const override {
-return true;
+ TargetInfo::ConstraintInfo &Info) const override {
+switch (*Name) {
+default: break;
+case 'v': // vgpr
+case 's': // sgpr
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 
   ArrayRef getTargetBuiltins() const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Ben Craig via cfe-commits
bcraig marked an inline comment as done.
bcraig added a comment.

In http://reviews.llvm.org/D14779#293236, @zaks.anna wrote:

> > I have seen plenty of structures where the specific layout was important 
> > and couldn't be changed.
>
>
> Can you give specific examples of these? Can we develop heuristics for them?


The previously mentioned flock and flock64 structures are one example.  These 
structures have ABI significance for that client, as they cross .so / .dll 
boundaries.  Other general examples would be structures that mimic the layout 
of on-disk and on-network structures that people use for memcpy based 
serialization.  I don't know of a good way to make a heuristic for those 
structures, but the warnings can be suppressed without breaking ABI by adding 
explicit padding members.

> > These generally felt like noisy reports unless I had more specific 
> > justification for them (like evidence of 

> 

> >  an array of the elements). Should it be higher? As I get better at 
> > detecting arrays, then I think it makes 

> 

> >  sense to bump the raw value higher.

> 

> 

> I think it's better to report many fewer issues that are real problems to 
> "advertise" the checker. Once people see it's value, they can lower the 
> threshold. If we report hundreds of issues, it will scare people off.


I will bump the threshold from 8 to 24, then rerun against clang + llvm.  I'm 
guessing that that will get the number of reports down below 50.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:322
@@ +321,2 @@
+  Mgr.registerChecker();
+}

zaks.anna wrote:
> I think it is important to check the numbers to make sure that logic does not 
> regress. Maybe you could create one clone for x86 or only test on x86? Is 
> testing on each architecture tests the code you wrote?
I will do a partial fork of these tests on x64 to validate the numbers coming 
out.  Running an older versions of these tests on multiple platforms alerted me 
to the craziness of base class layout and tail padding.  Here's an example of 
the crazy...

  struct Base {
virtual ~Base() {}
int i;
char c;
  };

  struct Derived : public Base {
char c1;
short i1;
char c2;
  };

On some ABI's, the amount of padding in the Derived portion is 2 bytes (optimal 
0), and other ABIs, the observed amount is 3 bytes (optimal 3).  My padding 
calculation code at the time managed to hit my assert that "optimal" was worse 
than baseline.


http://reviews.llvm.org/D14779



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-19 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 40705.
pete added a comment.

After chatting with John offline, he mentioned that this code could be shared 
with all ObjC CG's if I put it in EmitObjCMessageExpr.

This moves it here and also checks that we don't do the retain/release 
call->msgSend optimization when GC is enabled.  There's also a test for that 
case.


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,9 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
+
+
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Make sure we don't do calls to retain/release when using GC.
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-gc | FileCheck %s --check-prefix=GC
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (id)autorelease;
+@end
+
+@interface NSString : NSObject
+- (void)retain_self;
+- (void)retain_super;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  // GC: {{call.*@objc_alloc}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
+
+@implementation NSString
+
+// Make sure we can convert a message to a dynamic receiver to a call
+// CHECK-LABEL: define {{.*}}void @retain_self
+- (void)retain_self {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_retain}}
+  // GC: {{call.*@objc_msgSend}}
+  [self retain];
+}
+
+// Make sure we never convert a message to super to a call
+// CHECK-LABEL: define {{.*}}void @retain_super
+- (void)retain_super {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [super retain];
+}
+
+@end
\ No newline at end of file
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -609,6 +609,9 @@
 }
   }
 
+  if (Args.hasArg(OPT_fno_objc_convert_messages_to_runtime_calls))
+Opts.ObjCConvertMessagesToRuntimeCalls = 0;
+
   Opts.EmulatedTLS =
   Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false);
 
Index: lib/Driver/Tools.cpp
===

Re: [PATCH] D14800: Honor system specific paths of MAN pages

2015-11-19 Thread Kamil Rytarowski via cfe-commits
krytarowski added a comment.

Please land it, I'm not a committer.


Repository:
  rL LLVM

http://reviews.llvm.org/D14800



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 40707.
rmaprath added a comment.

Addressing review comments by @jroelofs:

- Got rid of the default implementation for `__libcxx_noexceptions_abort` by 
making it a weak reference.


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/__noexcept
  include/array
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// 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.
+//
+//===--===//
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include
+#include
+#include
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+// some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+thread_local jmp_buf try_buf;
+#else
+jmp_buf try_buf;
+#endif
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(void) {
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: include/array
===
--- include/array
+++ include/array
@@ -110,6 +110,7 @@
 #if defined(_LIBCPP_NO_EXCEPTIONS)
 #include 
 #endif
+#include <__noexcept>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -201,11 +202,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+   __throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +212,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__noexcept
===
--- /dev/null
+++ include/__noexcept
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===-- __noexcept ===//
+//
+// 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.
+//
+//===--===//
+
+#ifndef _LIBCPP_NOEXCEPT_H
+#define _LIBCPP_NOEXCEPT_H
+
+#include <__config>
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include
+#include
+
+void _LIBCPP_WEAK __libcxx_noexceptions_abort();
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+template
+inline void __throw_helper(T t, const char *msg = nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+throw t;
+#else
+if (msg) // explicit error message provided
+  fprintf(stderr, "%s\n", msg);
+// FIXME: instead of using the default what() string of the std::exception
+// class, make all the exception classes return a meaningful error message.
+else if (t.what())
+  fprintf(stderr, "%s\n", t.what());
+else // use a generic error message
+  fprintf(stderr, "exception raised, cannot propagate. Aborting.\n");
+
+if (__libcxx_noexceptions_abort)
+  __libcxx_noexceptions_abort();
+else
+  abort();
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+#endif // _LIBCPP_NOEXCEPT_H
Index: include/__config
=

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-19 Thread John McCall via cfe-commits
rjmccall added a comment.

By "in CGObjC", I mean you should be able to do it in 
CodeGenFunction::EmitObjCMessageExpr.  Maybe put it in a separate function like

  static llvm::Value *tryGenerateSpecializedMessageSend(...)

and then do something like

  } else if (llvm::Value *SpecializedResult = 
tryGenerateSpecializedMessageSend(...)) {
result = RValue::get(SpecializedResult);
  } else {

right before the call to GenerateMessageSend.



Comment at: include/clang/Basic/ObjCRuntime.h:176
@@ +175,3 @@
+  /// than an ordinary message send of the appropriate selector?
+
+  /// The ARC entrypoints are guaranteed to be equivalent to just sending the

The vertical whitespace is good, but please continue the doc comments across it.


Comment at: include/clang/Basic/ObjCRuntime.h:207
@@ +206,3 @@
+  /// Does this runtime provide entrypoints that are likely to be faster
+  /// than an ordinary message send of the appropriate selector?
+

You can just say "alloc" here. :)


Comment at: include/clang/Driver/Options.td:896
@@ -895,1 +895,3 @@
+def fno_objc_convert_messages_to_runtime_calls :
+  Flag<["-"], "fno-objc-convert-messages-to-runtime-calls">, Group, 
Flags<[CC1Option]>;
 def fobjc_arc_exceptions : Flag<["-"], "fobjc-arc-exceptions">, 
Group, Flags<[CC1Option]>,

It's fine to have both the "yes" and "no" options; I just meant that only the 
"no" option needs to be a cc1 option.


Comment at: lib/CodeGen/CGObjCMac.cpp:1874
@@ +1873,3 @@
+auto &Runtime = CGM.getLangOpts().ObjCRuntime;
+if (Method->getMethodFamily() == OMF_alloc &&
+Runtime.shouldUseRuntimeFunctionsForAlloc()) {

I'd just write this as a switch over the method family.  The runtime check 
isn't unreasonable to duplicate into each of the cases; also, in the dominant 
case it will be true, so we're not really saving any work in practice by doing 
it early.  It's the method family check that will usually avoid the rest of the 
work.

We don't really care if we have a method declaration; if there's no method, you 
can just ask the selector for its method family.  That won't be cached, though, 
and it's implemented with string comparisons, so please be sure to avoid 
calling it multiple times.

Please loosen the type restrictions here.  You shouldn't need to restrict the 
receiver type, and any ObjC pointer type should be fine for the return type.  
Of course, you'll need to add bitcasts to/from i8*, but that's easy enough.


Comment at: lib/CodeGen/CGObjCMac.cpp:1883
@@ +1882,3 @@
+return RValue::get(CGF.EmitObjCAlloc(Arg0));
+} else if (Runtime.shouldUseARCFunctionsForRetainRelease()) {
+  switch (Method->getMethodFamily()) {

Oh.  Additional check: don't do this if GC != NonGC.


Comment at: lib/CodeGen/CGObjCMac.cpp:1897
@@ +1896,3 @@
+  if (ResultType->isVoidType() && Arg0Ty->isObjCIdType()) {
+CGF.EmitARCRelease(Arg0, ARCImpreciseLifetime);
+return RValue::get(nullptr);

This has precise lifetime, actually.  Not that it really matters, since the ARC 
optimizer should be disabled, but it's best to be correct.


http://reviews.llvm.org/D14737



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


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> can be suppressed without breaking ABI by adding explicit padding members.


We should convey the suppression mechanism as part of the diagnostic.


http://reviews.llvm.org/D14779



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-19 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: EricWF.
jroelofs added a comment.

I don't have any more comments, but I don't feel comfortable LGTM-ing this. 
I'll save that for Eric or Marshall.



Comment at: test/support/noexcept.h:14
@@ +13,3 @@
+#include
+#include
+

s/http://reviews.llvm.org/D14653



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


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-19 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D14779#293339, @zaks.anna wrote:

> > can be suppressed without breaking ABI by adding explicit padding members.
>
>
> We should convey the suppression mechanism as part of the diagnostic.


I can make the diagnostic longer.  Alternatively, is there a way to provide 
"Note" style diagnostics in the analyzer?  If so, then that seems like the best 
place to put that information.


http://reviews.llvm.org/D14779



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


[PATCH] D14847: Support CMake's clang_rt.profile library naming scheme

2015-11-19 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added a reviewer: bogner.
beanz added a subscriber: cfe-commits.

This code is a bit undesirable, but it gets clang to work with the autoconf and 
cmake-built libclang_rt.profile libraries.

http://reviews.llvm.org/D14847

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  auto library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-  /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+ : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+ : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+ : "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-  /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, library,
+/*AlwaysLink*/ true);
   return;
 }
 


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  auto library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-  /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+ : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+ : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+ : "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-  /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, library,
+/*AlwaysLink*/ true);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14847: Support CMake's clang_rt.profile library naming scheme

2015-11-19 Thread Justin Bogner via cfe-commits
Chris Bieneman  writes:
> beanz created this revision.
> beanz added a reviewer: bogner.
> beanz added a subscriber: cfe-commits.
>
> This code is a bit undesirable, but it gets clang to work with the
> autoconf and cmake-built libclang_rt.profile libraries.

Yeah, this is a bit awkward, but it makes sense for the transition
period. LGTM with a couple of nits.

> http://reviews.llvm.org/D14847
>
> Files:
>   lib/Driver/ToolChains.cpp
>
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -323,21 +323,35 @@
>ArgStringList &CmdArgs) const {
>if (!needsProfileRT(Args)) return;
>  
> +  // TODO: Clean this up once autoconf is gone
> +  SmallString<128> P(getDriver().ResourceDir);
> +  llvm::sys::path::append(P, "lib", "darwin");
> +  auto library = "libclang_rt.profile_osx.a";

Did you just use auto for a 'const char *'? I don't think its worth the
saved keystrokes. Also, the variable should be named "Library".

> +
>// Select the appropriate runtime library for the target.
> -  if (isTargetWatchOSBased()) {
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
> -  /*AlwaysLink*/ true);
> -  } else if (isTargetTvOSBased()) {
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
> -  /*AlwaysLink*/ true);
> -  } else if (isTargetIOSBased()) {
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
> -  /*AlwaysLink*/ true);
> +  if (isTargetWatchOS()) {
> +library = "libclang_rt.profile_watchos.a";
> +  } else if (isTargetWatchOSSimulator()) {
> +llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
> +library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
> + : "libclang_rt.profile_watchos.a";
> +  } else if (isTargetTvOS()) {
> +library = "libclang_rt.profile_tvos.a";
> +  } else if (isTargetTvOSSimulator()) {
> +llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
> +library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
> + : "libclang_rt.profile_tvos.a";
> +  } else if (isTargetIPhoneOS()) {
> +library = "libclang_rt.profile_ios.a";
> +  } else if (isTargetIOSSimulator()) {
> +llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
> +library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
> + : "libclang_rt.profile_ios.a";
>} else {
>  assert(isTargetMacOS() && "unexpected non MacOS platform");
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
> -  /*AlwaysLink*/ true);
>}
> +  AddLinkRuntimeLib(Args, CmdArgs, library,
> +/*AlwaysLink*/ true);
>return;
>  }
>  
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14847: Support CMake's clang_rt.profile library naming scheme

2015-11-19 Thread Chris Bieneman via cfe-commits

> On Nov 19, 2015, at 4:12 PM, Justin Bogner  wrote:
> 
> Chris Bieneman mailto:be...@apple.com>> writes:
>> beanz created this revision.
>> beanz added a reviewer: bogner.
>> beanz added a subscriber: cfe-commits.
>> 
>> This code is a bit undesirable, but it gets clang to work with the
>> autoconf and cmake-built libclang_rt.profile libraries.
> 
> Yeah, this is a bit awkward, but it makes sense for the transition
> period. LGTM with a couple of nits.
> 
>> http://reviews.llvm.org/D14847
>> 
>> Files:
>>  lib/Driver/ToolChains.cpp
>> 
>> Index: lib/Driver/ToolChains.cpp
>> ===
>> --- lib/Driver/ToolChains.cpp
>> +++ lib/Driver/ToolChains.cpp
>> @@ -323,21 +323,35 @@
>>   ArgStringList &CmdArgs) const {
>>   if (!needsProfileRT(Args)) return;
>> 
>> +  // TODO: Clean this up once autoconf is gone
>> +  SmallString<128> P(getDriver().ResourceDir);
>> +  llvm::sys::path::append(P, "lib", "darwin");
>> +  auto library = "libclang_rt.profile_osx.a";
> 
> Did you just use auto for a 'const char *'? I don't think its worth the
> saved keystrokes. Also, the variable should be named "Library”.

I optimize for keystrokes, and that is more than 2x as many characters!

I’ll update and commit :-)

-Chris

> 
>> +
>>   // Select the appropriate runtime library for the target.
>> -  if (isTargetWatchOSBased()) {
>> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
>> -  /*AlwaysLink*/ true);
>> -  } else if (isTargetTvOSBased()) {
>> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
>> -  /*AlwaysLink*/ true);
>> -  } else if (isTargetIOSBased()) {
>> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
>> -  /*AlwaysLink*/ true);
>> +  if (isTargetWatchOS()) {
>> +library = "libclang_rt.profile_watchos.a";
>> +  } else if (isTargetWatchOSSimulator()) {
>> +llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
>> +library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
>> + : "libclang_rt.profile_watchos.a";
>> +  } else if (isTargetTvOS()) {
>> +library = "libclang_rt.profile_tvos.a";
>> +  } else if (isTargetTvOSSimulator()) {
>> +llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
>> +library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
>> + : "libclang_rt.profile_tvos.a";
>> +  } else if (isTargetIPhoneOS()) {
>> +library = "libclang_rt.profile_ios.a";
>> +  } else if (isTargetIOSSimulator()) {
>> +llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
>> +library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
>> + : "libclang_rt.profile_ios.a";
>>   } else {
>> assert(isTargetMacOS() && "unexpected non MacOS platform");
>> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
>> -  /*AlwaysLink*/ true);
>>   }
>> +  AddLinkRuntimeLib(Args, CmdArgs, library,
>> +/*AlwaysLink*/ true);
>>   return;
>> }

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


Re: [PATCH] D14847: Support CMake's clang_rt.profile library naming scheme

2015-11-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253625: Support CMake's clang_rt.profile library naming 
scheme (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D14847?vs=40712&id=40717#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14847

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  const char *Library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-  /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+Library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+ : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+Library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+ : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+Library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+ : "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-  /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, Library,
+/*AlwaysLink*/ true);
   return;
 }
 


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  const char *Library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-  /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+Library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+ : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+Library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+ : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+Library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+ : "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-  /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, Library,
+/*AlwaysLink*/ true);
   return;
 }
 
___
cfe-commits 

r253625 - Support CMake's clang_rt.profile library naming scheme

2015-11-19 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu Nov 19 18:19:21 2015
New Revision: 253625

URL: http://llvm.org/viewvc/llvm-project?rev=253625&view=rev
Log:
Support CMake's clang_rt.profile library naming scheme

Summary: This code is a bit undesirable, but it gets clang to work with the 
autoconf and cmake-built libclang_rt.profile libraries.

Reviewers: bogner

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253625&r1=253624&r2=253625&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Nov 19 18:19:21 2015
@@ -323,21 +323,35 @@ void Darwin::addProfileRTLibs(const ArgL
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  const char *Library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-  /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-  /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+Library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+ : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+Library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+ : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+Library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+ : "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-  /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, Library,
+/*AlwaysLink*/ true);
   return;
 }
 


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


Re: [PATCH] D14215: Disable frame pointer elimination when using -pg

2015-11-19 Thread David Li via cfe-commits
davidxl added a comment.

Can you also add a test case with option -momit-leaf-frame-pointer?


http://reviews.llvm.org/D14215



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-19 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 40719.
pete added a comment.

Thanks for all the feedback!

I've addressed all of your previous feedback and also applied clang-format to 
the whole patch as some parts were looking questionable.

BTW, each of the implementations of EmitObjC* ultimately called to 
emitARCValueOperation which handled the bit cast insertion when the dest type 
was not an id.  I've added a check for this in the test case, and verified that 
the IR looked good.

Let me know what you think.  Thanks!


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,7 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fobjc-convert-messages-to-runtime-calls -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -fobjc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Make sure we don't do calls to retain/release when using GC.
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-gc | FileCheck %s --check-prefix=GC
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (NSObject *)autorelease;
+@end
+
+@interface NSString : NSObject
+- (void)retain_self;
+- (void)retain_super;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+NSObject *test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  // CALLS-NEXT: bitcast i8*
+  // CALLS-NEXT: ret
+  // GC: {{call.*@objc_alloc}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  // The auto release returns its value here as then we can ensure we insert
+  // the bitcasts as needed.
+  return [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
+
+@implementation NSString
+
+// Make sure we can convert a message to a dynamic receiver to a call
+// CHECK-LABEL: define {{.*}}void @retain_self
+- (void)retain_self {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_retain}}
+  // GC: {{call.*@objc_msgSend}}
+  [self retain];
+}
+
+// Make sure we never convert a message to super to a call
+// CHECK-LABEL: define {{.*}}void @retain_super
+- (void)retain_super {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [super retain];
+}
+
+@end
\ No newline at end of file
Index: lib/Frontend/Compiler

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-19 Thread John McCall via cfe-commits
rjmccall added a comment.

The casts done by emitARCValueOperation will handle the input, but they don't 
quite handle the result properly.  The right test case here is a method named 
"retain" that's declared to return something completely unrelated to its 
receiver type, e.g.

  @class A;
  @interface B
  - (A*) retain;
  @end

You should also add a test case for unusual return types that your mechanism 
just can't support and that need to go through the ordinary message-send 
emission, like returning a float.



Comment at: test/CodeGenObjC/convert-messages-to-runtime-calls.m:62
@@ +61,3 @@
+
+// Make sure we can convert a message to a dynamic receiver to a call
+// CHECK-LABEL: define {{.*}}void @retain_self

You already test this case.  If you make retain_self a class method, this will 
be a class message; but it should still be okay to use objc_retain.


http://reviews.llvm.org/D14737



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


Re: [PATCH] D9600: Add scan-build python implementation

2015-11-19 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Hi Laszlo, thanks for the update!

Some high-level questions/comments (and various small things I noticed inline).

- I tried running scan-build in interposition mode (i.e., uncommenting  out 
#"$SCRIPT_DIR/analyze-build" $@ in scan-build) and got python compile errors. 
When you did your testing to compare output with the old scan-build, did you 
use this mode?
- When I run scan-build in intercept-build mode on openssl-1.0 on OS X I get 
compile errors. Is this one of the projects you tested with? When I run in it 
in analyze-build mode I get diffs with CmpRuns.py -- it looks like might be 
because some paths are absolute. What kind of fidelity with the old scan-build 
do expect at this point?

- What is the point of intercept-cc/intercept-c++? I thought libear didn't need 
to set CC/CXX environmental variables.

- Do all the files in this patch need to be committed into the clang repo? 
There seem to be some extraneous files (I've asked inline about the ones that 
don't seem necessary.)

- I found it difficult to understand how all the modules and command-line tools 
fit together. Can the module names be made more harmonious with the 
command-line tool names(the scripts in bin). It is not at all obvious which 
modules belong to which tools, etc. I think it would be good to document this 
in the code, as well.



Comment at: tools/scan-build-py/.travis.yml:1
@@ +1,2 @@
+language: python
+

Is this file needed in clang trunk?


Comment at: tools/scan-build-py/CHANGES.txt:1
@@ +1,1 @@
+v,  -- Initial release.

Is this one needed too?


Comment at: tools/scan-build-py/MANIFEST.in:1
@@ +1,2 @@
+include README.md
+include *.txt

How about this one? Is it needed in clang trunk?


Comment at: tools/scan-build-py/README.md:70
@@ +69,3 @@
+---
+If you find a bug in this documentation or elsewhere in the program or would
+like to propose an improvement, please use the project's [github issue

This should probably point to llvm bugzilla. 
https://llvm.org/bugs/enter_bug.cgi?product=clang


Comment at: tools/scan-build-py/bin/scan-build:13
@@ +12,3 @@
+#
+#"$SCRIPT_DIR/analyze-build" $@
+#"$SCRIPT_DIR/intercept-build" all $@

These should be controlled by flags rather than by commenting the required 
behavior in or out. 

I also think analyze-build should be the default behavior, to maintain 
compatibility with the existing scan-build.


Comment at: tools/scan-build-py/libear/__init__.py:1
@@ +1,2 @@
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure

How does this file fit into the overall build picture? Will this file go away 
once scan-build-py is built with the common clang cmake?


Comment at: tools/scan-build-py/libear/__init__.py:79
@@ +78,3 @@
+class Context(object):
+""" Abstract class to represent different toolset. """
+

Maybe "Toolset" would be a more descriptive name than "Context"?


Comment at: tools/scan-build-py/libear/__init__.py:99
@@ +98,3 @@
+def dl_libraries(self):
+pass
+

I gather the intent is that subclasses will override to provide their own 
versions of these methods? If so, these methods need to be documented so that 
people adding new support for additional platforms know what they should 
provide in their subclasses.

If there are reasonable defaults (for example., `[]` for `dl_libraries`), those 
should be returned here rather than `pass`. If not, these should probably raise 
an exception indicating they must be implemented rather than silently doing 
nothing.


Comment at: tools/scan-build-py/libear/__init__.py:151
@@ +150,3 @@
+@contextlib.contextmanager
+def make_context(src_dir):
+platform = sys.platform

Why is this a generator? There is no functionality after yield.


Comment at: tools/scan-build-py/libear/__init__.py:166
@@ +165,3 @@
+self.ctx = context
+self.results = {'APPLE': sys.platform == 'darwin'}
+

What does this do? Why is it hard-coded?


Comment at: tools/scan-build-py/libear/__init__.py:224
@@ +223,3 @@
+def do_configure(context):
+yield Configure(context)
+

Why is this a generator?


Comment at: tools/scan-build-py/libear/__init__.py:262
@@ +261,2 @@
+def create_shared_library(name, context):
+yield SharedLibrary(name, context)

Why is this a generator?


Comment at: tools/scan-build-py/libscanbuild/clang.py:33
@@ +32,3 @@
+
+This method receives the full command line for direct compilation. And
+it generates the command for indirect compilation. """

I think it would be more accurate to say that this method returns the front-end 
invo

r253630 - [analyzer] DeadStoresChecker: Treat locals captured by reference in C++ lambdas as escaped.

2015-11-19 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Nov 19 19:53:44 2015
New Revision: 253630

URL: http://llvm.org/viewvc/llvm-project?rev=253630&view=rev
Log:
[analyzer] DeadStoresChecker: Treat locals captured by reference in C++ lambdas 
as escaped.

The analyzer currently reports dead store false positives when a local variable
is captured by reference in a C++ lambda.

For example:

  int local = 0; auto lambda = [&local]() {
local++;
  };
  local = 7; // False Positive: Value stored to 'local' is never read
  lambda();

In this case, the assignment setting `local` to 7 is not a dead store because
the called lambda will later read that assigned value.

This commit silences this source of false positives by treating locals captured
by reference in C++ lambdas as escaped, similarly to how the DeadStoresChecker
deals with locals whose address is taken.

rdar://problem/22165179

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
cfe/trunk/test/Analysis/lambdas.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=253630&r1=253629&r2=253630&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Thu Nov 19 
19:53:44 2015
@@ -401,6 +401,11 @@ public:
 // Check for '&'. Any VarDecl whose address has been taken we treat as
 // escaped.
 // FIXME: What about references?
+if (auto *LE = dyn_cast(S)) {
+  findLambdaReferenceCaptures(LE);
+  return;
+}
+
 const UnaryOperator *U = dyn_cast(S);
 if (!U)
   return;
@@ -412,6 +417,28 @@ public:
   if (const VarDecl *VD = dyn_cast(DR->getDecl()))
 Escaped.insert(VD);
   }
+
+  // Treat local variables captured by reference in C++ lambdas as escaped.
+  void findLambdaReferenceCaptures(const LambdaExpr *LE)  {
+const CXXRecordDecl *LambdaClass = LE->getLambdaClass();
+llvm::DenseMap CaptureFields;
+FieldDecl *ThisCaptureField;
+LambdaClass->getCaptureFields(CaptureFields, ThisCaptureField);
+
+for (const LambdaCapture &C : LE->captures()) {
+  if (!C.capturesVariable())
+continue;
+
+  VarDecl *VD = C.getCapturedVar();
+  const FieldDecl *FD = CaptureFields[VD];
+  if (!FD)
+continue;
+
+  // If the capture field is a reference type, it is capture-by-reference.
+  if (FD->getType()->isReferenceType())
+Escaped.insert(VD);
+}
+  }
 };
 } // end anonymous namespace
 

Modified: cfe/trunk/test/Analysis/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambdas.cpp?rev=253630&r1=253629&r2=253630&view=diff
==
--- cfe/trunk/test/Analysis/lambdas.cpp (original)
+++ cfe/trunk/test/Analysis/lambdas.cpp Thu Nov 19 19:53:44 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
inline-lambdas=true -verify %s 
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze 
-analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config 
inline-lambdas=true -verify %s
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze 
-analyzer-checker=core,debug.DumpCFG -analyzer-config inline-lambdas=true %s > 
%t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
@@ -281,6 +281,49 @@ void captureStructReference(const Struct
   }();
 }
 
+// Lambda capture counts as use for dead-store checking.
+
+int returnsValue();
+
+void captureByCopyCausesUse() {
+  int local1 = returnsValue(); // no-warning
+  int local2 = returnsValue(); // no-warning
+  int local3 = returnsValue(); // expected-warning{{Value stored to 'local3' 
during its initialization is never read}}
+
+  (void)[local1, local2]() { }; // Explicit capture by copy counts as use.
+
+  int local4 = returnsValue(); // no-warning
+  int local5 = returnsValue(); // expected-warning{{Value stored to 'local5' 
during its initialization is never read}}
+
+  (void)[=]() {
+(void)local4; // Implicit capture by copy counts as use
+  };
+}
+
+void captureByReference() {
+  int local1 = returnsValue(); // no-warning
+
+  auto lambda1 = [&local1]() { // Explicit capture by reference
+local1++;
+  };
+
+  // Don't treat as a dead store because local1 was was captured by reference.
+  local1 = 7; // no-warning
+
+  lambda1();
+
+  int local2 = returnsValue(); // no-warning
+
+  auto lambda2 = [&]() {
+local2++; // Implicit capture by reference
+  };
+
+  // Don't treat as a dead store because local2 was was captured by reference.
+  local2 = 7; // no-warning
+
+  lambda2();
+}
+
 
 // CHECK: [B2 (ENTRY)]
 // CHECK:   Succs (1): B1


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

r253636 - [CMake] Add a specific 'install-clang-headers' target.

2015-11-19 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Nov 19 20:24:03 2015
New Revision: 253636

URL: http://llvm.org/viewvc/llvm-project?rev=253636&view=rev
Log:
[CMake] Add a specific 'install-clang-headers' target.

Modified:
cfe/trunk/lib/Headers/CMakeLists.txt

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=253636&r1=253635&r2=253636&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Nov 19 20:24:03 2015
@@ -102,5 +102,14 @@ set_target_properties(clang-headers PROP
 
 install(
   FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
+  COMPONENT clang-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+
+if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  add_custom_target(install-clang-headers
+DEPENDS
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=clang-headers
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+endif()


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


r253641 - [coroutines] Per latest wording paper, co_* are no longer permitted in any

2015-11-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 19 20:54:01 2015
New Revision: 253641

URL: http://llvm.org/viewvc/llvm-project?rev=253641&view=rev
Log:
[coroutines] Per latest wording paper, co_* are no longer permitted in any
unevaluated operands.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253641&r1=253640&r2=253641&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 19 20:54:01 
2015
@@ -7960,6 +7960,8 @@ def note_declared_coroutine_here : Note<
   "'%select{co_await|co_yield|co_return}0' here">;
 def err_coroutine_objc_method : Error<
   "Objective-C methods as coroutines are not yet supported">;
+def err_coroutine_unevaluated_context : Error<
+  "'%0' cannot be used in an unevaluated context">;
 def err_coroutine_outside_function : Error<
   "'%0' cannot be used outside a function">;
 def err_coroutine_ctor_dtor : Error<

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253641&r1=253640&r2=253641&view=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Thu Nov 19 20:54:01 2015
@@ -99,10 +99,11 @@ static QualType lookupPromiseType(Sema &
 /// Check that this is a context in which a coroutine suspension can appear.
 static FunctionScopeInfo *
 checkCoroutineContext(Sema &S, SourceLocation Loc, StringRef Keyword) {
-  // 'co_await' and 'co_yield' are permitted in unevaluated operands.
-  // FIXME: Not in 'noexcept'.
-  if (S.isUnevaluatedContext())
+  // 'co_await' and 'co_yield' are not permitted in unevaluated operands.
+  if (S.isUnevaluatedContext()) {
+S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
 return nullptr;
+  }
 
   // Any other usage must be within a function.
   auto *FD = dyn_cast(S.CurContext);
@@ -206,11 +207,12 @@ ExprResult Sema::ActOnCoawaitExpr(Scope
 }
 ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) {
   auto *Coroutine = checkCoroutineContext(*this, Loc, "co_await");
+  if (!Coroutine)
+return ExprError();
 
   if (E->getType()->isDependentType()) {
 Expr *Res = new (Context) CoawaitExpr(Loc, Context.DependentTy, E);
-if (Coroutine)
-  Coroutine->CoroutineStmts.push_back(Res);
+Coroutine->CoroutineStmts.push_back(Res);
 return Res;
   }
 
@@ -230,8 +232,7 @@ ExprResult Sema::BuildCoawaitExpr(Source
 
   Expr *Res = new (Context) CoawaitExpr(Loc, E, RSS.Results[0], RSS.Results[1],
 RSS.Results[2]);
-  if (Coroutine)
-Coroutine->CoroutineStmts.push_back(Res);
+  Coroutine->CoroutineStmts.push_back(Res);
   return Res;
 }
 
@@ -244,11 +245,12 @@ ExprResult Sema::ActOnCoyieldExpr(Scope
 }
 ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {
   auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield");
+  if (!Coroutine)
+return ExprError();
 
   // FIXME: Build await_* calls.
   Expr *Res = new (Context) CoyieldExpr(Loc, Context.VoidTy, E);
-  if (Coroutine)
-Coroutine->CoroutineStmts.push_back(Res);
+  Coroutine->CoroutineStmts.push_back(Res);
   return Res;
 }
 
@@ -257,11 +259,12 @@ StmtResult Sema::ActOnCoreturnStmt(Sourc
 }
 StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) {
   auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return");
+  if (!Coroutine)
+return StmtError();
 
   // FIXME: Build return_* calls.
   Stmt *Res = new (Context) CoreturnStmt(Loc, E);
-  if (Coroutine)
-Coroutine->CoroutineStmts.push_back(Res);
+  Coroutine->CoroutineStmts.push_back(Res);
   return Res;
 }
 

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=253641&r1=253640&r2=253641&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Thu Nov 19 20:54:01 2015
@@ -78,8 +78,17 @@ struct CtorDtor {
   }
 };
 
-constexpr void constexpr_coroutine() { // expected-error {{never produces a 
constant expression}}
-  co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr 
function}} expected-note {{subexpression}}
+void unevaluated() {
+  decltype(co_await a); // expected-error {{cannot be used in an unevaluated 
context}}
+  sizeof(co_await a); // expected-error {{cannot be used in an unevaluated 
context}}
+  typeid(co_await a); // expected-error {{cannot be used in an unevaluated 
context}}
+  decltyp

r253645 - [libclang] Make sure to use the raw module format for libclang parsing.

2015-11-19 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Nov 19 21:36:21 2015
New Revision: 253645

URL: http://llvm.org/viewvc/llvm-project?rev=253645&view=rev
Log:
[libclang] Make sure to use the raw module format for libclang parsing.

Fixes crash when passing '-gmodules' in the compiler options.
rdar://23588717

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/test/Index/annotate-module.m
cfe/trunk/test/Index/complete-modules.m
cfe/trunk/test/Index/index-module.m
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=253645&r1=253644&r2=253645&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Nov 19 21:36:21 2015
@@ -827,6 +827,8 @@ public:
   ///
   /// \param ResourceFilesPath - The path to the compiler resource files.
   ///
+  /// \param ModuleFormat - If provided, uses the specific module format.
+  ///
   /// \param ErrAST - If non-null and parsing failed without any AST to return
   /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
   /// mainly to allow the caller to see the diagnostics.
@@ -845,6 +847,7 @@ public:
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false,
   bool UserFilesAreVolatile = false, bool ForSerialization = false,
+  llvm::Optional ModuleFormat = llvm::None,
   std::unique_ptr *ErrAST = nullptr);
 
   /// \brief Reparse the source files using the same command-line options that

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=253645&r1=253644&r2=253645&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Nov 19 21:36:21 2015
@@ -1934,6 +1934,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
 bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
 bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies,
 bool UserFilesAreVolatile, bool ForSerialization,
+llvm::Optional ModuleFormat,
 std::unique_ptr *ErrAST) {
   assert(Diags.get() && "no DiagnosticsEngine was provided");
 
@@ -1967,6 +1968,9 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
 
   CI->getFrontendOpts().SkipFunctionBodies = SkipFunctionBodies;
 
+  if (ModuleFormat)
+CI->getHeaderSearchOpts().ModuleFormat = ModuleFormat.getValue();
+
   // Create the AST unit.
   std::unique_ptr AST;
   AST.reset(new ASTUnit(false));

Modified: cfe/trunk/test/Index/annotate-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-module.m?rev=253645&r1=253644&r2=253645&view=diff
==
--- cfe/trunk/test/Index/annotate-module.m (original)
+++ cfe/trunk/test/Index/annotate-module.m Thu Nov 19 21:36:21 2015
@@ -6,6 +6,8 @@ int glob;
 // RUN: rm -rf %t.cache
 // RUN: c-index-test -test-annotate-tokens=%s:2:1:5:1 %s 
-fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs \
 // RUN:  | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:2:1:5:1 %s 
-fmodules-cache-path=%t.cache -fmodules -gmodules -F %S/../Modules/Inputs \
+// RUN:  | FileCheck %s
 
 // CHECK:  Punctuation: "#" [2:1 - 2:2] inclusion 
directive=[[INC_DIR:DependsOnModule[/\\]DependsOnModule\.h 
\(.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule.h\)]]
 // CHECK-NEXT: Identifier: "include" [2:2 - 2:9] inclusion 
directive=[[INC_DIR]]

Modified: cfe/trunk/test/Index/complete-modules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-modules.m?rev=253645&r1=253644&r2=253645&view=diff
==
--- cfe/trunk/test/Index/complete-modules.m (original)
+++ cfe/trunk/test/Index/complete-modules.m Thu Nov 19 21:36:21 2015
@@ -5,6 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: c-index-test -code-completion-at=%s:4:9 -fmodules-cache-path=%t 
-fmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck 
-check-prefix=CHECK-TOP-LEVEL %s
+// RUN: c-index-test -code-completion-at=%s:4:9 -fmodules-cache-path=%t 
-fmodules -gmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck 
-check-prefix=CHECK-TOP-LEVEL %s
 // CHECK-TOP-LEVEL: ModuleImport:{TypedText Framework} (50)
 // CHECK-TOP-LEVEL: ModuleImport:{TypedText LibA} (50)
 // CHECK-TOP-LEVEL: ModuleImport:{TypedText nested} (50)

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=253645&r1=253644&r

r253647 - [Myriad]: handle Preprocess job action (-E)

2015-11-19 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Thu Nov 19 22:58:12 2015
New Revision: 253647

URL: http://llvm.org/viewvc/llvm-project?rev=253647&view=rev
Log:
[Myriad]: handle Preprocess job action (-E)

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253647&r1=253646&r2=253647&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Nov 19 22:58:12 2015
@@ -4434,6 +4434,7 @@ Tool *MyriadToolChain::SelectTool(const
   if (!isShaveCompilation(getTriple()))
 return ToolChain::SelectTool(JA);
   switch (JA.getKind()) {
+  case Action::PreprocessJobClass:
   case Action::CompileJobClass:
 if (!Compiler)
   Compiler.reset(new tools::SHAVE::Compiler(*this));

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253647&r1=253646&r2=253647&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Nov 19 22:58:12 2015
@@ -9895,17 +9895,22 @@ void tools::SHAVE::Compiler::ConstructJo
   const InputInfoList &Inputs,
   const ArgList &Args,
   const char *LinkingOutput) const {
-
   ArgStringList CmdArgs;
-
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];
-  assert(II.getType() == types::TY_C || II.getType() == types::TY_CXX);
-  assert(Output.getType() == types::TY_PP_Asm); // Require preprocessed asm.
+  assert(II.getType() == types::TY_C || II.getType() == types::TY_CXX ||
+ II.getType() == types::TY_PP_CXX);
 
-  CmdArgs.push_back("-DMYRIAD2");
+  if (JA.getKind() == Action::PreprocessJobClass) {
+Args.ClaimAllArgs();
+CmdArgs.push_back("-E");
+  } else {
+assert(Output.getType() == types::TY_PP_Asm); // Require preprocessed asm.
+CmdArgs.push_back("-S");
+CmdArgs.push_back("-fno-exceptions"); // Always do this even if 
unspecified.
+  }
   CmdArgs.push_back("-mcpu=myriad2");
-  CmdArgs.push_back("-S");
+  CmdArgs.push_back("-DMYRIAD2");
 
   // Append all -I, -iquote, -isystem paths, defines/undefines,
   // 'f' flags, optimize flags, and warning options.
@@ -9931,8 +9936,6 @@ void tools::SHAVE::Compiler::ConstructJo
 }
   }
 
-  CmdArgs.push_back("-fno-exceptions"); // Always do this even if unspecified.
-
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=253647&r1=253646&r2=253647&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Thu Nov 19 22:58:12 2015
@@ -38,7 +38,7 @@
 
 // RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile" "-DMYRIAD2" "-mcpu=myriad2" "-S" "-isystem" 
"somewhere" "-I" "common"
+// MOVICOMPILE: moviCompile" "-S" "-fno-exceptions" "-mcpu=myriad2" 
"-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" 
"-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
@@ -58,11 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-MD" "-MF" "dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" 
"dep.d" "-MT" "foo.o"
 
 // RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-mcpu=myriad2" "-S" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+
+// RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=PREPROCESS
+// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"


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


Re: [PATCH] D14467: [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions.

2015-11-19 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253650: [MS] Fix for bug 25013 - #pragma vtordisp is unknown 
inside functions, by… (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D14467?vs=40380&id=40745#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14467

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/test/Layout/ms-vtordisp-local.cpp
  cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1007,6 +1007,24 @@
 bool OldFPContractState : 1;
   };
 
+  /// Records and restores the vtordisp state on entry/exit of C++ method body.
+  class VtorDispStackRAII {
+  public:
+VtorDispStackRAII(Sema &S, bool ShouldSaveAndRestore)
+  : S(S), ShouldSaveAndRestore(ShouldSaveAndRestore), OldVtorDispStack() {
+  if (ShouldSaveAndRestore)
+OldVtorDispStack = S.VtorDispModeStack;
+}
+~VtorDispStackRAII() {
+  if (ShouldSaveAndRestore)
+S.VtorDispModeStack = OldVtorDispStack;
+}
+  private:
+Sema &S;
+bool ShouldSaveAndRestore;
+SmallVector OldVtorDispStack;
+  };
+
   void addImplicitTypedef(StringRef Name, QualType T);
 
 public:
Index: cfe/trunk/test/Layout/ms-vtordisp-local.cpp
===
--- cfe/trunk/test/Layout/ms-vtordisp-local.cpp
+++ cfe/trunk/test/Layout/ms-vtordisp-local.cpp
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Base {
+  virtual ~Base() {}
+  virtual void BaseFunc() {}
+};
+
+#pragma vtordisp(0)
+
+struct Container {
+  static void f() try {
+#pragma vtordisp(2)
+struct HasVtorDisp : virtual Base {
+  virtual ~HasVtorDisp() {}
+  virtual void Func() {}
+};
+
+int x[sizeof(HasVtorDisp)];
+
+// HasVtorDisp: vtordisp because of pragma right before it.
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct HasVtorDisp
+// CHECK-NEXT:  0 |   (HasVtorDisp vftable pointer)
+// CHECK-NEXT:  8 |   (HasVtorDisp vbtable pointer)
+// CHECK-NEXT: 20 |   (vtordisp for vbase Base)
+// CHECK-NEXT: 24 |   struct Base (virtual base)
+// CHECK-NEXT: 24 | (Base vftable pointer)
+// CHECK-NEXT:| [sizeof=32, align=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=8]
+  } catch (...) {
+  }
+};
+
+struct NoVtorDisp1 : virtual Base {
+  virtual ~NoVtorDisp1() {}
+  virtual void Func() {}
+};
+
+int x1[sizeof(NoVtorDisp1)];
+
+// NoVtroDisp1: no vtordisp because of pragma disabling it.
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct NoVtorDisp1
+// CHECK-NEXT:  0 |   (NoVtorDisp1 vftable pointer)
+// CHECK-NEXT:  8 |   (NoVtorDisp1 vbtable pointer)
+// CHECK-NEXT: 16 |   struct Base (virtual base)
+// CHECK-NEXT: 16 | (Base vftable pointer)
+// CHECK-NEXT:| [sizeof=24, align=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=8]
+
+struct Container2 {
+  static void f1() {
+// Local pragma #1 - must be disabled on exit from f1().
+#pragma vtordisp(push, 2)
+struct HasVtorDisp1 : virtual Base {
+  virtual ~HasVtorDisp1() {}
+  virtual void Func() {}
+};
+
+int x2[sizeof(HasVtorDisp1)];
+
+// HasVtorDisp1: vtordisp because of pragma right before it.
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct HasVtorDisp1
+// CHECK-NEXT:  0 |   (HasVtorDisp1 vftable pointer)
+// CHECK-NEXT:  8 |   (HasVtorDisp1 vbtable pointer)
+// CHECK-NEXT: 20 |   (vtordisp for vbase Base)
+// CHECK-NEXT: 24 |   struct Base (virtual base)
+// CHECK-NEXT: 24 | (Base vftable pointer)
+// CHECK-NEXT:| [sizeof=32, align=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=8]
+
+struct InnerContainer {
+  static void g1() {
+struct HasVtorDisp2 : virtual Base {
+  virtual ~HasVtorDisp2() {}
+  virtual void Func() {}
+};
+
+int x3[sizeof(HasVtorDisp2)];
+
+// HasVtorDisp2: vtordisp because of vtordisp(2) in f1().
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct HasVtorDisp2
+// CHECK-NEXT:  0 |   (HasVtorDisp2 vftable pointer)
+// CHECK-NEXT:  8 |   (HasVtorDisp2 vbtable pointer)
+// CHECK-NEXT: 20 |   (vtordisp for vbase Base)
+// CHECK-NEXT: 24 |   struct B

r253650 - [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions, by Denis Zobnin.

2015-11-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov 20 01:02:57 2015
New Revision: 253650

URL: http://llvm.org/viewvc/llvm-project?rev=253650&view=rev
Log:
[MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions, by Denis 
Zobnin.
This patch adds support of #pragma vtordisp inside functions in attempt to 
improve compatibility. Microsoft compiler appears to save the stack of vtordisp 
modes on entry of struct methods' bodies and restore it on exit (method-local 
vtordisp).
Differential Revision: http://reviews.llvm.org/D14467


Added:
cfe/trunk/test/Layout/ms-vtordisp-local.cpp   (with props)
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=253650&r1=253649&r2=253650&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 20 01:02:57 2015
@@ -1007,6 +1007,24 @@ public:
 bool OldFPContractState : 1;
   };
 
+  /// Records and restores the vtordisp state on entry/exit of C++ method body.
+  class VtorDispStackRAII {
+  public:
+VtorDispStackRAII(Sema &S, bool ShouldSaveAndRestore)
+  : S(S), ShouldSaveAndRestore(ShouldSaveAndRestore), OldVtorDispStack() {
+  if (ShouldSaveAndRestore)
+OldVtorDispStack = S.VtorDispModeStack;
+}
+~VtorDispStackRAII() {
+  if (ShouldSaveAndRestore)
+S.VtorDispModeStack = OldVtorDispStack;
+}
+  private:
+Sema &S;
+bool ShouldSaveAndRestore;
+SmallVector OldVtorDispStack;
+  };
+
   void addImplicitTypedef(StringRef Name, QualType T);
 
 public:

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=253650&r1=253649&r2=253650&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Nov 20 01:02:57 2015
@@ -2854,6 +2854,11 @@ Parser::DeclGroupPtrTy Parser::ParseCXXC
 return DeclGroupPtrTy();
   }
 
+  if (Tok.is(tok::annot_pragma_ms_vtordisp)) {
+HandlePragmaMSVtorDisp();
+return DeclGroupPtrTy();
+  }
+
   // If we see a namespace here, a close brace was missing somewhere.
   if (Tok.is(tok::kw_namespace)) {
 DiagnoseUnexpectedNamespace(cast(TagDecl));

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=253650&r1=253649&r2=253650&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Nov 20 01:02:57 2015
@@ -358,6 +358,11 @@ Retry:
 HandlePragmaMSPragma();
 return StmtEmpty();
 
+  case tok::annot_pragma_ms_vtordisp:
+ProhibitAttributes(Attrs);
+HandlePragmaMSVtorDisp();
+return StmtEmpty();
+
   case tok::annot_pragma_loop_hint:
 ProhibitAttributes(Attrs);
 return ParsePragmaLoopHint(Stmts, OnlyStatement, TrailingElseLoc, Attrs);
@@ -885,6 +890,9 @@ void Parser::ParseCompoundStatementLeadi
 case tok::annot_pragma_ms_pragma:
   HandlePragmaMSPragma();
   break;
+case tok::annot_pragma_ms_vtordisp:
+  HandlePragmaMSVtorDisp();
+  break;
 default:
   checkForPragmas = false;
   break;
@@ -1895,6 +1903,11 @@ Decl *Parser::ParseFunctionStatementBody
   PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
   "parsing function body");
 
+  // Save and reset current vtordisp stack if we have entered a C++ method 
body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   // Do not enter a scope for the brace, as the arguments are in the same scope
   // (the function body) as the body itself.  Instead, just read the statement
   // list and put it into a CompoundStmt for safe keeping.
@@ -1934,6 +1947,11 @@ Decl *Parser::ParseFunctionTryBlock(Decl
 return Actions.ActOnSkippedFunctionBody(Decl);
   }
 
+  // Save and reset current vtordisp stack if we have entered a C++ method 
body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   SourceLocation LBraceLoc = Tok.getLocation();
   StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc, /*FnTry*/true));
   // If we failed to parse the try-catch, we just give the function an empty

Added: cfe/trunk/test/Layout/ms-vtordisp-local.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-vtordisp-local.cpp?rev=253650&view=auto