[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: beanz, doug.gregor.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

Install the 'clang-cpp' symlink used to spawn the preprocessor. The code 
handling this suffix is already included in Driver. FreeBSD is already creating 
such a symlink in ports, and a similar one was requested by Gentoo/FreeBSD 
team. The goal is to handle software that takes a C preprocessor via a variable 
but does not handle passing options correctly (i.e. 'clang -E' does not work).

Bug: https://bugs.gentoo.org/478810


https://reviews.llvm.org/D25161

Files:
  tools/driver/CMakeLists.txt


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -52,7 +52,7 @@
 add_dependencies(clang clang-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 
   if (WIN32)
 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -52,7 +52,7 @@
 add_dependencies(clang clang-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 
   if (WIN32)
 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25162: Make DeletedLines local variables in checkEmptyNamespace.

2016-10-02 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D25162

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   tok::kw_namespace)) {
-if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
+if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
+ DeletedLines))
   return false;
 CurrentLine = NewLine;
 continue;
@@ -1208,8 +1211,6 @@
 
   // Tokens to be deleted.
   std::set DeletedTokens;
-  // The line numbers of lines to be deleted.
-  std::set DeletedLines;
 };
 
 struct IncludeDirective {


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   tok::kw_namespace)) {
-if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
+if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
+ DeletedLines))
   return false;
 CurrentLine = NewLine;
 continue;
@@ -1208,8 +1211,6 @@
 
   // Tokens to be deleted.
   std::set DeletedTokens;
