r283856 - Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Tue Oct 11 02:31:29 2016
New Revision: 283856

URL: http://llvm.org/viewvc/llvm-project?rev=283856&view=rev
Log:
Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)

Modified:
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/FileSystemStatCache.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/FileSystemStatCache.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=283856&r1=283855&r2=283856&view=diff
==
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Tue Oct 11 02:31:29 2016
@@ -38,11 +38,10 @@ class FileSystemStatCache;
 /// \brief Cached information about one directory (either on disk or in
 /// the virtual file system).
 class DirectoryEntry {
-  const char *Name;   // Name of the directory.
+  StringRef Name; // Name of the directory.
   friend class FileManager;
 public:
-  DirectoryEntry() : Name(nullptr) {}
-  const char *getName() const { return Name; }
+  StringRef getName() const { return Name; }
 };
 
 /// \brief Cached information about one file (either on disk
@@ -165,7 +164,7 @@ class FileManager : public RefCountedBas
   // Caching.
   std::unique_ptr StatCache;
 
-  bool getStatValue(const char *Path, FileData &Data, bool isFile,
+  bool getStatValue(StringRef Path, FileData &Data, bool isFile,
 std::unique_ptr *F);
 
   /// Add all ancestors of the given path (pointing to either a file

Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=283856&r1=283855&r2=283856&view=diff
==
--- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original)
+++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Oct 11 02:31:29 2016
@@ -68,7 +68,7 @@ public:
   /// success for directories (not files).  On a successful file lookup, the
   /// implementation can optionally fill in \p F with a valid \p File object 
and
   /// the client guarantees that it will close it.
-  static bool get(const char *Path, FileData &Data, bool isFile,
+  static bool get(StringRef Path, FileData &Data, bool isFile,
   std::unique_ptr *F, FileSystemStatCache *Cache,
   vfs::FileSystem &FS);
 
@@ -92,11 +92,11 @@ protected:
   // FIXME: The pointer here is a non-owning/optional reference to the
   // unique_ptr. Optional&> might be nicer, but
   // Optional needs some work to support references so this isn't possible yet.
-  virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile,
+  virtual LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr *F,
vfs::FileSystem &FS) = 0;
 
