Re: [PATCH] D13128: Fix backend crash on multiple close of stdout.

2015-09-29 Thread Dan Gohman via cfe-commits
sunfish added a comment.

> In any case, that's not how clang deal with usage or even internal unexpected 
> errors. It asserts, print error messages but does not crash on purpose. 
> Having clang crash here does not seem like a good solution and will result in 
> this issue continue to surface again.


When clang has bugs, it is common for it to crash unceremoniously. That said, 
if you know of a reasonable way to assert here before the crash, that'd be 
great.

> The bad thing is that the same problem can be reproduced not only in 
> frontend, but also in opt tool. The test I wrote (test/Other/empty.ll) also 
> failed with the same message.


This could also be interpreted as opt failing to check for incompatible 
command-line options. One of the command-line options in this case is a hidden 
option, so this isn't especially surprising.

> And Yaron is right, I need to mix several outputs in stdout. What should I do 
> in this case?


What's the context? It may be worth investigating whether there are other ways 
to address your need.

If you want to use -rewrite-map-file and -info-output-file in a testcase at the 
same time, see the documentation for '%t' in the TestingGuide for creating 
multiple temporary output files.


http://reviews.llvm.org/D13128



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


Re: [PATCH] D13228: clang-format: Extend #include sorting functionality

2015-09-29 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/Format.cpp:1665
@@ +1664,3 @@
+
+  // Create pre-compile regular expressions for the #include categories.
+  SmallVector CategoryRegexs;

pre-compiled