-  // The line numbers of lines to be deleted.
-  std::set DeletedLines;
 };
 
 struct IncludeDirective {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-10-02 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

I will be reworking this to use CMake's PRIVATE and PUBLIC linked libs 
consistently across the build, linker scripts and possibly tests.

@EricWF, would you prefer if I killed the `add_library_flags*` macros or 
extended them to support specifying PRIVATE and PUBLIC libs separately?


https://reviews.llvm.org/D25008



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


[clang-tools-extra] r283067 - [clang-rename] Overhaul clang-rename.el.

2016-10-02 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Sun Oct  2 09:51:33 2016
New Revision: 283067

URL: http://llvm.org/viewvc/llvm-project?rev=283067&view=rev
Log:
[clang-rename] Overhaul clang-rename.el.

* Use lexical binding, as recommended for new libraries.
* Fix customization variable (set correct group and type).
* Create a new customization group for the library.
* Autoload the main clang-rename command so that users don't have to explicitly 
load the library.
* Correctly translate between file and buffer positions using 
bufferpos-to-filepos (if available) or a fallback.
* Don't invoke the shell, it's not necessary and adds complexity.
* Save clang-rename output in a buffer and display that on failure.
* Save all buffers before calling clang-rename. This is required anyway and 
prevents data loss when the buffer is later reverted.
* In revert-buffer, use keywords instead of t for Boolean arguments to improve 
readability.
* Don't reset buffer modes when reverting.
* Emacs treats the character after a symbol as part of the symbol, while 
clang-rename doesn't; resolve this inconsistency.
* Formatting.

Patch by Philipp Stephani!

Reviewers: omtcyfz

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

Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.el

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el?rev=283067&r1=283066&r2=283067&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el Sun Oct  2 
09:51:33 2016
@@ -1,11 +1,11 @@
-;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+;;; clang-rename.el --- Renames every occurrence of a symbol found at 
.  -*- lexical-binding: t; -*-
 
 ;; Keywords: tools, c
 
 ;;; Commentary:
 
 ;; To install clang-rename.el make sure the directory of this file is in your
-;; 'load-path' and add
+;; `load-path' and add
 ;;
 ;;   (require 'clang-rename)
 ;;
@@ -13,31 +13,61 @@
 
 ;;; Code:
 
+(defgroup clang-rename nil
+  "Integration with clang-rename"
+  :group 'c)
+
 (defcustom clang-rename-binary "clang-rename"
   "Path to clang-rename executable."
-  :type 'hook
-  :options '(turn-on-auto-fill flyspell-mode)
-  :group 'wp)
+  :type '(file :must-match t)
+  :group 'clang-rename)
 
+;;;###autoload
 (defun clang-rename (new-name)
-  "Rename all instances of the symbol at the point using clang-rename"
+  "Rename all instances of the symbol at point to NEW-NAME using clang-rename."
   (interactive "sEnter a new name: ")
-  (let (;; Emacs offset is 1-based.
-(offset (- (point) 1))
-(orig-buf (current-buffer))
-(file-name (buffer-file-name)))
-
-(let ((rename-command
-  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
-   clang-rename-binary offset new-name file-name)))
-  (message (format "Running clang-rename command %s" rename-command))
-  ;; Run clang-rename via bash.
-  (shell-command rename-command)
-  ;; Reload buffer.
-  (revert-buffer t t)
-)
-  )
-)
+  (save-some-buffers :all)
+  ;; clang-rename should not be combined with other operations when undoing.
+  (undo-boundary)
+  (let ((output-buffer (get-buffer-create "*clang-rename*")))
+(with-current-buffer output-buffer (erase-buffer))
+(let ((exit-code (call-process
+  clang-rename-binary nil output-buffer nil
+  (format "-offset=%d"
+  ;; clang-rename wants file (byte) offsets, not
+  ;; buffer (character) positions.
+  (clang-rename--bufferpos-to-filepos
+   ;; Emacs treats one character after a symbol as
+   ;; part of the symbol, but clang-rename 
doesn’t.
+   ;; Use the beginning of the current symbol, if
+   ;; available, to resolve the inconsistency.
+   (or (car (bounds-of-thing-at-point 'symbol))
+   (point))
+   'exact))
+  (format "-new-name=%s" new-name)
+  "-i" (buffer-file-name
+  (if (and (integerp exit-code) (zerop exit-code))
+  ;; Success; revert current buffer so it gets the modifications.
+  (progn
+(kill-buffer output-buffer)
+(revert-buffer :ignore-auto :noconfirm :preserve-modes))
+;; Failure; append exit code to output buffer and display it.
+(let ((message (format-message
+"clang-rename failed with %s %s"
+(if (integerp exit-code) "exit status" "signal")
+exit-code)))
+   

r283068 - [CUDA] Allow extern __shared__ on empty-length arrays.

2016-10-02 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Sun Oct  2 10:24:50 2016
New Revision: 283068

URL: http://llvm.org/viewvc/llvm-project?rev=283068&view=rev
Log:
[CUDA] Allow extern __shared__ on empty-length arrays.

"extern __shared__ int x[]" is OK.

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCUDA/extern-shared.cu

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=283068&r1=283067&r2=283068&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Oct  2 10:24:50 2016
@@ -3714,7 +3714,9 @@ static void handleSharedAttr(Sema &S, De
  Attr.getName()))
 return;
   auto *VD = cast(D);
-  if (VD->hasExternalStorage()) {
+  // extern __shared__ is only allowed on arrays with no length (e.g.
+  // "int x[]").
+  if (VD->hasExternalStorage() && !isa(VD->getType())) {
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }

Modified: cfe/trunk/test/SemaCUDA/extern-shared.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/extern-shared.cu?rev=283068&r1=283067&r2=283068&view=diff
==
--- cfe/trunk/test/SemaCUDA/extern-shared.cu (original)
+++ cfe/trunk/test/SemaCUDA/extern-shared.cu Sun Oct  2 10:24:50 2016
@@ -5,10 +5,19 @@
 
 __device__ void foo() {
   extern __shared__ int x; // expected-error {{__shared__ variable 'x' cannot 
be 'extern'}}
+  extern __shared__ int arr[];  // ok
+  extern __shared__ int arr0[0]; // expected-error {{__shared__ variable 
'arr0' cannot be 'extern'}}
+  extern __shared__ int arr1[1]; // expected-error {{__shared__ variable 
'arr1' cannot be 'extern'}}
+  extern __shared__ int* ptr ; // expected-error {{__shared__ variable 'ptr' 
cannot be 'extern'}}
 }
 
 __host__ __device__ void bar() {
-  extern __shared__ int x; // expected-error {{__shared__ variable 'x' cannot 
be 'extern'}}
+  extern __shared__ int arr[];  // ok
+  extern __shared__ int arr0[0]; // expected-error {{__shared__ variable 
'arr0' cannot be 'extern'}}
+  extern __shared__ int arr1[1]; // expected-error {{__shared__ variable 
'arr1' cannot be 'extern'}}
+  extern __shared__ int* ptr ; // expected-error {{__shared__ variable 'ptr' 
cannot be 'extern'}}
 }
 
 extern __shared__ int global; // expected-error {{__shared__ variable 'global' 
cannot be 'extern'}}
+extern __shared__ int global_arr[]; // ok
+extern __shared__ int global_arr1[1]; // expected-error {{__shared__ variable 
'global_arr1' cannot be 'extern'}}


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


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-02 Thread Steve O'Brien via cfe-commits
elsteveogrande added a comment.

Added a couple of notes



> PrintPreprocessedOutput.cpp:241
>}
> -  
>return false;

Re-reading this diff, I saw hat my editor trimmed EOL whitespace automatically 
and I let these minor changes become part of the patch.  Sorry for the noise :)

> PrintPreprocessedOutput.cpp:390
> +if (DumpIncludeDirectives) {
> +  // FIXME: Preserve whether this was a 
> #include/#include_next/#include_macros/#import.
> +  OS << "#include "

The FIXME and hardcoded `#include` are copied from the clause just above this.  
Seems getting the text for this token wasn't that easy.  I can try again and 
solve this in a future patch, if it's ok to let this ine slide, @rsmith.

> dump_import.m:1
> +// RUN: %clang_cc1 -E -dI %s -o - | grep '^#i'
> +#import "dump_import.h"

Also: I should have said `^#include` at the end of this line.  Fortunately if 
the TODO is fixed, the preprocessor will report `#import` and this test will 
still work :)

Repository:
  rL LLVM

https://reviews.llvm.org/D25153



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


[PATCH] D24894: [clang-tidy] Prefer transparent functors to non-transparent one.

2016-10-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


> UseTransparentFunctorsCheck.cpp:26
> +  unless(hasAnyTemplateArgument(refersToType(voidType(,
> +  hasAnyName("::std::plus", "::std::minus", "::std::multiplies",
> + "::std::divides", "::std::modulus", "::std::negate",

Should we make this a configurable list that users can add to?

> UseTransparentFunctorsCheck.cpp:61
> +  Result.Nodes.getNodeAs("FuncInst")) {
> +diag(FuncInst->getLocStart(), "prefer transparent functors");
> +return;

This diagnostic is too terse; anyone that is unaware of what a transparent 
functor is will likely be stumped by it, especially since there is no fixit.

Since this is the case where we cannot be sure that a transparent functor is 
the correct solution, should this be enabled via an option (default on)?

> UseTransparentFunctorsCheck.cpp:93
> +
> +  diag(ReportLoc, "prefer transparent functors")
> +  << 
> FixItHint::CreateRemoval(FunctorTypeLoc.getArgLoc(0).getSourceRange());

This diagnostic could stand to be less terse as well, IMO. The fixit helps 
though.

> modernize-use-transparent-functors.rst:6
> +
> +Prefer transparent functors to non-transparent ones. Using transparent 
> functors
> +the type does not need to be repeated. The code is easier to read, maintain 
> and

Using transparent functors the -> When using transparent functors, the

Repository:
  rL LLVM

https://reviews.llvm.org/D24894



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


[PATCH] D24933: Enable configuration files in clang

2016-10-02 Thread Michał Górny via cfe-commits
mgorny requested changes to this revision.
mgorny added a reviewer: mgorny.
mgorny added a comment.
This revision now requires changes to proceed.

Few minor nits. However, I'd like to say that I like the idea in general and 
see forward to deploy it in Gentoo.

One use case which doesn't seem to have been mentioned yes is setting the 
default -rtlib= and -stdlib=. Currently we're only able to set the defaults at 
compile-time but it generally sucks to rebuild the compiler to change the 
default. With this, we'd be able to set them via the system config file ;-).



> driver.cpp:334
> +  // Try reading options from configuration file.
> +  static const char * const SearchDirs[] = { "~/.llvm", "/etc/llvm" };
> +  llvm::SmallString<128> ConfigFile;

1. I'm not sure if others would agree with me but I think it would be better to 
move those default paths straight to LLVM. If others tools are to adopt those 
configuration files, it would only be reasonable to use the same search paths 
consistently and not repeat them in every tool.

2. I think the `/etc` prefix should be made configurable via CMake options. One 
case that would benefit from this is Gentoo Prefix where the Gentoo system root 
is located in a subdirectory of /.

> driver.cpp:336
> +  llvm::SmallString<128> ConfigFile;
> +  auto SRes = llvm::cl::findConfigFile(ConfigFile, argv, SearchDirs, 
> "clang");
> +  llvm::cl::reportConfigFileSearchError(SRes, ConfigFile, SearchDirs, 
> ProgName);

1. You need to update this, following your update on 
https://reviews.llvm.org/D24926.
2. I think you need to use `clang.cfg` here.

https://reviews.llvm.org/D24933



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


Re: r283063 - Alias must point to a definition

2016-10-02 Thread Yaron Keren via cfe-commits
The mangling is different when targeting MSVC ABI, see failure at

http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/29889/steps/test_all/logs/Clang%20%3A%3A%20CodeGenCXX__alias-available-externally.cpp

maybe   -triple x86_64-pc-linux  ?

2016-10-02 6:06 GMT+03:00 Aditya Kumar via cfe-commits <
cfe-commits@lists.llvm.org>:

> Author: hiraditya
> Date: Sat Oct  1 22:06:36 2016
> New Revision: 283063
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283063&view=rev
> Log:
> Alias must point to a definition
>
> Reapplying the patch after modifying the test case.
>
> Inlining the destructor caused the compiler to generate bad IR which
> failed the Verifier in the backend.
> https://llvm.org/bugs/show_bug.cgi?id=30341
>
> This patch disables alias to available_externally definitions.
>
> Reviewers: eugenis, rsmith
>
> Differential Revision: https://reviews.llvm.org/D24682
>
> Added:
> cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGCXX.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGCXX.cpp?rev=283063&r1=283062&r2=283063&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Oct  1 22:06:36 2016
> @@ -134,6 +134,11 @@ bool CodeGenModule::TryEmitDefinitionAsA
>llvm::GlobalValue::LinkageTypes TargetLinkage =
>getFunctionLinkage(TargetDecl);
>
> +  // available_externally definitions aren't real definitions, so we
> cannot
> +  // create an alias to one.
> +  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)
> +return true;
> +
>// Check if we have it already.
>StringRef MangledName = getMangledName(AliasDecl);
>llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
> @@ -156,14 +161,7 @@ bool CodeGenModule::TryEmitDefinitionAsA
>
>// Instead of creating as alias to a linkonce_odr, replace all of the
> uses
>// of the aliasee.
> -  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
> - (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
> -  !TargetDecl.getDecl()->hasAttr())) {
> -// FIXME: An extern template instantiation will create functions with
> -// linkage "AvailableExternally". In libc++, some classes also define
> -// members with attribute "AlwaysInline" and expect no reference to
> -// be generated. It is desirable to reenable this optimisation after
> -// corresponding LLVM changes.
> +  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
>  addReplacement(MangledName, Aliasee);
>  return false;
>}
>
> Added: cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/alias-available-externally.cpp?rev=283063&view=auto
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp Sat Oct  1
> 22:06:36 2016
> @@ -0,0 +1,20 @@
> +// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s
> | FileCheck %s
> +// Clang should not generate alias to available_externally definitions.
> +// Check that the destructor of Foo is defined.
> +// The destructors have different return type for different targets.
> +// CHECK: define linkonce_odr {{.*}} @_ZN3FooD2Ev
> +template 
> +struct String {
> +  String() {}
> +  ~String();
> +};
> +
> +template 
> +inline __attribute__((visibility("hidden"), always_inline))
> +String::~String() {}
> +
> +extern template struct String;
> +
> +struct Foo : public String { Foo() { String s; } };
> +
> +Foo f;
>
>
> ___
> 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


[PATCH] D25123: [OpenCL] Fix bug in __builtin_astype causing invalid LLVM cast instructions

2016-10-02 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D25123



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


[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Joerg Sonnenberger via cfe-commits
joerg accepted this revision.
joerg added a reviewer: joerg.
joerg added a comment.
This revision is now accepted and ready to land.

LGTM, have been doing that in NetBSD for ages as well.

Side note, someone from Apple please make sure that xcode gets a similar link.


https://reviews.llvm.org/D25161



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


r283073 - [AVX-512] Use native IR for masked 512-bit add/sub/mul/div ps/pd intrinsics when rounding mode isn't used.

2016-10-02 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Oct  2 12:43:00 2016
New Revision: 283073

URL: http://llvm.org/viewvc/llvm-project?rev=283073&view=rev
Log:
[AVX-512] Use native IR for masked 512-bit add/sub/mul/div ps/pd intrinsics 
when rounding mode isn't used.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=283073&r1=283072&r2=283073&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Sun Oct  2 12:43:00 2016
@@ -1976,38 +1976,30 @@ _mm_maskz_add_sd(__mmask8 __U,__m128d __
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_mask_add_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_addpd512_mask ((__v8df) __A,
- (__v8df) __B,
- (__v8df) __W,
- (__mmask8) __U,
- _MM_FROUND_CUR_DIRECTION);
+  return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U,
+  (__v8df)_mm512_add_pd(__A, __B),
+  (__v8df)__W);
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_maskz_add_pd(__mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_addpd512_mask ((__v8df) __A,
- (__v8df) __B,
- (__v8df) _mm512_setzero_pd (),
- (__mmask8) __U,
- _MM_FROUND_CUR_DIRECTION);
+  return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U,
+  (__v8df)_mm512_add_pd(__A, __B),
+  (__v8df)_mm512_setzero_pd());
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_mask_add_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) {
-  return (__m512) __builtin_ia32_addps512_mask ((__v16sf) __A,
-(__v16sf) __B,
-(__v16sf) __W,
-(__mmask16) __U,
-_MM_FROUND_CUR_DIRECTION);
+  return (__m512)__builtin_ia32_selectps_512((__mmask16)__U,
+ (__v16sf)_mm512_add_ps(__A, __B),
+ (__v16sf)__W);
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_maskz_add_ps(__mmask16 __U, __m512 __A, __m512 __B) {
-  return (__m512) __builtin_ia32_addps512_mask ((__v16sf) __A,
-(__v16sf) __B,
-(__v16sf) _mm512_setzero_ps (),
-(__mmask16) __U,
-_MM_FROUND_CUR_DIRECTION);
+  return (__m512)__builtin_ia32_selectps_512((__mmask16)__U,
+ (__v16sf)_mm512_add_ps(__A, __B),
+ (__v16sf)_mm512_setzero_ps());
 }
 
 #define _mm512_add_round_pd(A, B, R) __extension__ ({ \
@@ -2119,40 +2111,30 @@ _mm_maskz_sub_sd(__mmask8 __U,__m128d __
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_mask_sub_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_subpd512_mask ((__v8df) __A,
- (__v8df) __B,
- (__v8df) __W,
- (__mmask8) __U,
- _MM_FROUND_CUR_DIRECTION);
+  return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U,
+  (__v8df)_mm512_sub_pd(__A, __B),
+  (__v8df)__W);
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_maskz_sub_pd(__mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_subpd512_mask ((__v8df) __A,
- (__v8df) __B,
- (__v8df)
- _mm512_setzero_pd (),
- (__mmask8) __U,
- _MM_FROUND_CUR_DIRECTION);
+  return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U,
+  (__v8df)_mm512_sub_pd(__A, __B),
+  (__v8df)_mm512_setzero_pd());
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_mask_sub_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) {
-  return (__m512) __builtin_ia32_subps512_mask ((__v16sf) __A,
-(__v16sf) __B,
-(__v16sf) __W,
-(__mmask16) __U,
-_MM_FROUND_CUR_DIRECTION);
+  return (__m512)__builtin_ia32_selectps_512((__mmask16)__U,
+ (__v16sf)_mm512_sub_ps(__A, __B),
+ (__v16sf)__W);
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_maskz_sub_ps(__mmask16 __U, __m512 __A, __m512 __B) {
-  return (__m512) __builtin_ia32_subps512_mask ((__v16sf) __A,
-(__v16sf) __B,
-(__v16sf)
-_mm512_setzero_ps (),
-(__mmask16) __U,
-_MM_FROUND_CUR_DIRECTION);
+  return (__m512)__builtin_ia32_selectps_512((__mmask16)__U,
+ 

r283075 - [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Sun Oct  2 14:28:57 2016
New Revision: 283075

URL: http://llvm.org/viewvc/llvm-project?rev=283075&view=rev
Log:
[cmake] Install 'clang-cpp' symlink

Install the 'clang-cpp' symlink used to spawn the preprocessor. The code
handling this suffix is already included in Driver. FreeBSD is already
creating such a symlink in ports, and a similar one was requested
by Gentoo/FreeBSD team. The goal is to handle software that takes a C
preprocessor via a variable but does not handle passing options
correctly (i.e. 'clang -E' does not work).

Bug: https://bugs.gentoo.org/478810

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

Modified:
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=283075&r1=283074&r2=283075&view=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Sun Oct  2 14:28:57 2016
@@ -52,7 +52,7 @@ endif()
 add_dependencies(clang clang-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 
   if (WIN32)
 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)


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


[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review. Proceeding with the commit now.


https://reviews.llvm.org/D25161



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


[PATCH] D25166: [CUDA] Mark device functions as nounwind.

2016-10-02 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

This prevents clang from emitting 'invoke's and catch statements.

Things previously mostly worked thanks to TryToMarkNoThrow() in
CodeGenFunction.  But this is not a proper IPO, and it doesn't properly
handle cases like mutual recursion.

Fixes bug 30593.


https://reviews.llvm.org/D25166

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCUDA/convergent.cu
  clang/test/CodeGenCUDA/device-var-init.cu
  clang/test/CodeGenCUDA/nothrow.cu


Index: clang/test/CodeGenCUDA/nothrow.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/nothrow.cu
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fcuda-is-device -triple 
nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple 
x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ void f();
+
+// HOST: define void @_Z7host_fnv() [[HOST_ATTR:#[0-9]+]]
+void host_fn() { f(); }
+
+// DEVICE: define void @_Z3foov() [[DEVICE_ATTR:#[0-9]+]]
+__device__ void foo() { f(); }
+
+// This is nounwind only on the device side.
+// CHECK: define void @_Z3foov() [[DEVICE_ATTR:#[0-9]+]]
+__host__ __device__ void bar() { f(); }
+
+// DEVICE: define void @_Z3bazv() [[DEVICE_ATTR:#[0-9]+]]
+__global__ void baz() { f(); }
+
+// DEVICE: attributes [[DEVICE_ATTR]] = {
+// DEVICE-SAME: nounwind
+// HOST: attributes [[HOST_ATTR]] = {
+// HOST-NOT: nounwind
+// HOST-SAME: }
Index: clang/test/CodeGenCUDA/device-var-init.cu
===
--- clang/test/CodeGenCUDA/device-var-init.cu
+++ clang/test/CodeGenCUDA/device-var-init.cu
@@ -182,9 +182,9 @@
   df(); // CHECK: call void @_Z2dfv()
 
   // Verify that we only call non-empty destructors
-  // CHECK-NEXT: call void @_ZN8T_FA_NEDD1Ev(%struct.T_FA_NED* %t_fa_ned) #6
-  // CHECK-NEXT: call void @_ZN7T_F_NEDD1Ev(%struct.T_F_NED* %t_f_ned) #6
-  // CHECK-NEXT: call void @_ZN7T_B_NEDD1Ev(%struct.T_B_NED* %t_b_ned) #6
+  // CHECK-NEXT: call void @_ZN8T_FA_NEDD1Ev(%struct.T_FA_NED* %t_fa_ned)
+  // CHECK-NEXT: call void @_ZN7T_F_NEDD1Ev(%struct.T_F_NED* %t_f_ned)
+  // CHECK-NEXT: call void @_ZN7T_B_NEDD1Ev(%struct.T_B_NED* %t_b_ned)
   // CHECK-NEXT: call void @_ZN2VDD1Ev(%struct.VD* %vd)
   // CHECK-NEXT: call void @_ZN3NEDD1Ev(%struct.NED* %ned)
   // CHECK-NEXT: call void @_ZN2UDD1Ev(%struct.UD* %ud)
Index: clang/test/CodeGenCUDA/convergent.cu
===
--- clang/test/CodeGenCUDA/convergent.cu
+++ clang/test/CodeGenCUDA/convergent.cu
@@ -36,8 +36,8 @@
 // DEVICE: attributes [[BAZ_ATTR]] = {
 // DEVICE-SAME: convergent
 // DEVICE-SAME: }
-// DEVICE: attributes [[CALL_ATTR]] = { convergent }
-// DEVICE: attributes [[ASM_ATTR]] = { convergent
+// DEVICE-DAG: attributes [[CALL_ATTR]] = { convergent
+// DEVICE-DAG: attributes [[ASM_ATTR]] = { convergent
 
 // HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
 // HOST: attributes [[BAZ_ATTR]] = {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12074,6 +12074,14 @@
   FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
   }
 
+  // CUDA device functions cannot throw.
+  if (getLangOpts().CUDA && !FD->hasAttr()) {
+CUDAFunctionTarget T = IdentifyCUDATarget(FD);
+if (T == CFT_Device || T == CFT_Global ||
+(getLangOpts().CUDAIsDevice && T == CFT_HostDevice))
+  FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
+  }
+
   IdentifierInfo *Name = FD->getIdentifier();
   if (!Name)
 return;


Index: clang/test/CodeGenCUDA/nothrow.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/nothrow.cu
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ void f();
+
+// HOST: define void @_Z7host_fnv() [[HOST_ATTR:#[0-9]+]]
+void host_fn() { f(); }
+
+// DEVICE: define void @_Z3foov() [[DEVICE_ATTR:#[0-9]+]]
+__device__ void foo() { f(); }
+
+// This is nounwind only on the device side.
+// CHECK: define void @_Z3foov() [[DEVICE_ATTR:#[0-9]+]]
+__host__ __device__ void bar() { f(); }
+
+// DEVICE: define void @_Z3bazv() [[DEVICE_ATTR:#[0-9]+]]
+__global__ void baz() { f(); }
+
+// DE

[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-02 Thread Steve O'Brien via cfe-commits
elsteveogrande updated this revision to Diff 73224.
elsteveogrande added a comment.

Updated to actually use the include token's text, not a hardcoded `#include`.  
Updated unit test to expect the right word here.


https://reviews.llvm.org/D25153

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/PreprocessorOutputOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Preprocessor/dump_import.h
  test/Preprocessor/dump_import.m
  test/Preprocessor/dump_include.c
  test/Preprocessor/dump_include.h

Index: test/Preprocessor/dump_include.h
===
--- /dev/null
+++ test/Preprocessor/dump_include.h
@@ -0,0 +1,2 @@
+#pragma once
+#define DUMP_INCLUDE_TESTVAL 1
Index: test/Preprocessor/dump_include.c
===
--- /dev/null
+++ test/Preprocessor/dump_include.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -E -dI %s -o - | grep '^#include'
+#include "dump_include.h"
Index: test/Preprocessor/dump_import.m
===
--- /dev/null
+++ test/Preprocessor/dump_import.m
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -E -dI %s -o - | grep '^#import'
+#import "dump_import.h"
Index: test/Preprocessor/dump_import.h
===
--- /dev/null
+++ test/Preprocessor/dump_import.h
@@ -0,0 +1 @@
+#define DUMP_IMPORT_TESTVAL 1
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -93,13 +93,15 @@
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
-   bool defines, bool UseLineDirectives)
+   bool defines, bool dumpIncludeDirectives, bool UseLineDirectives)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
+DumpIncludeDirectives(dumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives) {
 CurLine = 0;
 CurFilename += "";
@@ -154,7 +156,7 @@
   }
   bool MoveToLine(unsigned LineNo);
 
-  bool AvoidConcat(const Token &PrevPrevTok, const Token &PrevTok, 
+  bool AvoidConcat(const Token &PrevPrevTok, const Token &PrevTok,
const Token &Tok) {
 return ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, Tok);
   }
@@ -238,7 +240,7 @@
   ++CurLine;
 return true;
   }
-  
+
   return false;
 }
 
@@ -252,11 +254,11 @@
   // Unless we are exiting a #include, make sure to skip ahead to the line the
   // #include directive was at.
   SourceManager &SourceMgr = SM;
-  
+
   PresumedLoc UserLoc = SourceMgr.getPresumedLoc(Loc);
   if (UserLoc.isInvalid())
 return;
-  
+
   unsigned NewLine = UserLoc.getLine();
 
   if (Reason == PPCallbacks::EnterFile) {
@@ -271,7 +273,7 @@
 // off by one. We can do better by simply incrementing NewLine here.
 NewLine += 1;
   }
-  
+
   CurLine = NewLine;
 
   CurFilename.clear();
@@ -282,7 +284,7 @@
 startNewLineIfNeeded(/*ShouldUpdateCurrentLine=*/false);
 return;
   }
-  
+
   if (!Initialized) {
 WriteLineInfo(CurLine);
 Initialized = true;
@@ -311,6 +313,54 @@
   }
 }
 
+namespace {
+/**
+ * Escape chars which are bad to print inside preprocessed output; e.g. we cannot break lines
+ * if we're emitting a '#'-style directive (escape both CR and LF).  Paths are quoted in some
+ * instances, so escape quotes.  Escaping is with a backslash (and backslashes themselves have
+ * to be escaped); for CR or LF, we use "\r" or "\n".
+ */
+std::string sanitizePath(const StringRef& path) {
+  std::string str(path.size() * 2, '\0');
+  size_t len = 0;
+  for (size_t i = 0; i < path.size(); i++) {
+const char c = path[i];
+switch (c) {
+  case '\\':
+str[len++] = '\\';
+str[len++] = '\\';
+break;
+  case '\r':
+str[len++] = '\\';
+str[len++] = 'r';
+break;
+  case '\n':
+str[len++] = '\\';
+str[len++] = 'n';
+break;
+  case '"':
+str[len++] = '\\';
+str[len++] = '"';
+break;
+  default:
+str[len++] = c;
+}
+  }
+  return str.substr(0, len);
+}
+
+bool tryGetTokenText(std::string* InclusionKeyword, const Token &tok) {
+  if (tok.getKind() == clang::tok::identifier) {
+const auto* idInfo = tok.getIdentifierInfo();
+if (idInfo && idInfo->getNameStart() != nullptr) {
+  *InclusionKeyword = std::string(idInfo->getNameStart(), idInfo->getLength());
+  return true;
+}
+  }
+  return false;
+}
+}
+
 void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocati

[PATCH] D24426: DebugInfo: Pass non-zero alignment to DIBuilder only if aligment was forced

2016-10-02 Thread Victor Leschuk via cfe-commits
vleschuk updated this revision to Diff 73228.
vleschuk added a comment.

- Move alignment detection into helper functions in anon namespace
- Use updated LLVM DIBuilder API (from https://reviews.llvm.org/D24425)


https://reviews.llvm.org/D24426

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/debug-info-packed-struct.c
  test/CodeGen/debug-info-vector.c
  test/CodeGenCXX/debug-info-calling-conventions.cpp
  test/CodeGenCXX/debug-info-enum-class.cpp
  test/CodeGenCXX/debug-info-indirect-field-decl.cpp
  test/CodeGenCXX/debug-info-ms-bitfields.cpp
  test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
  test/CodeGenCXX/debug-info-rvalue-ref.cpp
  test/CodeGenCXX/debug-info-template-quals.cpp
  test/CodeGenCXX/debug-info-template.cpp
  test/CodeGenCXX/debug-info-union.cpp
  test/CodeGenCXX/debug-info-uuid.cpp
  test/CodeGenCXX/debug-info-vla.cpp
  test/CodeGenCXX/debug-info-zero-length-arrays.cpp
  test/CodeGenCXX/debug-info.cpp
  test/CodeGenCXX/debug-lambda-this.cpp
  test/CodeGenObjC/block-byref-debuginfo.m
  test/CodeGenObjC/debug-info-block-type.m
  test/CodeGenObjC/debug-info-ivars-extension.m
  test/CodeGenObjC/debug-info-ivars-private.m
  test/CodeGenObjC/debug-info-ivars.m
  test/CodeGenObjCXX/debug-info-cyclic.mm

Index: test/CodeGenObjCXX/debug-info-cyclic.mm
===
--- test/CodeGenObjCXX/debug-info-cyclic.mm
+++ test/CodeGenObjCXX/debug-info-cyclic.mm
@@ -3,7 +3,7 @@
 struct B {
 // CHECK: ![[B:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "B"
 // CHECK-SAME: line: [[@LINE-2]],
-// CHECK-SAME: size: 8, align: 8,
+// CHECK-SAME: size: 8,
 // CHECK-NOT:  offset:
 // CHECK-NOT:  DIFlagFwdDecl
 // CHECK-SAME: elements: ![[BMEMBERS:[0-9]+]]
Index: test/CodeGenObjC/debug-info-ivars.m
===
--- test/CodeGenObjC/debug-info-ivars.m
+++ test/CodeGenObjC/debug-info-ivars.m
@@ -21,24 +21,24 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i"
 // CHECK-SAME:   line: 10
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_1"
 // CHECK-SAME:   line: 11
 // CHECK-SAME:   baseType: ![[UNSIGNED:[0-9]+]]
-// CHECK-SAME:   size: 9, align: 32,
+// CHECK-SAME:   size: 9,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[UNSIGNED]] = !DIBasicType(name: "unsigned int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_2"
 // CHECK-SAME:   line: 12
 // CHECK-SAME:   baseType: ![[UNSIGNED]]
-// CHECK-SAME:   size: 9, align: 32, offset: 1,
+// CHECK-SAME:   size: 9, offset: 1,
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_3"
 // CHECK-SAME:   line: 14
 // CHECK-SAME:   baseType: ![[UNSIGNED]]
-// CHECK-SAME:   size: 9, align: 32, offset: 3,
+// CHECK-SAME:   size: 9, offset: 3,
 // CHECK-SAME:   flags: DIFlagProtected
Index: test/CodeGenObjC/debug-info-ivars-private.m
===
--- test/CodeGenObjC/debug-info-ivars-private.m
+++ test/CodeGenObjC/debug-info-ivars-private.m
@@ -35,13 +35,13 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "foo"
 // CHECK-SAME:   line: 14
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "bar"
 // CHECK-SAME:   line: 27
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagPrivate
Index: test/CodeGenObjC/debug-info-ivars-extension.m
===
--- test/CodeGenObjC/debug-info-ivars-extension.m
+++ test/CodeGenObjC/debug-info-ivars-extension.m
@@ -30,7 +30,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "a"
 // CHECK-SAME:   line: 7
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32
+// CHECK-SAME:   size: 32
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagPublic
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
@@ -42,6 +42,6 @

[PATCH] D24426: DebugInfo: Pass non-zero alignment to DIBuilder only if aligment was forced

2016-10-02 Thread Victor Leschuk via cfe-commits
vleschuk marked 3 inline comments as done.
vleschuk added inline comments.


> vleschuk wrote in CGDebugInfo.cpp:608
> Will check if this works in all cases. I think it's worth putting this 
> snippet into helper function within anon namespace.

That is correct for types, for particular decls we still need to use hasAttr<>. 
Moved both cases into separate functions.

> dblaikie wrote in CGDebugInfo.cpp:609
> Maybe add a comment here about why we're specifying zero alignment (or 
> possibly change the API to not take an alignment at all so we don't have to 
> explain it?)
> 
> (similarly for other cases where the alignment is just hardcoded to zero)

Default arguments now are zeros.

https://reviews.llvm.org/D24426



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


[PATCH] D25171: clang-format: Add two new formatting options

2016-10-02 Thread Robin Sommer via cfe-commits
rsmmr created this revision.
rsmmr added reviewers: djasper, lodato.
rsmmr added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch adds two new options, feedback welcome.

SpacesAroundConditions (bool)

  If true, spaces will be inserted around if/for/while conditions.

SpacesAfterNot (bool)

  If true, spaces will be inserted after '!'.


https://reviews.llvm.org/D25171

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10194,6 +10194,8 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpacesAfterNot);
+  CHECK_PARSE_BOOL(SpacesAroundConditions);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterControlStatement);
@@ -11500,6 +11502,24 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST_F(FormatTest, SpacesAfterNot) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesAfterNot = true;
+  verifyFormat("if (! a)\n  return;", Spaces);
+  verifyFormat("while (! (x || y))\n  return;", Spaces);
+  verifyFormat("do {\n} while (! foo);", Spaces);
+}
+
+TEST_F(FormatTest, SpacesAroundConditions) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesAroundConditions = true;
+  verifyFormat("if ( !a )\n  return;", Spaces);
+  verifyFormat("if ( a )\n  return;", Spaces);
+  verifyFormat("while ( a )\n  return;", Spaces);
+  verifyFormat("while ( (a && b) )\n  return;", Spaces);
+  verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+}
+
 // Since this test case uses UNIX-style file path. We disable it for MS
 // compiler.
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1984,6 +1984,16 @@
 return Right.is(tok::hash);
   if (Left.is(tok::l_paren) && Right.is(tok::r_paren))
 return Style.SpaceInEmptyParentheses;
+  if (Style.SpacesAroundConditions) {
+if (Left.is(tok::l_paren) && Left.Previous &&
+  Left.Previous->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
+ tok::kw_switch, TT_ForEachMacro))
+return true;
+if (Right.is(tok::r_paren) && Right.MatchingParen && Right.MatchingParen->Previous &&
+  Right.MatchingParen->Previous->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
+ tok::kw_switch, TT_ForEachMacro))
+return true;
+  }
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren))
 return (Right.is(TT_CastRParen) ||
 (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
@@ -2219,6 +2229,8 @@
   return Style.SpacesInContainerLiterals;
 return true;
   }
+ if (Style.SpacesAfterNot && Left.is(tok::exclaim))
+return true;
   if (Left.is(TT_UnaryOperator))
 return Right.is(TT_BinaryOperator);
 
@@ -2237,7 +2249,7 @@
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
-  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment))
+  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
 return (Left.is(TT_TemplateOpener) &&
 Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -352,6 +352,10 @@
Style.SpacesInCStyleCastParentheses);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
+IO.mapOptional("SpacesAfterNot",
+   Style.SpacesAfterNot);
+IO.mapOptional("SpacesAroundConditions",
+   Style.SpacesAroundConditions);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("UseTab", Style.UseTab);
@@ -557,6 +561,8 @@
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpacesInAngles = false;
+  LLVMStyle.SpacesAfterNot = false;
+  LLVMStyle.SpacesAroundConditions = false;
 
   LLVMStyle.PenaltyBreakComment = 300;
   LLVMStyle.PenaltyBreakFirstLessLess = 120;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Fo

[PATCH] D24815: [clang] make reciprocal estimate codegen a function attribute

2016-10-02 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Going to accept this pending the backend patch, but when that one is applied I 
wanted you to feel OK to add this. A couple of inline nitpick comments and some 
agreement that we should do something uniform for fast-math is all.

-eric



> CGCall.cpp:1735
> +// TODO: Are these all needed?
> +// unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags.
>  FuncAttrs.addAttribute("no-infs-fp-math",

Would be nice to get these pulled into a single fast-math string that's set and 
then used all over for sure. :)

> CGCall.cpp:1755
> +if (!Recips.empty())
> +  FuncAttrs.addAttribute("mrecip",
> + llvm::join(Recips.begin(), Recips.end(), ","));

I commented on naming here in the backend patch, but just want to make them the 
same.

> attr-mrecip.c:1
> +// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3 -disable-llvm-optzns -emit-llvm 
> %s -o - | FileCheck %s
> +

Shouldn't need to disable the llvm optimizations here.

https://reviews.llvm.org/D24815



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


r283085 - Keep the test only for Itanium abi

2016-10-02 Thread Aditya Kumar via cfe-commits
Author: hiraditya
Date: Sun Oct  2 21:36:33 2016
New Revision: 283085

URL: http://llvm.org/viewvc/llvm-project?rev=283085&view=rev
Log:
Keep the test only for Itanium abi

Modified:
cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp

Modified: cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp?rev=283085&r1=283084&r2=283085&view=diff
==
--- cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp Sun Oct  2 
21:36:33 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -triple %itanium_abi_triple 
-disable-llvm-passes -o - %s | FileCheck %s
 // Clang should not generate alias to available_externally definitions.
 // Check that the destructor of Foo is defined.
 // The destructors have different return type for different targets.


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