-  LookupResult statChained(const char *Path, FileData &Data, bool isFile,
+  LookupResult statChained(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr *F, vfs::FileSystem &FS) 
{
 if (FileSystemStatCache *Next = getNextStatCache())
   return Next->getStat(Path, Data, isFile, F, FS);
@@ -121,7 +121,7 @@ public:
   iterator begin() const { return StatCalls.begin(); }
   iterator end() const { return StatCalls.end(); }
 
-  LookupResult getStat(const char *Path, FileData &Data, bool isFile,
+  LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr *F,
vfs::FileSystem &FS) override;
 };

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=283856&r1=283855&r2=283856&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Oct 11 02:31:29 2016
@@ -140,7 +140,7 @@ void FileManager::addAncestorsAsVirtualD
 
   // Add the virtual directory to the cache.
   auto UDE = llvm::make_unique();
-  UDE->Name = NamedDirEnt.first().data();
+  UDE->Name = NamedDirEnt.first();
   NamedDirEnt.second = UDE.get();
   VirtualDirectoryEntries.push_back(std::move(UDE));
 
@@ -185,7 +185,7 @@ const DirectoryEntry *FileManager::getDi
 
   // Get the null-terminated directory name as stored as the key of the
   // SeenDirEntries map.
-  const char *InterndDirName = NamedDirEnt.first().data();
+  StringRef InterndDirName = NamedDirEnt.first();
 
   // Check to see if the directory exists.
   FileData Data;
@@ -203,7 +203,7 @@ const Di

[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-11 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with one more nit.




Comment at: clang-tidy/utils/ASTUtils.h:25
+
+#endif

missing a trailing comment  `// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H`


https://reviews.llvm.org/D24997



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


[PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

2016-10-11 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D24572



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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 01:01, Bruno Cardoso Lopes via cfe-commits
 wrote:
> Author: bruno
> Date: Mon Oct 10 19:01:22 2016
> New Revision: 283827
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283827&view=rev
> Log:
> [Driver][Diagnostics] Make 'show option names' default for driver warnings
>
> Currently, driver level warnings do not show option names (e.g. warning:
> complain about foo [-Woption-name]) in a diagnostic unless
> -fdiagnostics-show-option is explictly specified. OTOH, the driver by
> default turn this option on for CC1. Change the logic to show option
> names by default in the driver as well.
>
> Differential Revision: https://reviews.llvm.org/D24516

Hi Bruno,

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3292

clang-4.0: warning: no such sysroot directory: '/FOO' [-Wmissing-sysroot]
error: unable to create target: 'No available targets are compatible
with this triple.'
1 error generated.

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


[clang-tools-extra] r283861 - Make Emacs libraries compatible with Emacs 24.

2016-10-11 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct 11 04:15:10 2016
New Revision: 283861

URL: http://llvm.org/viewvc/llvm-project?rev=283861&view=rev
Log:
Make Emacs libraries compatible with Emacs 24.

Emacs 24 doesn't have format-message, fall back to format in that case.

Patch by Philipp Stephani.

Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.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=283861&r1=283860&r2=283861&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el Tue Oct 11 
04:15:10 2016
@@ -52,7 +52,7 @@
 (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
+(let ((message (clang-rename--format-message
 "clang-rename failed with %s %s"
 (if (integerp exit-code) "exit status" "signal")
 exit-code)))
@@ -69,6 +69,11 @@
 (lambda (position &optional _quality _coding-system)
   (1- (position-bytes position)
 
+;; ‘format-message’ is new in Emacs 25.1.  Provide a fallback for older
+;; versions.
+(defalias 'clang-rename--format-message
+  (if (fboundp 'format-message) 'format-message 'format))
+
 (provide 'clang-rename)
 
 ;;; clang-rename.el ends here

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=283861&r1=283860&r2=283861&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Tue Oct 
11 04:15:10 2016
@@ -281,8 +281,8 @@ They are replaced by the single element
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
   (let* ((header (ido-completing-read
-  (format-message "Select include for '%s': "
-  symbol)
+  (clang-include-fixer--format-message
+   "Select include for '%s': " symbol)
   (mapcar #'header .HeaderInfos)
   nil :require-match nil
   'clang-include-fixer--history))
@@ -402,5 +402,10 @@ non-nil.  Otherwise return nil."
 (lambda (byte &optional _quality _coding-system)
   (byte-to-position (1+ byte)
 
+;; ‘format-message’ is new in Emacs 25.1.  Provide a fallback for older
+;; versions.
+(defalias 'clang-include-fixer--format-message
+  (if (fboundp 'format-message) 'format-message 'format))
+
 (provide 'clang-include-fixer)
 ;;; clang-include-fixer.el ends here


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


[clang-tools-extra] r283863 - clang-include-fixer.el: Don't prompt the user about killing clang-include-fixer processes

2016-10-11 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct 11 04:21:20 2016
New Revision: 283863

URL: http://llvm.org/viewvc/llvm-project?rev=283863&view=rev
Log:
clang-include-fixer.el: Don't prompt the user about killing clang-include-fixer 
processes

By default, Emacs prompts the user when killing processes on exit. This is 
useful for stateful processes such as interactive shells. However, 
clang-include-fixer processes are stateless; the only effect of killing them is 
to cancel a clang-include-fixer operation. Therefore prompting the user is just 
a nuisance.

Patch by Philipp Stephani.

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

Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=283863&r1=283862&r2=283863&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Tue Oct 
11 04:21:20 2016
@@ -101,6 +101,7 @@ arguments.  Return the new process objec
   :buffer stdout
   :command (clang-include-fixer--command args)
   :coding 'utf-8-unix
+  :noquery t
   :connection-type 'pipe
   :sentinel (clang-include-fixer--sentinel stdin stdout stderr
callback)
@@ -118,6 +119,7 @@ arguments.  Return the new process objec
  (process (apply #'start-process "clang-include-fixer" stdout
  (clang-include-fixer--command args
 (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
+(set-process-query-on-exit-flag process nil)
 (set-process-sentinel process
   (clang-include-fixer--sentinel stdin stdout nil
  callback))


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


r283864 - Delete clang-completion-mode.el.

2016-10-11 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct 11 04:25:34 2016
New Revision: 283864

URL: http://llvm.org/viewvc/llvm-project?rev=283864&view=rev
Log:
Delete clang-completion-mode.el.

It has been unmaintained for a while (last change was more than four
years ago), and it appears not widely used.
By now there are multiple well-maintained alternatives (emacs-ycmd,
atuo-complete-clang), and if users try to make this work they'll likely
have a bad user experience.

Reasoning and problems pointed out by Philipp Stephani.

Removed:
cfe/trunk/utils/clang-completion-mode.el

Removed: cfe/trunk/utils/clang-completion-mode.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang-completion-mode.el?rev=283863&view=auto
==
--- cfe/trunk/utils/clang-completion-mode.el (original)
+++ cfe/trunk/utils/clang-completion-mode.el (removed)
@@ -1,248 +0,0 @@
-;;; Clang Code-Completion minor mode, for use with C/Objective-C/C++.
-
-;;; Commentary:
-
-;; This minor mode uses Clang's command line interface for code
-;; completion to provide code completion results for C, Objective-C,
-;; and C++ source files. When enabled, Clang will provide
-;; code-completion results in a secondary buffer based on the code
-;; being typed. For example, after typing "struct " (triggered via the
-;; space), Clang will provide the names of all structs visible from
-;; the current scope. After typing "p->" (triggered via the ">"),
-;; Clang will provide the names of all of the members of whatever
-;; class/struct/union "p" points to. Note that this minor mode isn't
-;; meant for serious use: it is meant to help experiment with code
-;; completion based on Clang. It needs your help to make it better!
-;;
-;; To use the Clang code completion mode, first make sure that the
-;; "clang" variable below refers to the "clang" executable,
-;; which is typically installed in libexec/. Then, place
-;; clang-completion-mode.el somewhere in your Emacs load path. You can
-;; add a new load path to Emacs by adding some like the following to
-;; your .emacs:
-;;
-;;   (setq load-path (cons "~/.emacs.d" load-path))
-;;
-;; Then, use
-;;
-;;   M-x load-library
-;;
-;; to load the library in your Emacs session or add the following to
-;; your .emacs to always load this mode (not recommended):
-;;
-;;   (load-library "clang-completion-mode")
-;;
-;; Once you have done this, you can set various parameters with
-;;
-;;   M-x customize-group RET clang-completion-mode RET
-;;
-;; Finally, to try Clang-based code completion in a particular buffer,
-;; use M-x clang-completion-mode. When "Clang" shows up in the mode
-;; line, Clang's code-completion is enabled.
-;;
-;; Clang's code completion is based on parsing the complete source
-;; file up to the point where the cursor is located. Therefore, Clang
-;; needs all of the various compilation flags (include paths, dialect
-;; options, etc.) to provide code-completion results. Currently, these
-;; need to be placed into the clang-flags variable in a format
-;; acceptable to clang. This is a hack: patches are welcome to
-;; improve the interface between this Emacs mode and Clang! 
-;;
-
-;;; Code:
-;;; The clang executable
-(defcustom clang "clang"
-  "The location of the Clang compiler executable"
-  :type 'file
-  :group 'clang-completion-mode)
-
-;;; Extra compilation flags to pass to clang.
-(defcustom clang-flags nil
-  "Extra flags to pass to the Clang executable.
-This variable will typically contain include paths, e.g., -I~/MyProject."
-  :type '(repeat (string :tag "Argument" ""))
-  :group 'clang-completion-mode)
-
-;;; The prefix header to use with Clang code completion. 
-(defvar clang-completion-prefix-header "")
-
-;;; The substring we will use to filter completion results
-(defvar clang-completion-substring "")
-
-;;; The current completion buffer
-(defvar clang-completion-buffer nil)
-
-(defvar clang-result-string "")
-
-;;; Compute the current line in the buffer 
-(defun current-line ()
-  "Return the vertical position of point..."
-  (+ (count-lines (point-min) (point))
- (if (= (current-column) 0) 1 0)
- -1))
-
-;;; Set the Clang prefix header
-(defun clang-prefix-header ()
-  (interactive)
-  (setq clang-completion-prefix-header
-(read-string "Clang prefix header> " "" clang-completion-prefix-header
- "")))
-
-;; Process "filter" that keeps track of the code-completion results
-;; produced. We store all of the results in a string, then the
-;; sentinel processes the entire string at once.
-(defun clang-completion-stash-filter (proc string)
-  (setq clang-result-string (concat clang-result-string string)))
-
-;; Filter the given list based on a predicate.
-(defun filter (condp lst)
-(delq nil
-  (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
-
-;; Determine whether FIXME: explain better
-(defun is-completion-line (line)
-  (or (string-match "OVERLOAD:" line)
-  (string-matc

[clang-tools-extra] r283865 - Fix typo in documentation

2016-10-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Oct 11 04:42:13 2016
New Revision: 283865

URL: http://llvm.org/viewvc/llvm-project?rev=283865&view=rev
Log:
Fix typo in documentation

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst?rev=283865&r1=283864&r2=283865&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst 
Tue Oct 11 04:42:13 2016
@@ -14,4 +14,4 @@ Options
 
 .. option:: WhiteListTypes
 
-   A semicolon-separated list of names of whitelist types. Defualt is empty.
+   A semicolon-separated list of names of whitelist types. Default is empty.


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


[PATCH] D25419: Use unique_ptr in LLVMContextImpl's constant maps.

2016-10-11 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283767: Use unique_ptr in LLVMContextImpl's constant maps. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25419?vs=74097&id=74206#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25419

Files:
  llvm/trunk/lib/IR/Constants.cpp
  llvm/trunk/lib/IR/LLVMContextImpl.cpp
  llvm/trunk/lib/IR/LLVMContextImpl.h

Index: llvm/trunk/lib/IR/LLVMContextImpl.h
===
--- llvm/trunk/lib/IR/LLVMContextImpl.h
+++ llvm/trunk/lib/IR/LLVMContextImpl.h
@@ -1049,10 +1049,12 @@
   LLVMContext::YieldCallbackTy YieldCallback;
   void *YieldOpaqueHandle;
 
-  typedef DenseMap IntMapTy;
+  typedef DenseMap, DenseMapAPIntKeyInfo>
+  IntMapTy;
   IntMapTy IntConstants;
 
-  typedef DenseMap FPMapTy;
+  typedef DenseMap, DenseMapAPFloatKeyInfo>
+  FPMapTy;
   FPMapTy FPConstants;
 
   FoldingSet AttrsSet;
@@ -1078,7 +1080,7 @@
   // them on context teardown.
   std::vector DistinctMDNodes;
 
-  DenseMap CAZConstants;
+  DenseMap> CAZConstants;
 
   typedef ConstantUniqueMap ArrayConstantsTy;
   ArrayConstantsTy ArrayConstants;
@@ -1088,11 +1090,11 @@
   
   typedef ConstantUniqueMap VectorConstantsTy;
   VectorConstantsTy VectorConstants;
-  
-  DenseMap CPNConstants;
 
-  DenseMap UVConstants;
-  
+  DenseMap> CPNConstants;
+
+  DenseMap> UVConstants;
+
   StringMap CDSConstants;
 
   DenseMap, BlockAddress *>
Index: llvm/trunk/lib/IR/Constants.cpp
===
--- llvm/trunk/lib/IR/Constants.cpp
+++ llvm/trunk/lib/IR/Constants.cpp
@@ -545,14 +545,14 @@
 ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) {
   // get an existing value or the insertion position
   LLVMContextImpl *pImpl = Context.pImpl;
-  ConstantInt *&Slot = pImpl->IntConstants[V];
+  std::unique_ptr &Slot = pImpl->IntConstants[V];
   if (!Slot) {
 // Get the corresponding integer type for the bit width of the value.
 IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());
-Slot = new ConstantInt(ITy, V);
+Slot.reset(new ConstantInt(ITy, V));
   }
   assert(Slot->getType() == IntegerType::get(Context, V.getBitWidth()));
-  return Slot;
+  return Slot.get();
 }
 
 Constant *ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) {
@@ -685,7 +685,7 @@
 ConstantFP* ConstantFP::get(LLVMContext &Context, const APFloat& V) {
   LLVMContextImpl* pImpl = Context.pImpl;
 
-  ConstantFP *&Slot = pImpl->FPConstants[V];
+  std::unique_ptr &Slot = pImpl->FPConstants[V];
 
   if (!Slot) {
 Type *Ty;
@@ -704,10 +704,10 @@
  "Unknown FP format");
   Ty = Type::getPPC_FP128Ty(Context);
 }
-Slot = new ConstantFP(Ty, V);
+Slot.reset(new ConstantFP(Ty, V));
   }
 
-  return Slot;
+  return Slot.get();
 }
 
 Constant *ConstantFP::getInfinity(Type *Ty, bool Negative) {
@@ -1259,12 +1259,13 @@
 ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) {
   assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
  "Cannot create an aggregate zero of non-aggregate type!");
-  
-  ConstantAggregateZero *&Entry = Ty->getContext().pImpl->CAZConstants[Ty];
+
+  std::unique_ptr &Entry =
+  Ty->getContext().pImpl->CAZConstants[Ty];
   if (!Entry)
-Entry = new ConstantAggregateZero(Ty);
+Entry.reset(new ConstantAggregateZero(Ty));
 
-  return Entry;
+  return Entry.get();
 }
 
 /// Remove the constant from the constant table.
@@ -1325,24 +1326,25 @@
 //
 
 ConstantPointerNull *ConstantPointerNull::get(PointerType *Ty) {
-  ConstantPointerNull *&Entry = Ty->getContext().pImpl->CPNConstants[Ty];
+  std::unique_ptr &Entry =
+  Ty->getContext().pImpl->CPNConstants[Ty];
   if (!Entry)
-Entry = new ConstantPointerNull(Ty);
+Entry.reset(new ConstantPointerNull(Ty));
 
-  return Entry;
+  return Entry.get();
 }
 
 /// Remove the constant from the constant table.
 void ConstantPointerNull::destroyConstantImpl() {
   getContext().pImpl->CPNConstants.erase(getType());
 }
 
 UndefValue *UndefValue::get(Type *Ty) {
-  UndefValue *&Entry = Ty->getContext().pImpl->UVConstants[Ty];
+  std::unique_ptr &Entry = Ty->getContext().pImpl->UVConstants[Ty];
   if (!Entry)
-Entry = new UndefValue(Ty);
+Entry.reset(new UndefValue(Ty));
 
-  return Entry;
+  return Entry.get();
 }
 
 /// Remove the constant from the constant table.
Index: llvm/trunk/lib/IR/LLVMContextImpl.cpp
===
--- llvm/trunk/lib/IR/LLVMContextImpl.cpp
+++ llvm/trunk/lib/IR/LLVMContextImpl.cpp
@@ -94,12 +94,13 @@
   ArrayConstants.freeConstants();
   StructConstants.freeConstants();
   VectorConstants.freeConstants();
-  DeleteContainerSeconds(CAZConstants);
-  DeleteContainerSeconds(CPNConstants);
-  DeleteContainerSeconds(UVConstants);
   InlineAsms.freeConstants();
-  DeleteContainerSeconds(IntConstants);
-  DeleteContaine

[PATCH] D25425: [AST] Convert Marshallers to use unique_ptr.

2016-10-11 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL283773: [AST] Convert Marshallers to use unique_ptr. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25425?vs=74103&id=74207#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25425

Files:
  cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -31,43 +31,45 @@
 
 using internal::MatcherDescriptor;
 
-typedef llvm::StringMap ConstructorMap;
+typedef llvm::StringMap> ConstructorMap;
 class RegistryMaps {
 public:
   RegistryMaps();
   ~RegistryMaps();
 
   const ConstructorMap &constructors() const { return Constructors; }
 
 private:
-  void registerMatcher(StringRef MatcherName, MatcherDescriptor *Callback);
+  void registerMatcher(StringRef MatcherName,
+   std::unique_ptr Callback);
+
   ConstructorMap Constructors;
 };
 
-void RegistryMaps::registerMatcher(StringRef MatcherName,
-   MatcherDescriptor *Callback) {
+void RegistryMaps::registerMatcher(
+StringRef MatcherName, std::unique_ptr Callback) {
   assert(Constructors.find(MatcherName) == Constructors.end());
-  Constructors[MatcherName] = Callback;
+  Constructors[MatcherName] = std::move(Callback);
 }
 
 #define REGISTER_MATCHER(name) \
   registerMatcher(#name, internal::makeMatcherAutoMarshall(\
  ::clang::ast_matchers::name, #name));
 
 #define SPECIFIC_MATCHER_OVERLOAD(name, Id)\
-  static_cast< ::clang::ast_matchers::name##_Type##Id>(\
+  static_cast<::clang::ast_matchers::name##_Type##Id>( \
   ::clang::ast_matchers::name)
 
 #define REGISTER_OVERLOADED_2(name)\
   do { \
-MatcherDescriptor *Callbacks[] = { \
-  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),\
-#name),\
-  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1),\
-#name) \
-}; \
-registerMatcher(#name, \
-new internal::OverloadedMatcherDescriptor(Callbacks)); \
+std::unique_ptr Callbacks[] = { \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),  \
+  #name),  \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1),  \
+  #name)}; \
+registerMatcher(   \
+#name, \
+llvm::make_unique(Callbacks));  \
   } while (0)
 
 /// \brief Generate a registry map with all the known matchers.
@@ -426,21 +428,18 @@
   REGISTER_MATCHER(withInitializer);
 }
 
-RegistryMaps::~RegistryMaps() {
-  llvm::DeleteContainerSeconds(Constructors);
-}
+RegistryMaps::~RegistryMaps() {}
 
 static llvm::ManagedStatic RegistryData;
 
 } // anonymous namespace
 
 // static
 llvm::Optional Registry::lookupMatcherCtor(StringRef MatcherName) {
-  ConstructorMap::const_iterator it =
-  RegistryData->constructors().find(MatcherName);
+  auto it = RegistryData->constructors().find(MatcherName);
   return it == RegistryData->constructors().end()
  ? llvm::Optional()
- : it->second;
+ : it->second.get();
 }
 
 namespace {
@@ -499,26 +498,26 @@
 
   // Search the registry for acceptable matchers.
   for (const auto &M : RegistryData->constructors()) {
-const auto *Matcher = M.getValue();
+const MatcherDescriptor& Matcher = *M.getValue();
 StringRef Name = M.getKey();
 
 std::set RetKinds;
-unsigned NumArgs = Matcher->isVariadic() ? 1 : Matcher->getNumArgs();
-bool IsPolymorphic = Matcher->isPolymorphic();
+unsigned NumArgs = Matcher.isVariadic() ? 1 : Matcher.getNumArgs();
+bool IsPolymorphic = Matcher.isPolymorphic();
 std::vector> ArgsKinds(NumArgs);
 unsigned MaxSpecificity = 0;
 for (const ArgKind& Kind : AcceptedTypes) {
   if (Kind.getArgKind() != Kind.AK_Matcher)
 continue;
   unsigned Specific

[PATCH] D25453: Add -fno-sanitize-address-use-after-scope flag

2016-10-11 Thread Vitaly Buka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283801: Add -fno-sanitize-address-use-after-scope flag 
(authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D25453?vs=74176&id=74210#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25453

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/fsanitize.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -687,6 +687,9 @@
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
 Group, 
Flags<[CC1Option]>,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
+def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
+   Group, 
Flags<[CC1Option]>,
+   HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group,
 Flags<[CoreOption]>;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -108,14 +108,20 @@
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-working-set,kernel-address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANKA
 // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=kernel-address'
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-USE-AFTER-SCOPE
-// CHECK-ONLY-USE-AFTER-SCOPE: '-fsanitize-address-use-after-scope' only 
allowed with '-fsanitize=address'
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-NO-USE-AFTER-SCOPE
-// CHECK-ASAN-NO-USE-AFTER-SCOPE-NOT: 
-cc1{{.*}}-fsanitize-address-use-after-scope
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
+// CHECK-USE-AFTER-SCOPE-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
+// CHECK-USE-AFTER-SCOPE-BOTH: -cc1{{.*}}-fsanitize-address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope -fno-sanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH-OFF
+// CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: 
'-fsanitize-memory-track-origins'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -732,8 +732,11 @@
   Args.hasArg(OPT_fsanitize_memory_use_after_dtor);
   Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
-  Opts.SanitizeAddressUseAfterScope =
-  Args.hasArg(OPT_fsanitize_address_use_after_scope);
+  if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
+   OPT_fno_sanitize_address_use_after_scope)) {
+Opts.SanitizeAddressUseAfterScope =
+A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
+  }
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp
===
--- cfe/t

[PATCH] D25225: Add an option to save the backend-produced YAML optimization record to a file

2016-10-11 Thread Hal Finkel via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283834: Add an option to save the backend-produced YAML 
optimization record to a file (authored by hfinkel).

Changed prior to commit:
  https://reviews.llvm.org/D25225?vs=74001&id=74214#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25225

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/Inputs/opt-record.proftext
  cfe/trunk/test/CodeGen/opt-record.c
  cfe/trunk/test/Driver/opt-record.c

Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -33,6 +33,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Timer.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/YAMLTraits.h"
 #include 
 using namespace clang;
 using namespace llvm;
@@ -181,6 +183,24 @@
   Ctx.setDiagnosticHandler(DiagnosticHandler, this);
   Ctx.setDiagnosticHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
 
+  std::unique_ptr OptRecordFile;
+  if (!CodeGenOpts.OptRecordFile.empty()) {
+std::error_code EC;
+OptRecordFile =
+  llvm::make_unique(CodeGenOpts.OptRecordFile,
+EC, sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_cannot_open_file) <<
+CodeGenOpts.OptRecordFile << EC.message();
+  return;
+}
+
+Ctx.setDiagnosticsOutputFile(new yaml::Output(OptRecordFile->os()));
+
+if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+  Ctx.setDiagnosticHotnessRequested(true);
+  }
+
   // Link LinkModule into this module if present, preserving its validity.
   for (auto &I : LinkModules) {
 unsigned LinkFlags = I.first;
@@ -198,6 +218,9 @@
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
   Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+
+  if (OptRecordFile)
+OptRecordFile->keep();
 }
 
 void HandleTagDeclDefinition(TagDecl *D) override {
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6080,6 +6080,39 @@
 CmdArgs.push_back("-fno-math-builtin");
   }
 
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false)) {
+CmdArgs.push_back("-opt-record-file");
+
+const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+if (A) {
+  CmdArgs.push_back(A->getValue());
+} else {
+  SmallString<128> F;
+  if (Output.isFilename() && (Args.hasArg(options::OPT_c) ||
+  Args.hasArg(options::OPT_S))) {
+F = Output.getFilename();
+  } else {
+// Use the compilation directory.
+F = llvm::sys::path::stem(Input.getBaseInput());
+
+// If we're compiling for an offload architecture (i.e. a CUDA device),
+// we need to make the file name for the device compilation different
+// from the host compilation.
+if (!JA.isDeviceOffloading(Action::OFK_None) &&
+!JA.isDeviceOffloading(Action::OFK_Host)) {
+  llvm::sys::path::replace_extension(F, "");
+  F += JA.getOffloadingFileNamePrefix(Triple.normalize());
+  F += "-";
+  F += JA.getOffloadingArch();
+}
+  }
+
+  llvm::sys::path::replace_extension(F, "opt.yaml");
+  CmdArgs.push_back(Args.MakeArgString(F));
+}
+  }
+
 // Default to -fno-builtin-str{cat,cpy} on Darwin for ARM.
 //
 // FIXME: Now that PR4941 has been fixed this can be enabled.
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -826,6 +826,10 @@
   Opts.LinkerOptions = Args.getAllArgValues(OPT_linker_option);
   bool NeedLocTracking = false;
 
+  Opts.OptRecordFile = Args.getLastArgValue(OPT_opt_record_file);
+  if (!Opts.OptRecordFile.empty())
+NeedLocTracking = true;
+
   if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
 Opts.OptimizationRemarkPattern =
 GenerateOptimizationRemarkRegex(Diags, Args, A);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1192,6 +1192,15 @@
   

[PATCH] D21508: Make friend function template definition available if class is instantiated.

2016-10-11 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 74218.
sepavloff added a comment.

Updated comments, NFC otherwise.


https://reviews.llvm.org/D21508

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -101,7 +101,6 @@
   friend void func_12(int x = 0);  // expected-error{{friend declaration specifying a default argument must be the only declaration}}
 };
 
-
 namespace pr22307 {
 
 struct t {
@@ -170,3 +169,70 @@
 template class Test;
 
 }
+
+// Case of template friend functions.
+
+template void func_21(T *x);
+template
+struct C21a {
+  template friend void func_21(T *x) {}
+};
+template
+struct C21b {
+  template friend void func_21(T *x) {}
+};
+
+
+template inline void func_22(T *x) {}
+template
+struct C22a {
+  template friend void func_22(T *x) {}
+};
+template
+struct C22b {
+  template friend void func_22(T *x) {}
+};
+
+
+template
+struct C23a {
+  template friend void func_23(T *x) {}
+};
+template
+struct C23b {
+  template friend void func_23(T *x) {}
+};
+
+
+template inline void func_24(T *x) {}  // expected-note{{previous definition is here}}
+template
+struct C24 {
+  template friend void func_24(T *x) {} // expected-error{{redefinition of 'func_24'}}
+};
+
+C24 v24;  // expected-note{{in instantiation of template class 'C24' requested here}}
+
+
+template inline void func_25(T *x);
+template
+struct C25a {
+  template friend void func_25(T *x) {} // expected-note{{previous definition is here}}
+};
+template
+struct C25b {
+  template friend void func_25(T *x) {} // expected-error{{redefinition of 'func_25'}}
+};
+
+C25a v25a;
+C25b v25b;  // expected-note{{in instantiation of template class 'C25b' requested here}}
+
+
+template void func_26(T *x);
+template
+struct C26 {
+  template friend void func_26(T *x) {}  // expected-error{{redefinition of 'func_26'}}
+ // expected-note@-1{{previous definition is here}}
+};
+
+C26 v26a;
+C26 v26b;  //expected-note{{in instantiation of template class 'C26' requested here}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8846,10 +8846,23 @@
 
 if (FunctionTemplateDecl *OldTemplateDecl
   = dyn_cast(OldDecl)) {
-  NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   FunctionTemplateDecl *NewTemplateDecl
 = NewFD->getDescribedFunctionTemplate();
   assert(NewTemplateDecl && "Template/non-template mismatch");
+  Redeclaration = shouldLinkDependentDeclWithPrevious(NewTemplateDecl,
+  OldTemplateDecl);
+  if (Redeclaration &&
+  (NewTemplateDecl->getFriendObjectKind() != Decl::FOK_None ||
+   OldTemplateDecl->getFriendObjectKind() != Decl::FOK_None))
+if (FunctionTemplateDecl *NewDef = NewTemplateDecl->getDefinition())
+  if (FunctionTemplateDecl *OldDef = OldTemplateDecl->getDefinition()) {
+Diag(NewDef->getLocation(), diag::err_redefinition)
+<< NewDef->getDeclName();
+Diag(OldDef->getLocation(), diag::note_previous_definition);
+Redeclaration = false;
+  }
+  if (Redeclaration)
+NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   if (CXXMethodDecl *Method
 = dyn_cast(NewTemplateDecl->getTemplatedDecl())) {
 Method->setAccess(OldTemplateDecl->getAccess());
Index: lib/AST/DeclTemplate.cpp
===
--- lib/AST/DeclTemplate.cpp
+++ lib/AST/DeclTemplate.cpp
@@ -289,6 +289,27 @@
   }
 }
 
+FunctionTemplateDecl *FunctionTemplateDecl::getDefinition() const {
+  for (auto *R : redecls()) {
+FunctionTemplateDecl *F = cast(R);
+if (F->isThisDeclarationADefinition())
+  return F;
+
+// If template does not have a body, probably it is instantiated from
+// another template and is not used yet.
+if (FunctionTemplateDecl *P = F->getInstantiatedFromMemberTemplate()) {
+  // If we have hit a point where the user provided a specialization of
+  // this template, we're done looking.
+  if (F->isMemberSpecialization())
+return F;
+  if (FunctionTemplateDecl *Def = P->getDefinition())
+return Def;
+}
+  }
+
+  return nullptr;
+}
+
 llvm::FoldingSetVector &
 FunctionTemplateDecl::getSpecializations() const {
   LoadLazySpecializations();
Index: include/clang/AST/DeclTemplate.h
===
--- include/clang/AST/DeclTemplate.h
+++ include/clang/AST/DeclTemplate.h
@@ -933,6 +933,15 @@
 return getTemplatedDecl()->isThisDeclarationADefinition();
   

[PATCH] D25308: [Sema] Ignore transparent_union attributes in C++

2016-10-11 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

Thanks!




Comment at: include/clang/Basic/Attr.td:1545
 //  let Subjects = SubjectList<[Record, TypedefName]>;
   let Documentation = [Undocumented];
+  let LangOpts = [COnly];

aaron.ballman wrote:
> If you, or anyone else, is bored, it would be nice to document this attribute 
> now that we're touching it. (I am not signing you up for work as part of this 
> patch, just prodding in case you wanted to do it.)
That's a good idea, the lack of documentation stood out to me as well. I'll try 
to find some time this week for it.


Repository:
  rL LLVM

https://reviews.llvm.org/D25308



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


r283868 - Revert "[Driver][Diagnostics] Make 'show option names' default for driver warnings"

2016-10-11 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Tue Oct 11 05:26:33 2016
New Revision: 283868

URL: http://llvm.org/viewvc/llvm-project?rev=283868&view=rev
Log:
Revert "[Driver][Diagnostics] Make 'show option names' default for driver 
warnings"

This reverts commit r283827, as it's breaking all ARM/AARch64 bots.

Removed:
cfe/trunk/test/Driver/show-option-names.c
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=283868&r1=283867&r2=283868&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Tue Oct 11 05:26:33 
2016
@@ -48,8 +48,7 @@ class DiagnosticsEngine;
 /// report the error(s).
 bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
  DiagnosticsEngine *Diags = nullptr,
- bool DefaultDiagColor = true,
- bool DefaultShowOpt = true);
+ bool DefaultDiagColor = true);
 
 class CompilerInvocationBase : public RefCountedBase {
   void operator=(const CompilerInvocationBase &) = delete;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=283868&r1=283867&r2=283868&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Oct 11 05:26:33 2016
@@ -957,7 +957,7 @@ static bool parseShowColorsArgs(const Ar
 
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
-bool DefaultDiagColor, bool DefaultShowOpt) {
+bool DefaultDiagColor) {
   using namespace options;
   bool Success = true;
 
@@ -977,9 +977,7 @@ bool clang::ParseDiagnosticArgs(Diagnost
   Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
   Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
-  Opts.ShowOptionNames =
-  Args.hasFlag(OPT_fdiagnostics_show_option,
-   OPT_fno_diagnostics_show_option, DefaultShowOpt);
+  Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
 
   llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
 
@@ -2406,9 +2404,8 @@ bool CompilerInvocation::CreateFromArgs(
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
-  Success &=
-  ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
-  false /*DefaultDiagColor*/, false 
/*DefaultShowOpt*/);
+  Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
+ false /*DefaultDiagColor*/);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here

Removed: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283867&view=auto
==
--- cfe/trunk/test/Driver/show-option-names.c (original)
+++ cfe/trunk/test/Driver/show-option-names.c (removed)
@@ -1,5 +0,0 @@
-// RUN: (%clang -c -target i386-apple-darwin10 -isysroot /FOO %s 2>&1 || true) 
| FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
-// CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
-
-// RUN: (%clang -c -target i386-apple-darwin10 -fno-diagnostics-show-option 
-isysroot /FOO %s 2>&1 || true) | FileCheck 
--check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
-// CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 10:14, Renato Golin  wrote:
> clang-4.0: warning: no such sysroot directory: '/FOO' [-Wmissing-sysroot]
> error: unable to create target: 'No available targets are compatible
> with this triple.'
> 1 error generated.

Reverted in r283868, as it was also breaking ARM bots.

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


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 74221.
hokein added a comment.

Add FIXME.


https://reviews.llvm.org/D25437

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,13 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
 class Base {
  public:
   void f();
@@ -150,6 +157,10 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +181,11 @@
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,13 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
 class Base {
  public:
   void f();
@@ -150,6 +157,10 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +181,11 @@
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: test/clang-tidy/misc-unused-using-decls.cpp:191
+// n::N is using in the explicit template instantiations.
+template void h(n::M* t);

aaron.ballman wrote:
> Can you add a test using a non-type template argument, like an integer 
> literal? I believe that still causes the diagnostic, though do we want it to?
Yeah, I agree that we need support non-type template arguments in the long 
term, but it seems out of scope of this patch (Supporting all non-type template 
arguments needs more stuff), I have added to FIXME.


https://reviews.llvm.org/D25437



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


[PATCH] D25397: [change-namespace] don't miss comments in the beginning of a namespace block.

2016-10-11 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:387
+  Token Tok;
+  while (!Lex->LexFromRawLexer(Tok) && Tok.isNot(tok::TokenKind::l_brace)) {
+  }

Maybe we can use `findLocationAfterToken` here? 


https://reviews.llvm.org/D25397



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


[clang-tools-extra] r283869 - [clang-tidy] modernize-use-default default constructor bugfix

2016-10-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Oct 11 05:47:06 2016
New Revision: 283869

URL: http://llvm.org/viewvc/llvm-project?rev=283869&view=rev
Log:
[clang-tidy] modernize-use-default default constructor bugfix

Summary:
Only member initializers that are written should prevent
using '= default' on a default constructor.

Reviewers: klimek, sbenza, aaron.ballman, alexfh

Subscribers: Eugene.Zelenko, alexfh, klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=283869&r1=283868&r2=283869&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Tue Oct 11 
05:47:06 2016
@@ -238,7 +238,7 @@ void UseDefaultCheck::registerMatchers(M
 isDefinition(),
 anyOf(
 // Default constructor.
-allOf(unless(hasAnyConstructorInitializer(anything())),
+allOf(unless(hasAnyConstructorInitializer(isWritten())),
   parameterCountIs(0)),
 // Copy constructor.
 allOf(isCopyConstructor(),
@@ -296,12 +296,12 @@ void UseDefaultCheck::check(const MatchF
   if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor))
 return;
   SpecialFunctionName = "copy constructor";
-}
-// If there are constructor initializers, they must be removed.
-if (Ctor->getNumCtorInitializers() != 0) {
-  StartLoc = getColonLoc(Result.Context, Ctor);
-  if (!StartLoc.isValid())
-return;
+  // If there are constructor initializers, they must be removed.
+  if (Ctor->getNumCtorInitializers() != 0) {
+StartLoc = getColonLoc(Result.Context, Ctor);
+if (!StartLoc.isValid())
+  return;
+  }
 }
   } else if (isa(SpecialFunctionDecl)) {
 SpecialFunctionName = "destructor";

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp?rev=283869&r1=283868&r2=283869&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp Tue Oct 
11 05:47:06 2016
@@ -43,6 +43,24 @@ public:
   int Field;
 };
 
+// Default member initializer
+class DMI {
+public:
+  DMI() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: DMI() = default;
+  int Field = 5;
+};
+
+// Class member
+class CM {
+public:
+  CM() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: CM() = default;
+  OL o;
+};
+
 // Private constructor/destructor.
 class Priv {
   Priv() {}


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


[PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

2016-10-11 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: 
test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp:1
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.LiteralInitializers", value: 1}]}" -- 
-std=c++11
+

`-std=c++11` is not needed. This extra compile argument is added by default 
when running check_clang_tidy.


https://reviews.llvm.org/D24892



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


[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

2016-10-11 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 74227.
arphaman marked an inline comment as done.
arphaman added a comment.

The updated patch handles protocol properties together with the interface 
properties.


Repository:
  rL LLVM

https://reviews.llvm.org/D25436

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/objc-protocol-member-access.m


Index: test/CodeCompletion/objc-protocol-member-access.m
===
--- /dev/null
+++ test/CodeCompletion/objc-protocol-member-access.m
@@ -0,0 +1,24 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@protocol Bar
+@property (readonly) int bar;
+@end
+
+@protocol Foo 
+
+@property (nonatomic, readonly) int foo;
+- (void)foobar: (int)x;
+
+@end
+
+int getFoo(id object) {
+  id modelObject = (id)object;
+  int foo = modelObject.;
+  return foo;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | 
FileCheck %s
+// CHECK: bar : [#int#]bar
+// CHECK: foo : [#int#]foo
+// CHECK-NOT: foobar
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3720,20 +3720,21 @@
   Results.AddResult(Result("template"));
   }
 }
-  } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) {
+  } else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
 // Objective-C property reference.
 AddedPropertiesSet AddedProperties;
-
-// Add property results based on our interface.
-const ObjCObjectPointerType *ObjCPtr
-  = BaseType->getAsObjCInterfacePointerType();
-assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
-AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
-  /*AllowNullaryMethods=*/true, CurContext, 
-  AddedProperties, Results);
-
+
+if (const ObjCObjectPointerType *ObjCPtr =
+BaseType->getAsObjCInterfacePointerType()) {
+  // Add property results based on our interface.
+  assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
+  AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
+/*AllowNullaryMethods=*/true, CurContext,
+AddedProperties, Results);
+}
+
 // Add properties from the protocols in a qualified interface.
-for (auto *I : ObjCPtr->quals())
+for (auto *I : BaseType->getAs()->quals())
   AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true,
 CurContext, AddedProperties, Results);
   } else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||


Index: test/CodeCompletion/objc-protocol-member-access.m
===
--- /dev/null
+++ test/CodeCompletion/objc-protocol-member-access.m
@@ -0,0 +1,24 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@protocol Bar
+@property (readonly) int bar;
+@end
+
+@protocol Foo 
+
+@property (nonatomic, readonly) int foo;
+- (void)foobar: (int)x;
+
+@end
+
+int getFoo(id object) {
+  id modelObject = (id)object;
+  int foo = modelObject.;
+  return foo;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | FileCheck %s
+// CHECK: bar : [#int#]bar
+// CHECK: foo : [#int#]foo
+// CHECK-NOT: foobar
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3720,20 +3720,21 @@
   Results.AddResult(Result("template"));
   }
 }
-  } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) {
+  } else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
 // Objective-C property reference.
 AddedPropertiesSet AddedProperties;
-
-// Add property results based on our interface.
-const ObjCObjectPointerType *ObjCPtr
-  = BaseType->getAsObjCInterfacePointerType();
-assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
-AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
-  /*AllowNullaryMethods=*/true, CurContext, 
-  AddedProperties, Results);
-
+
+if (const ObjCObjectPointerType *ObjCPtr =
+BaseType->getAsObjCInterfacePointerType()) {
+  // Add property results based on our interface.
+  assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
+  AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
+/*AllowNullaryMethods=*/true, CurContext,
+AddedProperties, Results);
+}
+
 // Add properties from the protocols in a qualified interface.
-for (auto *I : ObjCPtr->quals())
+for (auto *I : BaseType->getAs()->quals())
   AddObjCProperties(CCContext, I, true, /*Allo

[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

2016-10-11 Thread Alex Lorenz via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:3723
 }
   } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) {
 // Objective-C property reference.

manmanren wrote:
> I feel like the added logic belongs to here :] Both handle property reference.
> 
> The clause here handles ObjCObjectPointerType that is based on an 
> ObjCInterfaceType. We need to handle the case where the base type is "id".
> 
> What do you think?
Yes, that makes sense. I updated the patch to handle properties in both the 
interface and qualified IDs in this body of code.


Repository:
  rL LLVM

https://reviews.llvm.org/D25436



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


[PATCH] D24444: [clang-tidy] modernize-use-default default constructor bugfix

2016-10-11 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283869: [clang-tidy] modernize-use-default default 
constructor bugfix (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D2?vs=70966&id=74232#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D2

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -43,6 +43,24 @@
   int Field;
 };
 
+// Default member initializer
+class DMI {
+public:
+  DMI() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: DMI() = default;
+  int Field = 5;
+};
+
+// Class member
+class CM {
+public:
+  CM() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: CM() = default;
+  OL o;
+};
+
 // Private constructor/destructor.
 class Priv {
   Priv() {}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -238,7 +238,7 @@
 isDefinition(),
 anyOf(
 // Default constructor.
-allOf(unless(hasAnyConstructorInitializer(anything())),
+allOf(unless(hasAnyConstructorInitializer(isWritten())),
   parameterCountIs(0)),
 // Copy constructor.
 allOf(isCopyConstructor(),
@@ -296,12 +296,12 @@
   if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor))
 return;
   SpecialFunctionName = "copy constructor";
-}
-// If there are constructor initializers, they must be removed.
-if (Ctor->getNumCtorInitializers() != 0) {
-  StartLoc = getColonLoc(Result.Context, Ctor);
-  if (!StartLoc.isValid())
-return;
+  // If there are constructor initializers, they must be removed.
+  if (Ctor->getNumCtorInitializers() != 0) {
+StartLoc = getColonLoc(Result.Context, Ctor);
+if (!StartLoc.isValid())
+  return;
+  }
 }
   } else if (isa(SpecialFunctionDecl)) {
 SpecialFunctionName = "destructor";


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -43,6 +43,24 @@
   int Field;
 };
 
+// Default member initializer
+class DMI {
+public:
+  DMI() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: DMI() = default;
+  int Field = 5;
+};
+
+// Class member
+class CM {
+public:
+  CM() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: CM() = default;
+  OL o;
+};
+
 // Private constructor/destructor.
 class Priv {
   Priv() {}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -238,7 +238,7 @@
 isDefinition(),
 anyOf(
 // Default constructor.
-allOf(unless(hasAnyConstructorInitializer(anything())),
+allOf(unless(hasAnyConstructorInitializer(isWritten())),
   parameterCountIs(0)),
 // Copy constructor.
 allOf(isCopyConstructor(),
@@ -296,12 +296,12 @@
   if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor))
 return;
   SpecialFunctionName = "copy constructor";
-}
-// If there are constructor initializers, they must be removed.
-if (Ctor->getNumCtorInitializers() != 0) {
-  StartLoc = getColonLoc(Result.Context, Ctor);
-  if (!StartLoc.isValid())
-return;
+  // If there are constructor initializers, they must be removed.
+  if (Ctor->getNumCtorInitializers() != 0) {
+StartLoc = getColonLoc(Result.Context, Ctor);
+if (!StartLoc.isValid())
+  return;
+  }
 }
   } else if (isa(SpecialFunctionDecl)) {
 SpecialFunctionName = "destructor";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r283853 - Explicitly ignore return code in test for test systems that use pipefail

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 07:13, Daniel Jasper via cfe-commits
 wrote:
> Author: djasper
> Date: Tue Oct 11 01:13:18 2016
> New Revision: 283853
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283853&view=rev
> Log:
> Explicitly ignore return code in test for test systems that use pipefail

Hi Daniel,

I missed this commit and reverted the original patch.

However, before we reapply, why not use "not" instead of "|| true" ?

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


Re: r283853 - Explicitly ignore return code in test for test systems that use pipefail

2016-10-11 Thread Daniel Jasper via cfe-commits
On Tue, Oct 11, 2016 at 1:38 PM, Renato Golin 
wrote:

> On 11 October 2016 at 07:13, Daniel Jasper via cfe-commits
>  wrote:
> > Author: djasper
> > Date: Tue Oct 11 01:13:18 2016
> > New Revision: 283853
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=283853&view=rev
> > Log:
> > Explicitly ignore return code in test for test systems that use pipefail
>
> Hi Daniel,
>
> I missed this commit and reverted the original patch.
>
> However, before we reapply, why not use "not" instead of "|| true" ?
>

Just because I don't know shell very well :). Feel free to use "not"
instead.


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


[clang-tools-extra] r283873 - [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-10-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Oct 11 07:02:16 2016
New Revision: 283873

URL: http://llvm.org/viewvc/llvm-project?rev=283873&view=rev
Log:
[clang-tidy] readability-avoid-const-params-in-decls template instantiation 
bugfix

Summary: Bugfix for 30398.  Don't warn for template instantiations

Reviewers: aaron.ballman, hokein, alexfh

Subscribers: omtcyfz, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp?rev=283873&r1=283872&r2=283873&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp 
Tue Oct 11 07:02:16 2016
@@ -36,7 +36,12 @@ void AvoidConstParamsInDecls::registerMa
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but they
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(),
+   // Class template instantiations have a non-definition
+   // CXXMethodDecl for methods that aren't used in this
+   // translation unit. Ignore those, as the template will have
+   // already been checked.
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp?rev=283873&r1=283872&r2=283873&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
 Tue Oct 11 07:02:16 2016
@@ -53,6 +53,12 @@ void F12(const bool b = true);
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@ struct Foo {
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@ void NF5(const int) {}
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);


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


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-11 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added a reviewer: EricWF.
rmaprath added a subscriber: cfe-commits.

This fixes a small omission where even when `__external_threading` is provided, 
we attempt to declare a pthread based threading API. Instead, we should leave 
out everything for the `__external_threading` header to take care of.

The `__threading_support` header provides a proof-of-concept externally 
threaded `libc++` variant when `_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined. 
But if the `__external_threading` header is present, we should exclude all of 
that POC stuff.


https://reviews.llvm.org/D25468

Files:
  include/__threading_support


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r283853 - Explicitly ignore return code in test for test systems that use pipefail

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 12:39, Daniel Jasper  wrote:
> Just because I don't know shell very well :). Feel free to use "not"
> instead.

Ah, ok. I'll reapply. :)

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


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

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



Comment at: test/clang-tidy/misc-unused-using-decls.cpp:191
+// n::N is using in the explicit template instantiations.
+template void h(n::M* t);

hokein wrote:
> aaron.ballman wrote:
> > Can you add a test using a non-type template argument, like an integer 
> > literal? I believe that still causes the diagnostic, though do we want it 
> > to?
> Yeah, I agree that we need support non-type template arguments in the long 
> term, but it seems out of scope of this patch (Supporting all non-type 
> template arguments needs more stuff), I have added to FIXME.
Certainly; I would mostly like a test showing that we considered it and 
understand the current behavior. If the test has a FIXME comment with it, 
that's also totally fine.


https://reviews.llvm.org/D25437



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


[PATCH] D25470: [libclang] Fix a failure in a test for python bindings on CursorKind.OVERLOAD_CANDIDATE.

2016-10-11 Thread Igor Kudrin via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: hansonw, compnerd.
ikudrin added a subscriber: cfe-commits.

The test fails because the value does not lay in any existing group.

The value was added in r268167.


https://reviews.llvm.org/D25470

Files:
  bindings/python/tests/cindex/test_cursor_kind.py


Index: bindings/python/tests/cindex/test_cursor_kind.py
===
--- bindings/python/tests/cindex/test_cursor_kind.py
+++ bindings/python/tests/cindex/test_cursor_kind.py
@@ -42,7 +42,8 @@
 CursorKind.MACRO_DEFINITION,
 CursorKind.MACRO_INSTANTIATION,
 CursorKind.INCLUSION_DIRECTIVE,
-CursorKind.PREPROCESSING_DIRECTIVE):
+CursorKind.PREPROCESSING_DIRECTIVE,
+CursorKind.OVERLOAD_CANDIDATE):
 assert len(group) == 0
 else:
 assert len(group) == 1


Index: bindings/python/tests/cindex/test_cursor_kind.py
===
--- bindings/python/tests/cindex/test_cursor_kind.py
+++ bindings/python/tests/cindex/test_cursor_kind.py
@@ -42,7 +42,8 @@
 CursorKind.MACRO_DEFINITION,
 CursorKind.MACRO_INSTANTIATION,
 CursorKind.INCLUSION_DIRECTIVE,
-CursorKind.PREPROCESSING_DIRECTIVE):
+CursorKind.PREPROCESSING_DIRECTIVE,
+CursorKind.OVERLOAD_CANDIDATE):
 assert len(group) == 0
 else:
 assert len(group) == 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 74239.
hokein added a comment.

Add a non-type template argument test.


https://reviews.llvm.org/D25437

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
+
+// Test on Non-type template arguments.
+template 
+void i(n::P* t) {}
+template void i(n::P* t);
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
+
+// Test on Non-type template arguments.
+template 
+void i(n::P* t) {}
+template void i(n::P* t);
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


https://reviews.llvm.org/D25437



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


[PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-10-11 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283873: [clang-tidy] readability-avoid-const-params-in-decls 
template instantiation… (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D24652?vs=72476&id=74242#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24652

Files:
  clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: 
clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -36,7 +36,12 @@
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but they
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(),
+   // Class template instantiations have a non-definition
+   // CXXMethodDecl for methods that aren't used in this
+   // translation unit. Ignore those, as the template will have
+   // already been checked.
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);


Index: clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void 

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-11 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

A simple case that still seems to fail:

  #include 
  
  struct foo {
uint32_t x;
uint8_t y[2];
uint16_t z;
  } __attribute__((__packed__));
  
  typedef struct foo __attribute__((__aligned__(16))) aligned_foo;
  
  int main(void) {
struct foo x;
struct foo __attribute__((__aligned__(4))) y;
aligned_foo z;
  
uint32_t *p32;
p32 = &x.x;
p32 = &y.x;
p32 = &z.x;
  }

Only the first assignment to p32 should warn, the others are all correctly 
aligned.


https://reviews.llvm.org/D23657



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


[clang-tools-extra] r283879 - [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct 11 08:50:34 2016
New Revision: 283879

URL: http://llvm.org/viewvc/llvm-project?rev=283879&view=rev
Log:
[clang-tidy] Fix template agrument false positives in unused-using-decls.

Summary:
* Fix a false postive when an using class is used in an explicit template 
instantiation.
* Fix a false postive when an using template class is used as template argument.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=283879&r1=283878&r2=283879&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Tue Oct 
11 08:50:34 2016
@@ -42,6 +42,8 @@ void UnusedUsingDeclsCheck::registerMatc
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@ void UnusedUsingDeclsCheck::check(const
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=283879&r1=283878&r2=283879&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Tue Oct 
11 08:50:34 2016
@@ -21,6 +21,16 @@ template  class J {};
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@ using n::Blue;
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@ void g() {
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
+
+// Test on Non-type template arguments.
+template 
+void i(n::P* t) {}
+template void i(n::P* t);


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


r283882 - [modules] PR28752: Do not instantiate variable declarations which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 08:57:36 2016
New Revision: 283882

URL: http://llvm.org/viewvc/llvm-project?rev=283882&view=rev
Log:
[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 08:57:36 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,27 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1322,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 08:57:36 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+  }
+  return VTD->getTemplatedDecl()->getDefinition();
+ 

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Landed in r283882.




Comment at: include/clang/AST/Decl.h:1222
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");

rsmith wrote:
> You can remove this; it's covered by the next line.
Ok. This would allow calling the method on already demoted definition. Do we 
want to allow that?



Comment at: lib/AST/Decl.cpp:2284
+  while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
+VD = NewVD;
+  return VD->getDefinition();

rsmith wrote:
> Missing a member specialization check here.
Isn't that covered by the cases above? It seems there is no API to make such 
check, here. The current state looks to me consistent with 
`CXXRecordDecl::getTemplateInstantiationPattern` and 
`FunctionDecl::getTemplateInstantiationPattern`.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3086-3090
+  if (CurD->isThisDeclarationADemotedDefinition()) {
+VD->demoteThisDefinitionToDeclaration();
+break;
+  }
+  if (CurD->isThisDeclarationADefinition()) {

rsmith wrote:
> Maybe combine these two `if`s into one, since their bodies are identical?
Good point ;)


https://reviews.llvm.org/D24508



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


[PATCH] D25474: [ARM] Fix - missing target-cpu in test

2016-10-11 Thread Javed Absar via cfe-commits
javed.absar created this revision.
javed.absar added reviewers: jmolloy, rengolin.
javed.absar added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This patch fixes an incomplete test, wherein the target-cpu name (cortex-r52) 
was missing.


https://reviews.llvm.org/D25474

Files:
  test/Driver/arm-cortex-cpus.c


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -165,7 +165,7 @@
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
 // RUN: %clang -target arm -march=armv8r -mthumb -mbig-endian -### -c %s 2>&1 
| \
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
-// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu
+// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} 
"-target-cpu" "cortex-r52"
 
 // RUN: %clang -mcpu=generic -target armv8 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8A-GENERIC %s
 // RUN: %clang -mcpu=generic -target arm -march=armv8 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V8A-GENERIC %s


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -165,7 +165,7 @@
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
 // RUN: %clang -target arm -march=armv8r -mthumb -mbig-endian -### -c %s 2>&1 | \
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
-// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu
+// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu" "cortex-r52"
 
 // RUN: %clang -mcpu=generic -target armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
 // RUN: %clang -mcpu=generic -target arm -march=armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283879: [clang-tidy] Fix template agrument false positives 
in unused-using-decls. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25437?vs=74239&id=74254#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25437

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@
   int t3 = 0;
   a.func1(&t3);
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
+
+// Test on Non-type template arguments.
+template 
+void i(n::P* t) {}
+template void i(n::P* t);


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 

[PATCH] D25238: [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init

2016-10-11 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283886: [clang-tidy] Ignore empty members and bases in 
cppcoreguidelines-pro-type… (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25238?vs=74125&id=74256#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25238

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) 
{
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext &Context, const QualType &Type) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext &Context, const CXXRecordDecl &ClassDecl,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -423,3 +423,30 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) {
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext &Context, const QualType &Type) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext &Context, const CXXRecordDecl &ClassDecl,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===

[clang-tools-extra] r283886 - [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init

2016-10-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Oct 11 09:49:24 2016
New Revision: 283886

URL: http://llvm.org/viewvc/llvm-project?rev=283886&view=rev
Log:
[clang-tidy] Ignore empty members and bases in 
cppcoreguidelines-pro-type-member-init

Summary: Empty/incomplete variables/members/bases don't need to be initialized

Reviewers: mgehre, aaron.ballman, alexfh

Subscribers: nemanjai, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=283886&r1=283885&r2=283886&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Oct 11 09:49:24 2016
@@ -317,6 +317,28 @@ void ProTypeMemberInitCheck::storeOption
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) 
{
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext &Context, const QualType &Type) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext &Context, const CXXRecordDecl &ClassDecl,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@ void ProTypeMemberInitCheck::checkMissin
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=283886&r1=283885&r2=283886&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Tue Oct 11 09:49:24 2016
@@ -423,3 +423,30 @@ UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUA
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};


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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-11 Thread Kirill Romanenkov via cfe-commits
kromanenkov created this revision.
kromanenkov added reviewers: zaks.anna, NoQ, dcoughlin.
kromanenkov added subscribers: a.sidorin, cfe-commits.

Add a new type of NonLoc SVal for pointer-to-member operations. This SVal 
supports both pointers to member functions and pointers to member data.


https://reviews.llvm.org/D25475

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/pointer-to-member.cpp

Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -35,8 +35,7 @@
   clang_analyzer_eval(&A::getPtr == &A::getPtr); // expected-warning{{TRUE}}
   clang_analyzer_eval(&A::getPtr == 0); // expected-warning{{FALSE}}
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{TRUE}}
 }
 
 namespace PR15742 {
@@ -72,11 +71,65 @@
 
   A::MemberPointer member = &A::m_ptr;
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(obj.*member == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(obj.*member == 0); // expected-warning{{TRUE}}
 
   member = 0;
 
   // FIXME: Should emit a null dereference.
   return obj.*member; // no-warning
 }
+
+namespace testPointerToMemberFunction {
+  struct A {
+virtual int foo() { return 1; }
+int bar() { return 2;  }
+  };
+
+  struct B : public A {
+virtual int foo() { return 3; }
+  };
+
+  typedef int (A::*AFnPointer)();
+  typedef int (B::*BFnPointer)();
+
+  void testPointerToMemberCasts() {
+AFnPointer AFP = &A::bar;
+BFnPointer StaticCastedBase2Derived = static_cast(&A::bar),
+   CCastedBase2Derived = (BFnPointer) (&A::bar);
+A a;
+B b;
+
+clang_analyzer_eval((a.*AFP)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval((b.*StaticCastedBase2Derived)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval(((b.*CCastedBase2Derived)() == 2)); // expected-warning{{TRUE}}
+  }
+
+  void testPointerToMemberVirtualCall() {
+A a;
+B b;
+A *APtr = &a;
+AFnPointer AFP = &A::foo;
+
+clang_analyzer_eval((APtr->*AFP)() == 1); // expected-warning{{TRUE}}
+
+APtr = &b;
+
+clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberFunction namespace
+
+namespace testPointerToMemberData {
+  struct A {
+int i;
+  };
+
+  void testPointerToMemberData() {
+int A::*AMdPointer = &A::i;
+A a;
+
+a.i = 42;
+a.*AMdPointer += 1;
+
+clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberData namespace
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -69,6 +69,9 @@
 
   bool isLocType = Loc::isLocType(castTy);
 
+  if (val.getAs())
+return val;
+
   if (Optional LI = val.getAs()) {
 if (isLocType)
   return LI->getLoc();
@@ -335,6 +338,21 @@
 switch (lhs.getSubKind()) {
 default:
   return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+case nonloc::PointerToMemberKind: {
+  assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
+ "Both SVals should have pointer-to-member-type");
+  const DeclaratorDecl *LDD =
+  lhs.castAs().getDecl(),
+  *RDD = rhs.castAs().getDecl();
+  switch (op) {
+case BO_EQ:
+  return makeTruthVal(LDD == RDD, resultTy);
+case BO_NE:
+  return makeTruthVal(LDD != RDD, resultTy);
+default:
+  return UnknownVal();
+  }
+}
 case nonloc::LocAsIntegerKind: {
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
@@ -857,6 +875,14 @@
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
   BinaryOperator::Opcode op,
   Loc lhs, NonLoc rhs, QualType resultTy) {
+  if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
+if (auto PTMSV = rhs.getAs())
+  if (const FieldDecl *FD = PTMSV->getDeclAs())
+return state->getLValue(FD, lhs);
+
+return rhs;
+  }
+
   assert(!BinaryOperator::isComparisonOp(op) &&
  "arguments to comparison ops must be of the same type");
 
Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===

r283887 - r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:09:26 2016
New Revision: 283887

URL: http://llvm.org/viewvc/llvm-project?rev=283887&view=rev
Log:
r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=283887&r1=283886&r2=283887&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 11 10:09:26 2016
@@ -9709,20 +9709,22 @@ void Sema::AddInitializerToDecl(Decl *Re
   // The previous definition is hidden, and multiple definitions are
   // permitted (in separate TUs). Form another definition of it.
 
-  // Demote the newly parsed definition to a fake declaration.
-  if (!VDecl->isThisDeclarationADemotedDefinition())
-VDecl->demoteThisDefinitionToDeclaration();
+  if (!isa(VDecl)) {
+// Demote the newly parsed definition to a fake declaration.
+if (!VDecl->isThisDeclarationADemotedDefinition())
+  VDecl->demoteThisDefinitionToDeclaration();
 
-  // Make the definition visible from the point of the demotion on.
-  assert (!Hidden || Def == Hidden &&
-  "We were suggested another hidden definition!");
-  makeMergedDefinitionVisible(Def, VDecl->getLocation());
+// Make the definition visible from the point of the demotion on.
+assert (!Hidden || Def == Hidden &&
+"We were suggested another hidden definition!");
+makeMergedDefinitionVisible(Def, VDecl->getLocation());
 
-  // If this is a variable template definition, make its enclosing template
-  // visible.
-  if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
-if (VarPattern->isThisDeclarationADefinition())
-  makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+// If this is a variable template definition, make its enclosing 
template
+// visible.
+if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
+  if (VarPattern->isThisDeclarationADefinition())
+makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+  }
 } else {
   Diag(VDecl->getLocation(), diag::err_redefinition)
 << VDecl->getDeclName();


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


r283888 - Use StringRef instead of raw pointer in SourceManagerInternals LineTableInfo API (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Tue Oct 11 10:15:32 2016
New Revision: 283888

URL: http://llvm.org/viewvc/llvm-project?rev=283888&view=rev
Log:
Use StringRef instead of raw pointer in SourceManagerInternals LineTableInfo 
API (NFC)

Modified:
cfe/trunk/include/clang/Basic/SourceManagerInternals.h

Modified: cfe/trunk/include/clang/Basic/SourceManagerInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManagerInternals.h?rev=283888&r1=283887&r2=283888&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManagerInternals.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManagerInternals.h Tue Oct 11 10:15:32 
2016
@@ -95,9 +95,9 @@ public:
   }
 
   unsigned getLineTableFilenameID(StringRef Str);
-  const char *getFilename(unsigned ID) const {
+  StringRef getFilename(unsigned ID) const {
 assert(ID < FilenamesByID.size() && "Invalid FilenameID");
-return FilenamesByID[ID]->getKeyData();
+return FilenamesByID[ID]->getKey();
   }
   unsigned getNumFilenames() const { return FilenamesByID.size(); }
 


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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Renato!

On Tue, Oct 11, 2016 at 3:36 AM, Renato Golin  wrote:
> On 11 October 2016 at 10:14, Renato Golin  wrote:
>> clang-4.0: warning: no such sysroot directory: '/FOO' [-Wmissing-sysroot]
>> error: unable to create target: 'No available targets are compatible
>> with this triple.'
>> 1 error generated.
>
> Reverted in r283868, as it was also breaking ARM bots.
>
> cheers,
> --renato



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25335: [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/partial_initializer.cl:5
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHEC:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 x 
float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 

Anastasia wrote:
> These could be moved down to each member.
Will do when committing. Thanks.


https://reviews.llvm.org/D25335



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


[PATCH] D25343: [OpenCL] Mark group functions as noduplicate in opencl-c.h

2016-10-11 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:

> Do you have any code example where Clang/LLVM performs wrong optimizations 
> with respect to the control flow of SPMD execution?
>
> My understanding from the earlier discussion we have had: 
> https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> noduplicate is essentially enough for the frontend to prevent erroneous 
> optimizations. Because in general compiler can't do much with unknown 
> function calls.


noduplicate is enough for correctness, but it prevents legal optimizations, 
like unrolling loops with barriers.  The convergent attribute was added 
specifically for these kinds of builtins, so we should be using it here instead 
of noduplicate.

> For LLVM intrinsics it is slightly different as I can deduce from this 
> discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . It 
> seems like by default it's assumed to be side effect free and can be 
> optimized in various ways.




https://reviews.llvm.org/D25343



___
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-11 Thread Steve O'Brien via cfe-commits
elsteveogrande updated this revision to Diff 74265.
elsteveogrande added a comment.

Thanks very much @vsk for the feedback!  Updated per your recommendations; 
`CHECK` looks much better


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,11 @@
+// RUN: %clang_cc1 -w -E -dI -isystem %S -imacros %S/dump_include.h %s -o - | FileCheck %s
+// CHECK: {{^}}#__include_macros "/{{([^/]+/)+}}dump_
+// CHECK: {{^}}#include 
+#include "dump_include.h"
+#include_next "dump_include.h"
Index: test/Preprocessor/dump_import.m
===
--- /dev/null
+++ test/Preprocessor/dump_import.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -dI %s -o - | FileCheck %s
+// CHECK: {{^}}#import "dump_
+
+// See also `dump_include.c` which tests other inclusion cases with `-dI`.
+
+#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,16 @@
   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 += "";
@@ -320,20 +323,20 @@
   StringRef SearchPath,
   StringRef RelativePath,
   const Module *Imported) {
-  // When preprocessing, turn implicit imports into @imports.
-  // FIXME: This is a stop-gap until a more comprehensive "preprocessing with
-  // modules" solution is introduced.
   if (Imported) {
+// When preprocessing, turn implicit imports into @imports.
+// FIXME: This is a stop-gap until a more comprehensive "preprocessing with
+// modules" solution is introduced.
 startNewLineIfNeeded();
 MoveToLine(HashLoc);
 if (PP.getLangOpts().ObjC2) {
   OS << "@import " << Imported->getFullModuleName() << ";"
  << " /* clang -E: implicit import for \"" << File->getName()
  << "\" */";
 } else {
-  // FIXME: Preseve whether this was a
-  // #include/#include_next/#include_macros/#import.
-  OS << "#include "
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
  << (IsAngled ? '<' : '"')
  << FileName
  << (IsAngled ? '>' : '"')
@@ -344,6 +347,18 @@
 // line immediately.
 EmittedTokensOnThisLine = true;
 startNewLineIfNeeded();
+  } else {
+// Not a module import; it's a more vanilla inclusion of some file using one
+// of: #include, #import, #include_next, #include_macros.
+if (DumpIncludeDirectives) {
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
+ << (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"')
+ << " /* clang -E -dI */";
+  setEmittedDirectiveOnThisLine();
+  startNewLineIfNeeded();
+}
   }
 }
 
@@ -751,7 +766,8 @@
   PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments);
 
   PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(
-  PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, Opts.UseLineDirectives);
+  PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros,
+  Opts.ShowIncludeDirectives, Opts.UseLineDirectives);
 
   // Expand macros in pragmas with -fms-extensions.  The assumption is that

[PATCH] D25479: Guard flag –fdenormal-fp-math with –fno-fast-math

2016-10-11 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: rengolin, jmolloy.
SjoerdMeijer added a subscriber: cfe-commits.

Guard the -fdenormal-fp-math with -fno-fast-math. This allows disabling the FP 
options with just one flag: –fno-fast-math.


https://reviews.llvm.org/D25479

Files:
  lib/Driver/Tools.cpp
  test/Driver/denormal-fp-math.c


Index: test/Driver/denormal-fp-math.c
===
--- test/Driver/denormal-fp-math.c
+++ test/Driver/denormal-fp-math.c
@@ -1,9 +1,11 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck 
-check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo 
-v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4390,11 +4390,16 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_fdenormal_fp_math_EQ))
+if (A->getOption().getID() != options::OPT_fno_fast_math &&
+A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations)
+  Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
 
   // Validate and pass through -fp-contract option.
   if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,


Index: test/Driver/denormal-fp-math.c
===
--- test/Driver/denormal-fp-math.c
+++ test/Driver/denormal-fp-math.c
@@ -1,9 +1,11 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4390,11 +4390,16 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_fdenormal_fp_math_EQ))
+if (A->getOption().getID() != options::OPT_fno_fast_math &&
+A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations)
+  Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
 
   // Validate and pass through -fp-contract option.
   if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283890 - Revert r283887 and r283882, until the issue is understood and fixed.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:51:06 2016
New Revision: 283890

URL: http://llvm.org/viewvc/llvm-project?rev=283890&view=rev
Log:
Revert r283887 and r283882, until the issue is understood and fixed.

Removed:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 10:51:06 2016
@@ -865,11 +865,6 @@ protected:
 
 unsigned : NumVarDeclBits;
 
-// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
-/// \brief Whether this variable is a definition which was demoted due to
-/// module merge.
-unsigned IsThisDeclarationADemotedDefinition : 1;
-
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1203,27 +1198,12 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
+
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
-  /// \brief If this definition should pretend to be a declaration.
-  bool isThisDeclarationADemotedDefinition() const {
-return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
-  }
-
-  /// \brief This is a definition which should be demoted to a declaration.
-  ///
-  /// In some cases (mostly module merging) we can end up with two visible
-  /// definitions one of which needs to be demoted to a declaration to keep
-  /// the AST invariants.
-  void demoteThisDefinitionToDeclaration() {
-assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
-assert (isThisDeclarationADefinition() && "Not a definition!");
-NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
-  }
-
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1322,10 +1302,6 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
-  /// \brief Retrieve the variable declaration from which this variable could
-  /// be instantiated, if it is an instantiation (rather than a non-template).
-  VarDecl *getTemplateInstantiationPattern() const;
-
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 10:51:06 2016
@@ -1926,9 +1926,6 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
-  if (isThisDeclarationADemotedDefinition())
-return DeclarationOnly;
-
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2253,56 +2250,6 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
-VarDecl *VarDecl::getTemplateInstantiationPattern() const {
-  // If it's a variable template specialization, find the template or partial
-  // specialization from which it was instantiated.
-  if (auto *VDTemplSpec = dyn_cast(this)) {
-auto From = VDTemplSpec->getInstantiatedFrom();
-if (auto *VTD = From.dyn_cast()) {
-  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
-if (NewVTD->isMemberSpecialization())
-  break;
-VTD = NewVTD;
-  }
-  return VTD->getTemplatedDecl()->getDefinition();
-}
-if (auto *VTPSD =
-From.dyn_cast()) {
-  while (auto *NewVTPSD = VTPSD->getInstantiatedFromMember()) {
-if (NewVTPSD->isMemberSpecialization())
-  break;
-VTPSD = NewVTPSD;
-  }
-  return VTPSD->getDefinition();
-}
-  }
-
-  if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
-if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
-  VarDecl *VD = getInstantiatedFromStat

r283891 - [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct 11 10:53:28 2016
New Revision: 283891

URL: http://llvm.org/viewvc/llvm-project?rev=283891&view=rev
Log:
[OpenCL] Allow partial initializer for array and struct

Currently Clang allows partial initializer for C99 but not for OpenCL, e.g.

float a[16][16] = {1.0f, 2.0f};

is allowed in C99 but not allowed in OpenCL.

This patch fixes that.

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

Added:
cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=283891&r1=283890&r2=283891&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Oct 11 10:53:28 2016
@@ -1238,8 +1238,9 @@ void InitListChecker::CheckSubElementTyp
   //   subaggregate, brace elision is assumed and the initializer is
   //   considered for the initialization of the first member of
   //   the subaggregate.
-  if (!SemaRef.getLangOpts().OpenCL && 
-  (ElemType->isAggregateType() || ElemType->isVectorType())) {
+  // OpenCL vector initializer is handled elsewhere.
+  if ((!SemaRef.getLangOpts().OpenCL && ElemType->isVectorType()) ||
+  ElemType->isAggregateType()) {
 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
   StructuredIndex);
 ++StructuredIndex;

Added: cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl?rev=283891&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl Tue Oct 11 10:53:28 2016
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s 
-O0 -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(2) ))  int int2;
+typedef __attribute__(( ext_vector_type(4) ))  int int4;
+
+// CHECK: %struct.StrucTy = type { i32, i32, i32 }
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHECK:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 
x float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 
+float GA[6][6]  = {1.0f, 2.0f};
+
+typedef struct {
+  int x;
+  int y;
+  int z;
+} StrucTy;
+
+// CHECK: @GS = addrspace(1) global %struct.StrucTy { i32 1, i32 2, i32 0 }, 
align 4
+StrucTy GS = {1, 2};
+
+// CHECK: @GV1 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV1 = (int4)((int2)(1,2),3,4);
+
+// CHECK: @GV2 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV2 = (int4)(1);
+
+// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, 
i32 0 }, align 4
+
+// CHECK-LABEL: define spir_func void @f()
+void f(void) {
+  // CHECK: %[[A:.*]] = alloca [6 x [6 x float]], align 4
+  // CHECK: %[[S:.*]] = alloca %struct.StrucTy, align 4
+  // CHECK: %[[V1:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral1:.*]] = alloca <2 x i32>, align 8
+  // CHECK: %[[V2:.*]] = alloca <4 x i32>, align 16
+
+  // CHECK: %[[v0:.*]] = bitcast [6 x [6 x float]]* %A to i8*
+  // CHECK: call void @llvm.memset.p0i8.i32(i8* %[[v0]], i8 0, i32 144, i32 4, 
i1 false)
+  // CHECK: %[[v1:.*]] = bitcast i8* %[[v0]] to [6 x [6 x float]]*
+  // CHECK: %[[v2:.*]] = getelementptr [6 x [6 x float]], [6 x [6 x float]]* 
%[[v1]], i32 0, i32 0
+  // CHECK: %[[v3:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 0
+  // CHECK: store float 1.00e+00, float* %[[v3]]
+  // CHECK: %[[v4:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 1
+  // CHECK: store float 2.00e+00, float* %[[v4]]
+  float A[6][6]  = {1.0f, 2.0f};
+
+  // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast 
(%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false)
+  StrucTy S = {1, 2};
+
+  // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[v6:.*]] = load <2 x i32>, <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[vext:.*]] = shufflevector <2 x i32> %[[v6]], <2 x i32> undef, 
<4 x i32> 
+  // CHECK: %[[vecinit:.*]] = shufflevector <4 x i32> %[[vext]], <4 x i32> 
undef, <4 x i32> 
+  // CHECK: %[[vecinit2:.*]] = insertelement <4 x i32> %[[vecinit]], i32 3, 
i32 2
+  // CHECK: %[[vecinit3:.*]] = insertelement <4 x i32> %[[vecinit2]], i32 4, 
i32 3
+  // CHECK: store <4 x i32> %[[vecinit3]], <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: %[[v7:.*]] = load <4 x i32>

[PATCH] D25335: [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283891: [OpenCL] Allow partial initializer for array and 
struct (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D25335?vs=73818&id=74266#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25335

Files:
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl


Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -1238,8 +1238,9 @@
   //   subaggregate, brace elision is assumed and the initializer is
   //   considered for the initialization of the first member of
   //   the subaggregate.
-  if (!SemaRef.getLangOpts().OpenCL && 
-  (ElemType->isAggregateType() || ElemType->isVectorType())) {
+  // OpenCL vector initializer is handled elsewhere.
+  if ((!SemaRef.getLangOpts().OpenCL && ElemType->isVectorType()) ||
+  ElemType->isAggregateType()) {
 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
   StructuredIndex);
 ++StructuredIndex;
Index: cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
===
--- cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
+++ cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s 
-O0 -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(2) ))  int int2;
+typedef __attribute__(( ext_vector_type(4) ))  int int4;
+
+// CHECK: %struct.StrucTy = type { i32, i32, i32 }
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHECK:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 
x float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 
+float GA[6][6]  = {1.0f, 2.0f};
+
+typedef struct {
+  int x;
+  int y;
+  int z;
+} StrucTy;
+
+// CHECK: @GS = addrspace(1) global %struct.StrucTy { i32 1, i32 2, i32 0 }, 
align 4
+StrucTy GS = {1, 2};
+
+// CHECK: @GV1 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV1 = (int4)((int2)(1,2),3,4);
+
+// CHECK: @GV2 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV2 = (int4)(1);
+
+// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, 
i32 0 }, align 4
+
+// CHECK-LABEL: define spir_func void @f()
+void f(void) {
+  // CHECK: %[[A:.*]] = alloca [6 x [6 x float]], align 4
+  // CHECK: %[[S:.*]] = alloca %struct.StrucTy, align 4
+  // CHECK: %[[V1:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral1:.*]] = alloca <2 x i32>, align 8
+  // CHECK: %[[V2:.*]] = alloca <4 x i32>, align 16
+
+  // CHECK: %[[v0:.*]] = bitcast [6 x [6 x float]]* %A to i8*
+  // CHECK: call void @llvm.memset.p0i8.i32(i8* %[[v0]], i8 0, i32 144, i32 4, 
i1 false)
+  // CHECK: %[[v1:.*]] = bitcast i8* %[[v0]] to [6 x [6 x float]]*
+  // CHECK: %[[v2:.*]] = getelementptr [6 x [6 x float]], [6 x [6 x float]]* 
%[[v1]], i32 0, i32 0
+  // CHECK: %[[v3:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 0
+  // CHECK: store float 1.00e+00, float* %[[v3]]
+  // CHECK: %[[v4:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 1
+  // CHECK: store float 2.00e+00, float* %[[v4]]
+  float A[6][6]  = {1.0f, 2.0f};
+
+  // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast 
(%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false)
+  StrucTy S = {1, 2};
+
+  // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[v6:.*]] = load <2 x i32>, <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[vext:.*]] = shufflevector <2 x i32> %[[v6]], <2 x i32> undef, 
<4 x i32> 
+  // CHECK: %[[vecinit:.*]] = shufflevector <4 x i32> %[[vext]], <4 x i32> 
undef, <4 x i32> 
+  // CHECK: %[[vecinit2:.*]] = insertelement <4 x i32> %[[vecinit]], i32 3, 
i32 2
+  // CHECK: %[[vecinit3:.*]] = insertelement <4 x i32> %[[vecinit2]], i32 4, 
i32 3
+  // CHECK: store <4 x i32> %[[vecinit3]], <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: %[[v7:.*]] = load <4 x i32>, <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: store <4 x i32> %[[v7]], <4 x i32>* %[[V1]], align 16
+  int4 V1 = (int4)((int2)(1,2),3,4);
+
+  // CHECK: store <4 x i32> , <4 x i32>* %[[V2]], 
align 16
+  int4 V2 = (int4)(1);
+}
+


Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -1238,8 +1238,9 @@
   //   subaggregate, brace elision is ass

r283895 - Fix clang-offload-bundler test.

2016-10-11 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Tue Oct 11 11:06:32 2016
New Revision: 283895

URL: http://llvm.org/viewvc/llvm-project?rev=283895&view=rev
Log:
Fix clang-offload-bundler test.

A recent change to llvm::cl slightly changed the format of
the help output, and it broke this test.  NFC

Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=283895&r1=283894&r2=283895&view=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Tue Oct 11 11:06:32 2016
@@ -31,7 +31,7 @@
 // CK-HELP: {{.*}}referring to the same source file but different targets into 
a single
 // CK-HELP: {{.*}}one. The resulting file can also be unbundled into different 
files by
 // CK-HELP: {{.*}}this tool if -unbundle is provided.
-// CK-HELP: {{.*}}USAGE: clang-offload-bundler [subcommand] [options]
+// CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
 // CK-HELP: {{.*}}-inputs=  - [,...]
 // CK-HELP: {{.*}}-outputs= - [,...]
 // CK-HELP: {{.*}}-targets= - [-,...]


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


Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Reid Kleckner via cfe-commits
Can we figure out why having an incremental stage1 is problematic? I want
to keep it that way to speed up the bot.

It sounds like the problem is that we do not delete the stage1 install
directory before installing to it, or our install step uses a glob that may
include stale files from previous builds.

On Mon, Oct 10, 2016 at 8:56 AM, Justin Lebar  wrote:

> As discussed over IM, builds are still failing after reverting this.
>
> The issue seems to be that the stage 1 build in bootstrap compiles is
> not a clean build.  Therefore the errant  and 
> headers are never removed from the install directory.
>
> I believe I fixed the cmake in r283683 (sent a few hours after this
> one), but because the stage 1 builds are not clean, they were still
> broken after that change.
>
> Easiest fix at this point would be to find someone with ssh access to
> the buildbots to rm -rf the stage 1 directory.
>
> On Mon, Oct 10, 2016 at 7:19 AM, Nico Weber  wrote:
> > This broke bootstrap builds, I reverted it for now in r283747.
> >
> > On Sat, Oct 8, 2016 at 6:16 PM, Justin Lebar via cfe-commits
> >  wrote:
> >>
> >> Author: jlebar
> >> Date: Sat Oct  8 17:16:12 2016
> >> New Revision: 283680
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283680&view=rev
> >> Log:
> >> [CUDA] Support  and std::min/max on the device.
> >>
> >> Summary:
> >> We do this by wrapping  and .
> >>
> >> Tests are in the test-suite.
> >>
> >> Reviewers: tra
> >>
> >> Subscribers: jhen, beanz, cfe-commits, mgorny
> >>
> >> Differential Revision: https://reviews.llvm.org/D24979
> >>
> >> Added:
> >> cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
> >> cfe/trunk/lib/Headers/cuda_wrappers/
> >> cfe/trunk/lib/Headers/cuda_wrappers/algorithm
> >> cfe/trunk/lib/Headers/cuda_wrappers/complex
> >> Modified:
> >> cfe/trunk/lib/Driver/ToolChains.cpp
> >> cfe/trunk/lib/Headers/CMakeLists.txt
> >> cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
> >>
> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains.cpp?rev=283680&r1=283679&r2=283680&view=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Oct  8 17:16:12 2016
> >> @@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
> >>
> >>  void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
> >> ArgStringList &CC1Args) const {
> >> +  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
> >> +// Add cuda_wrappers/* to our system include path.  This lets us
> wrap
> >> +// standard library headers.
> >> +SmallString<128> P(getDriver().ResourceDir);
> >> +llvm::sys::path::append(P, "include");
> >> +llvm::sys::path::append(P, "cuda_wrappers");
> >> +addSystemInclude(DriverArgs, CC1Args, P);
> >> +  }
> >> +
> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
> >>  return;
> >>
> >>
> >> Modified: cfe/trunk/lib/Headers/CMakeLists.txt
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> CMakeLists.txt?rev=283680&r1=283679&r2=283680&view=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Headers/CMakeLists.txt (original)
> >> +++ cfe/trunk/lib/Headers/CMakeLists.txt Sat Oct  8 17:16:12 2016
> >> @@ -24,10 +24,13 @@ set(files
> >>bmiintrin.h
> >>__clang_cuda_builtin_vars.h
> >>__clang_cuda_cmath.h
> >> +  __clang_cuda_complex_builtins.h
> >>__clang_cuda_intrinsics.h
> >>__clang_cuda_math_forward_declares.h
> >>__clang_cuda_runtime_wrapper.h
> >>cpuid.h
> >> +  cuda_wrappers/algorithm
> >> +  cuda_wrappers/complex
> >>clflushoptintrin.h
> >>emmintrin.h
> >>f16cintrin.h
> >>
> >> Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> __clang_cuda_complex_builtins.h?rev=283680&view=auto
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h (added)
> >> +++ cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h Sat Oct  8
> >> 17:16:12 2016
> >> @@ -0,0 +1,203 @@
> >> +/*===-- __clang_cuda_complex_builtins - CUDA impls of runtime complex
> fns
> >> ---===
> >> + *
> >> + * Permission is hereby granted, free of charge, to any person
> obtaining
> >> a copy
> >> + * of this software and associated documentation files (the
> "Software"),
> >> to deal
> >> + * in the Software without restriction, including without limitation
> the
> >> rights
> >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> >> sell
> >> + * copies of the Software, and to permit persons to whom the Software
> is
> >> + * furnished to do so, subject to the following conditions:

[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

2016-10-11 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D25436



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


Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Justin Lebar via cfe-commits
> Can we figure out why having an incremental stage1 is problematic? I want to 
> keep it that way to speed up the bot.

The problem is that the cmake install rule that we use does not remove
extra files that happen to be present in the install directory.  So if
you put something bad in there, as I did, it's never coming out.

I spent a few hours trying to figure out how to do this yesterday to no avail.

But it would be nice not to block this change on fixing our cmake
rules, especially if the relevant expertise is hard to come by.

On Tue, Oct 11, 2016 at 9:31 AM, Reid Kleckner  wrote:
> Can we figure out why having an incremental stage1 is problematic? I want to
> keep it that way to speed up the bot.
>
> It sounds like the problem is that we do not delete the stage1 install
> directory before installing to it, or our install step uses a glob that may
> include stale files from previous builds.
>
> On Mon, Oct 10, 2016 at 8:56 AM, Justin Lebar  wrote:
>>
>> As discussed over IM, builds are still failing after reverting this.
>>
>> The issue seems to be that the stage 1 build in bootstrap compiles is
>> not a clean build.  Therefore the errant  and 
>> headers are never removed from the install directory.
>>
>> I believe I fixed the cmake in r283683 (sent a few hours after this
>> one), but because the stage 1 builds are not clean, they were still
>> broken after that change.
>>
>> Easiest fix at this point would be to find someone with ssh access to
>> the buildbots to rm -rf the stage 1 directory.
>>
>> On Mon, Oct 10, 2016 at 7:19 AM, Nico Weber  wrote:
>> > This broke bootstrap builds, I reverted it for now in r283747.
>> >
>> > On Sat, Oct 8, 2016 at 6:16 PM, Justin Lebar via cfe-commits
>> >  wrote:
>> >>
>> >> Author: jlebar
>> >> Date: Sat Oct  8 17:16:12 2016
>> >> New Revision: 283680
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=283680&view=rev
>> >> Log:
>> >> [CUDA] Support  and std::min/max on the device.
>> >>
>> >> Summary:
>> >> We do this by wrapping  and .
>> >>
>> >> Tests are in the test-suite.
>> >>
>> >> Reviewers: tra
>> >>
>> >> Subscribers: jhen, beanz, cfe-commits, mgorny
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D24979
>> >>
>> >> Added:
>> >> cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
>> >> cfe/trunk/lib/Headers/cuda_wrappers/
>> >> cfe/trunk/lib/Headers/cuda_wrappers/algorithm
>> >> cfe/trunk/lib/Headers/cuda_wrappers/complex
>> >> Modified:
>> >> cfe/trunk/lib/Driver/ToolChains.cpp
>> >> cfe/trunk/lib/Headers/CMakeLists.txt
>> >> cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
>> >>
>> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=283680&r1=283679&r2=283680&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Oct  8 17:16:12 2016
>> >> @@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
>> >>
>> >>  void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
>> >> ArgStringList &CC1Args) const {
>> >> +  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
>> >> +// Add cuda_wrappers/* to our system include path.  This lets us
>> >> wrap
>> >> +// standard library headers.
>> >> +SmallString<128> P(getDriver().ResourceDir);
>> >> +llvm::sys::path::append(P, "include");
>> >> +llvm::sys::path::append(P, "cuda_wrappers");
>> >> +addSystemInclude(DriverArgs, CC1Args, P);
>> >> +  }
>> >> +
>> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
>> >>  return;
>> >>
>> >>
>> >> Modified: cfe/trunk/lib/Headers/CMakeLists.txt
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=283680&r1=283679&r2=283680&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Headers/CMakeLists.txt (original)
>> >> +++ cfe/trunk/lib/Headers/CMakeLists.txt Sat Oct  8 17:16:12 2016
>> >> @@ -24,10 +24,13 @@ set(files
>> >>bmiintrin.h
>> >>__clang_cuda_builtin_vars.h
>> >>__clang_cuda_cmath.h
>> >> +  __clang_cuda_complex_builtins.h
>> >>__clang_cuda_intrinsics.h
>> >>__clang_cuda_math_forward_declares.h
>> >>__clang_cuda_runtime_wrapper.h
>> >>cpuid.h
>> >> +  cuda_wrappers/algorithm
>> >> +  cuda_wrappers/complex
>> >>clflushoptintrin.h
>> >>emmintrin.h
>> >>f16cintrin.h
>> >>
>> >> Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h?rev=283680&view=auto
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h (added)

Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Reid Kleckner via cfe-commits
On Tue, Oct 11, 2016 at 9:34 AM, Justin Lebar  wrote:

> > Can we figure out why having an incremental stage1 is problematic? I
> want to keep it that way to speed up the bot.
>
> The problem is that the cmake install rule that we use does not remove
> extra files that happen to be present in the install directory.  So if
> you put something bad in there, as I did, it's never coming out.
>
> I spent a few hours trying to figure out how to do this yesterday to no
> avail.
>
> But it would be nice not to block this change on fixing our cmake
> rules, especially if the relevant expertise is hard to come by.


Sure. I don't think the "install" step is expensive. We should be able to
fix this problem going forward by changing our bot config to clean out the
installation directory before the install step.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl updated this revision to Diff 74269.

https://reviews.llvm.org/D24669

Files:
  llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/CodeGen/vecshift.c
  llvm/tools/clang/test/Sema/vecshift.c

Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8784,6 +8784,16 @@
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT &&
+  S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) {
+S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+<< LHS.get()->getType() << RHS.get()->getType()
+<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =
Index: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2301,6 +2301,9 @@
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
Index: llvm/tools/clang/test/CodeGen/vecshift.c
===
--- llvm/tools/clang/test/CodeGen/vecshift.c
+++ llvm/tools/clang/test/CodeGen/vecshift.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -DEXT -emit-llvm %s -o - | FileCheck %s
 
+#ifdef EXT
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
 typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
@@ -12,6 +14,20 @@
 typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;
+#else
+typedef __attribute__((vector_size(8))) char vector_char8;
+typedef __attribute__((vector_size(16))) short vector_short8;
+typedef __attribute__((vector_size(32))) int vector_int8;
+typedef __attribute__((vector_size(8))) unsigned char vector_uchar8;
+typedef __attribute__((vector_size(16))) unsigned short vector_ushort8;
+typedef __attribute__((vector_size(32))) unsigned int vector_uint8;
+typedef __attribute__((vector_size(4))) char vector_char4;
+typedef __attribute__((vector_size(4))) short vector_short4;
+typedef __attribute__((vector_size(16))) int vector_int4;
+typedef __attribute__((vector_size(4))) unsigned char vector_uchar4;
+typedef __attribute__((vector_size(8))) unsigned short vector_ushort4;
+typedef __attribute__((vector_size(16))) unsigned int vector_uint4;
+#endif
 
 char c;
 short s;
Index: llvm/tools/clang/test/Sema/vecshift.c
===
--- llvm/tools/clang/test/Sema/vecshift.c
+++ llvm/tools/clang/test/Sema/vecshift.c
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-error-vec-elem-size -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DEXT -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DEXT -Wno-error-vec-elem-size -verify %s
 
+#ifdef EXT
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
 typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
@@ -12,6 +16,20 @@
 typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;
+#else
+typedef __attribute__((vector_size(8))) char vector_char8;
+typedef __attribute__((vector_size(16))) short vector_short8;
+typedef __attribute__((vector_size(32))) int vector_int8;
+typedef __attribute__((vector_size(8))) unsigned char vector_uchar8;
+typedef __attribute__((v

[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

bruno wrote:
> vbyakovlcl wrote:
> > bruno wrote:
> > > Besides `__ext_vector_type__`, would this also trigger for `vector_size`? 
> > > Right now this is an error for `vector_size` primarily because the number 
> > > of elements is different, can you confirm this won't change?
> > I compare vector element sizes, so there must not be any differencies 
> > caused by different triggers. I added additional type definitions to the 
> > tests. All compiles fain.
> 
> I don't think this is right. When I try to compile similar code for 
> `vector_size` without your patch, I get the errors:
> 
> /tmp/x.c:80:15: error: vector operands do not have the same number of 
> elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> (vector of 8 'unsigned char' values))
>   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have the 
> same elements sizes}}
>   ^  ~
> /tmp/x.c:81:17: error: vector operands do not have the same number of 
> elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> 'vector_int8n' (vector of 2 'int' values))
>   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^  
> /tmp/x.c:82:17: error: vector operands do not have the same number of 
> elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> 'vector_uint8n' (vector of 2 'unsigned int' values))
>   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^  ~
> /tmp/x.c:83:17: error: vector operands do not have the same number of 
> elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> 'vector_short8n' (vector of 4 'short' values))
>   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^   
> 
> Given your test changes, it seems that now, instead of "vector operands do 
> not have the same number of elements" we would get "vector operands do not 
> have the same elements sizes". I rather we stay with the first. Additionally, 
> even if we had "vector operands do not have the same elements sizes" for 
> `vector_size`, this should never be demoted to a warning.
Argument of a GNU vector size attribute specifies vector size measured in 
bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So you 
got right diagnostics. Both compilers with and without my changes print the 
same diagnostics  for yours case. Here is a small testcase used both GNU and 
clang extensions

$ cat bruno.c   

 
typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
 
typedef __attribute__((vector_size(8))) int vector_int8n;
typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
 
vector_int8  vi8;
vector_uchar8 vuc8;
vector_int8n  vi8n;
vector_uchar8n vuc8n;
 
int foo() {
  vi8 = vi8 << vuc8;
  vi8n = vi8n << vuc8n;

$ clang -c bruno.c -Wno-error-vec-elem-size 

 
bruno.c:13:13: warning: vector operands do not have the same elements sizes 
('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
'unsigned char' values)) [-Wvec-elem-size]
  vi8 = vi8 << vuc8;
~~~ ^  
bruno.c:14:15: error: vector operands do not have the same number of elements 
('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' (vector of 8 
'unsigned char' values))
  vi8n = vi8n << vuc8n;

The compiler without the changes prints the second error only (bruno.c:14:15).



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8795-8798
+if (S.Diags.getDiagnosticLevel(
+diag::warn_typecheck_vector_element_sizes_not_equal, Loc) ==
+DiagnosticsEngine::Level::Error)
+  return QualType();

majnemer wrote:
> Why `return QualType()` here? Would returning `LHSType` provide confusing or 
> incorrect diagnostics?
This is really excessive. Thanks.


https://reviews.llvm.org/D24669



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


[PATCH] D25244: [clang-tidy] Add a whitelist option in google-runtime-references.

2016-10-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/google/NonConstReferences.cpp:73
+   [&](llvm::StringRef WhiteListType) {
+ return ReferencedType.getCanonicalType().getAsString(
+Result.Context->getPrintingPolicy()) ==

It should be possible to check the whitelist in the matcher 
(`qualType(unless(anyOf(isConstQualified(), 
hasDeclaration(namedDecl(hasAnyName(WhiteListTypes))` or something similar).


https://reviews.llvm.org/D25244



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


Re: r283856 - Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)

2016-10-11 Thread Reid Kleckner via cfe-commits
This breaks MSVC 2013 builds:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/30238/steps/run%20tests/logs/stdio

FAILED:
tools/clang/lib/Frontend/CMakeFiles/clangFrontend.dir/CacheTokens.cpp.obj
...
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(63)
: error C2620: '`anonymous-namespace'::PTHEntryKeyVariant::Path' : illegal
union member; type 'llvm::StringRef' has a user-defined constructor or
non-trivial default constructor
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(71)
: error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member
initialization: 'Path' is not a base or member
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(74)
: error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member
initialization: 'Path' is not a base or member
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(80)
: error C2065: 'Path' : undeclared identifier

On Tue, Oct 11, 2016 at 12:31 AM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Tue Oct 11 02:31:29 2016
> New Revision: 283856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283856&view=rev
> Log:
> Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)
>
> Modified:
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/FileSystemStatCache.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/FileSystemStatCache.cpp
> cfe/trunk/lib/Frontend/CacheTokens.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PTHLexer.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>
> Modified: cfe/trunk/include/clang/Basic/FileManager.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/FileManager.h?rev=283856&r1=283855&r2=283856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> +++ cfe/trunk/include/clang/Basic/FileManager.h Tue Oct 11 02:31:29 2016
> @@ -38,11 +38,10 @@ class FileSystemStatCache;
>  /// \brief Cached information about one directory (either on disk or in
>  /// the virtual file system).
>  class DirectoryEntry {
> -  const char *Name;   // Name of the directory.
> +  StringRef Name; // Name of the directory.
>friend class FileManager;
>  public:
> -  DirectoryEntry() : Name(nullptr) {}
> -  const char *getName() const { return Name; }
> +  StringRef getName() const { return Name; }
>  };
>
>  /// \brief Cached information about one file (either on disk
> @@ -165,7 +164,7 @@ class FileManager : public RefCountedBas
>// Caching.
>std::unique_ptr StatCache;
>
> -  bool getStatValue(const char *Path, FileData &Data, bool isFile,
> +  bool getStatValue(StringRef Path, FileData &Data, bool isFile,
>  std::unique_ptr *F);
>
>/// Add all ancestors of the given path (pointing to either a file
>
> Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> FileSystemStatCache.h?rev=283856&r1=283855&r2=283856&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original)
> +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Oct 11
> 02:31:29 2016
> @@ -68,7 +68,7 @@ public:
>/// success for directories (not files).  On a successful file lookup,
> the
>/// implementation can optionally fill in \p F with a valid \p File
> object and
>/// the client guarantees that it will close it.
> -  static bool get(const char *Path, FileData &Data, bool isFile,
> +  static bool get(StringRef Path, FileData &Data, bool isFile,
>std::unique_ptr *F, FileSystemStatCache
> *Cache,
>vfs::FileSystem &FS);
>
> @@ -92,11 +92,11 @@ protected:
>// FIXME: The pointer here is a non-owning/optional reference to the
>// unique_ptr. Optional&> might be nicer, but
>// Optional needs some work to support references so this isn't
> possible yet.
> -  virtual LookupResult getStat(const char *Path, FileData &Data, bool
> isFile,
> +  virtual LookupResult getStat(StringRef Path, FileData &Data, bool
> isFile,
> std::unique_ptr *F,
> vfs::FileSystem &FS) = 0;
>
> -  LookupResult statChained(const char *Path, FileData &Data, bool isFile,
> +  LookupResult statChained(StringRef Path, FileData &Data, bool isFile,
> std::unique_ptr *F, vfs::FileSystem
> &FS) {
>  if (FileSystemStatCache *Next = getNextStatCache())
>return Next->getStat(Path, Data, isFile, F, FS);
> @@ -121,7 +121,7 @@ public:
>iterator begin() const { return StatCalls.begin(); }
>iterator end() const { return StatCalls.end(); }
>
> -  LookupResult g

Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 16:34, Bruno Cardoso Lopes
 wrote:
> Thanks Renato!

So, Daniel Jasper did a trick on r283853 (clang || true) to make it
not fail when it returns on error. However, I wasn't able to make it
return anything but 0, so I'm at odds why this fails on the bot.

I was expecting it to actually return non-zero, since it emits an
error, which is even weirder. So, using "not clang" doesn't work in
this case. Do you have any ideas why this behaviour is like that?

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


[PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

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



Comment at: include/clang/Basic/Attr.td:1469
+  let Spellings = [CXX11<"clang", "suppress">, CXX11<"gsl", "suppress">];
+  let Args = [VariadicStringArgument<"Rules">];
+  let Documentation = [SuppressDocs];

Perhaps we should name this something other than "Rules" -- you don't suppress 
a rule, you're suppressing a diagnostic based on some identifier, so I'd go 
with `DiagnosticIdentifiers` or something along those lines.



Comment at: include/clang/Basic/AttrDocs.td:2509
+to suppress specific clang-tidy warnings. They can be attached to a scope,
+statement or type. The ``[[gsl::suppress]]`` is an alias of 
``[[clang::suppress]]``
+which is intended to be used for suppressing rules of the C++ Core Guidelines_

This statement does not match the test cases -- it does not appear to be 
possible to attach the attribute to a type.


https://reviews.llvm.org/D24886



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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

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



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

mgehre wrote:
> aaron.ballman wrote:
> > Hmm, it seems like this is boilerplate we are going to want for every rule, 
> > and that it's pretty easy to not get this right (for instance, if you 
> > change the way the check is spelled, you have to remember to update this as 
> > well). Could this actually be handled more transparently, by gathering this 
> > information when the check is registered and exposing it to the check?
> > 
> > The checks would still need to use `unless(isSuppressed(Rules))` in some 
> > form, but I am thinking that it would be more convenient if we could do: 
> > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> >  this);`
> I see multiple ways on how to integrate that into clang-tidy:
> 1) Add something like you proposed to each matcher of each check
> 2) Change (or add overload of)
> ```
>  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
>  DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
> ```
> to add a AST node as parameter and make the SourceLocation optional. Most 
> checks anyhow
> call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> "...").
> Diag then would check from the that AST node upwards to see if it finds a 
> matching [[suppress]] attribute
> 
> 3) Change the RecursiveASTVistor that drives the AST Matches to prune certain 
> matchers from the list of to-be-evaluated matchers
> for all AST subtrees that are below a certain [[suppress]] attribute. (This 
> is based on how I image that the AST matchers work)
Ideally, I would like to see this attribute used to suppress Clang diagnostics 
as well, however. So while I think Option 2 is better suited to that future 
direction, it's still not ideal because all instances of diag() need to be 
updated to take advantage. Options 1 and 3 are basically limited to clang-tidy 
use.

I wonder if there's a way to modify the diagnostic builder to transparently 
handle this without requiring modifying all of the call sites?



Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

mgehre wrote:
> aaron.ballman wrote:
> > Why is the check for `hasAttrs` required?
> > 
> > Also, this use of `hasAncestor()` makes this expensive to use, and that 
> > expense may be hidden from the caller. Is there a way to structure this so 
> > that we don't need to walk the entire ancestor tree?
> hasAttr() is needed here, because inside of hasSuppressAttr(), we call 
> getAttrs() which would assert if hasAttr() is false.
> I cannot push hasAttr() into hasSuppressAttr(), because hasSuppressAttr() is 
> a template getting either Decl or AttributedStmt,
> and AttributedStmt does not have an hasAttr() method.
I believe that `getSpecificAttr` should be resilient to no attributes being 
present (since it also has to handle the case there are no attributes of the 
specific type, so no attributes at all is simply a degenerate case), and so the 
check for `hasAttrs()` should be redundant.


https://reviews.llvm.org/D24888



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


r283906 - Fix the build with MSVC 2013 after r283856

2016-10-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Oct 11 12:24:09 2016
New Revision: 283906

URL: http://llvm.org/viewvc/llvm-project?rev=283906&view=rev
Log:
Fix the build with MSVC 2013 after r283856

Modified:
cfe/trunk/lib/Frontend/CacheTokens.cpp

Modified: cfe/trunk/lib/Frontend/CacheTokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CacheTokens.cpp?rev=283906&r1=283905&r2=283906&view=diff
==
--- cfe/trunk/lib/Frontend/CacheTokens.cpp (original)
+++ cfe/trunk/lib/Frontend/CacheTokens.cpp Tue Oct 11 12:24:09 2016
@@ -60,8 +60,10 @@ public:
 class PTHEntryKeyVariant {
   union {
 const FileEntry *FE;
-StringRef Path;
+// FIXME: Use "StringRef Path;" when MSVC 2013 is dropped.
+const char *PathPtr;
   };
+  size_t PathSize;
   enum { IsFE = 0x1, IsDE = 0x2, IsNoExist = 0x0 } Kind;
   FileData *Data;
 
@@ -69,15 +71,17 @@ public:
   PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(nullptr) 
{}
 
   PTHEntryKeyVariant(FileData *Data, StringRef Path)
-  : Path(Path), Kind(IsDE), Data(new FileData(*Data)) {}
+  : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsDE),
+Data(new FileData(*Data)) {}
 
   explicit PTHEntryKeyVariant(StringRef Path)
-  : Path(Path), Kind(IsNoExist), Data(nullptr) {}
+  : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsNoExist),
+Data(nullptr) {}
 
   bool isFile() const { return Kind == IsFE; }
 
   StringRef getString() const {
-return Kind == IsFE ? FE->getName() : Path;
+return Kind == IsFE ? FE->getName() : StringRef(PathPtr, PathSize);
   }
 
   unsigned getKind() const { return (unsigned) Kind; }


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


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Tania Albarghouthi via cfe-commits
taniabarg created this revision.
taniabarg added reviewers: davidsh, hubert.reinterpretcast.
taniabarg added a subscriber: cfe-commits.

BIF fpclassify has the wrong number of integer parameters specified in 
Builtins.def. There should be 5 int parameters (each representing the values 
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL and FP_ZERO) but Builtins.def 
previously specified 4.


https://reviews.llvm.org/D25480

Files:
  include/clang/Basic/Builtins.def


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -367,7 +367,7 @@
 BUILTIN(__builtin_isunordered   , "i.", "Fnc")

 // Unary FP classification
-BUILTIN(__builtin_fpclassify, "i.", "Fnc")
+BUILTIN(__builtin_fpclassify, "ii.", "Fnc")
 BUILTIN(__builtin_isfinite,   "i.", "Fnc")
 BUILTIN(__builtin_isinf,  "i.", "Fnc")
 BUILTIN(__builtin_isinf_sign, "i.", "Fnc")


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -367,7 +367,7 @@
 BUILTIN(__builtin_isunordered   , "i.", "Fnc")

 // Unary FP classification
-BUILTIN(__builtin_fpclassify, "i.", "Fnc")
+BUILTIN(__builtin_fpclassify, "ii.", "Fnc")
 BUILTIN(__builtin_isfinite,   "i.", "Fnc")
 BUILTIN(__builtin_isinf,  "i.", "Fnc")
 BUILTIN(__builtin_isinf_sign, "i.", "Fnc")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

vbyakovlcl wrote:
> bruno wrote:
> > vbyakovlcl wrote:
> > > bruno wrote:
> > > > Besides `__ext_vector_type__`, would this also trigger for 
> > > > `vector_size`? Right now this is an error for `vector_size` primarily 
> > > > because the number of elements is different, can you confirm this won't 
> > > > change?
> > > I compare vector element sizes, so there must not be any differencies 
> > > caused by different triggers. I added additional type definitions to the 
> > > tests. All compiles fain.
> > 
> > I don't think this is right. When I try to compile similar code for 
> > `vector_size` without your patch, I get the errors:
> > 
> > /tmp/x.c:80:15: error: vector operands do not have the same number of 
> > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > (vector of 8 'unsigned char' values))
> >   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ^  ~
> > /tmp/x.c:81:17: error: vector operands do not have the same number of 
> > elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> > 'vector_int8n' (vector of 2 'int' values))
> >   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^  
> > /tmp/x.c:82:17: error: vector operands do not have the same number of 
> > elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> > 'vector_uint8n' (vector of 2 'unsigned int' values))
> >   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^  ~
> > /tmp/x.c:83:17: error: vector operands do not have the same number of 
> > elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> > 'vector_short8n' (vector of 4 'short' values))
> >   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^   
> > 
> > Given your test changes, it seems that now, instead of "vector operands do 
> > not have the same number of elements" we would get "vector operands do not 
> > have the same elements sizes". I rather we stay with the first. 
> > Additionally, even if we had "vector operands do not have the same elements 
> > sizes" for `vector_size`, this should never be demoted to a warning.
> Argument of a GNU vector size attribute specifies vector size measured in 
> bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So you 
> got right diagnostics. Both compilers with and without my changes print the 
> same diagnostics  for yours case. Here is a small testcase used both GNU and 
> clang extensions
> 
> $ cat bruno.c 
>   
>  
> typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
> typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
>  
> typedef __attribute__((vector_size(8))) int vector_int8n;
> typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
>  
> vector_int8  vi8;
> vector_uchar8 vuc8;
> vector_int8n  vi8n;
> vector_uchar8n vuc8n;
>  
> int foo() {
>   vi8 = vi8 << vuc8;
>   vi8n = vi8n << vuc8n;
> 
> $ clang -c bruno.c -Wno-error-vec-elem-size   
>   
>  
> bruno.c:13:13: warning: vector operands do not have the same elements sizes 
> ('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
> 'unsigned char' values)) [-Wvec-elem-size]
>   vi8 = vi8 << vuc8;
> ~~~ ^  
> bruno.c:14:15: error: vector operands do not have the same number of elements 
> ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' (vector of 8 
> 'unsigned char' values))
>   vi8n = vi8n << vuc8n;
> 
> The compiler without the changes prints the second error only (bruno.c:14:15).
What actually concerns me here is the following: if you invoke `clang -c 
bruno.c -Wvec-elem-size`, will that override the `error: vector operands do not 
have the same number of elements ` message for `vector_size` typed vectors? If 
so, I don't think this is right.


https://reviews.llvm.org/D24669



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


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-10-11 Thread Paweł Żukowski via cfe-commits
idlecode marked an inline comment as done.
idlecode added a comment.

Sure, I will upload diff as soon as I test it


https://reviews.llvm.org/D25439



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


r283907 - [CUDA] Re-land support for (r283683 and r283680).

2016-10-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Oct 11 12:36:03 2016
New Revision: 283907

URL: http://llvm.org/viewvc/llvm-project?rev=283907&view=rev
Log:
[CUDA] Re-land support for  (r283683 and r283680).

These were reverted in r283753 and r283747.

The first patch added a header to the root 'Headers' install directory,
instead of into 'Headers/cuda_wrappers'.  This was fixed in the second
patch, but by then the damage was done: The bad header stayed in the
'Headers' directory, continuing to break the build.

We reverted both patches in an attempt to fix things, but that still
didn't get rid of the header, so the Windows boostrap build remained
broken.

It's probably worth fixing up our cmake logic to remove things from the
install dirs, but in the meantime, re-land these patches, since we
believe they no longer have this bug.

Added:
cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
cfe/trunk/lib/Headers/cuda_wrappers/
cfe/trunk/lib/Headers/cuda_wrappers/algorithm
cfe/trunk/lib/Headers/cuda_wrappers/complex
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=283907&r1=283906&r2=283907&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 11 12:36:03 2016
@@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
 
 void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+// Add cuda_wrappers/* to our system include path.  This lets us wrap
+// standard library headers.
+SmallString<128> P(getDriver().ResourceDir);
+llvm::sys::path::append(P, "include");
+llvm::sys::path::append(P, "cuda_wrappers");
+addSystemInclude(DriverArgs, CC1Args, P);
+  }
+
   if (DriverArgs.hasArg(options::OPT_nocudainc))
 return;
 

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=283907&r1=283906&r2=283907&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue Oct 11 12:36:03 2016
@@ -24,6 +24,7 @@ set(files
   bmiintrin.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
+  __clang_cuda_complex_builtins.h
   __clang_cuda_intrinsics.h
   __clang_cuda_math_forward_declares.h
   __clang_cuda_runtime_wrapper.h
@@ -89,6 +90,11 @@ set(files
   xtestintrin.h
   )
 
+set(cuda_wrapper_files
+  cuda_wrappers/algorithm
+  cuda_wrappers/complex
+)
+
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
 
 # Generate arm_neon.h
@@ -96,7 +102,7 @@ clang_tablegen(arm_neon.h -gen-arm-neon
   SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
 
 set(out_files)
-foreach( f ${files} )
+foreach( f ${files} ${cuda_wrapper_files} )
   set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
   set( dst ${output_dir}/${f} )
   add_custom_command(OUTPUT ${dst}
@@ -121,6 +127,12 @@ install(
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
 
+install(
+  FILES ${cuda_wrapper_files}
+  COMPONENT clang-headers
+  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+  DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
+
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
   add_custom_target(install-clang-headers
 DEPENDS clang-headers

Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h?rev=283907&view=auto
==
--- cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h (added)
+++ cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h Tue Oct 11 12:36:03 
2016
@@ -0,0 +1,203 @@
+/*===-- __clang_cuda_complex_builtins - CUDA impls of runtime complex fns 
---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF

[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

A test should probably be added as well.


https://reviews.llvm.org/D25480



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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Oct 11, 2016 at 10:09 AM, Renato Golin  wrote:
> On 11 October 2016 at 16:34, Bruno Cardoso Lopes
>  wrote:
>> Thanks Renato!
>
> So, Daniel Jasper did a trick on r283853 (clang || true) to make it
> not fail when it returns on error. However, I wasn't able to make it
> return anything but 0, so I'm at odds why this fails on the bot.
>
> I was expecting it to actually return non-zero, since it emits an
> error, which is even weirder. So, using "not clang" doesn't work in
> this case. Do you have any ideas why this behaviour is like that?

I have no idea. I'm gonna try to re-introduce the commit without a
target specifc triple, that hopefully should be enough to get it
working (there was no specific reason this test should be using a
specific target anyway)

Thanks again Renato



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25397: [change-namespace] don't miss comments in the beginning of a namespace block.

2016-10-11 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:387
+  Token Tok;
+  while (!Lex->LexFromRawLexer(Tok) && Tok.isNot(tok::TokenKind::l_brace)) {
+  }

hokein wrote:
> Maybe we can use `findLocationAfterToken` here? 
This doesn't seem to work in this case. Note that we are lexing from the 
beginning of `NsDecl`, which is `namespace` or `inline`, and the next token is 
not necessarily `{`.

  /// \brief Checks that the given token is the first token that occurs after 
the
  /// given location (this excludes comments and whitespace). Returns the 
location
  /// immediately after the specified token. If the token is not found or the
  /// location is inside a macro, the returned source location will be invalid.
  SourceLocation Lexer::findLocationAfterToken(...);



https://reviews.llvm.org/D25397



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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Benjamin Kramer via cfe-commits
I don't think this change is worth it. We create huge static arrays
with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
char*) is not constexpr (because of strlen). This means you'll get a
huge generated initialization function for it. We want to reduce the
number of global initializers in LLVM, not create new ones.

On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
 wrote:
> Author: mehdi_amini
> Date: Mon Oct 10 16:34:29 2016
> New Revision: 283802
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
> Log:
> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> @@ -51,7 +51,8 @@ enum ID {
>  };
>
>  struct Info {
> -  const char *Name, *Type, *Attributes, *HeaderName;
> +  llvm::StringRef Name;
> +  const char *Type, *Attributes, *HeaderName;
>LanguageID Langs;
>const char *Features;
>  };
> @@ -80,7 +81,7 @@ public:
>
>/// \brief Return the identifier name for the specified builtin,
>/// e.g. "__builtin_abs".
> -  const char *getName(unsigned ID) const {
> +  llvm::StringRef getName(unsigned ID) const {
>  return getRecord(ID).Name;
>}
>
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>if (FD->hasAttr())
>  Name = getMangledName(D);
>else
> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>
>llvm::FunctionType *Ty =
>  cast(getTypes().ConvertType(FD->getType()));
> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>checkTargetFeatures(E, FD);
>
>// See if we have a target specific intrinsic.
> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>StringRef Prefix =
>llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>if (!Prefix.empty()) {
> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>  IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>  // NOTE we dont need to perform a compatibility flag check here since the
>  // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
> the
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>// Get the decl for the concrete builtin from this, we can tell what the
>// concrete integer type we should convert to is.
>unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>FunctionDecl *NewBuiltinDecl;
>if (NewBuiltinID == BuiltinID)
>  NewBuiltinDecl = FDecl;
>else {
>  // Perform builtin lookup to avoid redeclaring it.
> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>  DeclarationName DN(&Context.Idents.get(NewBuiltinName));
>  LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>  LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
> @@ -6263,7 +6263,7 @@ static void emitReplacement(Sema &S, Sou
>  unsigned AbsKind, QualType ArgType) {
>bool EmitHeaderHint = true;
>const char *HeaderName = nullptr;
> -  const char *FunctionName = nullptr;
> +  StringRef FunctionName;
>if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
>  FunctionName = "std::abs";
>  if (ArgType->isIntegralOrEnumerationType()) {
> @@ -6381,7 +6381,7 @@ void Sema::CheckAbsoluteValueFunction(co
>// Unsigned types cannot be negative.  Suggest removing the absolute value
>// function call.
>if (ArgType->isUnsignedIntegerType()) {
> -const char *FunctionName =
> +StringRef 

r283913 - Reapply [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:21:26 2016
New Revision: 283913

URL: http://llvm.org/viewvc/llvm-project?rev=283913&view=rev
Log:
Reapply [Driver][Diagnostics] Make 'show option names' default for driver 
warnings

Reapply r283827 by fixing the tests to not be target specific

Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.

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

rdar://problem/27300909

Added:
cfe/trunk/test/Driver/show-option-names.c
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=283913&r1=283912&r2=283913&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Tue Oct 11 13:21:26 
2016
@@ -48,7 +48,8 @@ class DiagnosticsEngine;
 /// report the error(s).
 bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
  DiagnosticsEngine *Diags = nullptr,
- bool DefaultDiagColor = true);
+ bool DefaultDiagColor = true,
+ bool DefaultShowOpt = true);
 
 class CompilerInvocationBase : public RefCountedBase {
   void operator=(const CompilerInvocationBase &) = delete;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=283913&r1=283912&r2=283913&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Oct 11 13:21:26 2016
@@ -957,7 +957,7 @@ static bool parseShowColorsArgs(const Ar
 
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
-bool DefaultDiagColor) {
+bool DefaultDiagColor, bool DefaultShowOpt) {
   using namespace options;
   bool Success = true;
 
@@ -977,7 +977,9 @@ bool clang::ParseDiagnosticArgs(Diagnost
   Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
   Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
-  Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
+  Opts.ShowOptionNames =
+  Args.hasFlag(OPT_fdiagnostics_show_option,
+   OPT_fno_diagnostics_show_option, DefaultShowOpt);
 
   llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
 
@@ -2404,8 +2406,9 @@ bool CompilerInvocation::CreateFromArgs(
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
-  Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
- false /*DefaultDiagColor*/);
+  Success &=
+  ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
+  false /*DefaultDiagColor*/, false 
/*DefaultShowOpt*/);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here

Added: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283913&view=auto
==
--- cfe/trunk/test/Driver/show-option-names.c (added)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:21:26 2016
@@ -0,0 +1,5 @@
+// RUN: %clang -c -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
+
+// RUN: %clang -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Let's see how it goes: Committed r283913

On Tue, Oct 11, 2016 at 11:13 AM, Bruno Cardoso Lopes
 wrote:
> On Tue, Oct 11, 2016 at 10:09 AM, Renato Golin  
> wrote:
>> On 11 October 2016 at 16:34, Bruno Cardoso Lopes
>>  wrote:
>>> Thanks Renato!
>>
>> So, Daniel Jasper did a trick on r283853 (clang || true) to make it
>> not fail when it returns on error. However, I wasn't able to make it
>> return anything but 0, so I'm at odds why this fails on the bot.
>>
>> I was expecting it to actually return non-zero, since it emits an
>> error, which is even weirder. So, using "not clang" doesn't work in
>> this case. Do you have any ideas why this behaviour is like that?
>
> I have no idea. I'm gonna try to re-introduce the commit without a
> target specifc triple, that hopefully should be enough to get it
> working (there was no specific reason this test should be using a
> specific target anyway)
>
> Thanks again Renato
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
This is temporary: the last patch of my series of patches adds the constexpr 
ctor and remove all these static initializers.

> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
> 
> I don't think this change is worth it. We create huge static arrays
> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> char*) is not constexpr (because of strlen). This means you'll get a
> huge generated initialization function for it. We want to reduce the
> number of global initializers in LLVM, not create new ones.
> 
> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>  wrote:
>> Author: mehdi_amini
>> Date: Mon Oct 10 16:34:29 2016
>> New Revision: 283802
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
>> Log:
>> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>> 
>> Modified:
>>cfe/trunk/include/clang/Basic/Builtins.h
>>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>cfe/trunk/lib/Sema/SemaChecking.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
>> @@ -51,7 +51,8 @@ enum ID {
>> };
>> 
>> struct Info {
>> -  const char *Name, *Type, *Attributes, *HeaderName;
>> +  llvm::StringRef Name;
>> +  const char *Type, *Attributes, *HeaderName;
>>   LanguageID Langs;
>>   const char *Features;
>> };
>> @@ -80,7 +81,7 @@ public:
>> 
>>   /// \brief Return the identifier name for the specified builtin,
>>   /// e.g. "__builtin_abs".
>> -  const char *getName(unsigned ID) const {
>> +  llvm::StringRef getName(unsigned ID) const {
>> return getRecord(ID).Name;
>>   }
>> 
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>>   if (FD->hasAttr())
>> Name = getMangledName(D);
>>   else
>> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>> 
>>   llvm::FunctionType *Ty =
>> cast(getTypes().ConvertType(FD->getType()));
>> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>>   checkTargetFeatures(E, FD);
>> 
>>   // See if we have a target specific intrinsic.
>> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>>   StringRef Prefix =
>>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>>   if (!Prefix.empty()) {
>> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>> // NOTE we dont need to perform a compatibility flag check here since the
>> // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
>> the
>> 
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
>> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>>   // Get the decl for the concrete builtin from this, we can tell what the
>>   // concrete integer type we should convert to is.
>>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
>> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>   FunctionDecl *NewBuiltinDecl;
>>   if (NewBuiltinID == BuiltinID)
>> NewBuiltinDecl = FDecl;
>>   else {
>> // Perform builtin lookup to avoid redeclaring it.
>> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>> DeclarationName DN(&Context.Idents.get(NewBuiltinName));
>> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>> LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
>> @@ -6263,7 +6263,7 @@ static void emitReplacement(Sema &S, Sou
>> unsigned AbsKind, QualType ArgType) {
>>   bool EmitHeaderHint = true;
>>   const char *HeaderName = nullptr;
>> -  const char *FunctionName = nullptr;
>> +  StringRef FunctionName;
>>   if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
>> FunctionName = "std::abs";
>> if (ArgType->isIntegralOrEnumerationType()) 

r283915 - [Driver] Fix test from r283913 to unbreak bots

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:31:45 2016
New Revision: 283915

URL: http://llvm.org/viewvc/llvm-project?rev=283915&view=rev
Log:
[Driver] Fix test from r283913 to unbreak bots

Followup from r283913 & r283827

http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55135

Modified:
cfe/trunk/test/Driver/show-option-names.c

Modified: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283915&r1=283914&r2=283915&view=diff
==
--- cfe/trunk/test/Driver/show-option-names.c (original)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:31:45 2016
@@ -1,5 +1,7 @@
-// RUN: %clang -c -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target x86_64-apple-darwin -c -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
 // CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
 
-// RUN: %clang -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -c -fno-diagnostics-show-option 
-isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
 // CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


r283917 - [Driver] Use -fsyntax-only in test/Driver/show-option-names.c

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:38:33 2016
New Revision: 283917

URL: http://llvm.org/viewvc/llvm-project?rev=283917&view=rev
Log:
[Driver] Use -fsyntax-only in test/Driver/show-option-names.c

Make the test less expensive, follow up from r283915.

Modified:
cfe/trunk/test/Driver/show-option-names.c

Modified: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283917&r1=283916&r2=283917&view=diff
==
--- cfe/trunk/test/Driver/show-option-names.c (original)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:38:33 2016
@@ -1,7 +1,7 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -target x86_64-apple-darwin -c -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -fsyntax-only -isysroot /FOO %s 
2>&1 | FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
 // CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
 
-// RUN: %clang -target x86_64-apple-darwin -c -fno-diagnostics-show-option 
-isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -fsyntax-only 
-fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
 // CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


[PATCH] D25483: [libcxx] [test] Fix non-Standard assumptions about how many elements are allocated

2016-10-11 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

The recently-added limited_allocator is much more conformant than the evil old 
stack_allocator. However, limited_allocator encodes non-Standard assumptions 
about how many allocations containers perform, which don't hold for MSVC. 
Specifically, MSVC's STL dynamically allocates sentinel nodes and "container 
proxies" (for debug mode checking), and its vector famously grows by 1.5x 
instead of 2x. I would like to retain the limited_allocator coverage, but tweak 
things so that they pass for both libc++ and MSVC.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
deque is too weird. (MSVC's deque reallocates its blockmap several times while 
doing this.) Just mark the tests as LIBCPP_ONLY, the coward's way out.

test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
test/std/containers/sequences/list/list.cons/size_type.pass.cpp
test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
"Add 2 for implementations that dynamically allocate a sentinel node and 
container proxy."

test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
"Add 1 for implementations that dynamically allocate a container proxy."

test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
Ditto. The (InIt, InIt) ctor is unchanged at 63 elements allocated (MSVC's 1.5x 
results in fewer element allocations, enough to make room for the container 
proxy).

test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
Adjust numbers for container proxy and 1.5x growth, with the calculations in 
the comments.


https://reviews.llvm.org/D25483

Files:
  test/std/containers/sequences/deque/deque.cons/size.pass.cpp
  test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
  test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
  test/std/containers/sequences/list/list.cons/size_type.pass.cpp
  test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
  test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
  test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
  
test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
  test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
  test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
  test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
  
test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp

Index: test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
===
--- test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
+++ test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -50,7 +50,10 @@
 assert(c[j] == MoveOnly(j));
 }
 {
-std::vector > c;
+// libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+// Use 17 for implementations that dynamically allocate a container proxy
+// and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+std::vector > c;
 c.push_back(MoveOnly(0));
 assert(c.size() == 1);
 assert(is_contiguous_container_asan_correct(c));
Index: test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
===
--- test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
+++ test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -48,7 +48,10 @@
 assert(c[j] == j);
 }
 {
-std::vector > c;
+// libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+// Use 17 for implementations that dynamically allocate a container proxy
+// and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+std::vector > c;
 c.push_back(0);
 assert(c.size() == 1);
 assert(is_contiguous_container_asan_correct(c));
Index: test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
===
--- test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
+++ test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -34,7 +34,8 @@
 int main()
 {
 test >(50, 3);
-test > >(50, 5);
+// Add 1 for implementations that dynami

[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-11 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > Hmm, it seems like this is boilerplate we are going to want for every 
> > > rule, and that it's pretty easy to not get this right (for instance, if 
> > > you change the way the check is spelled, you have to remember to update 
> > > this as well). Could this actually be handled more transparently, by 
> > > gathering this information when the check is registered and exposing it 
> > > to the check?
> > > 
> > > The checks would still need to use `unless(isSuppressed(Rules))` in some 
> > > form, but I am thinking that it would be more convenient if we could do: 
> > > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> > >  this);`
> > I see multiple ways on how to integrate that into clang-tidy:
> > 1) Add something like you proposed to each matcher of each check
> > 2) Change (or add overload of)
> > ```
> >  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
> >  DiagnosticIDs::Level Level = 
> > DiagnosticIDs::Warning);
> > ```
> > to add a AST node as parameter and make the SourceLocation optional. Most 
> > checks anyhow
> > call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> > "...").
> > Diag then would check from the that AST node upwards to see if it finds a 
> > matching [[suppress]] attribute
> > 
> > 3) Change the RecursiveASTVistor that drives the AST Matches to prune 
> > certain matchers from the list of to-be-evaluated matchers
> > for all AST subtrees that are below a certain [[suppress]] attribute. (This 
> > is based on how I image that the AST matchers work)
> Ideally, I would like to see this attribute used to suppress Clang 
> diagnostics as well, however. So while I think Option 2 is better suited to 
> that future direction, it's still not ideal because all instances of diag() 
> need to be updated to take advantage. Options 1 and 3 are basically limited 
> to clang-tidy use.
> 
> I wonder if there's a way to modify the diagnostic builder to transparently 
> handle this without requiring modifying all of the call sites?
clang-tidy reports how many warnings were suppressed by NOLINT comments.
I'd expect the number of warnings suppressed by [[clang::suppress]] to be 
included in the count.
Handling suppressions in the matchers or visitors would prevent this.


https://reviews.llvm.org/D24888



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


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

__builtin_fpclassify takes five int arguments followed by one last argument 
that is of floating point type. Do you know if there is a way to specify the 
last one argument is a floating point rather than using '.'?


https://reviews.llvm.org/D25480



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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Benjamin Kramer via cfe-commits
Committing this patch before the constexpr change seems backwards
then? The static initializers are already breaking stuff because it
takes GCC with optimization and debug info takes 10+ minutes to
generate megabytes of static initializer code in Targets.cpp. Can you
please revert this until the constexpr change is ready?

On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
> This is temporary: the last patch of my series of patches adds the constexpr 
> ctor and remove all these static initializers.
>
>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>
>> I don't think this change is worth it. We create huge static arrays
>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>> char*) is not constexpr (because of strlen). This means you'll get a
>> huge generated initialization function for it. We want to reduce the
>> number of global initializers in LLVM, not create new ones.
>>
>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>  wrote:
>>> Author: mehdi_amini
>>> Date: Mon Oct 10 16:34:29 2016
>>> New Revision: 283802
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
>>> Log:
>>> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>>>
>>> Modified:
>>>cfe/trunk/include/clang/Basic/Builtins.h
>>>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>>cfe/trunk/lib/Sema/SemaChecking.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
>>> @@ -51,7 +51,8 @@ enum ID {
>>> };
>>>
>>> struct Info {
>>> -  const char *Name, *Type, *Attributes, *HeaderName;
>>> +  llvm::StringRef Name;
>>> +  const char *Type, *Attributes, *HeaderName;
>>>   LanguageID Langs;
>>>   const char *Features;
>>> };
>>> @@ -80,7 +81,7 @@ public:
>>>
>>>   /// \brief Return the identifier name for the specified builtin,
>>>   /// e.g. "__builtin_abs".
>>> -  const char *getName(unsigned ID) const {
>>> +  llvm::StringRef getName(unsigned ID) const {
>>> return getRecord(ID).Name;
>>>   }
>>>
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>>> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>>>   if (FD->hasAttr())
>>> Name = getMangledName(D);
>>>   else
>>> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>>> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>>>
>>>   llvm::FunctionType *Ty =
>>> cast(getTypes().ConvertType(FD->getType()));
>>> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>>>   checkTargetFeatures(E, FD);
>>>
>>>   // See if we have a target specific intrinsic.
>>> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>>>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>>>   StringRef Prefix =
>>>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>>>   if (!Prefix.empty()) {
>>> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>>> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>>> // NOTE we dont need to perform a compatibility flag check here since 
>>> the
>>> // intrinsics are declared in Builtins*.def via LANGBUILTIN which 
>>> filter the
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
>>> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>>>   // Get the decl for the concrete builtin from this, we can tell what the
>>>   // concrete integer type we should convert to is.
>>>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
>>> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>>   FunctionDecl *NewBuiltinDecl;
>>>   if (NewBuiltinID == BuiltinID)
>>> NewBuiltinDecl = FDecl;
>>>   else {
>>> // Perform builtin lookup to avoid redeclaring it.
>>> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>> DeclarationName DN(&Context.Idents.get(NewBuiltinName));
>>> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>>> LookupName(Res, 

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Craig Topper via cfe-commits
But this also increases the size of the builtin table too right? Since
StringRef is twice the size of a pointer.

~Craig

On Tue, Oct 11, 2016 at 11:40 AM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This is temporary: the last patch of my series of patches adds the
> constexpr ctor and remove all these static initializers.
>
> > On Oct 11, 2016, at 11:26 AM, Benjamin Kramer 
> wrote:
> >
> > I don't think this change is worth it. We create huge static arrays
> > with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> > char*) is not constexpr (because of strlen). This means you'll get a
> > huge generated initialization function for it. We want to reduce the
> > number of global initializers in LLVM, not create new ones.
> >
> > On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> >  wrote:
> >> Author: mehdi_amini
> >> Date: Mon Oct 10 16:34:29 2016
> >> New Revision: 283802
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
> >> Log:
> >> Change Builtins name to be stored as StringRef instead of raw pointers
> (NFC)
> >>
> >> Modified:
> >>cfe/trunk/include/clang/Basic/Builtins.h
> >>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >>cfe/trunk/lib/Sema/SemaChecking.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
> >> 
> ==
> >> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> >> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> >> @@ -51,7 +51,8 @@ enum ID {
> >> };
> >>
> >> struct Info {
> >> -  const char *Name, *Type, *Attributes, *HeaderName;
> >> +  llvm::StringRef Name;
> >> +  const char *Type, *Attributes, *HeaderName;
> >>   LanguageID Langs;
> >>   const char *Features;
> >> };
> >> @@ -80,7 +81,7 @@ public:
> >>
> >>   /// \brief Return the identifier name for the specified builtin,
> >>   /// e.g. "__builtin_abs".
> >> -  const char *getName(unsigned ID) const {
> >> +  llvm::StringRef getName(unsigned ID) const {
> >> return getRecord(ID).Name;
> >>   }
> >>
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
> >> 
> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> >> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
> >>   if (FD->hasAttr())
> >> Name = getMangledName(D);
> >>   else
> >> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> >> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> >>
> >>   llvm::FunctionType *Ty =
> >> cast(getTypes().ConvertType(FD->getType()));
> >> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >>   checkTargetFeatures(E, FD);
> >>
> >>   // See if we have a target specific intrinsic.
> >> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
> >>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
> >>   StringRef Prefix =
> >>   llvm::Triple::getArchTypePrefix(getTarget().
> getTriple().getArch());
> >>   if (!Prefix.empty()) {
> >> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> >> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(),
> Name);
> >> // NOTE we dont need to perform a compatibility flag check here
> since the
> >> // intrinsics are declared in Builtins*.def via LANGBUILTIN which
> filter the
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> >> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
> >>   // Get the decl for the concrete builtin from this, we can tell what
> the
> >>   // concrete integer type we should convert to is.
> >>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
> >> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(
> NewBuiltinID);
> >>   FunctionDecl *NewBuiltinDecl;
> >>   if (NewBuiltinID == BuiltinID)
> >> NewBuiltinDecl = FDecl;
> >>   else {
> >> // Perform builtin lookup to avoid redeclaring it.
> >> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(
> NewBuiltinID);
> >> DeclarationName DN(&Context.Idents.get(NewBuiltinName));
> >> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
> >> LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
> >> @@

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits

> On Oct 11, 2016, at 12:04 PM, Benjamin Kramer  wrote:
> 
> Committing this patch before the constexpr change seems backwards
> then?

Well not really because I need to make StringRef(const char *) explicit, so all 
the others have to go first.

> The static initializers are already breaking stuff because it
> takes GCC with optimization and debug info takes 10+ minutes to
> generate megabytes of static initializer code in Targets.cpp. Can you
> please revert this until the constexpr change is ready?

I already landed > 30 patches like this one, I have no problem temporarily 
reverting this one in particular, but there are others instance of static 
initializers in the other patches.

— 
Mehdi



> 
> On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
>> This is temporary: the last patch of my series of patches adds the constexpr 
>> ctor and remove all these static initializers.
>> 
>>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>> 
>>> I don't think this change is worth it. We create huge static arrays
>>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>>> char*) is not constexpr (because of strlen). This means you'll get a
>>> huge generated initialization function for it. We want to reduce the
>>> number of global initializers in LLVM, not create new ones.
>>> 
>>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>>  wrote:
 Author: mehdi_amini
 Date: Mon Oct 10 16:34:29 2016
 New Revision: 283802
 
 URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
 Log:
 Change Builtins name to be stored as StringRef instead of raw pointers 
 (NFC)
 
 Modified:
   cfe/trunk/include/clang/Basic/Builtins.h
   cfe/trunk/lib/CodeGen/CGBuiltin.cpp
   cfe/trunk/lib/Sema/SemaChecking.cpp
 
 Modified: cfe/trunk/include/clang/Basic/Builtins.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/include/clang/Basic/Builtins.h (original)
 +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
 @@ -51,7 +51,8 @@ enum ID {
 };
 
 struct Info {
 -  const char *Name, *Type, *Attributes, *HeaderName;
 +  llvm::StringRef Name;
 +  const char *Type, *Attributes, *HeaderName;
  LanguageID Langs;
  const char *Features;
 };
 @@ -80,7 +81,7 @@ public:
 
  /// \brief Return the identifier name for the specified builtin,
  /// e.g. "__builtin_abs".
 -  const char *getName(unsigned ID) const {
 +  llvm::StringRef getName(unsigned ID) const {
return getRecord(ID).Name;
  }
 
 
 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
 @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
  if (FD->hasAttr())
Name = getMangledName(D);
  else
 -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
 
  llvm::FunctionType *Ty =
cast(getTypes().ConvertType(FD->getType()));
 @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
  checkTargetFeatures(E, FD);
 
  // See if we have a target specific intrinsic.
 -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
  StringRef Prefix =
  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
  if (!Prefix.empty()) {
 +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
// NOTE we dont need to perform a compatibility flag check here since 
 the
// intrinsics are declared in Builtins*.def via LANGBUILTIN which 
 filter the
 
 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
 @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
  // Get the decl for the concrete builtin from this, we can tell what the
  // concrete integer type we should convert to is.
  unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
 -  const char *NewBuil

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Yes, do you have a specific concern for this table size in particular?

> On Oct 11, 2016, at 12:07 PM, Craig Topper  wrote:
> 
> But this also increases the size of the builtin table too right? Since 
> StringRef is twice the size of a pointer.
> 
> ~Craig
> 
> On Tue, Oct 11, 2016 at 11:40 AM, Mehdi Amini via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> This is temporary: the last patch of my series of patches adds the constexpr 
> ctor and remove all these static initializers.
> 
> > On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  > > wrote:
> >
> > I don't think this change is worth it. We create huge static arrays
> > with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> > char*) is not constexpr (because of strlen). This means you'll get a
> > huge generated initialization function for it. We want to reduce the
> > number of global initializers in LLVM, not create new ones.
> >
> > On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >> Author: mehdi_amini
> >> Date: Mon Oct 10 16:34:29 2016
> >> New Revision: 283802
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev 
> >> 
> >> Log:
> >> Change Builtins name to be stored as StringRef instead of raw pointers 
> >> (NFC)
> >>
> >> Modified:
> >>cfe/trunk/include/clang/Basic/Builtins.h
> >>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >>cfe/trunk/lib/Sema/SemaChecking.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> >> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> >> @@ -51,7 +51,8 @@ enum ID {
> >> };
> >>
> >> struct Info {
> >> -  const char *Name, *Type, *Attributes, *HeaderName;
> >> +  llvm::StringRef Name;
> >> +  const char *Type, *Attributes, *HeaderName;
> >>   LanguageID Langs;
> >>   const char *Features;
> >> };
> >> @@ -80,7 +81,7 @@ public:
> >>
> >>   /// \brief Return the identifier name for the specified builtin,
> >>   /// e.g. "__builtin_abs".
> >> -  const char *getName(unsigned ID) const {
> >> +  llvm::StringRef getName(unsigned ID) const {
> >> return getRecord(ID).Name;
> >>   }
> >>
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> >> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
> >>   if (FD->hasAttr())
> >> Name = getMangledName(D);
> >>   else
> >> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> >> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> >>
> >>   llvm::FunctionType *Ty =
> >> cast(getTypes().ConvertType(FD->getType()));
> >> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >>   checkTargetFeatures(E, FD);
> >>
> >>   // See if we have a target specific intrinsic.
> >> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
> >>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
> >>   StringRef Prefix =
> >>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
> >>   if (!Prefix.empty()) {
> >> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> >> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), 
> >> Name);
> >> // NOTE we dont need to perform a compatibility flag check here since 
> >> the
> >> // intrinsics are declared in Builtins*.def via LANGBUILTIN which 
> >> filter the
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> >> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
> >>   // Get the decl for the concrete builtin from this, we can tell what the
> >>   // concret

r283920 - Revert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"

2016-10-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Tue Oct 11 14:04:24 2016
New Revision: 283920

URL: http://llvm.org/viewvc/llvm-project?rev=283920&view=rev
Log:
Revert "Change Builtins name to be stored as StringRef instead of raw pointers 
(NFC)"

This reverts commit r283802. It introduces temporarily static
initializers, because StringRef ctor isn't (yet) constexpr for
string literals.
I plan to get there this week, but apparently GCC is so terrible
with these static initializer right now (10 min+ extra codegen
time was reported) that I'll hold on to this patch till the
constexpr one is ready, and land these at the same time.

Modified:
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283920&r1=283919&r2=283920&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Tue Oct 11 14:04:24 2016
@@ -51,8 +51,7 @@ enum ID {
 };
 
 struct Info {
-  llvm::StringRef Name;
-  const char *Type, *Attributes, *HeaderName;
+  const char *Name, *Type, *Attributes, *HeaderName;
   LanguageID Langs;
   const char *Features;
 };
@@ -81,7 +80,7 @@ public:
 
   /// \brief Return the identifier name for the specified builtin,
   /// e.g. "__builtin_abs".
-  llvm::StringRef getName(unsigned ID) const {
+  const char *getName(unsigned ID) const {
 return getRecord(ID).Name;
   }
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283920&r1=283919&r2=283920&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Oct 11 14:04:24 2016
@@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
   if (FD->hasAttr())
 Name = getMangledName(D);
   else
-Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
+Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 
   llvm::FunctionType *Ty =
 cast(getTypes().ConvertType(FD->getType()));
@@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   checkTargetFeatures(E, FD);
 
   // See if we have a target specific intrinsic.
+  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
   StringRef Prefix =
   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
   if (!Prefix.empty()) {
-StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
 IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
 // NOTE we dont need to perform a compatibility flag check here since the
 // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
the

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283920&r1=283919&r2=283920&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Oct 11 14:04:24 2016
@@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
   // Get the decl for the concrete builtin from this, we can tell what the
   // concrete integer type we should convert to is.
   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
+  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
   FunctionDecl *NewBuiltinDecl;
   if (NewBuiltinID == BuiltinID)
 NewBuiltinDecl = FDecl;
   else {
 // Perform builtin lookup to avoid redeclaring it.
-StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
 DeclarationName DN(&Context.Idents.get(NewBuiltinName));
 LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
 LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
@@ -6263,7 +6263,7 @@ static void emitReplacement(Sema &S, Sou
 unsigned AbsKind, QualType ArgType) {
   bool EmitHeaderHint = true;
   const char *HeaderName = nullptr;
-  StringRef FunctionName;
+  const char *FunctionName = nullptr;
   if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
 FunctionName = "std::abs";
 if (ArgType->isIntegralOrEnumerationType()) {
@@ -6381,7 +6381,7 @@ void Sema::CheckAbsoluteValueFunction(co
   // Unsigned types cannot be negative.  Suggest removing the absolute value
   // function call.
   if (ArgType->isUnsignedIntegerType()) {
-StringRef FunctionName =
+const char *FunctionName =
 IsStdAbs ? "std::abs" : Context.BuiltinInfo.getName(AbsKind);
 Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
 Diag(Call->getExprLoc(), diag

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Reverted in r283920, can you check if it is enough to “fix” the GCC issue?

> On Oct 11, 2016, at 12:04 PM, Benjamin Kramer  wrote:
> 
> Committing this patch before the constexpr change seems backwards
> then? The static initializers are already breaking stuff because it
> takes GCC with optimization and debug info takes 10+ minutes to
> generate megabytes of static initializer code in Targets.cpp. Can you
> please revert this until the constexpr change is ready?
> 
> On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
>> This is temporary: the last patch of my series of patches adds the constexpr 
>> ctor and remove all these static initializers.
>> 
>>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>> 
>>> I don't think this change is worth it. We create huge static arrays
>>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>>> char*) is not constexpr (because of strlen). This means you'll get a
>>> huge generated initialization function for it. We want to reduce the
>>> number of global initializers in LLVM, not create new ones.
>>> 
>>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>>  wrote:
 Author: mehdi_amini
 Date: Mon Oct 10 16:34:29 2016
 New Revision: 283802
 
 URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
 Log:
 Change Builtins name to be stored as StringRef instead of raw pointers 
 (NFC)
 
 Modified:
   cfe/trunk/include/clang/Basic/Builtins.h
   cfe/trunk/lib/CodeGen/CGBuiltin.cpp
   cfe/trunk/lib/Sema/SemaChecking.cpp
 
 Modified: cfe/trunk/include/clang/Basic/Builtins.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/include/clang/Basic/Builtins.h (original)
 +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
 @@ -51,7 +51,8 @@ enum ID {
 };
 
 struct Info {
 -  const char *Name, *Type, *Attributes, *HeaderName;
 +  llvm::StringRef Name;
 +  const char *Type, *Attributes, *HeaderName;
  LanguageID Langs;
  const char *Features;
 };
 @@ -80,7 +81,7 @@ public:
 
  /// \brief Return the identifier name for the specified builtin,
  /// e.g. "__builtin_abs".
 -  const char *getName(unsigned ID) const {
 +  llvm::StringRef getName(unsigned ID) const {
return getRecord(ID).Name;
  }
 
 
 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
 @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
  if (FD->hasAttr())
Name = getMangledName(D);
  else
 -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
 
  llvm::FunctionType *Ty =
cast(getTypes().ConvertType(FD->getType()));
 @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
  checkTargetFeatures(E, FD);
 
  // See if we have a target specific intrinsic.
 -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
  StringRef Prefix =
  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
  if (!Prefix.empty()) {
 +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
// NOTE we dont need to perform a compatibility flag check here since 
 the
// intrinsics are declared in Builtins*.def via LANGBUILTIN which 
 filter the
 
 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802&r1=283801&r2=283802&view=diff
 ==
 --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
 @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
  // Get the decl for the concrete builtin from this, we can tell what the
  // concrete integer type we should convert to is.
  unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
 -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
  FunctionDecl *NewBuiltinDecl;
  if (NewBuiltinID == BuiltinID)
NewBuiltinDecl = FDecl;
  else {
// Perform builtin lookup to avoid redeclaring it.
 +   

[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

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



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

malcolm.parsons wrote:
> aaron.ballman wrote:
> > mgehre wrote:
> > > aaron.ballman wrote:
> > > > Hmm, it seems like this is boilerplate we are going to want for every 
> > > > rule, and that it's pretty easy to not get this right (for instance, if 
> > > > you change the way the check is spelled, you have to remember to update 
> > > > this as well). Could this actually be handled more transparently, by 
> > > > gathering this information when the check is registered and exposing it 
> > > > to the check?
> > > > 
> > > > The checks would still need to use `unless(isSuppressed(Rules))` in 
> > > > some form, but I am thinking that it would be more convenient if we 
> > > > could do: 
> > > > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> > > >  this);`
> > > I see multiple ways on how to integrate that into clang-tidy:
> > > 1) Add something like you proposed to each matcher of each check
> > > 2) Change (or add overload of)
> > > ```
> > >  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
> > >  DiagnosticIDs::Level Level = 
> > > DiagnosticIDs::Warning);
> > > ```
> > > to add a AST node as parameter and make the SourceLocation optional. Most 
> > > checks anyhow
> > > call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> > > "...").
> > > Diag then would check from the that AST node upwards to see if it finds a 
> > > matching [[suppress]] attribute
> > > 
> > > 3) Change the RecursiveASTVistor that drives the AST Matches to prune 
> > > certain matchers from the list of to-be-evaluated matchers
> > > for all AST subtrees that are below a certain [[suppress]] attribute. 
> > > (This is based on how I image that the AST matchers work)
> > Ideally, I would like to see this attribute used to suppress Clang 
> > diagnostics as well, however. So while I think Option 2 is better suited to 
> > that future direction, it's still not ideal because all instances of diag() 
> > need to be updated to take advantage. Options 1 and 3 are basically limited 
> > to clang-tidy use.
> > 
> > I wonder if there's a way to modify the diagnostic builder to transparently 
> > handle this without requiring modifying all of the call sites?
> clang-tidy reports how many warnings were suppressed by NOLINT comments.
> I'd expect the number of warnings suppressed by [[clang::suppress]] to be 
> included in the count.
> Handling suppressions in the matchers or visitors would prevent this.
As would handling the suppression transparently within the diagnostic engine 
itself.


https://reviews.llvm.org/D24888



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


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

In https://reviews.llvm.org/D25480#567552, @ahatanak wrote:

> __builtin_fpclassify takes five int arguments followed by one last argument 
> that is of floating point type. Do you know if there is a way to specify the 
> last one argument is a floating point rather than using '.'?


There is already code in `clang/lib/Sema/SemaChecking.cpp` to generate 
`diag::err_typecheck_call_invalid_unary_fp`.


https://reviews.llvm.org/D25480



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


Re: [PATCH] D25387: When optimizing for size, enable loop rerolling by default.

2016-10-11 Thread Chris Matthews via cfe-commits
Hal,

I noticed since this commit there is a test-suite failure:

http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/

SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.

Tailing the output of the program gets:

…
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed


On October 8, 2016 at 8:16:18 PM, Hal Finkel via cfe-commits 
(cfe-commits@lists.llvm.org) wrote:

hfinkel closed this revision.
hfinkel added a comment.

r283685


https://reviews.llvm.org/D25387



___
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: r283685 - When optimizing for size, enable loop rerolling by default

2016-10-11 Thread Chris Matthews via cfe-commits

I noticed since this commit there is a test-suite failure:


http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/


SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.


Tailing the output of the program gets:


…

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed



On October 8, 2016 at 8:15:40 PM, Hal Finkel via cfe-commits 
(cfe-commits@lists.llvm.org) wrote:

Author: hfinkel
Date: Sat Oct 8 22:06:31 2016
New Revision: 283685

URL: http://llvm.org/viewvc/llvm-project?rev=283685&view=rev
Log:
When optimizing for size, enable loop rerolling by default

We have a loop-rerolling optimization which can be enabled by using
-freroll-loops. While sometimes loops are hand-unrolled for performance
reasons, when optimizing for size, we should always undo this manual
optimization to produce smaller code (our optimizer's unroller will still
unroll the rerolled loops if it thinks that is a good idea).

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283685&r1=283684&r2=283685&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Oct 8 22:06:31 2016
@@ -5227,9 +5227,18 @@ void Clang::ConstructJob(Compilation &C,
}

if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
- options::OPT_fno_reroll_loops))
+ options::OPT_fno_reroll_loops)) {
if (A->getOption().matches(options::OPT_freroll_loops))
CmdArgs.push_back("-freroll-loops");
+ } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+ // If rerolling is not explicitly enabled or disabled, then enable when
+ // optimizing for size.
+ if (A->getOption().matches(options::OPT_O)) {
+ StringRef S(A->getValue());
+ if (S == "s" || S == "z")
+ CmdArgs.push_back("-freroll-loops");
+ }
+ }

Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=283685&r1=283684&r2=283685&view=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Sat Oct 8 22:06:31 2016
@@ -47,7 +47,12 @@
// CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"

// RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
+// RUN: %clang -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
+// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
// RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -Os -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -Oz -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -O1 %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
// RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
// RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
// CHECK-REROLL-LOOPS: "-freroll-loops"


___
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: r283685 - When optimizing for size, enable loop rerolling by default

2016-10-11 Thread Hal Finkel via cfe-commits
Hi Chris, 

Thanks! Can you (or someone else) revert this. I won't be able to look at it 
until tonight. 

-Hal 

- Original Message -

> From: "Chris Matthews" 
> To: "Hal Finkel" , cfe-commits@lists.llvm.org
> Sent: Tuesday, October 11, 2016 2:32:33 PM
> Subject: Re: r283685 - When optimizing for size, enable loop
> rerolling by default

> I noticed since this commit there is a test-suite failure:

> http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/

> SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.

> Tailing the output of the program gets:

> …
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed

> On October 8, 2016 at 8:15:40 PM, Hal Finkel via cfe-commits (
> cfe-commits@lists.llvm.org ) wrote:
> > Author: hfinkel
> 
> > Date: Sat Oct 8 22:06:31 2016
> 
> > New Revision: 283685
> 

> > URL: http://llvm.org/viewvc/llvm-project?rev=283685&view=rev
> 
> > Log:
> 
> > When optimizing for size, enable loop rerolling by default
> 

> > We have a loop-rerolling optimization which can be enabled by using
> 
> > -freroll-loops. While sometimes loops are hand-unrolled for
> > performance
> 
> > reasons, when optimizing for size, we should always undo this
> > manual
> 
> > optimization to produce smaller code (our optimizer's unroller will
> > still
> 
> > unroll the rerolled loops if it thinks that is a good idea).
> 

> > Modified:
> 
> > cfe/trunk/lib/Driver/Tools.cpp
> 
> > cfe/trunk/test/Driver/clang_f_opts.c
> 

> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> 
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283685&r1=283684&r2=283685&view=diff
> 
> > ==
> 
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> 
> > +++ cfe/trunk/lib/Driver/Tools.cpp Sat Oct 8 22:06:31 2016
> 
> > @@ -5227,9 +5227,18 @@ void Clang::ConstructJob(Compilation &C,
> 
> > }
> 

> > if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
> 
> > - options::OPT_fno_reroll_loops))
> 
> > + options::OPT_fno_reroll_loops)) {
> 
> > if (A->getOption().matches(options::OPT_freroll_loops))
> 
> > CmdArgs.push_back("-freroll-loops");
> 
> > + } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
> 
> > + // If rerolling is not explicitly enabled or disabled, then
> > enable
> > when
> 
> > + // optimizing for size.
> 
> > + if (A->getOption().matches(options::OPT_O)) {
> 
> > + StringRef S(A->getValue());
> 
> > + if (S == "s" || S == "z")
> 
> > + CmdArgs.push_back("-freroll-loops");
> 
> > + }
> 
> > + }
> 

> > Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
> 
> > Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,
> 

> > Modified: cfe/trunk/test/Driver/clang_f_opts.c
> 
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=283685&r1=283684&r2=283685&view=diff
> 
> > ==
> 
> > --- cfe/trunk/test/Driver/clang_f_opts.c (original)
> 
> > +++ cfe/trunk/test/Driver/clang_f_opts.c Sat Oct 8 22:06:31 2016
> 
> > @@ -47,7 +47,12 @@
> 
> > // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
> 

> > // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Os %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Os -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Oz -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -O1 %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 |
> > FileCheck -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 |
> > FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > // CHECK-REROLL-LOOPS: "-freroll-loops"
> 

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

-- 

Hal Finkel 
Lead, Compiler Technology and Programming Languages 
Leadership Computing Facility 
Argonne National Laboratory 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

bruno wrote:
> vbyakovlcl wrote:
> > bruno wrote:
> > > vbyakovlcl wrote:
> > > > bruno wrote:
> > > > > Besides `__ext_vector_type__`, would this also trigger for 
> > > > > `vector_size`? Right now this is an error for `vector_size` primarily 
> > > > > because the number of elements is different, can you confirm this 
> > > > > won't change?
> > > > I compare vector element sizes, so there must not be any differencies 
> > > > caused by different triggers. I added additional type definitions to 
> > > > the tests. All compiles fain.
> > > 
> > > I don't think this is right. When I try to compile similar code for 
> > > `vector_size` without your patch, I get the errors:
> > > 
> > > /tmp/x.c:80:15: error: vector operands do not have the same number of 
> > > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > > (vector of 8 'unsigned char' values))
> > >   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have 
> > > the same elements sizes}}
> > >   ^  ~
> > > /tmp/x.c:81:17: error: vector operands do not have the same number of 
> > > elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> > > 'vector_int8n' (vector of 2 'int' values))
> > >   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^  
> > > /tmp/x.c:82:17: error: vector operands do not have the same number of 
> > > elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> > > 'vector_uint8n' (vector of 2 'unsigned int' values))
> > >   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^  ~
> > > /tmp/x.c:83:17: error: vector operands do not have the same number of 
> > > elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> > > 'vector_short8n' (vector of 4 'short' values))
> > >   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^   
> > > 
> > > Given your test changes, it seems that now, instead of "vector operands 
> > > do not have the same number of elements" we would get "vector operands do 
> > > not have the same elements sizes". I rather we stay with the first. 
> > > Additionally, even if we had "vector operands do not have the same 
> > > elements sizes" for `vector_size`, this should never be demoted to a 
> > > warning.
> > Argument of a GNU vector size attribute specifies vector size measured in 
> > bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So 
> > you got right diagnostics. Both compilers with and without my changes print 
> > the same diagnostics  for yours case. Here is a small testcase used both 
> > GNU and clang extensions
> > 
> > $ cat bruno.c   
> > 
> >  
> > typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
> > typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
> >  
> > typedef __attribute__((vector_size(8))) int vector_int8n;
> > typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
> >  
> > vector_int8  vi8;
> > vector_uchar8 vuc8;
> > vector_int8n  vi8n;
> > vector_uchar8n vuc8n;
> >  
> > int foo() {
> >   vi8 = vi8 << vuc8;
> >   vi8n = vi8n << vuc8n;
> > 
> > $ clang -c bruno.c -Wno-error-vec-elem-size 
> > 
> >  
> > bruno.c:13:13: warning: vector operands do not have the same elements sizes 
> > ('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
> > 'unsigned char' values)) [-Wvec-elem-size]
> >   vi8 = vi8 << vuc8;
> > ~~~ ^  
> > bruno.c:14:15: error: vector operands do not have the same number of 
> > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > (vector of 8 'unsigned char' values))
> >   vi8n = vi8n << vuc8n;
> > 
> > The compiler without the changes prints the second error only 
> > (bruno.c:14:15).
> What actually concerns me here is the following: if you invoke `clang -c 
> bruno.c -Wvec-elem-size`, will that override the `error: vector operands do 
> not have the same number of elements ` message for `vector_size` typed 
> vectors? If so, I don't think this is right.
No, this will not override the error because these diagnostics use independent 
conditions. The option  vec-elem-size is used only for con

r283933 - Swift Calling Convention: Parameters are allowed after the

2016-10-11 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Tue Oct 11 15:34:06 2016
New Revision: 283933

URL: http://llvm.org/viewvc/llvm-project?rev=283933&view=rev
Log:
Swift Calling Convention: Parameters are allowed after the
swift_error/swift_context parameter

We need to be able to decelare witness functions which append the self type and
the self witness tables at the end of the parameter list.

rdar://28720996

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/attr-swiftcall.c
cfe/trunk/test/SemaCXX/attr-swiftcall.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=283933&r1=283932&r2=283933&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Oct 11 15:34:06 2016
@@ -2400,28 +2400,16 @@ static void checkExtParameterInfos(Sema
   }
   continue;
 
-// swift_context parameters must be the last parameter except for
-// a possible swift_error parameter.
 case ParameterABI::SwiftContext:
   checkForSwiftCC(paramIndex);
-  if (!(paramIndex == numParams - 1 ||
-(paramIndex == numParams - 2 &&
- EPI.ExtParameterInfos[numParams - 1].getABI()
-   == ParameterABI::SwiftErrorResult))) {
-S.Diag(getParamLoc(paramIndex),
-   diag::err_swift_context_not_before_swift_error_result);
-  }
   continue;
 
-// swift_error parameters must be the last parameter.
+// swift_error parameters must be preceded by a swift_context parameter.
 case ParameterABI::SwiftErrorResult:
   checkForSwiftCC(paramIndex);