Comment at: lib/Format/Format.cpp:1677
@@ +1676,3 @@
+unsigned Category;
+if (LookForMainHeader &&! Matches[1].startswith("<")) {
+  Category = 0;

Run clang-format.

Also, shouldn't we try to figure out whether the name matches, instead of 
simply assuming the first one is the main header?


http://reviews.llvm.org/D13228



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


Re: [PATCH] D13228: clang-format: Extend #include sorting functionality

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper marked an inline comment as done.


Comment at: lib/Format/Format.cpp:1677
@@ +1676,3 @@
+unsigned Category;
+if (LookForMainHeader &&! Matches[1].startswith("<")) {
+  Category = 0;

klimek wrote:
> Run clang-format.
> 
> Also, shouldn't we try to figure out whether the name matches, instead of 
> simply assuming the first one is the main header?
Ran clang-format and added a comment.


http://reviews.llvm.org/D13228



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


Re: [PATCH] D13228: clang-format: Extend #include sorting functionality

2015-09-29 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13228



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


Re: [PATCH] D13210: Make brace styles more configurable

2015-09-29 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13210



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


r248782 - clang-format: Extend #include sorting functionality

2015-09-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Sep 29 02:53:08 2015
New Revision: 248782

URL: http://llvm.org/viewvc/llvm-project?rev=248782&view=rev
Log:
clang-format: Extend #include sorting functionality

Recognize the main module header as well as different #include categories.
This should now mimic the behavior of llvm/utils/sort_includes.py as
well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very
closely.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=248782&r1=248781&r2=248782&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Tue Sep 29 02:53:08 2015
@@ -259,6 +259,21 @@ struct FormatStyle {
   /// For example: BOOST_FOREACH.
   std::vector ForEachMacros;
 
+  /// \brief Regular expressions denoting the different #include categories 
used
+  /// for ordering #includes.
+  ///
+  /// These regular expressions are matched against the filename of an include
+  /// (including the <> or "") in order. The value belonging to the first
+  /// matching regular expression is assigned and #includes are sorted first
+  /// according to increasing category number and then alphabetically within
+  /// each category.
+  ///
+  /// If none of the regular expressions match, UINT_MAX is assigned as
+  /// category. The main header for a source file automatically gets category 
0,
+  /// so that it is kept at the beginning of the #includes
+  /// (http://llvm.org/docs/CodingStandards.html#include-style).
+  std::vector> IncludeCategories;
+
   /// \brief Indent case labels one level from the switch statement.
   ///
   /// When \c false, use the same indentation level as for the switch 
statement.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=248782&r1=248781&r2=248782&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Sep 29 02:53:08 2015
@@ -13,6 +13,7 @@
 ///
 
//===--===//
 
+#include "clang/Format/Format.h"
 #include "ContinuationIndenter.h"
 #include "TokenAnnotator.h"
 #include "UnwrappedLineFormatter.h"
@@ -21,7 +22,6 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
@@ -375,6 +375,9 @@ FormatStyle getLLVMStyle() {
   LLVMStyle.ForEachMacros.push_back("foreach");
   LLVMStyle.ForEachMacros.push_back("Q_FOREACH");
   LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH");
+  LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2},
+ {"^(<|\"(gtest|isl|json)/)", 3},
+ {".*", 1}};
   LLVMStyle.IndentCaseLabels = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
@@ -423,6 +426,7 @@ FormatStyle getGoogleStyle(FormatStyle::
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
+  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
@@ -1575,7 +1579,7 @@ struct IncludeDirective {
   StringRef Filename;
   StringRef Text;
   unsigned Offset;
-  bool IsAngled;
+  unsigned Category;
 };
 
 } // end anonymous namespace
@@ -1605,7 +1609,8 @@ static void sortIncludes(const FormatSty
   for (unsigned i = 0, e = Includes.size(); i != e; ++i)
 Indices.push_back(i);
   std::sort(Indices.begin(), Indices.end(), [&](unsigned LHSI, unsigned RHSI) {
-return Includes[LHSI].Filename < Includes[RHSI].Filename;
+return std::tie(Includes[LHSI].Category, Includes[LHSI].Filename) <
+   std::tie(Includes[RHSI].Category, Includes[RHSI].Filename);
   });
 
   // If the #includes are out of order, we generate a single replacement fixing
@@ -1642,22 +1647,49 @@ tooling::Replacements sortIncludes(const
   tooling::Replacements Replaces;
   unsigned Prev = 0;
   unsigned SearchFrom = 0;
-  llvm::Regex IncludeRegex(R"(^[\t\ ]*#[\t\ 
]*include[^"<]*["<]([^">]*)([">]))");
+  llvm::Regex IncludeRegex(
+  R"(^[\t\ ]*#[\t\ ]*include[^"<]*(["<][^">]*[">]))");
   SmallVector Matches;
   SmallVector IncludesInBlock;
+
+  // In compiled files, consider the first #include

Re: [PATCH] D13228: clang-format: Extend #include sorting functionality

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r248782.


http://reviews.llvm.org/D13228



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


Re: [PATCH] D12633: Implement ACLE 2.0 macros of chapters 6.6 and 6.7 for [ARM] and [Aarch64] targets

2015-09-29 Thread Alexandros Lamprineas via cfe-commits
labrinea added a comment.

ping


http://reviews.llvm.org/D12633



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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-09-29 Thread Beren Minor via cfe-commits
berenm updated this revision to Diff 35946.
berenm added a comment.

Update the diff with the ProvideAutoLoad attribute.

Thanks @MyDeveloperDay for the review and tips!


http://reviews.llvm.org/D12407

Files:
  tools/clang-format-vs/ClangFormat/ClangFormat.csproj
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -12,12 +12,14 @@
 //
 //===--===//
 
+using Microsoft.VisualStudio;
 using Microsoft.VisualStudio.Editor;
 using Microsoft.VisualStudio.Shell;
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.Text;
 using Microsoft.VisualStudio.Text.Editor;
 using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.ComponentModelHost;
 using System;
 using System.ComponentModel;
 using System.ComponentModel.Design;
@@ -53,28 +55,54 @@
 get { return style; }
 set { style = value; }
 }
+
+[Category("LLVM/Clang")]
+[DisplayName("Reformat On Save")]
+[Description("Reformat code when the source file is saved on disk")]
+public bool ReformatOnSave
+{
+get;
+set;
+}
 }
 
 [PackageRegistration(UseManagedResourcesOnly = true)]
 [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
 [ProvideMenuResource("Menus.ctmenu", 1)]
 [Guid(GuidList.guidClangFormatPkgString)]
 [ProvideOptionPage(typeof(OptionPageGrid), "LLVM/Clang", "ClangFormat", 0, 0, true)]
-public sealed class ClangFormatPackage : Package
+[ProvideAutoLoad(UIContextGuids80.NoSolution)]
+public sealed class ClangFormatPackage : Package, IVsRunningDocTableEvents3
 {
+private IVsEditorAdaptersFactoryService editorAdaptersFactoryService;
+private IVsRunningDocumentTable runningDocumentTable;
+private uint adviseCookie;
+
 #region Package Members
 protected override void Initialize()
 {
 base.Initialize();
 
+IComponentModel componentModel = GetService(typeof(SComponentModel)) as IComponentModel;
+editorAdaptersFactoryService = componentModel.GetService();
+runningDocumentTable = GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
+runningDocumentTable.AdviseRunningDocTableEvents(this, out adviseCookie);
+
 var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
 if (commandService != null)
 {
 var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);
 var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
 commandService.AddCommand(menuItem);
 }
 }
+
+protected override void Dispose(bool disposing)
+{
+runningDocumentTable.UnadviseRunningDocTableEvents(adviseCookie);
+
+base.Dispose(disposing);
+}
 #endregion
 
 private void MenuItemCallback(object sender, EventArgs args)
@@ -92,10 +120,16 @@
 if (start >= text.Length && text.Length > 0)
 start = text.Length - 1;
 string path = GetDocumentParent(view);
+FormatTextBuffer(view.TextBuffer, start, length, path);
+}
+
+private void FormatTextBuffer(ITextBuffer textBuffer, int offset, int length, string path)
+{
 try
 {
-var root = XElement.Parse(RunClangFormat(text, start, length, path));
-var edit = view.TextBuffer.CreateEdit();
+string text = textBuffer.CurrentSnapshot.GetText();
+var root = XElement.Parse(RunClangFormat(text, offset, length, path));
+var edit = textBuffer.CreateEdit();
 foreach (XElement replacement in root.Descendants("replacement"))
 {
 var span = new Span(
@@ -199,7 +233,7 @@
 var userData = (IVsUserData)textView;
 if (userData == null)
 return null;
-Guid guidWpfViewHost = DefGuidList.guidIWpfTextViewHost;
+Guid guidWpfViewHost = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost;
 object host;
 userData.GetData(ref guidWpfViewHost, out host);
 return ((IWpfTextViewHost)host).TextView;
@@ -211,6 +245,12 @@
 return page.Style;
 }
 
+private bool ShouldReformatOnSave()
+{
+var page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
+return page.ReformatOnSave;
+}
+
 private

Re: [PATCH] D13166: Create modernize-make-unique check.

2015-09-29 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

apart from the comment, LG



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:67-70
@@ +66,6 @@
+  SourceLocation ConstructCallEnd;
+  if (LAngle == StringRef::npos) {
+ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
+Diag << FixItHint::CreateInsertion(ConstructCallEnd,
+   "<" + Type->getAsString() + ">");
+  } else {

Please add a comment what this does (in which cases do we want to insert the 
type).


http://reviews.llvm.org/D13166



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


Re: [PATCH] D13166: Create modernize-make-unique check.

2015-09-29 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 35949.
angelgarcia added a comment.

Add a comment.


http://reviews.llvm.org/D13166

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -0,0 +1,122 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t
+
+namespace std {
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(type *ptr);
+  unique_ptr(const unique_ptr &t) = delete;
+  unique_ptr(unique_ptr &&t);
+  ~unique_ptr();
+  type &operator*() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release();
+  void reset();
+  void reset(type *pt);
+
+private:
+  type *ptr;
+};
+
+}
+
+struct Base {
+  Base();
+  Base(int, int);
+};
+
+struct Derived : public Base {
+  Derived();
+  Derived(int, int);
+};
+
+struct Pair {
+  int a, b;
+};
+
+template using unique_ptr_ = std::unique_ptr;
+
+int g(std::unique_ptr P);
+
+std::unique_ptr getPointer() {
+  return std::unique_ptr(new Base);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
+  // CHECK-FIXES: return std::make_unique();
+}
+
+void f() {
+  std::unique_ptr P1 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P1 = std::make_unique();
+
+  // Without parenthesis.
+  std::unique_ptr P2 = std::unique_ptr(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P2 = std::make_unique();
+
+  // With auto.
+  auto P3 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: auto P3 = std::make_unique();
+
+  {
+// No std.
+using namespace std;
+unique_ptr Q = unique_ptr(new int());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead
+// CHECK-FIXES: unique_ptr Q = std::make_unique();
+  }
+
+  std::unique_ptr R(new int());
+
+  // Create the unique_ptr as a parameter to a function.
+  int T = g(std::unique_ptr(new int()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: int T = g(std::make_unique());
+
+  // Arguments are correctly handled.
+  std::unique_ptr Pbase = std::unique_ptr(new Base(5, T));
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T);
+
+  // Works with init lists.
+  std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1});
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1});
+
+  // Only replace if the type in the template is the same than the type returned
+  // by the new operator.
+  auto Pderived = std::unique_ptr(new Derived());
+
+  // The pointer is returned by the function, nothing to do.
+  std::unique_ptr RetPtr = getPointer();
+
+  // Aliases.
+  typedef std::unique_ptr IntPtr;
+  IntPtr Typedef = IntPtr(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead
+  // CHECK-FIXES: IntPtr Typedef = std::make_unique();
+
+#define PTR unique_ptr
+  std::unique_ptr Macro = std::PTR(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Macro = std::make_unique();
+#undef PTR
+
+  std::unique_ptr Using = unique_ptr_(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Using = std::make_unique();
+
+  // This emulates std::move.
+  std::unique_ptr Move = static_cast&&>(P1);
+
+  // Adding whitespaces.
+  auto Space = std::unique_ptr (new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Space = std::make_unique();
+
+  auto Spaces = std  ::unique_ptr  (new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Spaces = std::make_unique();
+}
Index: clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "LoopConvertCheck.h"
+#include "MakeUniqueCheck.h"
 #include "PassByValueCheck.h"
 #include "ReplaceAutoPtrCheck.h"
 #include "ShrinkToFitCheck.h"
@@ -28,6 +29,8 @@
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.re

[clang-tools-extra] r248785 - Create modernize-make-unique check.

2015-09-29 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Sep 29 04:36:41 2015
New Revision: 248785

URL: http://llvm.org/viewvc/llvm-project?rev=248785&view=rev
Log:
Create modernize-make-unique check.

Summary: create a check that replaces 'std::unique_ptr(new 
type(args...))' with 'std::make_unique(args...)'. It was on the list of 
"Ideas for new Tools". It needs to be tested more carefully, but first I wanted 
to know if you think it is worth the effort.

Reviewers: klimek

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=248785&r1=248784&r2=248785&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Sep 29 
04:36:41 2015
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyModernizeModule
   LoopConvertCheck.cpp
   LoopConvertUtils.cpp
+  MakeUniqueCheck.cpp
   ModernizeTidyModule.cpp
   PassByValueCheck.cpp
   ReplaceAutoPtrCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=248785&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Tue Sep 29 
04:36:41 2015
@@ -0,0 +1,108 @@
+//===--- MakeUniqueCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MakeUniqueCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+const char PointerType[] = "pointerType";
+const char ConstructorCall[] = "constructorCall";
+const char NewExpression[] = "newExpression";
+
+void MakeUniqueCheck::registerMatchers(MatchFinder *Finder) {
+  if (getLangOpts().CPlusPlus11) {
+Finder->addMatcher(
+cxxBindTemporaryExpr(has(
+cxxConstructExpr(
+
hasType(qualType(hasDeclaration(classTemplateSpecializationDecl(
+matchesName("::std::unique_ptr"),
+templateArgumentCountIs(1),
+hasTemplateArgument(
+0, templateArgument(
+   
refersToType(qualType().bind(PointerType,
+argumentCountIs(1),
+hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
+  equalsBoundNode(PointerType)
+   .bind(NewExpression)))
+.bind(ConstructorCall))),
+this);
+  }
+}
+
+void MakeUniqueCheck::check(const MatchFinder::MatchResult &Result) {
+  SourceManager &SM = *Result.SourceManager;
+  const auto *Construct =
+  Result.Nodes.getNodeAs(ConstructorCall);
+  const auto *New = Result.Nodes.getNodeAs(NewExpression);
+  const auto *Type = Result.Nodes.getNodeAs(PointerType);
+
+  SourceLocation ConstructCallStart = Construct->getExprLoc();
+
+  bool Invalid = false;
+  StringRef ExprStr = Lexer::getSourceText(
+  CharSourceRange::getCharRange(
+  ConstructCallStart, Construct->getParenOrBraceRange().getBegin()),
+  SM, LangOptions(), &Invalid);
+  if (Invalid)
+return;
+
+  auto Diag = diag(ConstructCallStart, "use std::make_unique instead");
+
+  // Find the location of the template's left angle.
+  size_t LAngle = ExprStr.find("<");
+  SourceLocation ConstructCallEnd;
+  if (LAngle == StringRef::npos) {
+// If the template argument is missing (because it is part of the alias)
+// we have to add it back.
+ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
+Diag << FixItHint::CreateInsertion(ConstructCallEnd,
+   "<" + Type->getAsString() + ">");
+  } else {
+ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
+  }
+
+  Diag << FixItHint::CreateReplacement(
+  C

Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a few comments.

Thanks for the new check! Do you think whether this could be a compiler warning 
some day?



Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:52
@@ +51,3 @@
+
+  const FunctionProtoType *FPT = Node.getType()->castAs();
+  ASTContext &Ctx = Node.getASTContext();

nit: `const auto *FPT` would be better here to avoid duplication of the type 
name.


Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.h:22
@@ +21,3 @@
+class NewDeleteOverloadsCheck : public ClangTidyCheck {
+  std::map> Overloads;

I wonder whether "class" here and below is actually needed. Did you try without 
it?


Comment at: test/clang-tidy/misc-new-delete-overloads.cpp:3
@@ +2,3 @@
+
+typedef unsigned int size_t;
+

I think, "unsigned long" should be used instead (and we might have to define it 
differently for different platforms).


http://reviews.llvm.org/D13071



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


Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:537
@@ +536,3 @@
+  return;
+Range.setBegin(Range.getBegin().getLocWithOffset(1));
+

There are cases where this will fail (`~ ClassName()` or `??-ClassName` or 
`~\ClassName`), but I saw these only a couple of times in real code. In 
other similar cases I'd recommend using the lexer and skip to the next token, 
but here it seems to be an overkill.


Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:545
@@ +544,3 @@
+  if (const auto *Loc = Result.Nodes.getNodeAs("typeLoc")) {
+if (const auto &Ref = Loc->getAs()) {
+  addUsage(NamingCheckFailures, Ref.getDecl(), Loc->getSourceRange(),

The four cases are too similar. It should be possible to write the code much 
shorter. This might work:

  if (isa(Loc) || isa(Loc) || ...)
addUsage(NamingCheckFailures, Loc->getType()->getDecl(),
Loc->getSourceRange(), Result.SourceManager);



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:575
@@ +574,3 @@
+return;
+  SourceRange Range = SourceRange(Ref.getTemplateNameLoc(),
+  Ref.getLAngleLoc().getLocWithOffset(-1));

Please remove ` = SourceRange`.


Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:578
@@ +577,3 @@
+
+  if (const auto *ClassDecl = dyn_cast(Decl)) {
+addUsage(NamingCheckFailures, ClassDecl->getTemplatedDecl(), Range,

Can you just cast to `TemplateDecl` or `RedeclarableTemplateDecl`, whichever 
suits better?


http://reviews.llvm.org/D13081



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


Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/NonCopyableObjects.cpp:88
@@ +87,3 @@
+  else if (E)
+diag(E->getExprLoc(), "expression has suspicious type '%0'")
+<< BD->getName();

What's a "suspicious type" and why should the user know about this? Should the 
message explain better what's wrong and what can be done about that?


http://reviews.llvm.org/D12945



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


[libclc] r248780 - Implement tanh builtin

2015-09-29 Thread Niels Ole Salscheider via cfe-commits
Author: olesalscheider
Date: Tue Sep 29 01:39:09 2015
New Revision: 248780

URL: http://llvm.org/viewvc/llvm-project?rev=248780&view=rev
Log:
Implement tanh builtin

This is a port from the AMD builtin library.

Added:
libclc/trunk/generic/include/clc/math/tanh.h
libclc/trunk/generic/include/clc/math/tanh.inc
libclc/trunk/generic/lib/math/tanh.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=248780&r1=248779&r2=248780&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Tue Sep 29 01:39:09 2015
@@ -77,6 +77,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/tanh.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/tanh.h?rev=248780&view=auto
==
--- libclc/trunk/generic/include/clc/math/tanh.h (added)
+++ libclc/trunk/generic/include/clc/math/tanh.h Tue Sep 29 01:39:09 2015
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * 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 ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/include/clc/math/tanh.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/tanh.inc?rev=248780&view=auto
==
--- libclc/trunk/generic/include/clc/math/tanh.inc (added)
+++ libclc/trunk/generic/include/clc/math/tanh.inc Tue Sep 29 01:39:09 2015
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * 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 ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE tanh(__CLC_GENTYPE a);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=248780&r1=248779&r2=248780&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Tue Sep 29 01:39:09 2015
@@ -109,6 +109,7 @@ math/sinpi.cl
 math/clc_sqrt.cl
 math/sqrt.cl
 math/tan.cl
+math/tanh.cl
 relational/all.cl
 relational/any.cl
 relational/bitselect.cl

Added: libclc/trunk/generic/lib/math/tanh.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/tanh.cl?rev=248780&view=auto
==
--- libclc/trunk/generic/lib/math/tanh.cl (added)
+++ libclc/trunk/generic/lib/math/tanh.cl Tue Sep 29 01:39:09 2015
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c

Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types

2015-09-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/NonCopyableObjects.cpp:88
@@ +87,3 @@
+  else if (E)
+diag(E->getExprLoc(), "expression has suspicious type '%0'")
+<< BD->getName();

alexfh wrote:
> What's a "suspicious type" and why should the user know about this? Should 
> the message explain better what's wrong and what can be done about that?
I was trying to find better wording for this, but it's really hard. This comes 
from dereferencing a type that should only be used as an opaque pointer type. 
eg) memcpy(some_buffer, *some_pthread_mutex_t, sizeof(pthread_mutex_t));

Perhaps:

expression has opaque data structure type '%0'; do not rely on internal 
implementation details

or something to that effect?


http://reviews.llvm.org/D12945



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


[clang-tools-extra] r248791 - Adding a checker (misc-new-delete-overloads) that detects mismatched overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https:

2015-09-29 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 29 08:12:21 2015
New Revision: 248791

URL: http://llvm.org/viewvc/llvm-project?rev=248791&view=rev
Log:
Adding a checker (misc-new-delete-overloads) that detects mismatched overloads 
of operator new and operator delete. Corresponds to the CERT C++ secure coding 
rule: 
https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope

Added:
clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-new-delete-overloads.rst

clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=248791&r1=248790&r2=248791&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Sep 29 08:12:21 
2015
@@ -11,6 +11,7 @@ add_clang_library(clangTidyMiscModule
   MacroRepeatedSideEffectsCheck.cpp
   MiscTidyModule.cpp
   MoveConstructorInitCheck.cpp
+  NewDeleteOverloadsCheck.cpp
   NoexceptMoveConstructorCheck.cpp
   SizeofContainerCheck.cpp
   StaticAssertCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=248791&r1=248790&r2=248791&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Tue Sep 29 
08:12:21 2015
@@ -19,6 +19,7 @@
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MoveConstructorInitCheck.h"
+#include "NewDeleteOverloadsCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
 #include "SizeofContainerCheck.h"
 #include "StaticAssertCheck.h"
@@ -53,6 +54,8 @@ public:
 "misc-macro-repeated-side-effects");
 CheckFactories.registerCheck(
 "misc-move-constructor-init");
+CheckFactories.registerCheck(
+"misc-new-delete-overloads");
 CheckFactories.registerCheck(
 "misc-noexcept-move-constructor");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp?rev=248791&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp Tue Sep 
29 08:12:21 2015
@@ -0,0 +1,215 @@
+//===--- NewDeleteOverloadsCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "NewDeleteOverloadsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace {
+AST_MATCHER(FunctionDecl, isPlacementOverload) {
+  bool New;
+  switch (Node.getOverloadedOperator()) {
+  default:
+return false;
+  case OO_New:
+  case OO_Array_New:
+New = true;
+break;
+  case OO_Delete:
+  case OO_Array_Delete:
+New = false;
+break;
+  }
+
+  // Variadic functions are always placement functions.
+  if (Node.isVariadic())
+return true;
+
+  // Placement new is easy: it always has more than one parameter (the first
+  // parameter is always the size). If it's an overload of delete or delete[]
+  // that has only one parameter, it's never a placement delete.
+  if (New)
+return Node.getNumParams() > 1;
+  if (Node.getNumParams() == 1)
+return false;
+
+  // Placement delete is a little more challenging. They always have more than
+  // one parameter with the first parameter being a pointer. However, the
+  // second parameter can be a size_t for sized deallocation, and that is never
+  // a placement delete operator.
+  if (Node.getNumParams() <= 1 || Node.getNumParams() > 2)
+return true;
+
+  const auto *FPT = Node.getType()->castAs();
+  ASTContext &Ctx = Node.getASTContex

Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions

2015-09-29 Thread Aaron Ballman via cfe-commits
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

In http://reviews.llvm.org/D13071#255446, @alexfh wrote:

> Looks good with a few comments.
>
> Thanks for the new check! Do you think whether this could be a compiler 
> warning some day?


I thought about implementing it as a frontend warning, but it seemed somewhat 
expensive for there (since it would have to be triggered on every TU 
completion). However, it might be reasonable to move it in there at some point.

Thank you for the reviews! I've commit in r248791.

~Aaron



Comment at: test/clang-tidy/misc-new-delete-overloads.cpp:3
@@ +2,3 @@
+
+typedef unsigned int size_t;
+

alexfh wrote:
> I think, "unsigned long" should be used instead (and we might have to define 
> it differently for different platforms).
I get a type redefinition error then, so I removed the typedef declaration 
entirely and will watch the bots to make sure this isn't an artifact of being 
on an MSVC build.


http://reviews.llvm.org/D13071



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


[clang-tools-extra] r248792 - Hopefully silencing some built bot warnings. Note, this should be unsigned long instead of unsigned int, but then *other* builds start to fail because of duplicate redefi

2015-09-29 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 29 08:20:26 2015
New Revision: 248792

URL: http://llvm.org/viewvc/llvm-project?rev=248792&view=rev
Log:
Hopefully silencing some built bot warnings. Note, this should be unsigned long 
instead of unsigned int, but then *other* builds start to fail because of 
duplicate redefinitions of size_t.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp?rev=248792&r1=248791&r2=248792&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
 Tue Sep 29 08:20:26 2015
@@ -1,5 +1,7 @@
 // RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- 
-std=c++14 -fsized-deallocation
 
+typedef unsigned int size_t;
+
 struct S {
   // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' 
has no matching declaration of 'operator new' at the same scope 
[misc-new-delete-overloads]
   void operator delete(void *ptr, size_t) noexcept; // not a placement delete

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp?rev=248792&r1=248791&r2=248792&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp Tue 
Sep 29 08:20:26 2015
@@ -1,5 +1,7 @@
 // RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- 
-std=c++14
 
+typedef unsigned int size_t;
+
 struct S {
   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope 
[misc-new-delete-overloads]
   void *operator new(size_t size) noexcept;


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


[clang-tools-extra] r248794 - Silencing bot failures a more creative and definitive way.

2015-09-29 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 29 08:38:00 2015
New Revision: 248794

URL: http://llvm.org/viewvc/llvm-project?rev=248794&view=rev
Log:
Silencing bot failures a more creative and definitive way.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp?rev=248794&r1=248793&r2=248794&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
 Tue Sep 29 08:38:00 2015
@@ -1,6 +1,6 @@
 // RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- 
-std=c++14 -fsized-deallocation
 
-typedef unsigned int size_t;
+typedef decltype(sizeof(int)) size_t;
 
 struct S {
   // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' 
has no matching declaration of 'operator new' at the same scope 
[misc-new-delete-overloads]

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp?rev=248794&r1=248793&r2=248794&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp Tue 
Sep 29 08:38:00 2015
@@ -1,6 +1,6 @@
 // RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- 
-std=c++14
 
-typedef unsigned int size_t;
+typedef decltype(sizeof(int)) size_t;
 
 struct S {
   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope 
[misc-new-delete-overloads]


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


Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-29 Thread Beren Minor via cfe-commits
berenm added inline comments.


Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:545
@@ +544,3 @@
+  if (const auto *Loc = Result.Nodes.getNodeAs("typeLoc")) {
+if (const auto &Ref = Loc->getAs()) {
+  addUsage(NamingCheckFailures, Ref.getDecl(), Loc->getSourceRange(),

alexfh wrote:
> The four cases are too similar. It should be possible to write the code much 
> shorter. This might work:
> 
>   if (isa(Loc) || isa(Loc) || ...)
> addUsage(NamingCheckFailures, Loc->getType()->getDecl(),
> Loc->getSourceRange(), Result.SourceManager);
> 
It doesn't look to work well with `TypeLoc`. This looks to be a convoluted 
class hierarchy (http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html) and 
getDecl() is only available on some derived `TypeLoc` classes.

I can change to something smaller, is that any better?
```
NamedDecl *Decl = nullptr;
if (const auto &Ref = Loc->getAs()) {
  Decl = Ref.getDecl();
} else if (const auto &Ref = Loc->getAs()) {
  Decl = Ref.getDecl();
} else if (const auto &Ref = Loc->getAs()) {
  Decl = Ref.getDecl();
} else if (const auto &Ref = Loc->getAs()) {
  Decl = Ref.getDecl();
}

if (Decl) {
  addUsage(NamingCheckFailures, Decl, Loc->getSourceRange(),
   Result.SourceManager);
  return;
}
```


http://reviews.llvm.org/D13081



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


[clang-tools-extra] r248797 - Some of the build bots are unhappy about the overload of the global operator new() because it was accidentally marked noexcept instead of noexcept(false). This should cor

2015-09-29 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 29 09:26:00 2015
New Revision: 248797

URL: http://llvm.org/viewvc/llvm-project?rev=248797&view=rev
Log:
Some of the build bots are unhappy about the overload of the global operator 
new() because it was accidentally marked noexcept instead of noexcept(false). 
This should correct those bots.

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp?rev=248797&r1=248796&r2=248797&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp Tue 
Sep 29 09:26:00 2015
@@ -10,7 +10,7 @@ struct S {
 };
 
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
-void *operator new(size_t size) noexcept;
+void *operator new(size_t size) noexcept(false);
 
 struct T {
   // Sized deallocations are not enabled by default, and so this new/delete 
pair


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


[PATCH] D13246: Fix bug in modernize-use-nullptr.

2015-09-29 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

https://llvm.org/bugs/show_bug.cgi?id=24960

modernize-use-nullptr would hit an assertion in some cases involving macros and 
initializer lists, due to finding a node with more than one parent (the two 
forms of the initializer list).

However, this doesn't mean that the replacement is incorrect, so instead of 
just rejecting this case I tried to find a way to make it work. Looking at the 
semantic form of the InitListExpr made sense to me (looking at both forms 
results in false negatives) but I am not sure of the things that we can miss by 
skipping the syntactic form.

http://reviews.llvm.org/D13246

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp

Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -174,4 +174,13 @@
 #define CALL(X) X
   OPTIONAL_CODE(NOT_NULL);
   CALL(NOT_NULL);
+
+#define ENTRY(X) {X}
+  struct A {
+int *Ptr;
+  } a[2] = {ENTRY(0), {0}};
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
+  // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
+#undef ENTRY
 }
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -150,6 +150,23 @@
 return true;
   }
 
+  bool TraverseInitListExpr(InitListExpr *S) {
+// Only go through the semantic form of the InitListExpr, because
+// ImplicitCast don't appear in the syntactic form, and this results in
+// finding usages of the macro argument that don't have a ImplicitCast as 
an
+// ancestor (thus invalidating the replacement) when they actually have.
+InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm();
+if (Sem) {
+  if (!WalkUpFromInitListExpr(Sem))
+return false;
+  for (Stmt *SubStmt : Sem->children()) {
+if (!TraverseStmt(SubStmt))
+  return false;
+  }
+}
+return true;
+  }
+
   bool foundInvalid() const { return InvalidFound; }
 
 private:
@@ -273,7 +290,7 @@
 // Visit children of this containing parent looking for the least-descended
 // nodes of the containing parent which are macro arg expansions that 
expand
 // from the given arg location.
-// Visitor needs: arg loc
+// Visitor needs: arg loc.
 MacroArgUsageVisitor ArgUsageVisitor(SM.getFileLoc(CastLoc), SM);
 if (const auto *D = ContainingAncestor.get())
   ArgUsageVisitor.TraverseDecl(const_cast(D));
@@ -345,8 +362,8 @@
   /// also handled.
   ///
   /// False means either:
-  /// - TestLoc is not from a macro expansion
-  /// - TestLoc is from a different macro expansion
+  /// - TestLoc is not from a macro expansion.
+  /// - TestLoc is from a different macro expansion.
   bool expandsFrom(SourceLocation TestLoc, SourceLocation TestMacroLoc) {
 if (TestLoc.isFileID()) {
   return false;
@@ -399,17 +416,24 @@
   ast_type_traits::DynTypedNode &Result) {
 // Below we're only following the first parent back up the AST. This should
 // be fine since for the statements we care about there should only be one
-// parent as far up as we care. If this assumption doesn't hold, need to
-// revisit what to do here.
+// parent, except for the case specified below.
 
 assert(MacroLoc.isFileID());
 
 while (true) {
   const auto &Parents = Context.getParents(Start);
   if (Parents.empty())
 return false;
-  assert(Parents.size() == 1 &&
- "Found an ancestor with more than one parent!");
+  if (Parents.size() > 1) {
+// If there are more than one parents, don't do the replacement unless
+// they are InitListsExpr (semantic and syntactic form). In this case 
we
+// can choose any one here, and the ASTVisitor will take care of
+// traversing the right one.
+for (const auto &Parent : Parents) {
+  if (!Parent.get())
+return false;
+}
+  }
 
   const ast_type_traits::DynTypedNode &Parent = Parents[0];
 


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -174,4 +174,13 @@
 #define CALL(X) X
   OPTIONAL_CODE(NOT_NULL);
   CALL(NOT_NULL);
+
+#define ENTRY(X) {X}
+  struct A {
+int *Ptr;
+  } a[2] = {ENTRY(0), {0}};
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
+  // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
+#undef ENTRY
 }
I

Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-29 Thread Beren Minor via cfe-commits
berenm updated this revision to Diff 35972.
berenm added a comment.

Address the latest comments, as well as useless code removal.

- Only the start of the token range is stored, so there is no need to care 
about the end of the range. Remove the code that was trying to match the end of 
the range (template, nested name).
- Add some spaces in test cases (destructors, templates) just to be sure that 
everything works as expected.
- Add a missing CHECK-FIXES in the test case on the abstract_class destructor.


http://reviews.llvm.org/D13081

Files:
  clang-query/tool/CMakeLists.txt
  clang-tidy/misc/UnusedRAIICheck.h
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/IdentifierNamingCheck.h
  clang-tidy/tool/run-clang-tidy.py
  docs/clang-tidy/checks/google-build-explicit-make-pair.rst
  docs/clang-tidy/checks/misc-unused-raii.rst
  docs/modularize.rst
  test/clang-tidy/Inputs/readability-identifier-naming/system/system-header.h
  test/clang-tidy/Inputs/readability-identifier-naming/user-header.h
  test/clang-tidy/modernize-make-unique.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -62,23 +62,44 @@
 // RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
-// RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing
+// RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
 
-// FIXME: There should be more test cases for checking that references to class
-// FIXME: name, declaration contexts, forward declarations, etc, are correctly
-// FIXME: checked and renamed
+// clang-format off
+
+#include 
+#include "user-header.h"
+// NO warnings or fixes expected from declarations within header files without
+// the -header-filter= option
 
 namespace FOO_NS {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}namespace foo_ns {{{$}}
 inline namespace InlineNamespace {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for inline namespace 'InlineNamespace'
 // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
 
+SYSTEM_NS::structure g_s1;
+// NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file
+
+USER_NS::object g_s2;
+// NO warnings or fixes expected as USER_NS and object are declared in a header file
+
+SYSTEM_MACRO(var1);
+// NO warnings or fixes expected as var1 is from macro expansion
+
+USER_MACRO(var2);
+// NO warnings or fixes expected as var2 is declared in a macro expansion
+
+int global;
+#define USE_IN_MACRO(m) auto use_##m = m
+USE_IN_MACRO(global);
+// NO warnings or fixes expected as global is used in a macro expansion
+
 #define BLA int FOO_bar
 BLA;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for global variable 'FOO_bar'
-// NO fix expected as FOO_bar is from macro expansion
+// NO warnings or fixes expected as FOO_bar is from macro expansion
 
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for enum 'my_enumeration'
@@ -102,6 +123,13 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class 'my_class'
 // CHECK-FIXES: {{^}}class CMyClass {{{$}}
 my_class();
+// CHECK-FIXES: {{^}}CMyClass();{{$}}
+
+~
+  my_class();
+// (space in destructor token test, we could check trigraph but they will be deprecated)
+// CHECK-FIXES: {{^}}~{{$}}
+// CHECK-FIXES: {{^}}  CMyClass();{{$}}
 
   const int MEMBER_one_1 = ConstExpr_variable;
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: invalid case style for constant member 'MEMBER_one_1'
@@ -135,15 +163,36 @@
 
 const int my_class::classConstant = 4;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class constant 'classConstant'
-// CHECK-FIXES: {{^}}const int my_class::kClassConstant = 4;{{$}}
-// FIXME: The fixup should reflect class name fixups as well:
-// FIXME: {{^}}const int CMyClass::kClassConstant = 4;{{$}}
+// CHECK-FIXES: {{^}}const int CMyClass::kClassConstant = 4;{{$}}
 
 int my_class::ClassMember_2 = 5;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class member 'ClassMember_2'
-// CHECK-FIXES: {{^}}int my_class::ClassMember2 = 5;{{$}}
-// FIXME: The fixup should reflect class name fixups as well:
-// FIXME: {{^}}int CMyCla

Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-29 Thread Beren Minor via cfe-commits
berenm updated this revision to Diff 35974.
berenm added a comment.

Fix arcanist messup...


http://reviews.llvm.org/D13081

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/Inputs/readability-identifier-naming/system/system-header.h
  test/clang-tidy/Inputs/readability-identifier-naming/user-header.h
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -62,25 +62,44 @@
 // RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
-// RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing
-
-// FIXME: There should be more test cases for checking that references to class
-// FIXME: name, declaration contexts, forward declarations, etc, are correctly
-// FIXME: checked and renamed
+// RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
 
 // clang-format off
 
+#include 
+#include "user-header.h"
+// NO warnings or fixes expected from declarations within header files without
+// the -header-filter= option
+
 namespace FOO_NS {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}namespace foo_ns {{{$}}
 inline namespace InlineNamespace {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for inline namespace 'InlineNamespace'
 // CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
 
+SYSTEM_NS::structure g_s1;
+// NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file
+
+USER_NS::object g_s2;
+// NO warnings or fixes expected as USER_NS and object are declared in a header file
+
+SYSTEM_MACRO(var1);
+// NO warnings or fixes expected as var1 is from macro expansion
+
+USER_MACRO(var2);
+// NO warnings or fixes expected as var2 is declared in a macro expansion
+
+int global;
+#define USE_IN_MACRO(m) auto use_##m = m
+USE_IN_MACRO(global);
+// NO warnings or fixes expected as global is used in a macro expansion
+
 #define BLA int FOO_bar
 BLA;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for global variable 'FOO_bar'
-// NO fix expected as FOO_bar is from macro expansion
+// NO warnings or fixes expected as FOO_bar is from macro expansion
 
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for enum 'my_enumeration'
@@ -104,6 +123,13 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class 'my_class'
 // CHECK-FIXES: {{^}}class CMyClass {{{$}}
 my_class();
+// CHECK-FIXES: {{^}}CMyClass();{{$}}
+
+~
+  my_class();
+// (space in destructor token test, we could check trigraph but they will be deprecated)
+// CHECK-FIXES: {{^}}~{{$}}
+// CHECK-FIXES: {{^}}  CMyClass();{{$}}
 
   const int MEMBER_one_1 = ConstExpr_variable;
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: invalid case style for constant member 'MEMBER_one_1'
@@ -137,15 +163,36 @@
 
 const int my_class::classConstant = 4;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class constant 'classConstant'
-// CHECK-FIXES: {{^}}const int my_class::kClassConstant = 4;{{$}}
-// FIXME: The fixup should reflect class name fixups as well:
-// FIXME: {{^}}const int CMyClass::kClassConstant = 4;{{$}}
+// CHECK-FIXES: {{^}}const int CMyClass::kClassConstant = 4;{{$}}
 
 int my_class::ClassMember_2 = 5;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class member 'ClassMember_2'
-// CHECK-FIXES: {{^}}int my_class::ClassMember2 = 5;{{$}}
-// FIXME: The fixup should reflect class name fixups as well:
-// FIXME: {{^}}int CMyClass::ClassMember2 = 5;{{$}}
+// CHECK-FIXES: {{^}}int CMyClass::ClassMember2 = 5;{{$}}
+
+class my_derived_class : public virtual my_class {};
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class 'my_derived_class'
+// CHECK-FIXES: {{^}}class CMyDerivedClass : public virtual CMyClass {};{{$}}
+
+class CMyWellNamedClass {};
+// No warning expected as this class is well named.
+
+template
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for type template parameter 'T'
+// CHECK-FIXES: {{^}}template{{$}}
+class my_templated_class : CMyWellNamedClass {};
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for class 'my_templated_class'
+// CHECK-FIXES: {{^}}class CMyTemplatedClass : CMyWellNamedClass {};{{$}}
+
+template
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for type template parameter 'T'
+// CHECK-FIXES: {{^}}template{{$}}
+class 

Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-29 Thread Beren Minor via cfe-commits
berenm marked 3 inline comments as done.
berenm added a comment.

http://reviews.llvm.org/D13081



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


Re: [PATCH] D13168: [OpenCL] OpenCL2.0 - Apply default address space rules

2015-09-29 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen requested changes to this revision.
This revision now requires changes to proceed.


Comment at: lib/Sema/SemaType.cpp:6166
@@ -6166,2 +6165,3 @@
   attr.setUsedAsTypeAttr();
+  hasOpenCLAddressSpace = true;
   break;

Should this be below AttributeList::AT_OpenCLGenericAddressSpace? Does it now 
include the address space attribute even when used from C? Probably doesn't 
harm, but a bit misleading.


Comment at: lib/Sema/SemaType.cpp:6282
@@ +6281,3 @@
+} else if (state.getCurrentChunkIndex() == 0 &&
+   D.getContext() == Declarator::FileContext &&
+   !D.isFunctionDeclarator() && !D.isFunctionDefinition() &&

Should this "white list" the cases where it's safe to add the default AS, not 
assume that it's applicable to any not listed here? Maybe safer that way.


http://reviews.llvm.org/D13168



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


r248802 - clang-format: Add a new brace style "custom" as well as flags to

2015-09-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Sep 29 09:57:55 2015
New Revision: 248802

URL: http://llvm.org/viewvc/llvm-project?rev=248802&view=rev
Log:
clang-format: Add a new brace style "custom" as well as flags to
control the individual braces. The existing choices for brace wrapping
are now merely presets for the different flags that get expanded upon
calling the reformat function.

All presets have been chose to keep the existing formatting, so there
shouldn't be any difference in formatting behavior.

Also change the dump_format_style.py to properly document the nested
structs that are used to keep these flags discoverable among all the
configuration flags.

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/docs/tools/dump_format_style.py
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=248802&r1=248801&r2=248802&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Tue Sep 29 09:57:55 2015
@@ -252,6 +252,27 @@ the configuration (without a prefix: ``A
   If ``false``, a function declaration's or function definition's
   parameters will either all be on the same line or will have one line each.
 
+**BraceWrapping** (``BraceWrappingFlags``)
+  Control of individual brace wrapping cases.
+
+  If ``BreakBeforeBraces`` is set to ``custom``, use this to specify how each
+  individual brace case should be handled. Otherwise, this is ignored.
+
+  Nested configuration flags:
+
+  * ``bool AfterClass`` Wrap class definitions.
+  * ``bool AfterControlStatement`` Wrap control statements 
(if/for/while/switch/..).
+  * ``bool AfterEnum`` Wrap enum definitions.
+  * ``bool AfterFunction`` Wrap function definitions.
+  * ``bool AfterNamespace`` Wrap namespace definitions.
+  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (@autoreleasepool, 
interfaces, ..).
+  * ``bool AfterStruct`` Wrap struct definitions.
+  * ``bool AfterUnion`` Wrap union definitions.
+  * ``bool BeforeCatch`` Wrap before ``catch``.
+  * ``bool BeforeElse`` Wrap before ``else``.
+  * ``bool IndentBraces`` Indent the wrapped braces themselves.
+
+
 **BreakBeforeBinaryOperators** (``BinaryOperatorStyle``)
   The way to wrap binary operators.
 
@@ -288,6 +309,8 @@ the configuration (without a prefix: ``A
 or other definitions.
   * ``BS_WebKit`` (in configuration: ``WebKit``)
 Like ``Attach``, but break before functions.
+  * ``BS_Custom`` (in configuration: ``Custom``)
+Configure each individual brace in ``BraceWrapping``.
 
 
 **BreakBeforeTernaryOperators** (``bool``)
@@ -365,6 +388,21 @@ the configuration (without a prefix: ``A
 
   For example: BOOST_FOREACH.
 
+**IncludeCategories** (``std::vector>``)
+  Regular expressions denoting the different #include categories used
+  for ordering #includes.
+
+  These regular expressions are matched against the filename of an include
+  (including the <> or "") in order. The value belonging to the first
+  matching regular expression is assigned and #includes are sorted first
+  according to increasing category number and then alphabetically within
+  each category.
+
+  If none of the regular expressions match, UINT_MAX is assigned as
+  category. The main header for a source file automatically gets category 0,
+  so that it is kept at the beginning of the #includes
+  (http://llvm.org/docs/CodingStandards.html#include-style).
+
 **IndentCaseLabels** (``bool``)
   Indent case labels one level from the switch statement.
 

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=248802&r1=248801&r2=248802&view=diff
==
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Tue Sep 29 09:57:55 2015
@@ -36,14 +36,35 @@ class Option:
 self.type = type
 self.comment = comment.strip()
 self.enum = None
+self.nested_struct = None
 
   def __str__(self):
 s = '**%s** (``%s``)\n%s' % (self.name, self.type,
  doxygen2rst(indent(self.comment, 2)))
 if self.enum:
   s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2)
+if self.nested_struct:
+  s += indent('\n\nNested configuration flags:\n\n%s\n' 
%self.nested_struct,
+  2)
 return s
 
+class NestedStruct:
+  def __init__(self, name, comment):
+self.name = name
+self.comment = comment.strip()
+self.values = []
+
+  def __str__(self):
+ 

Re: [PATCH] D13210: Make brace styles more configurable

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r248802.


http://reviews.llvm.org/D13210



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


Re: [PATCH] D12492: [Clang-Format] Add AlwaysBreakBeforeElse and AlwaysBreakBeforeCatch Style to avoid cuddled else/catch

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I think r248802 should make this mostly obsolete, but feel free to add the 
tests :-).


http://reviews.llvm.org/D12492



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


Re: [PATCH] D12362: [clang-format] Add support of consecutive declarations alignment

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/WhitespaceManager.cpp:270
@@ +269,3 @@
+  if (Changes[i].NewlinesBefore > 1 || !FoundDeclarationOnLine ||
+  FoundLeftBraceOnLine || FoundLeftParenOnLine) {
+AlignSequence();

Generally, we don't use braces for single-statement-ifs in LLVM style.


Comment at: unittests/Format/FormatTest.cpp:8699
@@ +8698,3 @@
+   Alignment));
+  Alignment.AlignConsecutiveAssignments = true;
+  verifyFormat("float  something = 2000;\n"

Can you add a case (unless I missed it) where aligning both consecutive 
assignments and consecutive declarations exceed the column limit? What should 
happen in that case? I am thinking of something like:

  int lngName = 1;
  LngType i = bbb;


http://reviews.llvm.org/D12362



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


r248803 - Thread Safety Analysis: fix before/after checks so that they work on global

2015-09-29 Thread DeLesley Hutchins via cfe-commits
Author: delesley
Date: Tue Sep 29 10:25:51 2015
New Revision: 248803

URL: http://llvm.org/viewvc/llvm-project?rev=248803&view=rev
Log:
Thread Safety Analysis:  fix before/after checks so that they work on global
variables as well member variables.

Modified:
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
cfe/trunk/test/Sema/warn-thread-safety-analysis.c
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h?rev=248803&r1=248802&r2=248803&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h Tue Sep 29 
10:25:51 2015
@@ -291,6 +291,8 @@ public:
   return nullptr;
 if (auto *P = dyn_cast(CapExpr))
   return P->clangDecl();
+if (auto *P = dyn_cast(CapExpr))
+  return P->clangDecl();
 return nullptr;
   }
 

Modified: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp?rev=248803&r1=248802&r2=248803&view=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp Tue Sep 29 10:25:51 2015
@@ -290,7 +290,7 @@ til::SExpr *SExprBuilder::translateDeclR
 VD = FD->getParamDecl(I);
   }
 
-  // For non-local variables, treat it as a referenced to a named object.
+  // For non-local variables, treat it as a reference to a named object.
   return new (Arena) til::LiteralPtr(VD);
 }
 

Modified: cfe/trunk/test/Sema/warn-thread-safety-analysis.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-thread-safety-analysis.c?rev=248803&r1=248802&r2=248803&view=diff
==
--- cfe/trunk/test/Sema/warn-thread-safety-analysis.c (original)
+++ cfe/trunk/test/Sema/warn-thread-safety-analysis.c Tue Sep 29 10:25:51 2015
@@ -81,7 +81,8 @@ int main() {
   mutex_shared_lock(&mu2);
   Foo_fun1(1);
 
-  mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is 
already held}}
+  mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is 
already held}} \
+  expected-warning{{mutex 'mu1' must be acquired 
before 'mu2'}}
   mutex_unlock(&mu1);
   mutex_unlock(&mu2);
   mutex_shared_lock(&mu1);

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=248803&r1=248802&r2=248803&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Tue Sep 29 10:25:51 
2015
@@ -5145,4 +5145,17 @@ void test() {
 }  // end namespace TestReferenceNoThreadSafetyAnalysis
 
 
+namespace GlobalAcquiredBeforeAfterTest {
+
+Mutex mu1;
+Mutex mu2 ACQUIRED_AFTER(mu1);
+
+void test3() {
+  mu2.Lock();
+  mu1.Lock();  // expected-warning {{mutex 'mu1' must be acquired before 
'mu2'}}
+  mu1.Unlock();
+  mu2.Unlock();
+}
+
+}  // end namespace  GlobalAcquiredBeforeAfterTest
 


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


[PATCH] D13249: Divide TraverseInitListExpr to a different function for each form.

2015-09-29 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

create TraverseSyntacticInitListExpr and TraverseSemanticInitListExpr.

http://reviews.llvm.org/D13249

Files:
  include/clang/AST/RecursiveASTVisitor.h

Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -255,6 +255,13 @@
   /// \returns false if the visitation was terminated early, true otherwise.
   bool TraverseLambdaBody(LambdaExpr *LE);
 
+  /// \brief Recursively visit the syntactic and semantic forms of a
+  /// initialization list.
+  ///
+  /// \returns false if the visitation was terminated early, true otherwise.
+  bool TraverseSyntacticInitListExpr(InitListExpr *S);
+  bool TraverseSemanticInitListExpr(InitListExpr *S);
+
   //  Methods on Attrs 
 
   // \brief Visit an attribute.
@@ -2056,21 +2063,21 @@
   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
 })
 
-// InitListExpr is a tricky one, because we want to do all our work on
-// the syntactic form of the listexpr, but this method takes the
-// semantic form by default.  We can't use the macro helper because it
-// calls WalkUp*() on the semantic form, before our code can convert
-// to the syntactic form.
 template 
-bool RecursiveASTVisitor::TraverseInitListExpr(InitListExpr *S) {
+bool RecursiveASTVisitor::TraverseSyntacticInitListExpr(InitListExpr 
*S) {
   InitListExpr *Syn = S->isSemanticForm() ? S->getSyntacticForm() : S;
   if (Syn) {
 TRY_TO(WalkUpFromInitListExpr(Syn));
 // All we need are the default actions.  FIXME: use a helper function.
 for (Stmt *SubStmt : Syn->children()) {
   TRY_TO(TraverseStmt(SubStmt));
 }
   }
+  return true;
+}
+
+template 
+bool RecursiveASTVisitor::TraverseSemanticInitListExpr(InitListExpr 
*S) {
   InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm();
   if (Sem) {
 TRY_TO(WalkUpFromInitListExpr(Sem));
@@ -2081,6 +2088,18 @@
   return true;
 }
 
+// InitListExpr is a tricky one, because we want to do all our work on
+// the syntactic form of the listexpr, but this method takes the
+// semantic form by default.  We can't use the macro helper because it
+// calls WalkUp*() on the semantic form, before our code can convert
+// to the syntactic form.
+template 
+bool RecursiveASTVisitor::TraverseInitListExpr(InitListExpr *S) {
+  TRY_TO(TraverseSyntacticInitListExpr(S));
+  TRY_TO(TraverseSemanticInitListExpr(S));
+  return true;
+}
+
 // GenericSelectionExpr is a special case because the types and expressions
 // are interleaved.  We also need to watch out for null types (default
 // generic associations).


Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -255,6 +255,13 @@
   /// \returns false if the visitation was terminated early, true otherwise.
   bool TraverseLambdaBody(LambdaExpr *LE);
 
+  /// \brief Recursively visit the syntactic and semantic forms of a
+  /// initialization list.
+  ///
+  /// \returns false if the visitation was terminated early, true otherwise.
+  bool TraverseSyntacticInitListExpr(InitListExpr *S);
+  bool TraverseSemanticInitListExpr(InitListExpr *S);
+
   //  Methods on Attrs 
 
   // \brief Visit an attribute.
@@ -2056,21 +2063,21 @@
   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
 })
 
-// InitListExpr is a tricky one, because we want to do all our work on
-// the syntactic form of the listexpr, but this method takes the
-// semantic form by default.  We can't use the macro helper because it
-// calls WalkUp*() on the semantic form, before our code can convert
-// to the syntactic form.
 template 
-bool RecursiveASTVisitor::TraverseInitListExpr(InitListExpr *S) {
+bool RecursiveASTVisitor::TraverseSyntacticInitListExpr(InitListExpr *S) {
   InitListExpr *Syn = S->isSemanticForm() ? S->getSyntacticForm() : S;
   if (Syn) {
 TRY_TO(WalkUpFromInitListExpr(Syn));
 // All we need are the default actions.  FIXME: use a helper function.
 for (Stmt *SubStmt : Syn->children()) {
   TRY_TO(TraverseStmt(SubStmt));
 }
   }
+  return true;
+}
+
+template 
+bool RecursiveASTVisitor::TraverseSemanticInitListExpr(InitListExpr *S) {
   InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm();
   if (Sem) {
 TRY_TO(WalkUpFromInitListExpr(Sem));
@@ -2081,6 +2088,18 @@
   return true;
 }
 
+// InitListExpr is a tricky one, because we want to do all our work on
+// the syntactic form of the listexpr, but this method takes the
+// semantic form by default.  We can't use the macro helper because it
+// calls WalkUp*() on the semantic form, before our code can convert
+// to the syntactic form.
+template 
+bool RecursiveASTVisitor::T

Re: [PATCH] D12362: [clang-format] Add support of consecutive declarations alignment

2015-09-29 Thread Beren Minor via cfe-commits
berenm added inline comments.


Comment at: unittests/Format/FormatTest.cpp:8699
@@ +8698,3 @@
+   Alignment));
+  Alignment.AlignConsecutiveAssignments = true;
+  verifyFormat("float  something = 2000;\n"

djasper wrote:
> Can you add a case (unless I missed it) where aligning both consecutive 
> assignments and consecutive declarations exceed the column limit? What should 
> happen in that case? I am thinking of something like:
> 
>   int lngName = 1;
>   LngType i = bbb;
AFAIR, the alignment doesn't work very well with the column limit at the 
moment. This is already true wrt the assignment alignment. The column limit is 
enforced before the alignment is done and aligning variable names and / or 
assignment will expand beyond that limit.

I will add the test case but I haven't tried to fix this issue yet.

Should test cases check the current behaviour or the ideal expected behaviour 
(that doesn't work) ?


http://reviews.llvm.org/D12362



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


Re: [PATCH] D12362: [clang-format] Add support of consecutive declarations alignment

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: unittests/Format/FormatTest.cpp:8699
@@ +8698,3 @@
+   Alignment));
+  Alignment.AlignConsecutiveAssignments = true;
+  verifyFormat("float  something = 2000;\n"

berenm wrote:
> djasper wrote:
> > Can you add a case (unless I missed it) where aligning both consecutive 
> > assignments and consecutive declarations exceed the column limit? What 
> > should happen in that case? I am thinking of something like:
> > 
> >   int lngName = 1;
> >   LngType i = bbb;
> AFAIR, the alignment doesn't work very well with the column limit at the 
> moment. This is already true wrt the assignment alignment. The column limit 
> is enforced before the alignment is done and aligning variable names and / or 
> assignment will expand beyond that limit.
> 
> I will add the test case but I haven't tried to fix this issue yet.
> 
> Should test cases check the current behaviour or the ideal expected behaviour 
> (that doesn't work) ?
Ah interesting. Then I am ok with submitting this as is. However, the issue 
should be fixed for both. It is fine to do the alignment after doing the 
overall layout, but we should then simply not align if alignment would violate 
the column limit. This is already done for trailing comments.

Please add a comment (FIXME) about this somewhere.


http://reviews.llvm.org/D12362



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


r248805 - Thread Safety Analysis: allow capability attribute on unions.

2015-09-29 Thread DeLesley Hutchins via cfe-commits
Author: delesley
Date: Tue Sep 29 11:24:18 2015
New Revision: 248805

URL: http://llvm.org/viewvc/llvm-project?rev=248805&view=rev
Log:
Thread Safety Analysis: allow capability attribute on unions.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-capabilities.c
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=248805&r1=248804&r2=248805&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep 29 11:24:18 2015
@@ -1543,8 +1543,8 @@ def Capability : InheritableAttr {
   let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
GNU<"shared_capability">,
CXX11<"clang", "shared_capability">];
-  let Subjects = SubjectList<[Struct, TypedefName], ErrorDiag,
- "ExpectedStructOrTypedef">;
+  let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,
+ "ExpectedStructOrUnionOrTypedef">;
   let Args = [StringArgument<"Name">];
   let Accessors = [Accessor<"isShared",
 [GNU<"shared_capability">,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=248805&r1=248804&r2=248805&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Sep 29 11:24:18 2015
@@ -628,13 +628,10 @@ static bool checkAcquireOrderAttrCommon(
 
   // Check that this attribute only applies to lockable types.
   QualType QT = cast(D)->getType();
-  if (!QT->isDependentType()) {
-const RecordType *RT = getRecordType(QT);
-if (!RT || !RT->getDecl()->hasAttr()) {
-  S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_lockable)
-<< Attr.getName();
-  return false;
-}
+  if (!QT->isDependentType() && !typeHasCapability(S, QT)) {
+S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_lockable)
+  << Attr.getName();
+return false;
   }
 
   // Check that all arguments are lockable objects.

Modified: cfe/trunk/test/Sema/attr-capabilities.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-capabilities.c?rev=248805&r1=248804&r2=248805&view=diff
==
--- cfe/trunk/test/Sema/attr-capabilities.c (original)
+++ cfe/trunk/test/Sema/attr-capabilities.c Tue Sep 29 11:24:18 2015
@@ -4,11 +4,15 @@ typedef int __attribute__((capability("r
 struct __attribute__((shared_capability("mutex"))) Mutex {};
 struct NotACapability {};
 
+// Put capability attributes on unions
+union __attribute__((capability("mutex"))) MutexUnion { int a; char* b; };
+typedef union { int a; char* b; } __attribute__((capability("mutex"))) 
MutexUnion2;
+
 // Test an invalid capability name
 struct __attribute__((capability("wrong"))) IncorrectName {}; // 
expected-warning {{invalid capability name 'wrong'; capability name must be 
'mutex' or 'role'}}
 
-int Test1 __attribute__((capability("test1")));  // expected-error 
{{'capability' attribute only applies to structs and typedefs}}
-int Test2 __attribute__((shared_capability("test2"))); // expected-error 
{{'shared_capability' attribute only applies to structs and typedefs}}
+int Test1 __attribute__((capability("test1")));  // expected-error 
{{'capability' attribute only applies to structs, unions, and typedefs}}
+int Test2 __attribute__((shared_capability("test2"))); // expected-error 
{{'shared_capability' attribute only applies to structs, unions, and typedefs}}
 int Test3 __attribute__((acquire_capability("test3")));  // expected-warning 
{{'acquire_capability' attribute only applies to functions}}
 int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error 
{{'try_acquire_capability' attribute only applies to functions}}
 int Test5 __attribute__((release_capability("test5"))); // expected-warning 
{{'release_capability' attribute only applies to functions}}

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=248805&r1=248804&r2=248805&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Tue Sep 29 11:24:18 
2015
@@ -5159,3 +5159,26 @@ void test3() {
 
 }  // end namespace  GlobalAcquiredBeforeAfterTest
 
+
+namespace LockableUnions {
+
+union LOCKABLE MutexUnion {
+  int a;
+  char* b;
+
+  void Lock()   EXCLUSIVE_LOCK_FUNCTION();
+  void

r248807 - Fix typo.

2015-09-29 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Tue Sep 29 11:51:08 2015
New Revision: 248807

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


Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=248807&r1=248806&r2=248807&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Sep 29 11:51:08 2015
@@ -716,7 +716,7 @@ bool Preprocessor::HandleIdentifier(Toke
 }
 
 void Preprocessor::Lex(Token &Result) {
-  // We loop here until a lex function retuns a token; this avoids recursion.
+  // We loop here until a lex function returns a token; this avoids recursion.
   bool ReturnedToken;
   do {
 switch (CurLexerKind) {


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


Re: [PATCH] D12492: [Clang-Format] Add AlwaysBreakBeforeElse and AlwaysBreakBeforeCatch Style to avoid cuddled else/catch

2015-09-29 Thread Paul Hoad via cfe-commits
MyDeveloperDay added a comment.

I don't have permission to commit

This looks good though.


http://reviews.llvm.org/D12492



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


Re: [PATCH] D12492: [Clang-Format] Add AlwaysBreakBeforeElse and AlwaysBreakBeforeCatch Style to avoid cuddled else/catch

2015-09-29 Thread Daniel Jasper via cfe-commits
djasper added a comment.

What do you mean by "this looks good"?


http://reviews.llvm.org/D12492



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


Re: [PATCH] D13249: Divide TraverseInitListExpr to a different function for each form.

2015-09-29 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/AST/RecursiveASTVisitor.h:2097
@@ +2096,3 @@
+template 
+bool RecursiveASTVisitor::TraverseInitListExpr(InitListExpr *S) {
+  TRY_TO(TraverseSyntacticInitListExpr(S));

Did you try putting an assert(S->isSemanticForm()); (or the reverse) here?


http://reviews.llvm.org/D13249



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


r248808 - Added MSVC natvis visualizers for Type and QualType. These could probably be improved, but anything is better than staring at hex values in the debugger.

2015-09-29 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 29 12:32:36 2015
New Revision: 248808

URL: http://llvm.org/viewvc/llvm-project?rev=248808&view=rev
Log:
Added MSVC natvis visualizers for Type and QualType. These could probably be 
improved, but anything is better than staring at hex values in the debugger.

Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=248808&r1=248807&r2=248808&view=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Tue Sep 29 12:32:36 2015
@@ -6,6 +6,14 @@ Put this file into "%USERPROFILE%\Docume
 or create a symbolic link so it updates automatically.
 -->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
+  
+Builtin 
Type={(clang::BuiltinType::Kind)BuiltinTypeBits.Kind}
+Modified 
Type={((clang::AttributedType*)this)->ModifiedType} 
Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
+Type 
Class={(clang::Type::TypeClass)TypeBits.TC}
+  
+  
+{((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 
clang::TypeAlignmentInBits) - 1)))->BaseType}
+  
   
 ({((llvm::StringMapEntry*)Entry)+1,s})
 


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


r248813 - Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1

2015-09-29 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Tue Sep 29 13:13:34 2015
New Revision: 248813

URL: http://llvm.org/viewvc/llvm-project?rev=248813&view=rev
Log:
Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1

This patch corresponds to review:
http://reviews.llvm.org/D13190

Implemented the following interfaces to conform to ELF V2 ABI version 1.1.

vector signed __int128 vec_adde (vector signed __int128, vector signed 
__int128, vector signed __int128);
vector unsigned __int128 vec_adde (vector unsigned __int128, vector unsigned 
__int128, vector unsigned __int128);
vector signed __int128 vec_addec (vector signed __int128, vector signed 
__int128, vector signed __int128);
vector unsigned __int128 vec_addec (vector unsigned __int128, vector unsigned 
__int128, vector unsigned __int128);
vector signed int vec_addc(vector signed int __a, vector signed int __b);
vector bool char vec_cmpge (vector signed char __a, vector signed char __b);
vector bool char vec_cmpge (vector unsigned char __a, vector unsigned char __b);
vector bool short vec_cmpge (vector signed short __a, vector signed short __b);
vector bool short vec_cmpge (vector unsigned short __a, vector unsigned short 
__b);
vector bool int vec_cmpge (vector signed int __a, vector signed int __b);
vector bool int vec_cmpge (vector unsigned int __a, vector unsigned int __b);
vector bool char vec_cmple (vector signed char __a, vector signed char __b);
vector bool char vec_cmple (vector unsigned char __a, vector unsigned char __b);
vector bool short vec_cmple (vector signed short __a, vector signed short __b);
vector bool short vec_cmple (vector unsigned short __a, vector unsigned short 
__b);
vector bool int vec_cmple (vector signed int __a, vector signed int __b);
vector bool int vec_cmple (vector unsigned int __a, vector unsigned int __b);
vector double vec_double (vector signed long long __a);
vector double vec_double (vector unsigned long long __a);
vector bool char vec_eqv(vector bool char __a, vector bool char __b);
vector bool short vec_eqv(vector bool short __a, vector bool short __b);
vector bool int vec_eqv(vector bool int __a, vector bool int __b);
vector bool long long vec_eqv(vector bool long long __a, vector bool long long 
__b);
vector signed short vec_madd(vector signed short __a, vector signed short __b, 
vector signed short __c);
vector signed short vec_madd(vector signed short __a, vector unsigned short 
__b, vector unsigned short __c);
vector signed short vec_madd(vector unsigned short __a, vector signed short 
__b, vector signed short __c);
vector unsigned short vec_madd(vector unsigned short __a, vector unsigned short 
__b, vector unsigned short __c);
vector bool long long vec_mergeh(vector bool long long __a, vector bool long 
long __b);
vector bool long long vec_mergel(vector bool long long __a, vector bool long 
long __b);
vector bool char vec_nand(vector bool char __a, vector bool char __b);
vector bool short vec_nand(vector bool short __a, vector bool short __b);
vector bool int vec_nand(vector bool int __a, vector bool int __b);
vector bool long long vec_nand(vector bool long long __a, vector bool long long 
__b);
vector bool char vec_orc(vector bool char __a, vector bool char __b);
vector bool short vec_orc(vector bool short __a, vector bool short __b);
vector bool int vec_orc(vector bool int __a, vector bool int __b);
vector bool long long vec_orc(vector bool long long __a, vector bool long long 
__b);
vector signed long long vec_sub(vector signed long long __a, vector signed long 
long __b);
vector signed long long vec_sub(vector bool long long __a, vector signed long 
long __b);
vector signed long long vec_sub(vector signed long long __a, vector bool long 
long __b);
vector unsigned long long vec_sub(vector unsigned long long __a, vector 
unsigned long long __b);
vector unsigned long long vec_sub(vector bool long long __a, vector unsigned 
long long __b);
vector unsigned long long vec_sub(vector unsigned long long __V2 ABI V1.1


http://ror float vec_sub(vector float __a, vector float __b);
unsigned char vec_extract(vector bool char __a, int __b);
signed short vec_extract(vector signed short __a, int __b);
unsigned short vec_extract(vector bool short __a, int __b);
signed int vec_extract(vector signed int __a, int __b);
unsigned int vec_extract(vector bool int __a, int __b);
signed long long vec_extract(vector signed long long __a, int __b);
unsigned long long vec_extract(vector unsigned long long __a, int __b);
unsigned long long vec_extract(vector bool long long __a, int __b);
double vec_extract(vector double __a, int __b);
vector bool char vec_insert(unsigned char __a, vector bool char __b, int __c);
vector signed short vec_insert(signed short __a, vector signed short __b, int 
__c);
vector bool short vec_insert(unsigned short __a, vector bool short __b, int 
__c);
vector signed int vec_insert(signed int __a, vector signed int __b, int __c);
vector bool int vec_insert(unsigned int __a, vector bool int __b, int __c);
vector

Re: [PATCH] D13190: Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1

2015-09-29 Thread Nemanja Ivanovic via cfe-commits
nemanjai closed this revision.
nemanjai added a comment.

Committed revision 248813.


Repository:
  rL LLVM

http://reviews.llvm.org/D13190



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


r248815 - Forgot to remove a FIXME that has been fixed. NFC.

2015-09-29 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Tue Sep 29 13:20:59 2015
New Revision: 248815

URL: http://llvm.org/viewvc/llvm-project?rev=248815&view=rev
Log:
Forgot to remove a FIXME that has been fixed. NFC.

Modified:
cfe/trunk/lib/Headers/altivec.h

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=248815&r1=248814&r2=248815&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Tue Sep 29 13:20:59 2015
@@ -13782,9 +13782,6 @@ support). As a result, we need to be abl
 The remaining ones (currently controlled by -mcrypto for GCC) still
 need to be provided on compliant hardware even if Vector.Crypto is not
 provided.
-FIXME: the naming convention for the builtins will be adjusted due
-to the inconsistency (__builtin_crypto_ prefix on builtins that cannot be
-removed with -mno-crypto). This is under development.
 */
 #ifdef __CRYPTO__
 #define vec_sbox_be __builtin_altivec_crypto_vsbox


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


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

2015-09-29 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added subscribers: cfe-commits, rsmith.

This was a fun patch :)

This patch adds the parameter attribute `pass_object_size` to Clang. The design 
doc for this attribute is available here: 
https://docs.google.com/document/d/14TwNLxFL_jhiYn7_kppNUDiaTopRAIY5bc-B8NcnKMM/edit?usp=sharing

General notes:

- Never mangled things before, so I'm open to any suggestions on how to make 
the mangling for pass_object_size better :)
- There's a tiny diagnostics bugfix in here -- I'm happy to make that its own 
patch. (See: `tryGetFunctionProtoType` in SemaOverload.cpp)
- A lot of the additions to Sema (anything that's a boolean named like 
`TakingCandidateAddress`) are to improve diagnostics on templated functions 
with pass_object_size on their parameters. I'm happy to simplify the diff a bit 
if we think that the improved diag ("functions with pass_object_size params 
cannot have their address taken" vs "assigning to 'int (*)(void *)' from 
incompatible type 'int (void *const pass_object_size)'") isn't worth the extra 
cruft.

@rsmith: Other than the name change, the design has changed (since the last 
time we talked) such that having `pass_object_size(N)` on some parameter P 
makes the function act like there's an enable_if that disables the function if 
we can't determine the object size of P at the callsite. More concretely:

- One can no longer take the address of a function with `pass_object_size`
- If an overload candidate parameter with `pass_object_size` on it cannot have 
its object size determined, then the candidate is not viable.
  - If there's no overloading going on at all (e.g. in C), it's still an error 
to call a function with `pass_object_size` on one or more of its params if the 
object size of that param can't be determined.

http://reviews.llvm.org/D13263

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Initialization.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  include/clang/Sema/TemplateDeduction.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/pass-object-size.c
  test/Sema/pass-object-size.c
  test/SemaCXX/pass-object-size.cpp

Index: test/SemaCXX/pass-object-size.cpp
===
--- /dev/null
+++ test/SemaCXX/pass-object-size.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+namespace simple {
+int Foo(void *const p __attribute__((pass_object_size(0;
+
+int OvlFoo(void *const p __attribute__((pass_object_size(0;
+int OvlFoo(void *const p, int);
+
+struct Statics {
+  static int Foo(void *const p __attribute__((pass_object_size(0;
+  static int OvlFoo(void *const p __attribute__((pass_object_size(0;
+  static int OvlFoo(void *const p __attribute__((pass_object_size(1;
+};
+
+struct Members {
+  int Foo(void *const p __attribute__((pass_object_size(0;
+  int OvlFoo(void *const p __attribute__((pass_object_size(0;
+  int OvlFoo(void *const p, int);
+};
+
+void Decls() {
+  int (*A)(void *) = &Foo; //expected-error{{functions with pass_object_size params cannot have their address taken}}
+  int (*B)(void *) = Foo; //expected-error{{functions with pass_object_size params cannot have their address taken}}
+
+  int (*C)(void *) = &OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@6{{candidate function made ineligible by pass_object_size attributes}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+  int (*D)(void *) = OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@6{{candidate function made ineligible by pass_object_size attributes}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+
+  int (*E)(void *) = &Statics::Foo; //expected-error{{functions with pass_object_size params cannot have their address taken}}
+  int (*F)(void *) = &Statics::OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@11{{candidate function made ineligible by pass_object_size attributes}} expected-note@12{{candidate function made ineligible by pass_object_size attributes}}
+
+  int (*G)(void *) = &Members::Foo; //expected-error{{functions with

Re: [PATCH] D12793: Three new overflow builtins with generic argument types

2015-09-29 Thread David Grayson via cfe-commits
DavidEGrayson added inline comments.


Comment at: lib/CodeGen/CGBuiltin.cpp:303
@@ +302,3 @@
+// the first element is the bit width of an integer type and the second element
+// is true if the integer type is signed.
+static struct WidthAndSignedness

Sorry, I need to fix this incorrect comment.  I would probably just remove the 
second paragraph.  After that, the patch is probably good to be committed.


http://reviews.llvm.org/D12793



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


r248826 - CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may

2015-09-29 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Sep 29 15:44:46 2015
New Revision: 248826

URL: http://llvm.org/viewvc/llvm-project?rev=248826&view=rev
Log:
CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
be modified in between. (NFC)

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015
@@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   // nullptr if the "Module" is a PCH, which is safe because we don't
   // support chained PCH debug info, so there can only be a single PCH.
   const Module *M = Mod.getModuleOrNull();
-  auto &ModRef = ModuleCache[M];
-  if (ModRef)
-return cast(ModRef);
+  auto ModRef = ModuleCache.find(M);
+  if (ModRef != ModuleCache.end())
+return cast(ModRef->second);
 
   // Macro definitions that were defined with "-D" on the command line.
   SmallString<128> ConfigMacros;
@@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   llvm::DIModule *DIMod =
   DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
 Mod.getPath(), CGM.getHeaderSearchOpts().Sysroot);
-  ModRef.reset(DIMod);
+  ModuleCache[M].reset(DIMod);
   return DIMod;
 }
 


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


Re: [PATCH] D13187: [Clang] Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; other minor cleanups.

2015-09-29 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

http://reviews.llvm.org/D13187



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


r248828 - Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; other minor cleanups.

2015-09-29 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep 29 15:56:43 2015
New Revision: 248828

URL: http://llvm.org/viewvc/llvm-project?rev=248828&view=rev
Log:
Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; 
other minor cleanups.

By Eugene Zelenko!

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

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=248828&r1=248827&r2=248828&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Sep 29 15:56:43 2015
@@ -62,7 +62,6 @@ struct SubobjectAdjustment {
 MemberPointerAdjustment
   } Kind;
 
-
   struct DTB {
 const CastExpr *BasePath;
 const CXXRecordDecl *DerivedClass;
@@ -807,7 +806,6 @@ public:
   }
 };
 
-
 
//===--===//
 // Primary Expressions.
 
//===--===//
@@ -1675,7 +1673,6 @@ public:
   child_range children() { return child_range(&Val, &Val+1); }
 };
 
-
 /// UnaryOperator - This represents the unary-expression's (except sizeof and
 /// alignof), the postinc/postdec operators from postfix-expression, and 
various
 /// extensions.
@@ -2159,7 +2156,6 @@ public:
   }
 };
 
-
 /// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
 /// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
 /// while its subclasses may represent alternative syntax that (semantically)
@@ -3456,7 +3452,6 @@ public:
   child_range children() { return child_range(&SubStmt, &SubStmt+1); }
 };
 
-
 /// ShuffleVectorExpr - clang-specific builtin-in function
 /// __builtin_shufflevector.
 /// This AST node represents a operator that does a constant
@@ -3712,7 +3707,7 @@ public:
 
   /// Create an empty __builtin_va_arg expression.
   explicit VAArgExpr(EmptyShell Empty)
-  : Expr(VAArgExprClass, Empty), Val(0), TInfo(0, false) {}
+  : Expr(VAArgExprClass, Empty), Val(nullptr), TInfo(nullptr, false) {}
 
   const Expr *getSubExpr() const { return cast(Val); }
   Expr *getSubExpr() { return cast(Val); }
@@ -4406,7 +4401,6 @@ public:
   }
 };
 
-
 class ParenListExpr : public Expr {
   Stmt **Exprs;
   unsigned NumExprs;
@@ -4452,7 +4446,6 @@ public:
   friend class ASTStmtWriter;
 };
 
-
 /// \brief Represents a C11 generic selection.
 ///
 /// A generic selection (C11 6.5.1.1) contains an unevaluated controlling
@@ -4568,7 +4561,6 @@ public:
 // Clang Extensions
 
//===--===//
 
-
 /// ExtVectorElementExpr - This represents access to specific elements of a
 /// vector, and may occur on the left hand side or right hand side.  For 
example
 /// the following is legal:  "V.xy = V.zw" if V is a 4 element extended vector.
@@ -4632,7 +4624,6 @@ public:
   child_range children() { return child_range(&Base, &Base+1); }
 };
 
-
 /// BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
 /// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
 class BlockExpr : public Expr {
@@ -4984,6 +4975,6 @@ public:
   }
 
 };
-}  // end namespace clang
+} // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_EXPR_H

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=248828&r1=248827&r2=248828&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Sep 29 15:56:43 2015
@@ -2513,7 +2513,7 @@ public:
   ///
   OMPDeviceClause()
   : OMPClause(OMPC_device, SourceLocation(), SourceLocation()), 
-LParenLoc(SourceLocation()), Device(0) {}
+LParenLoc(SourceLocation()), Device(nullptr) {}
   /// \brief Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
   /// \brief Returns the location of '('.
@@ -2593,5 +2593,4 @@ public:
 
 } // end namespace clang
 
-#endif
-
+#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=248828&r1=248827&r2=248828&view=diff
==

Re: [PATCH] D13187: [Clang] Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; other minor cleanups.

2015-09-29 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248828: Fix Clang-tidy modernize-use-nullptr warnings in 
headers and generated files… (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D13187?vs=35789&id=36034#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13187

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
  cfe/trunk/utils/TableGen/ClangCommentCommandInfoEmitter.cpp

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -62,7 +62,6 @@
 MemberPointerAdjustment
   } Kind;
 
-
   struct DTB {
 const CastExpr *BasePath;
 const CXXRecordDecl *DerivedClass;
@@ -807,7 +806,6 @@
   }
 };
 
-
 //===--===//
 // Primary Expressions.
 //===--===//
@@ -1675,7 +1673,6 @@
   child_range children() { return child_range(&Val, &Val+1); }
 };
 
-
 /// UnaryOperator - This represents the unary-expression's (except sizeof and
 /// alignof), the postinc/postdec operators from postfix-expression, and various
 /// extensions.
@@ -2159,7 +2156,6 @@
   }
 };
 
-
 /// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
 /// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
 /// while its subclasses may represent alternative syntax that (semantically)
@@ -3456,7 +3452,6 @@
   child_range children() { return child_range(&SubStmt, &SubStmt+1); }
 };
 
-
 /// ShuffleVectorExpr - clang-specific builtin-in function
 /// __builtin_shufflevector.
 /// This AST node represents a operator that does a constant
@@ -3712,7 +3707,7 @@
 
   /// Create an empty __builtin_va_arg expression.
   explicit VAArgExpr(EmptyShell Empty)
-  : Expr(VAArgExprClass, Empty), Val(0), TInfo(0, false) {}
+  : Expr(VAArgExprClass, Empty), Val(nullptr), TInfo(nullptr, false) {}
 
   const Expr *getSubExpr() const { return cast(Val); }
   Expr *getSubExpr() { return cast(Val); }
@@ -4406,7 +4401,6 @@
   }
 };
 
-
 class ParenListExpr : public Expr {
   Stmt **Exprs;
   unsigned NumExprs;
@@ -4452,7 +4446,6 @@
   friend class ASTStmtWriter;
 };
 
-
 /// \brief Represents a C11 generic selection.
 ///
 /// A generic selection (C11 6.5.1.1) contains an unevaluated controlling
@@ -4568,7 +4561,6 @@
 // Clang Extensions
 //===--===//
 
-
 /// ExtVectorElementExpr - This represents access to specific elements of a
 /// vector, and may occur on the left hand side or right hand side.  For example
 /// the following is legal:  "V.xy = V.zw" if V is a 4 element extended vector.
@@ -4632,7 +4624,6 @@
   child_range children() { return child_range(&Base, &Base+1); }
 };
 
-
 /// BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
 /// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
 class BlockExpr : public Expr {
@@ -4984,6 +4975,6 @@
   }
 
 };
-}  // end namespace clang
+} // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_EXPR_H
Index: cfe/trunk/include/clang/AST/OpenMPClause.h
===
--- cfe/trunk/include/clang/AST/OpenMPClause.h
+++ cfe/trunk/include/clang/AST/OpenMPClause.h
@@ -2513,7 +2513,7 @@
   ///
   OMPDeviceClause()
   : OMPClause(OMPC_device, SourceLocation(), SourceLocation()), 
-LParenLoc(SourceLocation()), Device(0) {}
+LParenLoc(SourceLocation()), Device(nullptr) {}
   /// \brief Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
   /// \brief Returns the location of '('.
@@ -2593,5 +2593,4 @@
 
 } // end namespace clang
 
-#endif
-
+#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -229,7 +229,6 @@
 return static_cast(Data2.getPointer());
   }
 
-
 private:
   friend class CFGElement;
   CFGDeleteDtor() {}
@@ -693,7 +692,7 @@
   iterator beginAutomaticObjDtorsInsert(iterator I, size_t Cnt,
   BumpVectorContext &C) {
 return iterator(Elements.insert(I.base(), Cnt,
-CFGAutomaticObjDtor(nullptr, 0), C));
+CFGAutomaticObjDtor(nullptr, nullptr), C));
   }
   iterator insertAutomaticObjDtor(iterator I, VarDecl *VD, 

Re: [PATCH] D13249: Divide TraverseInitListExpr to a different function for each form.

2015-09-29 Thread Angel Garcia via cfe-commits
angelgarcia added a comment.

Yes, it breaks a few tests:

FAIL: Clang :: Analysis/operator-calls.cpp (598 of 8596)

FAIL: Clang :: Analysis/misc-ps-region-store.cpp (599 of 8596)

FAIL: Clang :: Analysis/array-struct-region.c (602 of 8596)


http://reviews.llvm.org/D13249



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


[PATCH] Keep the IfStmt node even if the condition is invalid

2015-09-29 Thread Olivier Goffart via cfe-commits
Hi, 

Please review the attached patch. It does not discard the full 'if' statement 
if the condition is invalid.

This is quite useful for IDE's or other tools which would like to recover as 
much as possible even if there are a few errors in the code, and discarding 
the full 'if' bodies is unfortunate.

Thanks.
-- 
Olivier


P.S: For the same reason, i'm also trying to fix the fact that if there is any 
typo in an expression statement, the full statement is discarded. The reason 
is i believe that Sema::CorrectDelayedTyposInExpr just return null if any typo 
could not be corrected. That's unrelated to this patch, but i still would 
welcome hint on how to fix it.  Should CorrectDelayedTyposInExpr somehow 
replace the TypoExpr instead of removing them? Or should it create a new node 
(some kind of error ErrorExpr)? Or should the caller of 
CorrectDelayedTyposInExpr be changed to keep the original?
>From 8f5f74755cfa0c6165caff65dcc07b0d2543f481 Mon Sep 17 00:00:00 2001
From: Olivier Goffart 
Date: Sat, 12 Sep 2015 16:09:34 +0200
Subject: [PATCH] Keep the IfStmt node even if the condition is invalid

This is important to keep the information in IDE or other tools
even if the code contains a few errors
---
 lib/Sema/SemaStmt.cpp  | 22 +++---
 test/Misc/ast-dump-invalid.cpp | 23 +++
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index c39c80d..97a1160 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -483,13 +483,6 @@ StmtResult
 Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
   Stmt *thenStmt, SourceLocation ElseLoc,
   Stmt *elseStmt) {
-  // If the condition was invalid, discard the if statement.  We could recover
-  // better by replacing it with a valid expr, but don't do that yet.
-  if (!CondVal.get() && !CondVar) {
-getCurFunction()->setHasDroppedStmt();
-return StmtError();
-  }
-
   ExprResult CondResult(CondVal.release());
 
   VarDecl *ConditionVar = nullptr;
@@ -501,18 +494,17 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
   return StmtError();
   }
   Expr *ConditionExpr = CondResult.getAs();
-  if (!ConditionExpr)
-return StmtError();
+  if (ConditionExpr) {
+DiagnoseUnusedExprResult(thenStmt);
 
-  DiagnoseUnusedExprResult(thenStmt);
+if (!elseStmt) {
+  DiagnoseEmptyStmtBody(ConditionExpr->getLocEnd(), thenStmt,
+diag::warn_empty_if_body);
+}
 
-  if (!elseStmt) {
-DiagnoseEmptyStmtBody(ConditionExpr->getLocEnd(), thenStmt,
-  diag::warn_empty_if_body);
+DiagnoseUnusedExprResult(elseStmt);
   }
 
-  DiagnoseUnusedExprResult(elseStmt);
-
   return new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr,
   thenStmt, ElseLoc, elseStmt);
 }
diff --git a/test/Misc/ast-dump-invalid.cpp b/test/Misc/ast-dump-invalid.cpp
index 3b97cc6..899bfa0 100644
--- a/test/Misc/ast-dump-invalid.cpp
+++ b/test/Misc/ast-dump-invalid.cpp
@@ -18,3 +18,26 @@ void f(T i, T j) {
 // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}}  'T'
 // CHECK-NEXT:   |-DeclRefExpr {{.*}}  'T' lvalue ParmVar {{.*}} 'i' 'T'
 // CHECK-NEXT:   `-DeclRefExpr {{.*}}  'T' lvalue ParmVar {{.*}} 'j' 'T'
+
+
+namespace TestInvalidIf {
+int g(int i) {
+  if (invalid_condition)
+return 4;
+  else
+return i;
+}
+}
+// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidIf
+// CHECK-NEXT: `-FunctionDecl
+// CHECK-NEXT:   |-ParmVarDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: `-IfStmt {{.*}} 
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-ReturnStmt {{.*}} 
+// CHECK-NEXT:   | `-IntegerLiteral {{.*}}  'int' 4
+// CHECK-NEXT:   `-ReturnStmt {{.*}} 
+// CHECK-NEXT: `-ImplicitCastExpr {{.*}}  'int' 
+// CHECK-NEXT:   `-DeclRefExpr {{.*}}  'int' lvalue ParmVar {{.*}} 'i' 'int'
+
-- 
2.6.0

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


r248836 - Move functions declared in ExprObjC.h into ExprObjC.cpp.

2015-09-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Sep 29 17:28:44 2015
New Revision: 248836

URL: http://llvm.org/viewvc/llvm-project?rev=248836&view=rev
Log:
Move functions declared in ExprObjC.h into ExprObjC.cpp.

r51703 back in 2008 split out all the ObjC Expr subclasses from Expr.h
to a new ExprObjC.h file, but failed to also split the implementation
from Expr.cpp to ExprObjC.cpp. Do so, finally, for readability's sake.

Added:
cfe/trunk/lib/AST/ExprObjC.cpp
Modified:
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=248836&r1=248835&r2=248836&view=diff
==
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Tue Sep 29 17:28:44 2015
@@ -30,6 +30,7 @@ add_clang_library(clangAST
   ExprClassification.cpp
   ExprConstant.cpp
   ExprCXX.cpp
+  ExprObjC.cpp
   ExternalASTSource.cpp
   InheritViz.cpp
   ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=248836&r1=248835&r2=248836&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Sep 29 17:28:44 2015
@@ -3510,285 +3510,6 @@ void ExtVectorElementExpr::getEncodedEle
   }
 }
 
-ObjCMessageExpr::ObjCMessageExpr(QualType T,
- ExprValueKind VK,
- SourceLocation LBracLoc,
- SourceLocation SuperLoc,
- bool IsInstanceSuper,
- QualType SuperType,
- Selector Sel, 
- ArrayRef SelLocs,
- SelectorLocationsKind SelLocsK,
- ObjCMethodDecl *Method,
- ArrayRef Args,
- SourceLocation RBracLoc,
- bool isImplicit)
-  : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary,
- /*TypeDependent=*/false, /*ValueDependent=*/false,
- /*InstantiationDependent=*/false,
- /*ContainsUnexpandedParameterPack=*/false),
-SelectorOrMethod(reinterpret_cast(Method? Method
-   : 
Sel.getAsOpaquePtr())),
-Kind(IsInstanceSuper? SuperInstance : SuperClass),
-HasMethod(Method != nullptr), IsDelegateInitCall(false),
-IsImplicit(isImplicit), SuperLoc(SuperLoc), LBracLoc(LBracLoc),
-RBracLoc(RBracLoc)
-{
-  initArgsAndSelLocs(Args, SelLocs, SelLocsK);
-  setReceiverPointer(SuperType.getAsOpaquePtr());
-}
-
-ObjCMessageExpr::ObjCMessageExpr(QualType T,
- ExprValueKind VK,
- SourceLocation LBracLoc,
- TypeSourceInfo *Receiver,
- Selector Sel,
- ArrayRef SelLocs,
- SelectorLocationsKind SelLocsK,
- ObjCMethodDecl *Method,
- ArrayRef Args,
- SourceLocation RBracLoc,
- bool isImplicit)
-  : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, T->isDependentType(),
- T->isDependentType(), T->isInstantiationDependentType(),
- T->containsUnexpandedParameterPack()),
-SelectorOrMethod(reinterpret_cast(Method? Method
-   : 
Sel.getAsOpaquePtr())),
-Kind(Class),
-HasMethod(Method != nullptr), IsDelegateInitCall(false),
-IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc)
-{
-  initArgsAndSelLocs(Args, SelLocs, SelLocsK);
-  setReceiverPointer(Receiver);
-}
-
-ObjCMessageExpr::ObjCMessageExpr(QualType T,
- ExprValueKind VK,
- SourceLocation LBracLoc,
- Expr *Receiver,
- Selector Sel, 
- ArrayRef SelLocs,
- SelectorLocationsKind SelLocsK,
- ObjCMethodDecl *Method,
- ArrayRef Args,
- SourceLocation RBracLoc,
- bool isImplicit)
-  : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, Receiver->isTypeDependent(),
- Receiver->isTypeDependent(),
- Receiver->isInstantiationDependent(),
- Receiver->containsUnexpandedParameterPack()),
-SelectorOrMethod(reinterpret_cast(Method? Method
-   : 
Sel.getAsOpaquePtr())),
-Kind(Instance),
-HasMethod(Method !=

Re: r248826 - CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may

2015-09-29 Thread David Blaikie via cfe-commits
On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Tue Sep 29 15:44:46 2015
> New Revision: 248826
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248826&view=rev
> Log:
> CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
> be modified in between. (NFC)
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015
> @@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>// nullptr if the "Module" is a PCH, which is safe because we don't
>// support chained PCH debug info, so there can only be a single PCH.
>const Module *M = Mod.getModuleOrNull();
> -  auto &ModRef = ModuleCache[M];
> -  if (ModRef)
> -return cast(ModRef);
> +  auto ModRef = ModuleCache.find(M);
> +  if (ModRef != ModuleCache.end())
> +return cast(ModRef->second);
>

Maybe change this to:

if (const auto *Mod = ModuleCache[M])
  return cast(Mod);

Or similar, to reduce variable scope, since "ModRef" isn't needed/used
after this block.

It does cause the entry to be created earlier, but that shouldn't make a
difference in any real sense - but I could see a preference either way, if
you prefer it the way it is, that'd be cool too.


>
>// Macro definitions that were defined with "-D" on the command line.
>SmallString<128> ConfigMacros;
> @@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>llvm::DIModule *DIMod =
>DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
>  Mod.getPath(),
> CGM.getHeaderSearchOpts().Sysroot);
> -  ModRef.reset(DIMod);
> +  ModuleCache[M].reset(DIMod);
>return DIMod;
>  }
>
>
>
> ___
> 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: r248826 - CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may

2015-09-29 Thread Adrian Prantl via cfe-commits

> On Sep 29, 2015, at 3:52 PM, David Blaikie  wrote:
> 
> 
> 
> On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Tue Sep 29 15:44:46 2015
> New Revision: 248826
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=248826&view=rev 
> 
> Log:
> CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
> be modified in between. (NFC)
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015
> @@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>// nullptr if the "Module" is a PCH, which is safe because we don't
>// support chained PCH debug info, so there can only be a single PCH.
>const Module *M = Mod.getModuleOrNull();
> -  auto &ModRef = ModuleCache[M];
> -  if (ModRef)
> -return cast(ModRef);
> +  auto ModRef = ModuleCache.find(M);
> +  if (ModRef != ModuleCache.end())
> +return cast(ModRef->second);
> 
> Maybe change this to:
> 
> if (const auto *Mod = ModuleCache[M])
>   return cast(Mod);
> 
> Or similar, to reduce variable scope, since "ModRef" isn't needed/used after 
> this block.
> 
> It does cause the entry to be created earlier, but that shouldn't make a 
> difference in any real sense - but I could see a preference either way, if 
> you prefer it the way it is, that'd be cool too.

I thought about both variants, but then decided for myself that I disliked 
default-creating the entry just a tiny bit more. (In this particular case it is 
really cheap of course).

-- adrian
>  
> 
>// Macro definitions that were defined with "-D" on the command line.
>SmallString<128> ConfigMacros;
> @@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>llvm::DIModule *DIMod =
>DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
>  Mod.getPath(), 
> CGM.getHeaderSearchOpts().Sysroot);
> -  ModRef.reset(DIMod);
> +  ModuleCache[M].reset(DIMod);
>return DIMod;
>  }
> 
> 
> 
> ___
> 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: r248826 - CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may

2015-09-29 Thread David Blaikie via cfe-commits
On Tue, Sep 29, 2015 at 4:01 PM, Adrian Prantl  wrote:

>
> On Sep 29, 2015, at 3:52 PM, David Blaikie  wrote:
>
>
>
> On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Tue Sep 29 15:44:46 2015
>> New Revision: 248826
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=248826&view=rev
>> Log:
>> CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
>> be modified in between. (NFC)
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015
>> @@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>// nullptr if the "Module" is a PCH, which is safe because we don't
>>// support chained PCH debug info, so there can only be a single PCH.
>>const Module *M = Mod.getModuleOrNull();
>> -  auto &ModRef = ModuleCache[M];
>> -  if (ModRef)
>> -return cast(ModRef);
>> +  auto ModRef = ModuleCache.find(M);
>> +  if (ModRef != ModuleCache.end())
>> +return cast(ModRef->second);
>>
>
> Maybe change this to:
>
> if (const auto *Mod = ModuleCache[M])
>   return cast(Mod);
>
> Or similar, to reduce variable scope, since "ModRef" isn't needed/used
> after this block.
>
> It does cause the entry to be created earlier, but that shouldn't make a
> difference in any real sense - but I could see a preference either way, if
> you prefer it the way it is, that'd be cool too.
>
>
> I thought about both variants, but then decided for myself that I disliked
> default-creating the entry just a tiny bit more. (In this particular case
> it is really cheap of course).
>

Fair enough (:


>
> -- adrian
>
>
>
>>
>>// Macro definitions that were defined with "-D" on the command line.
>>SmallString<128> ConfigMacros;
>> @@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>llvm::DIModule *DIMod =
>>DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
>>  Mod.getPath(),
>> CGM.getHeaderSearchOpts().Sysroot);
>> -  ModRef.reset(DIMod);
>> +  ModuleCache[M].reset(DIMod);
>>return DIMod;
>>  }
>>
>>
>>
>> ___
>> 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: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-29 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 36048.
tra added a comment.

Renamed wrapper to cuda_runtime.h
Similarly to nvcc, automatically add "-include cuda_runtime.h" to CC1 
invocations unless -nocudainc is specified.


http://reviews.llvm.org/D13171

Files:
  lib/Driver/ToolChains.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/cuda_runtime.h

Index: lib/Headers/cuda_runtime.h
===
--- /dev/null
+++ lib/Headers/cuda_runtime.h
@@ -0,0 +1,119 @@
+#ifndef __CLANG_CUDA_SUPPORT_H__
+#define __CLANG_CUDA_SUPPORT_H__
+
+#if defined(__PTX__)
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.0 headers and are expected to break with
+// any other version of CUDA headers.
+#include "cuda.h"
+#if !defined(CUDA_VERSION)
+#error "cuda.h did not define CUDA_VERSION"
+#elif CUDA_VERSION != 7000
+#error "Unsupported CUDA version!"
+#endif
+
+#define __NVCC__ 1
+#if defined(__CUDA_ARCH__)
+#define __CUDABE__ 1
+#else
+#define __CUDACC__ 1
+#endif
+
+// Fake include guards to prevent inclusion of some CUDA headers.
+#define __HOST_DEFINES_H__
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+#define __TEXTURE_INDIRECT_FUNCTIONS_HPP__
+#define __SURFACE_INDIRECT_FUNCTIONS_HPP__
+
+// Standard CUDA attributes
+#define __constant__ __attribute__((constant))
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __host__ __attribute__((host))
+#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
+#define __shared__ __attribute__((shared))
+
+// Additional macros used throughout CUDA headers.
+#define __align__(x) __attribute__((aligned(x)))
+#define __builtin_align__(x) __align__(x)
+#define __cudart_builtin__
+#define __device_builtin__
+#define __forceinline__ __inline__ __attribute__((always_inline))
+
+#define CUDARTAPI
+#define _CRTIMP
+
+// Texture and surface types are not supported yet.
+#define __device_builtin_surface_type__
+#define __device_builtin_texture_type__
+
+// Include support for built-in variables.
+#include "cuda_builtin_vars.h"
+
+// CUDA headers were implemented with the assumption of split-mode
+// compilation and present CUDA functions differently for host and
+// device mode. Typically in host mode they provide declarations with
+// __device__ attribute attached. In device mode we get definitions
+// but *without* __device__ attribute. This does not work well in
+// combined compilation mode used by clang, so we have to trick CUDA
+// headers into something we can use.
+
+// libdevice functions in device_functions_decls.h either come with
+// __host__ __device__ attributes or with none at all. Temporarily
+// undefine __host__ so only __device__ is applied.
+#pragma push_macro("__CUDACC_RTC__")
+#pragma push_macro("__host__")
+#define __CUDACC_RTC__
+#define __host__
+#include "device_functions_decls.h"
+#pragma pop_macro("__host__")
+#pragma pop_macro("__CUDACC_RTC__")
+
+#include_next "cuda_runtime.h"
+#include "crt/device_runtime.h"
+
+#if defined(__CUDA_ARCH__)
+// device_functions.hpp and math_functions*.hpp use 'static
+// __forceinline__' (with no __device__) for definitions of device
+// functions. Temporarily redefine __forceinline__ to include
+// __device__.
+#pragma push_macro("__forceinline__")
+#define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+#include "device_functions.h"
+#include "math_functions.h"
+#pragma pop_macro("__forceinline__")
+#else
+#include "device_functions.h"
+#include "math_functions.h"
+#endif
+
+#if defined(__CUDA_ARCH__)
+// Definitions for device specific functions are provided only if
+// __CUDACC__ is defined. Alas, they've already been transitively
+// included by device_functions.h and are now behind include guards.
+// We need to temporarily define __CUDACC__, undo include guards and
+// include the files with implementation of these functions.
+
+#pragma push_macro("__CUDACC__")
+#define __CUDACC__ 1
+
+#undef __DEVICE_ATOMIC_FUNCTIONS_HPP__
+#include "device_atomic_functions.hpp"
+
+#undef __SM_20_ATOMIC_FUNCTIONS_HPP__
+#include "sm_20_atomic_functions.hpp"
+#undef __SM_32_ATOMIC_FUNCTIONS_HPP__
+#include "sm_32_atomic_functions.hpp"
+
+#undef __SM_20_INTRINSICS_HPP__
+#include "sm_20_intrinsics.hpp"
+#undef __SM_30_INTRINSICS_HPP__
+#include "sm_30_intrinsics.hpp"
+#undef __SM_32_INTRINSICS_HPP__
+#include "sm_32_intrinsics.hpp"
+
+#pragma pop_macro("__CUDACC__")
+#endif // __CUDA_ARCH__
+#endif // __PTX__
+#endif // __CLANG_CUDA_SUPPORT_H__
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -17,6 +17,7 @@
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  cuda_runtime.h
   emmintrin.h
   f16cintrin.h
   float.h
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolCh

Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2015-09-29 Thread Felix Berger via cfe-commits
flx updated this revision to Diff 36049.
flx marked 3 inline comments as done.
flx added a comment.

I had to convert the line endings of mis-move-constructor-init.cpp to unix 
style otherwise the test would not correctly work. This took a long time to 
debug since the checks failed complaining that error messages that look exactly 
the same didn't match.

Let me know if this needs to be converted back to DOS line endings, but it 
looks like most other tests have unix line endings.


http://reviews.llvm.org/D12839

Files:
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/IncludeSorter.cpp
  clang-tidy/utils/IncludeSorter.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,78 +1,145 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-move-constructor-init %t
-
-template  struct remove_reference  {typedef T type;};
-template  struct remove_reference  {typedef T type;};
-template  struct remove_reference {typedef T type;};
-
-template 
-typename remove_reference::type&& move(T&& arg) {
-  return static_cast::type&&>(arg);
-}
-
-struct C {
-  C() = default;
-  C(const C&) = default;
-};
-
-struct B {
-  B() {}
-  B(const B&) {}
-  B(B &&) {}
-};
-
-struct D : B {
-  D() : B() {}
-  D(const D &RHS) : B(RHS) {}
-  // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
-  // CHECK-MESSAGES: 19:3: note: copy constructor being called
-  // CHECK-MESSAGES: 20:3: note: candidate move constructor here
-  D(D &&RHS) : B(RHS) {}
-};
-
-struct E : B {
-  E() : B() {}
-  E(const E &RHS) : B(RHS) {}
-  E(E &&RHS) : B(move(RHS)) {} // ok
-};
-
-struct F {
-  C M;
-
-  F(F &&) : M(C()) {} // ok
-};
-
-struct G {
-  G() = default;
-  G(const G&) = default;
-  G(G&&) = delete;
-};
-
-struct H : G {
-  H() = default;
-  H(const H&) = default;
-  H(H &&RHS) : G(RHS) {} // ok
-};
-
-struct I {
-  I(const I &) = default; // suppresses move constructor creation
-};
-
-struct J : I {
-  J(J &&RHS) : I(RHS) {} // ok
-};
-
-struct K {}; // Has implicit copy and move constructors, is trivially copyable
-struct L : K {
-  L(L &&RHS) : K(RHS) {} // ok
-};
-
-struct M {
-  B Mem;
-  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init]
-  M(M &&RHS) : Mem(RHS.Mem) {}
-};
-
-struct N {
-  B Mem;
-  N(N &&RHS) : Mem(move(RHS.Mem)) {}
-};
+// RUN: %python %S/check_clang_tidy.py %s misc-move-constructor-init %t -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include 
+
+// CHECK-FIXES: #include 
+
+template  struct remove_reference  {typedef T type;};
+template  struct remove_reference  {typedef T type;};
+template  struct remove_reference {typedef T type;};
+
+template 
+typename remove_reference::type&& move(T&& arg) {
+  return static_cast::type&&>(arg);
+}
+
+struct C {
+  C() = default;
+  C(const C&) = default;
+};
+
+struct B {
+  B() {}
+  B(const B&) {}
+  B(B &&) {}
+};
+
+struct D : B {
+  D() : B() {}
+  D(const D &RHS) : B(RHS) {}
+  // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
+  // CHECK-MESSAGES: 23:3: note: copy constructor being called
+  // CHECK-MESSAGES: 24:3: note: candidate move constructor here
+  D(D &&RHS) : B(RHS) {}
+};
+
+struct E : B {
+  E() : B() {}
+  E(const E &RHS) : B(RHS) {}
+  E(E &&RHS) : B(move(RHS)) {} // ok
+};
+
+struct F {
+  C M;
+
+  F(F &&) : M(C()) {} // ok
+};
+
+struct G {
+  G() = default;
+  G(const G&) = default;
+  G(G&&) = delete;
+};
+
+struct H : G {
+  H() = default;
+  H(const H&) = default;
+  H(H &&RHS) : G(RHS) {} // ok
+};
+
+struct I {
+  I(const I &) = default; // suppresses move constructor creation
+};
+
+struct J : I {
+  J(J &&RHS) : I(RHS) {} // ok
+};
+
+struct K {}; // Has implicit copy and move constructors, is trivially copyable
+struct L : K {
+  L(L &&RHS) : K(RHS) {} // ok
+};
+
+struct M {
+  B Mem;
+  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init]
+  M(M &&RHS) : Mem(RHS.Mem) {}
+};
+
+struct N {
+  B Mem;
+  N(N &&RHS) : Mem(move(RHS.Mem)) {}
+};
+
+struct Movable {
+  Movable(Movable &&) = default;
+  Movable(const Movable &) = default;
+  Movable &operator=(const Movable &) = default;
+  ~Movable() {}
+};
+
+struct TriviallyCopya

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

2015-09-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> I think I understand, but to clarify:

>  The fields that shouldn't be invalidated should still be added to 
> ValuesToInvalidate, but with 

>  RegionAndSymbolInvalidationTraits::TK_PreserveContents set. This will result 
> in 

>  checkConstPointerEscape being called properly.




> Is that correct?


Yes, I think that is exactly how that works.


http://reviews.llvm.org/D13099



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


r248862 - Don't crash when a reserved global placement operator new is paired

2015-09-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Tue Sep 29 18:55:17 2015
New Revision: 248862

URL: http://llvm.org/viewvc/llvm-project?rev=248862&view=rev
Log:
Don't crash when a reserved global placement operator new is paired
with a non-reserved operator delete in a new-expression.

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/exceptions.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=248862&r1=248861&r2=248862&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Sep 29 18:55:17 2015
@@ -1289,9 +1289,11 @@ llvm::Value *CodeGenFunction::EmitCXXNew
   Address allocation = Address::invalid();
   CallArgList allocatorArgs;
   if (allocator->isReservedGlobalPlacementOperator()) {
+assert(E->getNumPlacementArgs() == 1);
+const Expr *arg = *E->placement_arguments().begin();
+
 AlignmentSource alignSource;
-allocation = EmitPointerWithAlignment(*E->placement_arguments().begin(),
-  &alignSource);
+allocation = EmitPointerWithAlignment(arg, &alignSource);
 
 // The pointer expression will, in many cases, be an opaque void*.
 // In these cases, discard the computed alignment and use the
@@ -1301,6 +1303,14 @@ llvm::Value *CodeGenFunction::EmitCXXNew
getContext().getTypeAlignInChars(allocType));
 }
 
+// Set up allocatorArgs for the call to operator delete if it's not
+// the reserved global operator.
+if (E->getOperatorDelete() &&
+!E->getOperatorDelete()->isReservedGlobalPlacementOperator()) {
+  allocatorArgs.add(RValue::get(allocSize), getContext().getSizeType());
+  allocatorArgs.add(RValue::get(allocation.getPointer()), arg->getType());
+}
+
   } else {
 const FunctionProtoType *allocatorType =
   allocator->getType()->castAs();

Modified: cfe/trunk/test/CodeGenCXX/exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions.cpp?rev=248862&r1=248861&r2=248862&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions.cpp Tue Sep 29 18:55:17 2015
@@ -2,6 +2,9 @@
 
 typedef __typeof(sizeof(0)) size_t;
 
+// Declare the reserved global placement new.
+void *operator new(size_t, void*);
+
 // This just shouldn't crash.
 namespace test0 {
   struct allocator {
@@ -526,4 +529,21 @@ namespace test11 {
   //   (After this is a terminate landingpad.)
 }
 
+namespace test12 {
+  struct A {
+void operator delete(void *, void *);
+A();
+  };
+
+  A *test(void *ptr) {
+return new (ptr) A();
+  }
+  // CHECK-LABEL: define {{.*}} @_ZN6test124testEPv(
+  // CHECK:   [[PTR:%.*]] = load i8*, i8*
+  // CHECK-NEXT:  [[CAST:%.*]] = bitcast i8* [[PTR]] to [[A:%.*]]*
+  // CHECK-NEXT:  invoke void @_ZN6test121AC1Ev([[A]]* [[CAST]])
+  // CHECK:   ret [[A]]* [[CAST]]
+  // CHECK:   invoke void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]])
+}
+
 // CHECK: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }


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


Re: r246985 - Compute and preserve alignment more faithfully in IR-generation.

2015-09-29 Thread John McCall via cfe-commits
> On Sep 27, 2015, at 5:56 PM, Joerg Sonnenberger  
> wrote:
> On Tue, Sep 08, 2015 at 08:06:00AM -, John McCall via cfe-commits wrote:
>> Author: rjmccall
>> Date: Tue Sep  8 03:05:57 2015
>> New Revision: 246985
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=246985&view=rev
>> Log:
>> Compute and preserve alignment more faithfully in IR-generation.
> 
> This seems to introduce an access-beyond-end on the attached input. Just
> -c should be enough to reproduce.

Should be fixed in r248862, sorry.

John.

> 
> Joerg
> 

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


[PATCH] D13276: Don't adjust field offsets for external record layouts

2015-09-29 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added a reviewer: majnemer.
zturner added a subscriber: cfe-commits.

injecting the VBPtr always behaves this way, but injecting the VFPtr was not.  
This patch fixes that.

http://reviews.llvm.org/D13276

Files:
  lib/AST/RecordLayoutBuilder.cpp

Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -2667,13 +2667,21 @@
   // alignment.
   CharUnits Offset = PointerInfo.Size.RoundUpToAlignment(
   std::max(RequiredAlignment, Alignment));
-  // Increase the size of the object and push back all fields, the vbptr and 
all
-  // bases by the offset amount.
+  // Push back the vbptr, but increase the size of the object and push back
+  // regular fields by the offset only if not using external record layout.
+  if (HasVBPtr)
+VBPtrOffset += Offset;
+
+  if (UseExternalLayout)
+return;
+
   Size += Offset;
+
+  // If we're using an external layout, the fields offsets have already
+  // accounted
+  // for this adjustment.
   for (uint64_t &FieldOffset : FieldOffsets)
 FieldOffset += Context.toBits(Offset);
-  if (HasVBPtr)
-VBPtrOffset += Offset;
   for (BaseOffsetsMapTy::value_type &Base : Bases)
 Base.second += Offset;
 }


Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -2667,13 +2667,21 @@
   // alignment.
   CharUnits Offset = PointerInfo.Size.RoundUpToAlignment(
   std::max(RequiredAlignment, Alignment));
-  // Increase the size of the object and push back all fields, the vbptr and all
-  // bases by the offset amount.
+  // Push back the vbptr, but increase the size of the object and push back
+  // regular fields by the offset only if not using external record layout.
+  if (HasVBPtr)
+VBPtrOffset += Offset;
+
+  if (UseExternalLayout)
+return;
+
   Size += Offset;
+
+  // If we're using an external layout, the fields offsets have already
+  // accounted
+  // for this adjustment.
   for (uint64_t &FieldOffset : FieldOffsets)
 FieldOffset += Context.toBits(Offset);
-  if (HasVBPtr)
-VBPtrOffset += Offset;
   for (BaseOffsetsMapTy::value_type &Base : Bases)
 Base.second += Offset;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2015-09-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

We gave a talk about building checkers a while back; even though it does not 
talk about the bug reporter visitors, it might be worth watching if you haven't 
already seen it.

http://llvm.org/devmtg/2012-11/ 
Building a Checker in 24 hours



Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.cpp:68
@@ +67,3 @@
+  const CallEventRef<> CERef = PreCallEvent.cloneWithState(State);
+  const ExplodedNode *const ExplNode = Ctx.addTransition();
+  llvm::SmallVector ReqRegions;

There is no reason to add an empty transition to the graph. Maybe you want to 
get the predecessor instead?


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.cpp:106
@@ +105,3 @@
+static CheckerProgramPointTag Tag("MPI-Checker", "MissingWait");
+ExplodedNode *const ExplNode =
+Ctx.generateNonFatalErrorNode(Ctx.getState(), &Tag);

generateNonFatalErrorNode will add a transition to the exploded graph, which 
means that you should only generate it if there is an error and you do not need 
to call addTransition later in the function. 


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h:67
@@ +66,3 @@
+  // Every time a request is 'set' a new 'RequestId' gets created.
+  // Therefore, the 'UserKind' does not need to be profiled.
+  const int RequestId{RequestIdCount++};

Still it looks like you have several pieces of information in the state that 
are redundant.. Looks like you've added more now.

For example, why do we need RequestId? Each report will only talk about a 
single request, is this not the case?

Do you absolutely need to store LastUser and VariableName?

Note that storing in the state is very expensive; on the other hand, we can 
afford to perform costly analysis on post-processing of an error report. This 
is why all other checkers store minimal information in the state, usually just 
a single enum and determine all the other information during the walk over the 
error path in BugReporterVisitor. The visitor will visit all nodes that you 
visited while reporting this bug, so it should have access to all the 
information you need.



http://reviews.llvm.org/D12761



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


r248867 - Promote a warning on ill-formed code (redeclaration missing an exception

2015-09-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 29 19:48:50 2015
New Revision: 248867

URL: http://llvm.org/viewvc/llvm-project?rev=248867&view=rev
Log:
Promote a warning on ill-formed code (redeclaration missing an exception
specification) to an error. No compiler other than Clang seems to allow this,
and it doesn't seem like a useful thing to accept as an extension in general.

The current behavior was added for PR5957, where the problem was specifically
related to mismatches of the exception specification on the implicitly-declared
global operator new and delete. To retain that workaround, we downgrade the
error to an ExtWarn when the declaration is of a replaceable global allocation
function.

Now that this is an error, stop trying (and failing) to recover from a missing
computed noexcept specification. That recovery didn't work, and led to crashes
in code like the added testcase.

Added:
cfe/trunk/test/SemaCXX/exception-spec.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/CXX/except/except.spec/p3.cpp
cfe/trunk/test/CXX/except/except.spec/p4.cpp
cfe/trunk/test/CXX/except/except.spec/p5-pointers.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=248867&r1=248866&r2=248867&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 29 19:48:50 
2015
@@ -1153,7 +1153,10 @@ def err_incompatible_exception_specs : E
   "target exception specification is not superset of source">;
 def err_deep_exception_specs_differ : Error<
   "exception specifications of %select{return|argument}0 types differ">;
-def warn_missing_exception_specification : Warning<
+def ext_missing_exception_specification : ExtWarn<
+  "%0 is missing exception specification '%1'">,
+  InGroup>;
+def err_missing_exception_specification : Error<
   "%0 is missing exception specification '%1'">;
 def err_noexcept_needs_constant_expression : Error<
   "argument to noexcept specifier must be a constant expression">;

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=248867&r1=248866&r2=248867&view=diff
==
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Tue Sep 29 19:48:50 2015
@@ -270,16 +270,31 @@ bool Sema::CheckEquivalentExceptionSpec(
   FunctionProtoType::ExceptionSpecInfo ESI = OldProto->getExceptionSpecType();
   if (ESI.Type == EST_Dynamic) {
 ESI.Exceptions = OldProto->exceptions();
-  } else if (ESI.Type == EST_ComputedNoexcept) {
-// FIXME: We can't just take the expression from the old prototype. It
-// likely contains references to the old prototype's parameters.
   }
 
-  // Update the type of the function with the appropriate exception
-  // specification.
-  New->setType(Context.getFunctionType(
-  NewProto->getReturnType(), NewProto->getParamTypes(),
-  NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
+  if (ESI.Type == EST_ComputedNoexcept) {
+// For computed noexcept, we can't just take the expression from the old
+// prototype. It likely contains references to the old prototype's
+// parameters.
+New->setInvalidDecl();
+  } else {
+// Update the type of the function with the appropriate exception
+// specification.
+New->setType(Context.getFunctionType(
+NewProto->getReturnType(), NewProto->getParamTypes(),
+NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
+  }
+
+  // Allow missing exception specifications in redeclarations as an extension,
+  // when declaring a replaceable global allocation function.
+  if (New->isReplaceableGlobalAllocationFunction() &&
+  ESI.Type != EST_ComputedNoexcept) {
+DiagID = diag::ext_missing_exception_specification;
+ReturnValueOnError = false;
+  } else {
+DiagID = diag::err_missing_exception_specification;
+ReturnValueOnError = true;
+  }
 
   // Warn about the lack of exception specification.
   SmallString<128> ExceptionSpecString;
@@ -322,17 +337,18 @@ bool Sema::CheckEquivalentExceptionSpec(
   SourceLocation FixItLoc;
   if (TypeSourceInfo *TSInfo = New->getTypeSourceInfo()) {
 TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens();
-if (FunctionTypeLoc FTLoc = TL.getAs())
-  FixItLoc = getLocForEndOfToken(FTLoc.getLocalRangeEnd());
+// FIXME: Preserve enough information so that we can produce a correct 
fixit
+// location when there is a trailing return type.
+if (au

Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-09-29 Thread Anna Zaks via cfe-commits
zaks.anna requested changes to this revision.
zaks.anna added a comment.
This revision now requires changes to proceed.

I find it very confusing to have 2 different fields for bug identification - 
issue_hash and BugId. Why do we need to treat the HTML reports differently from 
plist files?


http://reviews.llvm.org/D12906



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


Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

One of the error messages still needs to be made more clear. Otherwise looks 
good.

Thank you!



Comment at: clang-tidy/misc/NonCopyableObjects.cpp:88
@@ +87,3 @@
+  else if (E)
+diag(E->getExprLoc(), "expression has suspicious type '%0'")
+<< BD->getName();

aaron.ballman wrote:
> alexfh wrote:
> > What's a "suspicious type" and why should the user know about this? Should 
> > the message explain better what's wrong and what can be done about that?
> I was trying to find better wording for this, but it's really hard. This 
> comes from dereferencing a type that should only be used as an opaque pointer 
> type. eg) memcpy(some_buffer, *some_pthread_mutex_t, sizeof(pthread_mutex_t));
> 
> Perhaps:
> 
> expression has opaque data structure type '%0'; do not rely on internal 
> implementation details
> 
> or something to that effect?
That's much better, but the "do not rely on internal implementation details" is 
still not very clear. Maybe add that the type should only be used as a pointer 
and should never be dereferenced in the user code?


http://reviews.llvm.org/D12945



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


Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good. Please fix the patch and I can commit it for you.



Comment at: clang-tidy/utils/IncludeSorter.cpp:289
@@ +288,3 @@
+IncludeSorter::IncludeStyle
+IncludeSorter::toIncludeStyle(const std::string &Value) {
+  return Value == "llvm" ? IS_LLVM : IS_Google;

Did you forget to update the name here?


http://reviews.llvm.org/D12839



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


Re: [PATCH] D13134: [analyzer] Add keyboard shortcuts to report.html

2015-09-29 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for the patch! This looks very useful. What browsers does the JavaScript 
support?

One thing I noticed is that after immediately loading a new report page the 'j' 
and 'k' shortcuts don't work for me. In Safari, I get:

  TypeError: null is not an object (evaluating 
'document.location.hash.match(/Path\d+|EndPath/)')
  Jumpkeyboard-shortcuts.js:3
  onkeydownkeyboard-shortcuts.js:29

After clicking on the location link in the summary the keys **do** work. (I 
guess this has to with the # in the location?) Would it be possible to make 
these navigation keys go to the end of the path after the page has loaded but 
before the user has clicked on the location link?



Comment at: tools/scan-build/keyboard-shortcuts.js:24
@@ +23,3 @@
+  K: 75,
+  SLASH: 191
+}

Will this work on international keyboards where ? is not Shift + '/'? (E.g., 
AZERTY or QWERTZ?)


Repository:
  rL LLVM

http://reviews.llvm.org/D13134



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


Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2015-09-29 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D12839#256179, @flx wrote:

> I had to convert the line endings of mis-move-constructor-init.cpp to unix 
> style otherwise the test would not correctly work. This took a long time to 
> debug since the checks failed complaining that error messages that look 
> exactly the same didn't match.
>
> Let me know if this needs to be converted back to DOS line endings, but it 
> looks like most other tests have unix line endings.


All source and test files should have svn:eol-style=native property set to 
avoid this kind of an issue. I have no idea why is it not done on all 
llvm/clang sources.


http://reviews.llvm.org/D12839



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


r248869 - Fix the sample profile format that breaks in test http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/505

2015-09-29 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Sep 29 20:03:10 2015
New Revision: 248869

URL: http://llvm.org/viewvc/llvm-project?rev=248869&view=rev
Log:
Fix the sample profile format that breaks in test 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/505

http://reviews.llvm.org/D13145

Modified:
cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof

Modified: cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof?rev=248869&r1=248868&r2=248869&view=diff
==
--- cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof 
(original)
+++ cfe/trunk/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof Tue Sep 
29 20:03:10 2015
@@ -1,2 +1,2 @@
 bar:100:100
-1: 2000
+ 1: 2000


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


Re: [PATCH] D13249: Divide TraverseInitListExpr to a different function for each form.

2015-09-29 Thread Manuel Klimek via cfe-commits
I think it's worth figuring out when this is called with the semantic or
syntactic version and why this can't lead to double visitation. Then add a
comment while you're changing the method so the next person doesn't have to
figure it all out :)

On Wed, Sep 30, 2015 at 12:15 AM Angel Garcia 
wrote:

> angelgarcia added a comment.
>
> Yes, it breaks a few tests:
>
> FAIL: Clang :: Analysis/operator-calls.cpp (598 of 8596)
>
> FAIL: Clang :: Analysis/misc-ps-region-store.cpp (599 of 8596)
>
> FAIL: Clang :: Analysis/array-struct-region.c (602 of 8596)
>
>
> http://reviews.llvm.org/D13249
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13279: Decorating virtual functions load with invariant.load

2015-09-29 Thread Piotr Padlewski via cfe-commits
Prazek created this revision.
Prazek added reviewers: rsmith, majnemer, nlewycky, rjmccall.
Prazek added a subscriber: cfe-commits.

http://reviews.llvm.org/D13279

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/virtual-function-calls.cpp

Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} align 8, !invariant.load 
![[EMPTY_NODE:[0-9]]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1609,7 +1609,15 @@
   uint64_t VTableIndex = 
CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
   llvm::Value *VFuncPtr =
   CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-  return CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+  auto *Inst = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+  // It's safe to add "invariant.load" without -fstrict-vtable-pointers, but it
+  // would not help in devirtualization.
+  if (CGM.getCodeGenOpts().StrictVTablePointers)
+Inst->setMetadata(llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+  return Inst;
 }
 
 llvm::Value *ItaniumCXXABI::EmitVirtualDestructorCall(


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - -fstrict-vtable-pointers | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} align 8, !invariant.load ![[EMPTY_NODE:[0-9]]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1609,7 +1609,15 @@
   uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
   llvm::Value *VFuncPtr =
   CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-  return CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+  auto *Inst = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+  // It's safe to add "invariant.load" without -fstrict-vtable-pointers, but it
+  // would not help in devirtualization.
+  if (CGM.getCodeGenOpts().StrictVTablePointers)
+Inst->setMetadata(llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+  return Inst;
 }
 
 llvm::Value *ItaniumCXXABI::EmitVirtualDestructorCall(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits