Re: [PATCH] D20052: Add new ASTMatcher that matches dynamic exception specifications.

2016-05-08 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please add tests, re-generate documentation and add the matcher to the dynamic 
matchers registry. See http://reviews.llvm.org/D19871 for an example.


http://reviews.llvm.org/D20052



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


r268874 - Teach header search about GCC 4.9 header search paths in Gentoo, they

2016-05-08 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Sun May  8 02:59:56 2016
New Revision: 268874

URL: http://llvm.org/viewvc/llvm-project?rev=268874&view=rev
Log:
Teach header search about GCC 4.9 header search paths in Gentoo, they
now use the full GCC version in their weird suffix.

Added:
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268874&r1=268873&r2=268874&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun May  8 02:59:56 2016
@@ -4134,6 +4134,7 @@ void Linux::AddClangCXXStdlibIncludeArgs
   const std::string LibStdCXXIncludePathCandidates[] = {
   // Gentoo is weird and places its headers inside the GCC install,
   // so if the first attempt to find the headers fails, try these patterns.
+  InstallDir.str() + "/include/g++-v" + Version.Text,
   InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
   Version.MinorStr,
   InstallDir.str() + "/include/g++-v" + Version.MajorStr,

Added: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep?rev=268874&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o?rev=268874&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g%2B%2B-v4.9.3/.keep?rev=268874&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep?rev=268874&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/linux-header-search.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=268874&r1=268873&r2=268874&view=diff
==
--- cfe/trunk/test/Driver/linux-header-search.cpp (original)
+++ cfe/trunk/test/Driver/linux-header-search.cpp Sun May  8 02:59:56 2016
@@ -285,6 +285,21 @@
 // CHECK-GENTOO-4-6-4: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
 // CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.3_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+// CHECK-GENTOO-4-9-3: "{{.*}

Re: [PATCH] D19764: Keep invalid functions as part of the AST

2016-05-08 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

Ping?


http://reviews.llvm.org/D19764



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


[PATCH] D20054: Fix spurious warnings about unused private field

2016-05-08 Thread Olivier Goffart via cfe-commits
ogoffart created this revision.
ogoffart added reviewers: cfe-commits, djasper.

If the address of a field is taken as a pointer to member, we should
not warn that the field is not used.

Normaly, yse of fields are done from MemberExpr, but in case of pointer to
 member, it is in a DeclRefExpr


http://reviews.llvm.org/D20054

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-unused-private-field.cpp

Index: test/SemaCXX/warn-unused-private-field.cpp
===
--- test/SemaCXX/warn-unused-private-field.cpp
+++ test/SemaCXX/warn-unused-private-field.cpp
@@ -128,6 +128,7 @@
 int *use = &by_reference_;
 int test[2];
 test[as_array_index_] = 42;
+int EverythingUsed::*ptr = &EverythingUsed::by_pointer_to_member_;
   }
 
   template
@@ -142,6 +143,7 @@
   int by_template_function_;
   int as_array_index_;
   int by_initializer_;
+  int by_pointer_to_member_;
 };
 
 class HasFeatureTest {
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1736,10 +1736,12 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  // Just in case we're building an illegal pointer-to-member.
-  FieldDecl *FD = dyn_cast(D);
-  if (FD && FD->isBitField())
-E->setObjectKind(OK_BitField);
+  if (FieldDecl *FD = dyn_cast(D)) {
+UnusedPrivateFields.remove(FD);
+// Just in case we're building an illegal pointer-to-member.
+if (FD->isBitField())
+  E->setObjectKind(OK_BitField);
+  }
 
   return E;
 }


Index: test/SemaCXX/warn-unused-private-field.cpp
===
--- test/SemaCXX/warn-unused-private-field.cpp
+++ test/SemaCXX/warn-unused-private-field.cpp
@@ -128,6 +128,7 @@
 int *use = &by_reference_;
 int test[2];
 test[as_array_index_] = 42;
+int EverythingUsed::*ptr = &EverythingUsed::by_pointer_to_member_;
   }
 
   template
@@ -142,6 +143,7 @@
   int by_template_function_;
   int as_array_index_;
   int by_initializer_;
+  int by_pointer_to_member_;
 };
 
 class HasFeatureTest {
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1736,10 +1736,12 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  // Just in case we're building an illegal pointer-to-member.
-  FieldDecl *FD = dyn_cast(D);
-  if (FD && FD->isBitField())
-E->setObjectKind(OK_BitField);
+  if (FieldDecl *FD = dyn_cast(D)) {
+UnusedPrivateFields.remove(FD);
+// Just in case we're building an illegal pointer-to-member.
+if (FD->isBitField())
+  E->setObjectKind(OK_BitField);
+  }
 
   return E;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20053: [clang-tidy] Add misc-unnecessary-mutable check.

2016-05-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


http://reviews.llvm.org/D20053



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


Re: [PATCH] D20054: Fix spurious warnings about unused private field

2016-05-08 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


http://reviews.llvm.org/D20054



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


r268878 - clang-format: Support enum type template arguments.

2016-05-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Sun May  8 13:12:22 2016
New Revision: 268878

URL: http://llvm.org/viewvc/llvm-project?rev=268878&view=rev
Log:
clang-format: Support enum type template arguments.

Before:
  template  class A { public : E *f(); };

After:
  template  class A {
  public:
E *f();
  };

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=268878&r1=268877&r2=268878&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sun May  8 13:12:22 2016
@@ -902,6 +902,7 @@ void UnwrappedLineParser::parseStructura
 break;
   }
   do {
+const FormatToken *Previous = getPreviousToken();
 switch (FormatTok->Tok.getKind()) {
 case tok::at:
   nextToken();
@@ -909,6 +910,12 @@ void UnwrappedLineParser::parseStructura
 parseBracedList();
   break;
 case tok::kw_enum:
+  // Ignore if this is part of "template is(tok::less)) {
+nextToken();
+break;
+  }
+
   // parseEnum falls through and does not yet add an unwrapped line as an
   // enum definition can start a structural element.
   if (!parseEnum())

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=268878&r1=268877&r2=268878&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun May  8 13:12:22 2016
@@ -5381,6 +5381,10 @@ TEST_F(FormatTest, WrapsTemplateDeclarat
   verifyFormat("template  // T can be A, B or C.\n"
"struct C {};",
AlwaysBreak);
+  verifyFormat("template  class A {\n"
+   "public:\n"
+   "  E *f();\n"
+   "};");
 }
 
 TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {


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


r268879 - clang-format: Fix space after argument comments.

2016-05-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Sun May  8 13:14:01 2016
New Revision: 268879

URL: http://llvm.org/viewvc/llvm-project?rev=268879&view=rev
Log:
clang-format: Fix space after argument comments.

Before:
  f(/*a=*/a, /*b=*/ ::b);

After:
  f(/*a=*/a, /*b=*/::b);

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=268879&r1=268878&r2=268879&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun May  8 13:14:01 2016
@@ -2174,7 +2174,7 @@ bool TokenAnnotator::spaceRequiredBefore
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
-  if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
+  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment))
 return (Left.is(TT_TemplateOpener) &&
 Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren,

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=268879&r1=268878&r2=268879&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun May  8 13:14:01 2016
@@ -1122,7 +1122,7 @@ TEST_F(FormatTest, RemovesTrailingWhites
 
 TEST_F(FormatTest, UnderstandsBlockComments) {
   verifyFormat("f(/*noSpaceAfterParameterNamingComment=*/true);");
-  verifyFormat("void f() { g(/*aaa=*/x, /*bbb=*/!y); }");
+  verifyFormat("void f() { g(/*aaa=*/x, /*bbb=*/!y, /*c=*/::c); }");
   EXPECT_EQ("f(a, /* Trailing comment for aa... */\n"
 "  b);",
 format("f(a ,   \\\n"


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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-08 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:63
@@ +62,3 @@
+removeFromFoundDecls(Used->getCanonicalDecl());
+  } else if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {

Use early return here instead of "else".


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:65
@@ +64,3 @@
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate()) {
+removeFromFoundDecls(FDT);

No braces for single statement ifs.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:68
@@ +67,3 @@
+  } else {
+removeFromFoundDecls(FD);
+  }

Wouldn't you also want to do this via the canonical decl? Add a test.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:71
@@ +70,3 @@
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD);
+}

Would it be important to look at something like the canonical decl here? Can 
you add a test with a (static) class variable that is initialized out of line?


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:60
@@ +59,3 @@
+  UsedFunc();
+  UsedTemplateFunc();
+  cout << endl;

Can you add tests where variables and functions are solely referenced by 
pointers to members? Compare:
http://reviews.llvm.org/D20054


Repository:
  rL LLVM

http://reviews.llvm.org/D20018



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


Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas/colons in constructor initializer list.

2016-05-08 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1821
@@ +1820,3 @@
+  if (Line->Affected)
+checkConstructorInitList(*Line);
+}

Why are we restricting this to constructor initializers? I think we should 
directly be more generic and clean up different lists. Also, as an idea? Could 
we make this very generic and implement a function that analyzes a line for a 
specific sequence of tokens? E.g., I would assume that then the current 
checkConstructorInitList() could be written as:

  cleanupLeft(tok::comma, tok::comma);
  cleanupLeft(tok::comma, tok::l_brace);
  cleanupRight(tok::colon, tok::comma);
  cleanupLeft(tok::colon, tok::l_brace);

With cleanupLeft/Right meaning: Find this sequence of tokens (ignoring 
comments) and then clean up the left or the right side.

Not sure about the exact names of functions etc. What do you think?


http://reviews.llvm.org/D19804



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-08 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 56521.
hintonda added a comment.

- Fix typo in docs.


http://reviews.llvm.org/D18575

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A{};
+class B{};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo' uses dynamic exception specification 'throw()'; use 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw(...)'; use 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: function 'foobar' uses dynamic exception specification 'throw(A, B)'; use 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+// Should not trigger a replacement.
+void titi() noexcept {}
+void toto() noexcept(true) {}
Index: test/clang-tidy/modernize-use-noexcept-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept-macro.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
+// RUN:   -- -std=c++11
+
+#define NOEXCEPT noexcept
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw()'; use 'NOEXCEPT' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() NOEXCEPT {}
+
+// Should not trigger a replacement.
+void foo() noexcept(true);
+
Index: docs/clang-tidy/checks/modernize-use-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-noexcept.rst
@@ -0,0 +1,50 @@
+.. title:: clang-tidy - modernize-use-noexcept
+
+modernize-use-noexcept
+==
+
+The check converts dynamic exception specifications, e.g., throw(),
+throw([,...]), or throw(...) to noexcept, noexcept(false),
+or a user defined macro.
+
+Example
+---
+
+.. code-block:: c++
+
+  void foo() throw();
+	void bar() throw(int) {}
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() noexcept;
+	void bar() noexcept(false) {}
+
+
+User defined macros
+---
+
+By default this check will only replace ``throw()`` with ``noexcept``,
+and ``throw([,...])`` or ``throw(...)`` with
+``noexcept(false)``.  Additinally, users can also use
+:option:``ReplacementString`` to specify a macro to use instead of
+``noexcept``.  This is useful when maintaining source code that must
+be compiled with older compilers that don't support the ``noexcept``
+keyword.
+
+Example
+^^^
+
+.. code-block:: c++
+
+  void foo() throw() {}
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() NOEXCEPT {}
+
+if the ``ReplacementString`` option is set to ``NOEXCEPT``.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -191,6 +191,11 @@
   Selectively replaces string literals containing escaped characters with raw
   string literals.
 
+- New `modernize-use-noexcept
+  `_ check
+
+  Replaces dynamic exception specifications with noexcept.
+
 - New `performance-faster-string-find
   `_ check
 
Index: clang-tidy/utils/LexerUtils.h
===
--- clang-tidy/utils/LexerUtils.h
+++ clang-tidy/utils/LexerUtils.h
@@ -12,6 +12,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallVector.h"
 
 namespace clang {
 namespace tidy {
@@ -23,6 +24,10 @@
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location);
 
+SmallVector ParseTokens(const ASTContext &Context,
+   const SourceManager &Sources,
+   CharSourceRange Range);
+
 } // namespace lexer
 } // namespace 