-  if (paramIndex != numParams - 1) {
-S.Diag(getParamLoc(paramIndex),
-   diag::err_swift_error_result_not_last);
-  } else if (paramIndex == 0 ||
- EPI.ExtParameterInfos[paramIndex - 1].getABI()
-   != ParameterABI::SwiftContext) {
+  if (paramIndex == 0 ||
+  EPI.ExtParameterInfos[paramIndex - 1].getABI() !=
+  ParameterABI::SwiftContext) {
 S.Diag(getParamLoc(paramIndex),
diag::err_swift_error_result_not_after_swift_context);
   }

Modified: cfe/trunk/test/Sema/attr-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-swiftcall.c?rev=283933&r1=283932&r2=283933&view=diff
==
--- cfe/trunk/test/Sema/attr-swiftcall.c (original)
+++ cfe/trunk/test/Sema/attr-swiftcall.c Tue Oct 11 15:34:06 2016
@@ -18,13 +18,13 @@ void indirect_result_single(INDIRECT_RES
 void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void 
*out2) SWIFTCALL;
 
 void error_result_nonswift(ERROR_RESULT void **error); // expected-error 
{{'swift_error_result' parameter can only be used with swiftcall calling 
convention}} expected-error{{'swift_error_result' parameter must follow 
'swift_context' parameter}}
-void error_result_bad_position(ERROR_RESULT void **error, int last) SWIFTCALL; 
// expected-error {{'swift_error_result' parameter must be last parameter of 
function}}
 void error_result_bad_position2(int first, ERROR_RESULT void **error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 
'swift_context' parameter}}
 void error_result_bad_type(CONTEXT void *context, ERROR_RESULT int error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer 
to unqualified pointer type; type here is 'int'}}
 void error_result_bad_type2(CONTEXT void *context, ERROR_RESULT int *error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer 
to unqualified pointer type; type here is 'int *'}}
 void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void 
**error) SWIFTCALL;
+void error_result_okay2(CONTEXT void *context, ERROR_RESULT void **error, void 
*selfType, char **selfWitnessTable) SWIFTCALL;
 
 void context_nonswift(CONTEXT void *context); // expected-error 
{{'swift_context' parameter can only be used with swiftcall calling convention}}
-void context_bad_position(CONTEXT void *context, int x) SWIFTCALL; // 
expected-error {{'swift_context' parameter can only be followed by 
'swift_error_result' parameter}}
 void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error 
{{'swift_context' parameter must have pointer type; type here is 'int'}}
 void context_okay(CONTEXT void *context) SWIFTCALL;
+void context_okay2(CONTEXT void *context, void *selfType, char 
**selfWitnessTable) SWIFTCALL;

Modified: cfe/trunk/test/SemaCXX/attr-swiftcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-swiftcall.cpp?rev=283933&r1=283932&r2=283933&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-swiftcall.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-swiftcall.cp

r283932 - Pass the end of a component to SwiftAggLowering's enumerateComponents callback

2016-10-11 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Tue Oct 11 15:34:03 2016
New Revision: 283932

URL: http://llvm.org/viewvc/llvm-project?rev=283932&view=rev
Log:
Pass the end of a component to SwiftAggLowering's enumerateComponents callback

This is usefull for determining whether components overlap.

Modified:
cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp

Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=283932&r1=283931&r2=283932&view=diff
==
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Tue Oct 11 15:34:03 2016
@@ -90,7 +90,7 @@ public:
   bool shouldPassIndirectly(bool asReturnValue) const;
 
   using EnumerationCallback =
-llvm::function_ref;
+llvm::function_ref;
 
   /// Enumerate the expanded components of this type.
   ///

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=283932&r1=283931&r2=283932&view=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Tue Oct 11 15:34:03 2016
@@ -506,7 +506,7 @@ void SwiftAggLowering::enumerateComponen
   assert(Finished && "haven't yet finished lowering");
 
   for (auto &entry : Entries) {
-callback(entry.Begin, entry.Type);
+callback(entry.Begin, entry.End, entry.Type);
   }
 }
 


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


[libcxx] r283941 - Fix incorrect exception handling behavior in the uninitialized algorithms

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 16:13:44 2016
New Revision: 283941

URL: http://llvm.org/viewvc/llvm-project?rev=283941&view=rev
Log:
Fix incorrect exception handling behavior in the uninitialized algorithms

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=283941&r1=283940&r2=283941&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Oct 11 16:13:44 2016
@@ -3709,21 +3709,63 @@ uninitialized_fill_n(_ForwardIterator __
 
 #if _LIBCPP_STD_VER > 14
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void destroy_at(_Tp* __loc) {
+_LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+__loc->~_Tp();
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void destroy(_ForwardIterator __first, _ForwardIterator __last) {
+for (; __first != __last; ++__first)
+_VSTD::destroy_at(_VSTD::addressof(*__first));
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
+for (; __n > 0; (void)++__first, --__n)
+_VSTD::destroy_at(_VSTD::addressof(*__first));
+return __first;
+}
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void uninitialized_default_construct(_ForwardIterator __first, 
_ForwardIterator __last) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __first != __last; ++__first)
-::new((void*)_VSTD::addressof(*__first)) _Vt;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __idx != __last; ++__idx)
+::new((void*)_VSTD::addressof(*__idx)) _Vt;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, 
_Size __n) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __n > 0; (void)++__first, --__n)
-::new((void*)_VSTD::addressof(*__first)) _Vt;
-return __first;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __n > 0; (void)++__idx, --__n)
+::new((void*)_VSTD::addressof(*__idx)) _Vt;
+return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 
@@ -3731,60 +3773,79 @@ template 
 inline _LIBCPP_INLINE_VISIBILITY
 void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator 
__last) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __first != __last; ++__first)
-::new((void*)_VSTD::addressof(*__first)) _Vt();
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __idx != __last; ++__idx)
+::new((void*)_VSTD::addressof(*__idx)) _Vt();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, 
_Size __n) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __n > 0; (void)++__first, --__n)
-::new((void*)_VSTD::addressof(*__first)) _Vt();
-return __first;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __n > 0; (void)++__idx, --__n)
+::new((void*)_VSTD::addressof(*__idx)) _Vt();
+return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt 
__res) {
+_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt 
__first_res) {
 using _Vt = typename iterator_traits<_ForwardIt>::value_type;
-for (; __first != __last; (void)++__res, ++__first)
-::new((void*)_VSTD::addressof(*__res)) _Vt(std::move(*__first));
-return __res;
+auto __idx = __first_res;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {

r283943 - Module: for ObjectiveC, be consistent when checking hidden decls.

2016-10-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Oct 11 16:18:20 2016
New Revision: 283943

URL: http://llvm.org/viewvc/llvm-project?rev=283943&view=rev
Log:
Module: for ObjectiveC, be consistent when checking hidden decls.

In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

Added:
cfe/trunk/test/Modules/Inputs/objc-hidden/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/objc-hidden/System/
cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
cfe/trunk/test/Modules/objc-hidden.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=283943&r1=283942&r2=283943&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Oct 11 16:18:20 2016
@@ -2741,7 +2741,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getInstanceMethod(I->getSelector());
-  assert(CDecl->getInstanceMethod(I->getSelector()) &&
+  assert(CDecl->getInstanceMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {
@@ -2767,7 +2767,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getClassMethod(I->getSelector());
-  assert(CDecl->getClassMethod(I->getSelector()) &&
+  assert(CDecl->getClassMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h?rev=283943&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,7 @@
+#include 
+
+__attribute__((availability(macosx,introduced=1066.0)))  
__attribute__((availability(ios,introduced=1066.0)))
+@interface UnavailableObjCClass : NSObject
+- (void)someMethod;
+@end
+

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap?rev=283943&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,5 @@
+framework module FakeUnavailableObjCFramework {
+  umbrella header "FakeUnavailableObjCFramework.h"
+  // Do not export to test hidden decls.
+  // export *
+}

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h?rev=283943&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h Tue Oct 11 16:18:20 
2016
@@ -0,0 +1,5 @@
+@protocol NSObject
+@property (readonly) int hash;
+@end
+@interface NSObject 
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map?rev=283943&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map (added)
+++ cf

[libcxx] r283944 - Fix std::pair on FreeBSD

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 16:22:21 2016
New Revision: 283944

URL: http://llvm.org/viewvc/llvm-project?rev=283944&view=rev
Log:
Fix std::pair on FreeBSD

Summary:
FreeBSD ships an old ABI for std::pair which requires that it have non-trivial 
copy/move constructors. Currently the non-trivial copy/move is achieved by 
providing explicit definitions of the constructors. This is problematic because 
it means the constructors don't SFINAE properly. In order to SFINAE copy/move 
constructors they have to be explicitly defaulted and hense non-trivial.

This patch attempts to provide SFINAE'ing copy/move constructors for std::pair 
while still making them non-trivial. It does this by adding a base class with a 
non-trivial copy constructor and then allowing pair's constructors to be 
generated by the compiler. This also allows the constructors to be constexpr.


Reviewers: emaste, theraven, rsmith, dim

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/utility

libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=283944&r1=283943&r2=283944&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Oct 11 16:22:21 2016
@@ -291,9 +291,20 @@ extern const piecewise_construct_t piece
 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
 #endif
 
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+struct __non_trivially_copyable_base {
+  _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+  __non_trivially_copyable_base() _NOEXCEPT {}
+  _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+  __non_trivially_copyable_base(__non_trivially_copyable_base const&) 
_NOEXCEPT {}
+};
+#endif
 
 template 
 struct _LIBCPP_TYPE_VIS_ONLY pair
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+: private __non_trivially_copyable_base
+#endif
 {
 typedef _T1 first_type;
 typedef _T2 second_type;
@@ -301,26 +312,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 _T1 first;
 _T2 second;
 
-#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
-_LIBCPP_INLINE_VISIBILITY
-pair(const pair& __p)
-_NOEXCEPT_(is_nothrow_copy_constructible::value &&
-   is_nothrow_copy_constructible::value)
-: first(__p.first),
-  second(__p.second)
-{
-}
-
-# ifndef _LIBCPP_CXX03_LANG
-_LIBCPP_INLINE_VISIBILITY
-pair(pair&& __p) 
_NOEXCEPT_(is_nothrow_move_constructible::value &&
-
is_nothrow_move_constructible::value)
-: first(_VSTD::forward(__p.first)),
-  second(_VSTD::forward(__p.second))
-{
-}
-# endif
-#elif !defined(_LIBCPP_CXX03_LANG)
+#if !defined(_LIBCPP_CXX03_LANG)
 pair(pair const&) = default;
 pair(pair&&) = default;
 #else

Modified: 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp?rev=283944&r1=283943&r2=283944&view=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
 Tue Oct 11 16:22:21 2016
@@ -7,49 +7,142 @@
 //
 
//===--===//
 
+// The test fails due to the missing is_trivially_constructible intrinsic.
+// XFAIL: gcc-4.9
+
 // 
 
 // template  struct pair
 
-// Test that we properly provide the old non-trivial copy operations
-// when the ABI macro is defined.
+// Test that we properly provide the trivial copy operations by default.
 
+// FreeBSD provides the old ABI. This test checks the new ABI so we need
+// to manually turn it on.
+#undef _LIBCPP_ABI_UNSTABLE
+#undef _LIBCPP_ABI_VERSION
+#define _LIBCPP_ABI_VERSION 1
 #define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+
 #include 
+#include 
+#include 
 #include 
 
 #include "test_macros.h"
 
+#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+#error trivial ctor ABI macro defined
+#endif
+
+template 
+struct HasNonTrivialABI : std::integral_constant::value
+|| (std::is_copy_constructible::value && 
!std::is_trivially_copy_constructible::value)
+#if TEST_STD_VER >= 11
+   || (std::is_move_constructible::value && 
!std::is_trivially_move_constructible::value)
+#endif
+> {};
+
 #if TEST_STD_VER >= 11
-struct Dummy {
-  Dummy(Dummy const&) = delete;
-  Dummy(Dummy &&) = default;
+struct NonTrivialDtor {
+NonTrivialDtor(NonTri

RE: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Yung, Douglas via cfe-commits
We noticed that this change also caused VS2015 to take a lot longer when 
building Targets.cpp. The revert in r283920 seems to have fixed it. The 
upstream PS4 Windows bot went from a build time of 17:53 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12771)
 to 5:51 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12772).

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Mehdi Amini via cfe-commits
> Sent: Tuesday, October 11, 2016 12:14
> To: Benjamin Kramer
> Cc: cfe-commits
> Subject: Re: r283802 - Change Builtins name to be stored as StringRef
> instead of raw pointers (NFC)
> 
> Reverted in r283920, can you check if it is enough to “fix” the GCC
> issue?
> 
> > On Oct 11, 2016, at 12:04 PM, Benjamin Kramer 
> wrote:
> >
> > Committing this patch before the constexpr change seems backwards
> > then? The static initializers are already breaking stuff because it
> > takes GCC with optimization and debug info takes 10+ minutes to
> > generate megabytes of static initializer code in Targets.cpp. Can you
> > please revert this until the constexpr change is ready?
> >
> > On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini 
> wrote:
> >> This is temporary: the last patch of my series of patches adds the
> constexpr ctor and remove all these static initializers.
> >>
> >>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer 
> wrote:
> >>>
> >>> I don't think this change is worth it. We create huge static arrays
> >>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> >>> char*) is not constexpr (because of strlen). This means you'll get
> a
> >>> huge generated initialization function for it. We want to reduce
> the
> >>> number of global initializers in LLVM, not create new ones.
> >>>
> >>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> >>>  wrote:
>  Author: mehdi_amini
>  Date: Mon Oct 10 16:34:29 2016
>  New Revision: 283802
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=283802&view=rev
>  Log:
>  Change Builtins name to be stored as StringRef instead of raw
>  pointers (NFC)
> 
>  Modified:
>    cfe/trunk/include/clang/Basic/Builtins.h
>    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>    cfe/trunk/lib/Sema/SemaChecking.cpp
> 
>  Modified: cfe/trunk/include/clang/Basic/Builtins.h
>  URL:
>  http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Basic/B
>  uiltins.h?rev=283802&r1=283801&r2=283802&view=diff
> 
> ===
>  ===
>  --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>  +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29
>  +++ 2016
>  @@ -51,7 +51,8 @@ enum ID {
>  };
> 
>  struct Info {
>  -  const char *Name, *Type, *Attributes, *HeaderName;
>  +  llvm::StringRef Name;
>  +  const char *Type, *Attributes, *HeaderName;
>   LanguageID Langs;
>   const char *Features;
>  };
>  @@ -80,7 +81,7 @@ public:
> 
>   /// \brief Return the identifier name for the specified builtin,
>  /// e.g. "__builtin_abs".
>  -  const char *getName(unsigned ID) const {
>  +  llvm::StringRef getName(unsigned ID) const {
> return getRecord(ID).Name;
>   }
> 
> 
>  Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>  URL:
>  http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGBuiltin
>  .cpp?rev=283802&r1=283801&r2=283802&view=diff
> 
> ===
>  ===
>  --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>  +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>  @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi  if
>  (FD->hasAttr())
> Name = getMangledName(D);
>   else
>  -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>  +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> 
>   llvm::FunctionType *Ty =
> cast(getTypes().ConvertType(FD-
> >getType()));
>  @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>  checkTargetFeatures(E, FD);
> 
>   // See if we have a target specific intrinsic.
>  -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;  StringRef
>  Prefix =
> 
> 
> llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>   if (!Prefix.empty()) {
>  +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> IntrinsicID =
> Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
> // NOTE we dont need to perform a compatibility flag check here
> since the
> // intrinsics are declared in Builtins*.

  1   2   >