Re: [Clang] Convergent Attribute

2016-05-08 Thread Matt Arsenault via cfe-commits

> On May 6, 2016, at 18:12, Richard Smith via cfe-commits 
>  wrote:
> 
> On Fri, May 6, 2016 at 4:20 PM, Matt Arsenault via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
> This example looks wrong to me. It doesn't seem meaningful for a function to 
> be both readonly and convergent, because convergent means the call has some 
> side-effect visible to other threads and readonly means the call has no 
> side-effects visible outside the function.
> This s not correct. It is valid for convergent operations to be 
> readonly/readnone. Barriers are a common case which do have side effects, but 
> there are also classes of GPU instructions which do not access memory and 
> still need the convergent semantics.
> 
> Can you give an example? It's not clear to me how a function could be both 
> convergent and satisfy the readnone requirement that it not "access[...] any 
> mutable state (e.g. memory, control registers, etc) visible to caller 
> functions". Synchronizing with other threads seems like it would cause such a 
> state change in an abstract sense. Is the critical distinction here that the 
> state mutation is visible to the code that spawned the gang of threads, but 
> not to other threads within the gang? (This seems like a bug in the 
> definition of readonly if so, because it means that a readonly call whose 
> result is unused cannot be deleted.)
> 
> I care about this because Clang maps __attribute__((pure)) to LLVM readonly, 
> and -- irrespective of the LLVM semantics -- a call to a function marked pure 
> is permitted to be deleted if the return value is unused, or to have multiple 
> calls CSE'd. As a result, inside Clang, we use that attribute to determine 
> whether an expression has side effects, and Clang's reasoning about these 
> things may also lead to miscompiles if a call to a function marked 
> __attribute__((pure, convergent)) actually can have a side effect.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

These are communication operations between lanes that do not require 
synchronization within the wavefront. These are mostly cross lane communication 
instructions. An example would be the amdgcn.mov.dpp instruction, which reads a 
register from a neighboring lane, or the CUDA warp vote functions. There is no 
synchronization required, and there is no other way for the same item to access 
that information private to the other workitem. There’s no observable global 
state from the perspective of a single lane. The individual registers changed 
aren’t visible to the spawning host program (perhaps with the exception of some 
debug hardware inspecting all of the individual registers). Deleting these 
would be perfectly acceptable if the result is unused.

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


Re: [PATCH] D20052: Add new ASTMatcher that matches dynamic exception specifications.

2016-05-08 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 56522.
hintonda added a comment.

- Added test, re-generated documentation, and add new matcher to the dynamic 
matchers registry.


http://reviews.llvm.org/D20052

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3552,6 +3552,22 @@
   pointsTo(TypeMatcher(anything()));
 }
 
+TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) {
+  EXPECT_TRUE(notMatches("void f();", 
functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void g() noexcept;",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void h() noexcept(true);",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void i() noexcept(false);",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void j() throw();", functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void k() throw(int);", 
functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void l() throw(...);", 
functionDecl(hasDynamicExceptionSpec(;
+}
+
 TEST(HasImplicitDestinationType, MatchesSimpleCase) {
   // This test creates an implicit const cast.
   EXPECT_TRUE(matches("int x; const int i = x;",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -218,6 +218,7 @@
   REGISTER_MATCHER(hasDeducedType);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
+  REGISTER_MATCHER(hasDynamicExceptionSpec);
   REGISTER_MATCHER(hasEitherOperand);
   REGISTER_MATCHER(hasElementType);
   REGISTER_MATCHER(hasElse);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3212,6 +3212,26 @@
   return Node.isDefaulted();
 }
 
+/// \brief Matches functions that have a dynamic exception specification.
+///
+/// Given:
+/// \code
+///   void f();
+///   void g() noexcept;
+///   void h() noexcept(true);
+///   void i() noexcept(false);
+///   void j() throw();
+///   void k() throw(int);
+///   void l() throw(...);
+/// \endcode
+/// functionDecl(hasDynamicExceptionSpec())
+///   matches the declarations of j, k, and l, but not f, g, h, or i.
+AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
+  if (const auto *FnTy = Node.getType()->getAs())
+return FnTy->hasDynamicExceptionSpec();
+  return false;
+}
+
 /// \brief Matches functions that have a non-throwing exception specification.
 ///
 /// Given:
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2371,6 +2371,22 @@
 
 
 
+MatcherFunctionDecl>hasDynamicExceptionSpec
+Matches 
functions that have a dynamic exception specification.
+
+Given:
+  void f();
+  void g() noexcept;
+  void h() noexcept(true);
+  void i() noexcept(false);
+  void j() throw();
+  void k() throw(int);
+  void l() throw(...);
+functionDecl(hasDynamicExceptionSpec())
+  matches the declarations of j, k, and l, but not f, g, h, or i.
+
+
+
 MatcherFunctionDecl>hasOverloadedOperatorNameStringRef
 Name
 Matches 
overloaded operator names.
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3552,6 +3552,22 @@
   pointsTo(TypeMatcher(anything()));
 }
 
+TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) {
+  EXPECT_TRUE(notMatches("void f();", functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void g() noexcept;",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void h() noexcept(true);",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void i() noexcept(false);",
+ functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void j() throw();", functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void l() throw(...);", functionDe

[PATCH] D20053: [clang-tidy] Add misc-unnecessary-mutable check.

2016-05-08 Thread Marek Sokołowski via cfe-commits
mnbvmar created this revision.
mnbvmar added a reviewer: alexfh.
mnbvmar added subscribers: krystyna, sbarzowski, Prazek, staronj, cfe-commits.

This implements unnecessary-mutable check. It's still bug-prone and might 
produce false positives, so all suggestions are welcome.

http://reviews.llvm.org/D20053

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UnnecessaryMutableCheck.cpp
  clang-tidy/misc/UnnecessaryMutableCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-unnecessary-mutable.rst
  test/clang-tidy/misc-unnecessary-mutable.cpp

Index: test/clang-tidy/misc-unnecessary-mutable.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-unnecessary-mutable.cpp
@@ -0,0 +1,354 @@
+// RUN: %check_clang_tidy %s misc-unnecessary-mutable %t
+
+struct NothingMutable {
+  int field1;
+  unsigned field2;
+  const int field3;
+  volatile float field4;
+
+  NothingMutable(int a1, unsigned a2, int a3, float a4) : field1(a1), field2(a2), field3(a3), field4(a4) {}
+
+  void doSomething() {
+field1 = 1;
+field2 = 2;
+field4 = 4;
+  }
+};
+
+struct NoMethods {
+  int field1;
+  mutable unsigned field2; // These cannot be fixed; they're public
+  const int field3;
+  mutable volatile NothingMutable field4;
+};
+
+class NoMethodsClass {
+public:
+  int field1;
+  mutable unsigned field2;
+
+private:
+  const int field3;
+  mutable volatile NothingMutable field4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'mutable' modifier is unnecessary for field 'field4' [misc-unnecessary-mutable]
+  // CHECK-FIXES: {{^  }}volatile NothingMutable field4;
+};
+
+struct PrivateInStruct {
+private:
+  mutable volatile unsigned long long blah;
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'mutable' modifier is unnecessary for field 'blah' {{..}}
+  // CHECK-FIXES: {{^  }}volatile unsigned long long blah;
+};
+
+union PrivateInUnion {
+public:
+  int someField;
+
+private:
+  mutable char otherField;
+};
+
+class UnusedVar {
+private:
+  mutable int x __attribute__((unused));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'mutable' modifier is unnecessary for field 'x' {{..}}
+  // CHECK-FIXES: {{^  }}int x __attribute__((unused));
+};
+
+class NoConstMethodsClass {
+public:
+  int field1;
+  mutable unsigned field2;
+
+  NoConstMethodsClass() : field2(42), field3(9), field4(NothingMutable(1, 2, 3, 4)) {}
+
+  void doSomething() {
+field2 = 8;
+field1 = 99;
+field4.doSomething();
+  }
+
+private:
+  const int field3;
+  mutable NothingMutable field4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'mutable' modifier is unnecessary for field 'field4' {{..}}
+  // CHECK-FIXES: {{^  }}NothingMutable field4;
+};
+
+class ConstMethods {
+private:
+  mutable int field1, field2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'mutable' modifier is unnecessary for field 'field2' {{..}}
+  mutable int incr, decr, set, mul, constArg1, constArg2, constRef, ref1, ref2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'mutable' modifier is unnecessary for field 'constArg1' {{..}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: 'mutable' modifier is unnecessary for field 'constArg2' {{..}}
+  // CHECK-MESSAGES: :[[@LINE-3]]:59: warning: 'mutable' modifier is unnecessary for field 'constRef' {{..}}
+
+  void takeArg(int x) const { x *= 4; }
+  int takeConstRef(const int &x) const { return x + 99; }
+  void takeRef(int &) const {}
+
+  template 
+  void takeArgs(Args... args) const {}
+  template 
+  void takeArgRefs(Args &... args) const {}
+
+public:
+  void doSomething() const {
+field1 = field2;
+  }
+
+  void doOtherThing() const {
+incr++;
+decr--;
+set = 42;
+mul *= 3;
+takeArg(constArg1);
+takeConstRef(constRef);
+takeRef(ref1);
+takeArgs(constArg1, constArg2);
+takeArgRefs(ref1, ref2);
+  }
+};
+
+class NonFinalClass {
+public:
+  mutable int fPublic;
+
+protected:
+  mutable int fProtected;
+
+private:
+  mutable int fPrivate;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'mutable' modifier is unnecessary for field 'fPrivate' {{..}}
+  // CHECK-FIXES: {{^  }}int fPrivate;
+};
+
+class FinalClass final {
+public:
+  mutable int fPublic;
+
+protected:
+  mutable int fProtected;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'mutable' modifier is unnecessary for field 'fProtected' {{..}}
+  // CHECK-FIXES: {{^  }}int fProtected;
+
+private:
+  mutable int fPrivate;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'mutable' modifier is unnecessary for field 'fPrivate' {{..}}
+  // CHECK-FIXES: {{^  }}int fPrivate;
+};
+
+class NotAllFuncsKnown {
+  void doSomething();
+  void doSomethingConst() const {}
+
+private:
+  mutable int field;
+  // Can't be fixed. We don't know if doSomething() doesn't declare a *const* NotAllFuncsKnown instance
+  // and then modify 'field' field.
+};
+
+class NotAllConstFuncsKnown {
+  void doSomething() {}
+  void doSomethingC

Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-08 Thread Luchesar V. ILIEV via cfe-commits
kerberizer added a comment.

Just to confirm seeing exactly the same error as @foutrelis on Arch i686 (and 
everything else pass too), but when building the current 3.9.0svn trunk with 
only this patch applied unmodified on it. Thus, it's probably not likely to be 
something connected to Evangelos' specific setup.


http://reviews.llvm.org/D18035



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


[libcxx] r268887 - Generate code coverage for experimental libraries

2016-05-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun May  8 18:08:50 2016
New Revision: 268887

URL: http://llvm.org/viewvc/llvm-project?rev=268887&view=rev
Log:
Generate code coverage for experimental libraries

Modified:
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=268887&r1=268886&r2=268887&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Sun May  8 18:08:50 2016
@@ -56,7 +56,7 @@ add_lit_testsuite(check-libcxx
 if (LIBCXX_GENERATE_COVERAGE)
   include(CodeCoverage)
   set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
-  set(capture_dirs 
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${CMAKE_CURRENT_BINARY_DIR}")
+  set(capture_dirs 
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/;${CMAKE_CURRENT_BINARY_DIR}")
   set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
   setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" 
"${extract_dirs}")
 endif()


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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-08 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

In http://reviews.llvm.org/D18369#422367, @yaxunl wrote:

> In http://reviews.llvm.org/D18369#421963, @pxli168 wrote:
>
> > If we want to save some space, could we use some macro to expand the 
> > gentype or some script to expand the gentype into each types when the clang 
> > is build?
>
>
> We need to balance between space and readability. When I absorbed 
> __attribute__((overloadable)) into __const_func to save space, it did not 
> sacrifice readability. However using macro with gentype will cause the header 
> file more difficult to read.


But I don't think this kind of so long header is easy to read, it contains full 
pages of the same function with different types and it is hard to see if anyone 
is missing or find where these functions end. In spec builtin functions can be 
represented by

> gentype ctz (gentype x)

>  gentype max (gentype x, gentype y)

>  gentype max (gentype x, sgentype y)


If we could use some macro or script to generate the actual builtin functions, 
it seems more likely spec and clear to read, also will avoid missing or typo.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-08 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


http://reviews.llvm.org/D19780



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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-08 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

The pointer type seems to be not that important, we can just cast it to any 
type we want.



Comment at: test/SemaOpenCL/to_addr_builtin.cl:24
@@ +23,3 @@
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0

should this return a NULL or a build error?


Comment at: test/SemaOpenCL/to_addr_builtin.cl:35
@@ +34,3 @@
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes 
address space of pointer}}
+#endif

I think this will be handled by pointer bitcast if we used some void* as well, 
the address space is the important thing of these built-ins.


http://reviews.llvm.org/D19932



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


r268893 - [X86] Fix up type arguments of __builtin_ia32_cvtss2sd_round_mask and __builtin_ia32_cvtsd2ss_round_mask to match the backend.

2016-05-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May  9 00:34:22 2016
New Revision: 268893

URL: http://llvm.org/viewvc/llvm-project?rev=268893&view=rev
Log:
[X86] Fix up type arguments of __builtin_ia32_cvtss2sd_round_mask and 
__builtin_ia32_cvtsd2ss_round_mask to match the backend.

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268893&r1=268892&r2=268893&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May  9 00:34:22 2016
@@ -2259,11 +2259,11 @@ TARGET_BUILTIN(__builtin_ia32_vcvtps2ph2
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask512, "UiV32s","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask128, "UcV8s","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask256, "UsV16s","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_cvtsd2ss_round_mask, 
"V4fV4fV4fV2dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtsd2ss_round_mask, 
"V4fV4fV2dV4fUcIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtsi2sd64, "V2dV2dLLiIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtsi2ss32, "V4fV4fiIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtsi2ss64, "V4fV4fLLiIi","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_cvtss2sd_round_mask, 
"V2dV2dV2dV4fUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtss2sd_round_mask, 
"V2dV2dV4fV2dUcIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtusi2sd32, "V2dV2dUi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtusi2sd64, "V2dV2dULLiIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")


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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-08 Thread Nick Lewycky via cfe-commits
nicholas updated this revision to Diff 56526.
nicholas added a comment.

Unsure why, but the previous diff didn't have the 'volatile' check removed.


http://reviews.llvm.org/D19851

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/Parser/cxx-casting.cpp
  test/SemaCXX/cstyle-cast.cpp
  test/SemaCXX/functional-cast.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/static-cast.cpp

Index: test/SemaCXX/static-cast.cpp
===
--- test/SemaCXX/static-cast.cpp
+++ test/SemaCXX/static-cast.cpp
@@ -43,11 +43,11 @@
   (void)static_cast((int*)0);
   (void)static_cast((const int*)0);
   (void)static_cast((B*)0);
-  (void)static_cast(*((B*)0));
+  (void)static_cast(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((C1*)0);
-  (void)static_cast(*((C1*)0));
+  (void)static_cast(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((D*)0);
-  (void)static_cast(*((D*)0));
+  (void)static_cast(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((int A::*)0);
   (void)static_cast((void (A::*)())0);
 
Index: test/SemaCXX/new-delete.cpp
===
--- test/SemaCXX/new-delete.cpp
+++ test/SemaCXX/new-delete.cpp
@@ -444,11 +444,11 @@
 
   template
   void tfn() {
-new (*(PlacementArg*)0) T[1];
+new (*(PlacementArg*)0) T[1]; // expected-warning 2 {{binding null pointer to reference has undefined behavior}}
   }
 
   void fn() {
-tfn();
+tfn();  // expected-note {{in instantiation of function template specialization 'r150682::tfn' requested here}}
   }
 
 }
Index: test/SemaCXX/functional-cast.cpp
===
--- test/SemaCXX/functional-cast.cpp
+++ test/SemaCXX/functional-cast.cpp
@@ -126,14 +126,14 @@
   typedef A *Ap;
   (void)Ap((B*)0);
   typedef A &Ar;
-  (void)Ar(*((B*)0));
+  (void)Ar(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef const B *cBp;
   (void)cBp((C1*)0);
   typedef B &Br;
-  (void)Br(*((C1*)0));
+  (void)Br(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)Ap((D*)0);
   typedef const A &cAr;
-  (void)cAr(*((D*)0));
+  (void)cAr(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef int B::*Bmp;
   (void)Bmp((int A::*)0);
   typedef void (B::*Bmfp)();
Index: test/SemaCXX/cstyle-cast.cpp
===
--- test/SemaCXX/cstyle-cast.cpp
+++ test/SemaCXX/cstyle-cast.cpp
@@ -84,11 +84,11 @@
   (void)(void*)((int*)0);
   (void)(volatile const void*)((const int*)0);
   (void)(A*)((B*)0);
-  (void)(A&)(*((B*)0));
+  (void)(A&)(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(const B*)((C1*)0);
-  (void)(B&)(*((C1*)0));
+  (void)(B&)(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(A*)((D*)0);
-  (void)(const A&)(*((D*)0));
+  (void)(const A&)(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(int B::*)((int A::*)0);
   (void)(void (B::*)())((void (A::*)())0);
   (void)(A*)((E*)0); // C-style cast ignores access control
Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   template  class A {}; // expected-note 2{{here}}
-  void foo() { A(*(A*)0); }
+  void foo() { A(*(A*)0); } // expected-warning {{binding null pointer to reference has undefined behavior}}
 }
 
 typedef char* c;
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -11,7 +11,7 @@
 
 template
 struct bogus_override_if_virtual : public T {
-  bogus_override_if_virtual() : T(*(T*)0) { }
+  bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding null pointer to reference has undefined behavior}}
   int operator()() const;
 };
 
@@ -36,7 +36,7 @@
   lv(); // expected-error{{no matching function for call to object of type}}
   mlv(); // expected-error{{no matching function for call to object of type}}
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }
 
 // Core issue 974: default arguments (8.3.6) may be specified in the
Index: lib/Sema/SemaIni

Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-08 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 56529.
courbet marked an inline comment as done.

http://reviews.llvm.org/D19534

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/DefaultArgumentsCheck.cpp
  clang-tidy/google/DefaultArgumentsCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-default-arguments.cpp

Index: test/clang-tidy/google-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/google-default-arguments.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s google-default-arguments %t
+
+struct A {
+  virtual void f(int I, int J = 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: default arguments on virtual or override methods are prohibited [google-default-arguments]
+};
+
+struct B : public A {
+  void f(int I, int J = 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default arguments on virtual or override methods are prohibited
+};
+
+struct C : public B {
+  void f(int I, int J = 5) override;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default arguments on virtual or override methods are prohibited
+};
+
+// Negatives.
+struct D : public B {
+  void f(int I, int J) override;
+};
+
+struct X {
+  void f(int I, int J = 3);
+};
+
+struct Y : public X {
+  void f(int I, int J = 5);
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -33,6 +33,7 @@
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
+   google-default-arguments
google-explicit-constructor
google-global-names-in-headers
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
Index: docs/clang-tidy/checks/google-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-default-arguments.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - google-default-arguments
+
+google-default-arguments
+
+
+Checks that default arguments are not given for virtual methods.
+
+See https://google.github.io/styleguide/cppguide.html#Default_Arguments
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -100,6 +100,11 @@
   Flags user-defined constructor definitions that do not initialize all builtin
   and pointer fields which leaves their memory in an undefined state.
 
+- New `google-default-arguments
+  `_ check
+
+  Flags default arguments in virtual methods.
+
 - New `misc-dangling-handle
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
 #include "GlobalNamesInHeadersCheck.h"
@@ -42,6 +43,8 @@
 "google-build-namespaces");
 CheckFactories.registerCheck(
 "google-build-using-namespace");
+CheckFactories.registerCheck(
+"google-default-arguments");
 CheckFactories.registerCheck(
 "google-explicit-constructor");
 CheckFactories.registerCheck(
Index: clang-tidy/google/DefaultArgumentsCheck.h
===
--- /dev/null
+++ clang-tidy/google/DefaultArgumentsCheck.h
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+/// Checks that default parameters are not given for virtual methods.
+///
+/// See https://google.github.io/styleguide/cppguide.html#Default_Arguments
+class DefaultArgumentsCheck : public ClangTidyCheck {
+public:
+  DefaultArgumentsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+

Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-08 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks. I don't have write access, could you please submit this for me ?


http://reviews.llvm.org/D19534



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