[PATCH] D28189: Extend documentation of how to test clang-tidy checks.

2016-12-31 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Awesome! Thank you for adding clarity to this part.

Looks good with a couple of nits.




Comment at: docs/clang-tidy/index.rst:550
+separate `FileCheck`_ invocations: once with FileCheck's directive
+prefix set to `CHECK-MESSAGES`, validating the diagnostic messages,
+and once with the directive prefix set to `CHECK-FIXES`, running

Inline code snippets in rst should use double backquotes. I know, that's 
confusing, but it's what we have to deal with.



Comment at: docs/clang-tidy/index.rst:555
+that code was not modified by fixits, by checking that it is present
+unchanged in the fixed code.  The full set of `FileCheck` directives
+is available (e.g., `CHECK-MESSAGES-SAME:`, `CHECK-MESSAGES-NOT:`), though

Put an underscore after `FileCheck` (as in line 549). This is a syntax for a 
named reference. See also http://llvm.org/docs/SphinxQuickstartTemplate.html


https://reviews.llvm.org/D28189



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


[PATCH] D28189: Extend documentation of how to test clang-tidy checks.

2016-12-31 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/index.rst:558
+typically the basic `CHECK` forms (`CHECK-MESSAGES` and `CHECK-FIXES`)
+are sufficient for matcher tests.  Note that the `FileCheck`
+documentation mostly assumes the default prefix (`CHECK`), and hence

I'm not sure the term "matcher tests" is used anywhere else in our 
documentation. And it doesn't seem obvious to me either (if it refers to AST 
matchers, then it's just an implementation detail of clang-tidy checks, if it 
refers to the check patterns, then it's not a commonly used term for those 
either). I don't know what would be a good short replacement, maybe "clang-tidy 
lit tests" or just "clang-tidy tests".


https://reviews.llvm.org/D28189



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


Re: r290773 - Wdocumentation fix

2016-12-31 Thread Simon Pilgrim via cfe-commits


On 30/12/2016 23:12, Richard Smith wrote:
On 30 Dec 2016 3:06 pm, "Simon Pilgrim via cfe-commits" 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: rksimon
Date: Fri Dec 30 16:55:33 2016
New Revision: 290773

URL: http://llvm.org/viewvc/llvm-project?rev=290773&view=rev

Log:
Wdocumentation fix


Thanks, but please be careful you don't introduce trailing whitespace 
changes to unrelated code in the future.
Sorry about that - I'm working on my alt laptop for the holidays and 
didn't have the same whitespace diff settings for tortoisesvn - 
shouldn't happpen again.
Also perhaps we should turn this warning on by default for regular 
selfhosted builds so we don't need to wait for a buildbot to find 
issues like this?
The buildbots are there for us to unearth these kind of things, 
otherwise (in extremis) you'd be asking everyone to test on a much 
broader range of compile tools than they perhaps have access to.


IMO the problem is that these mundane warnings tend to stay unnoticed in 
build logs, where people don't go unless the build goes red - I would be 
interested in hearing people's thoughts on either enabling Werror by 
default in CMake gen and/or enabling Werror on a wider range of 
buildbots (gcc/clang/msvc)?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21298: [Clang-tidy] delete null check

2016-12-31 Thread Gergely Angeli via Phabricator via cfe-commits
SilverGeri updated this revision to Diff 82760.
SilverGeri added a comment.

reduce number `hasCondition` to 1;  
add FIXME comment;  
shorten check comments in test


https://reviews.llvm.org/D21298

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tidy/readability/DeleteNullPointerCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-delete-null-pointer.rst
  test/clang-tidy/readability-delete-null-pointer.cpp

Index: test/clang-tidy/readability-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-delete-null-pointer.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+
+#define NULL 0
+
+void f() {
+  int *p = 0;
+
+  // #1
+  if (p) { // #2
+delete p;
+  } // #3
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+
+  // CHECK-FIXES: {{^  }}// #1
+  // CHECK-FIXES-NEXT: {{^  }}// #2
+  // CHECK-FIXES-NEXT: delete p;
+  // CHECK-FIXES-NEXT: {{^  }}// #3
+
+  int *p2 = new int[3];
+  // #4
+  if (p2) // #5
+delete[] p2;
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'if' statement is unnecessary;
+
+  // CHECK-FIXES: // #4
+  // CHECK-FIXES-NEXT: {{^  }}// #5
+  // CHECK-FIXES-NEXT: delete[] p2;
+
+  int *p3 = 0;
+  if (NULL != p3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p3;
+  }
+  // CHECK-FIXES-NOT: if (NULL != p3) {
+  // CHECK-FIXES: delete p3;
+
+  int *p4 = nullptr;
+  if (p4 != nullptr) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p4;
+  }
+  // CHECK-FIXES-NOT: if (p4 != nullptr) {
+  // CHECK-FIXES: delete p4;
+
+  char *c;
+  if (c != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete c;
+  }
+  // CHECK-FIXES-NOT: if (c != 0) {
+  // CHECK-FIXES: delete c;
+
+  char *c2;
+  if (c2) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+// CHECK-FIXES: } else {
+// CHECK-FIXES: c2 = c;
+delete c2;
+  } else {
+c2 = c;
+  }
+}
+
+void g() {
+  int *p5, *p6;
+  if (p5)
+delete p6;
+
+  if (p5 && p6)
+delete p5;
+
+  if (p6) {
+int x = 5;
+delete p6;
+  }
+}
Index: docs/clang-tidy/checks/readability-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-delete-null-pointer.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - readability-delete-null-pointer
+
+readability-delete-null-pointer
+===
+
+Checks the ``if`` statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a null pointer has no effect.
+
+.. code:: c++
+
+  int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -127,6 +127,7 @@
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
+   readability-delete-null-pointer
readability-deleted-default
readability-else-after-return
readability-function-size
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
@@ -45,6 +46,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-delete-null-pointer");
 CheckFactories.registerCheck(
 "readability-deleted-default");
 CheckFactories.registerCheck(
Index: clang-tidy/readability/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/readability/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.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_READABILITY_DELETE_NULL_POINTER_H
+#define LLVM_CLANG_TOOL

[PATCH] D21298: [Clang-tidy] delete null check

2016-12-31 Thread Gergely Angeli via Phabricator via cfe-commits
SilverGeri marked 5 inline comments as done.
SilverGeri added inline comments.



Comment at: docs/clang-tidy/checks/readability-delete-null-pointer.rst:7
+Checks the 'if' statements where a pointer's existence is checked and then 
deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+

alexfh wrote:
> alexfh wrote:
> > Either `null pointer` or `nullptr` (enclosed in double backquotes).
> Sorry for not being clear enough: "null pointer" is not an inline code 
> snippet, it shouldn't be enclosed in double backquotes or anything else. The 
> "(enclosed in double backquotes)" part was meant to apply to `nullptr` only 
> (since it's a keyword and should be highlighted as a code snippet).
To be honest, I don't even understand why I did what I did... :D


https://reviews.llvm.org/D21298



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


[clang-tools-extra] r290784 - [clang-tidy] Add delete null pointer check.

2016-12-31 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Sat Dec 31 06:45:59 2016
New Revision: 290784

URL: http://llvm.org/viewvc/llvm-project?rev=290784&view=rev
Log:
[clang-tidy] Add delete null pointer check.

This check detects and fixes redundant null checks before deletes.

Patch by: Gergely Angeli!

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

Added:
clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-delete-null-pointer.rst
clang-tools-extra/trunk/test/clang-tidy/readability-delete-null-pointer.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=290784&r1=290783&r2=290784&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Sat Dec 31 
06:45:59 2016
@@ -4,6 +4,7 @@ add_clang_library(clangTidyReadabilityMo
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ContainerSizeEmptyCheck.cpp
+  DeleteNullPointerCheck.cpp
   DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionSizeCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp?rev=290784&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp 
Sat Dec 31 06:45:59 2016
@@ -0,0 +1,76 @@
+//===--- DeleteNullPointerCheck.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 "DeleteNullPointerCheck.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 readability {
+
+void DeleteNullPointerCheck::registerMatchers(MatchFinder *Finder) {
+  const auto DeleteExpr =
+  cxxDeleteExpr(has(castExpr(has(declRefExpr(
+to(decl(equalsBoundNode("deletedPointer"
+  .bind("deleteExpr");
+
+  const auto PointerExpr =
+  ignoringImpCasts(declRefExpr(to(decl().bind("deletedPointer";
+  const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean),
+ hasSourceExpression(PointerExpr));
+  const auto BinaryPointerCheckCondition =
+  binaryOperator(hasEitherOperand(castExpr(hasCastKind(CK_NullToPointer))),
+ hasEitherOperand(PointerExpr));
+
+  Finder->addMatcher(
+  ifStmt(hasCondition(anyOf(PointerCondition, 
BinaryPointerCheckCondition)),
+ hasThen(anyOf(DeleteExpr,
+   compoundStmt(has(DeleteExpr), statementCountIs(1))
+   .bind("compound"
+  .bind("ifWithDelete"),
+  this);
+}
+
+void DeleteNullPointerCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *IfWithDelete = Result.Nodes.getNodeAs("ifWithDelete");
+  const auto *Compound = Result.Nodes.getNodeAs("compound");
+
+  auto Diag = diag(
+  IfWithDelete->getLocStart(),
+  "'if' statement is unnecessary; deleting null pointer has no effect");
+  if (IfWithDelete->getElse())
+return;
+  // FIXME: generate fixit for this case.
+
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  IfWithDelete->getLocStart(),
+  Lexer::getLocForEndOfToken(IfWithDelete->getCond()->getLocEnd(), 0,
+ *Result.SourceManager,
+ Result.Context->getLangOpts(;
+  if (Compound) {
+Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+Compound->getLBracLoc(),
+Lexer::getLocForEndOfToken(Compound->getLBracLoc(), 0,
+   *Result.SourceManager,
+   Result.Context->getLangOpts(;
+Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+Compound->getRBracLoc(),
+Lexer::getLocForEndOfToken(Compound->getRBracLoc(), 0,
+   *R

[PATCH] D21298: [Clang-tidy] delete null check

2016-12-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290784: [clang-tidy] Add delete null pointer check. 
(authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D21298?vs=82760&id=82761#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21298

Files:
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.h
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-delete-null-pointer.rst
  clang-tools-extra/trunk/test/clang-tidy/readability-delete-null-pointer.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.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_READABILITY_DELETE_NULL_POINTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETE_NULL_POINTER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-delete-null-pointer.html
+class DeleteNullPointerCheck : public ClangTidyCheck {
+public:
+  DeleteNullPointerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETE_NULL_POINTER_H
Index: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
@@ -46,6 +47,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-delete-null-pointer");
 CheckFactories.registerCheck(
 "readability-deleted-default");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
@@ -4,6 +4,7 @@
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ContainerSizeEmptyCheck.cpp
+  DeleteNullPointerCheck.cpp
   DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionSizeCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
@@ -0,0 +1,76 @@
+//===--- DeleteNullPointerCheck.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 "DeleteNullPointerCheck.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 readability {
+
+void DeleteNullPointerCheck::registerMatchers(MatchFinder *Finder) {
+  const auto DeleteExpr =
+  cxxDeleteExpr(has(castExpr(has(declRefExpr(
+to(decl(equalsBoundNode("deletedPointer

[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2016-12-31 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

Hello everyone, so after a few more tests, I've uncovered a bug and perhaps a 
different meaning for fallback style. First, the bug: if you set fallback style 
to "none", clang-format will perform no replacements. This happens because 
getStyle will first initialize its local Style variable to LLVM style, and then 
because a fallback style is set, will then set it to the "none" style, will 
ends up setting Style.DisableFormatting to true. After that, when we parse YAML 
(either from Style arg or a config file), we use the Style variable as the 
"template" for fields that haven't been set. In this case, the "none" fallback 
style causes DisableFormatting to remain true, so no formatting will take place.

As it happens, my first diff patch uploaded here fixed this issue by accident. 
Instead of reusing the same local Style variable, I declared one for each case 
where we'd need to parse. The fallback style case would use its own variable, 
FallbackStyle, which would not be used as the template style when parsing the 
YAML config.

What's interesting is that the way the code is originally written allows you to 
use fallback style as a way to set the "base" configuration for which the 
subsequently parsed YAML overlays. For example, if I don't set fallback style, 
the assumed base style is "LLVM", and any YAML parsed modifies this LLVM base 
style. But if I pass a fallback style of "Mozilla", then this becomes the base 
style over which the YAML overlays.

So to my mind, we have 2 approaches to fix the "none" style bug:

1. Go with a similar approach to what I did originally; that is, we always 
assume LLVM as the base style, and make sure that the fallback style is not 
used as the base style, but rather only as the style to return if none is 
found. I think this is what FallbackStyle was originally intended for.

2. Allow fallback style to maintain its current meaning - that is, as a way to 
set the base style when "style" is "file" or YAML. In this case, I believe the 
right thing is to treat FallbackStyle set to "none" as though no fallback style 
were passed in at all. Concretely, we might want t to modify getPredefinedStyle 
to return LLVM style when "none" is passed in, instead of what it does now. I 
personally think this is more confusing, and also introduces more risk.

Let me know what you think. If we go with option 1, I could fold the fix into 
this change.




Comment at: lib/Format/Format.cpp:1900
 
-  if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) {
-llvm::errs() << "Invalid fallback style \"" << FallbackStyle
- << "\" using LLVM style\n";
-return Style;
-  }
+  FormatStyle FallbackStyle = getNoStyle();
+  if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))

Going over my diff, I realize that I didn't revert this local FormatStyle 
instance to make use of the top-level declared "FormatStyle Style" local 
variable. I will revert this one too.


https://reviews.llvm.org/D28081



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


[libcxx] r290785 - remove some inherited attributes on exceptions

2016-12-31 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Dec 31 11:34:26 2016
New Revision: 290785

URL: http://llvm.org/viewvc/llvm-project?rev=290785&view=rev
Log:
remove some inherited attributes on exceptions

These exception types are marked with `_LIBCPP_EXCEPTION_ABI` which
expands to `__attribute__((__visibility__("default")))` or
`__declspec(dllexport)`.  When building for Windows, we would hit an
error:

cannot apply 'dllexport' to a 'dllexport' class

Remove the duplicate annotations as they will be inherited from the
class.

Modified:
libcxx/trunk/include/optional
libcxx/trunk/include/variant

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=290785&r1=290784&r2=290785&view=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Sat Dec 31 11:34:26 2016
@@ -167,7 +167,6 @@ public:
 bad_optional_access() : logic_error("bad optional access") {}
 
 // Get the key function ~bad_optional_access() into the dylib
-_LIBCPP_FUNC_VIS
 virtual ~bad_optional_access() _NOEXCEPT;
 };
 

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=290785&r1=290784&r2=290785&view=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Sat Dec 31 11:34:26 2016
@@ -216,7 +216,7 @@ namespace std { // explicitly not using
 
 class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception {
 public:
-  _LIBCPP_FUNC_VIS virtual const char* what() const _NOEXCEPT;
+  virtual const char* what() const _NOEXCEPT;
 };
 
 } // namespace std


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


[libcxxabi] r290788 - clean up `-Wmisleading-indentation` warning

2016-12-31 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Dec 31 12:09:51 2016
New Revision: 290788

URL: http://llvm.org/viewvc/llvm-project?rev=290788&view=rev
Log:
clean up `-Wmisleading-indentation` warning

Clean up the misleading indentation warning from GCC 6.  NFC

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=290788&r1=290787&r2=290788&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sat Dec 31 12:09:51 2016
@@ -3058,9 +3058,9 @@ parse_unnamed_type_name(const char* firs
 }
 if (t0 == last || *t0 != 'E')
 {
-  if(!db.names.empty())
+  if (!db.names.empty())
 db.names.pop_back();
-return first;
+  return first;
 }
 ++t0;
 if (t0 == last)


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


[libcxx] r290789 - clean up some qualifier casting

2016-12-31 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Dec 31 12:13:34 2016
New Revision: 290789

URL: http://llvm.org/viewvc/llvm-project?rev=290789&view=rev
Log:
clean up some qualifier casting

This cleans up the `-Wqual-cast` warnings from gcc 6 when building
libc++.  NFC.

Modified:
libcxx/trunk/include/__std_stream
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/__std_stream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__std_stream?rev=290789&r1=290788&r2=290789&view=diff
==
--- libcxx/trunk/include/__std_stream (original)
+++ libcxx/trunk/include/__std_stream Sat Dec 31 12:13:34 2016
@@ -297,7 +297,7 @@ __stdoutbuf<_CharT>::overflow(int_type _
 return traits_type::eof();
 if (__r == codecvt_base::partial)
 {
-pbase = (char_type*)__e;
+pbase = const_cast(__e);
 }
 }
 else

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=290789&r1=290788&r2=290789&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sat Dec 31 12:13:34 2016
@@ -443,7 +443,8 @@ inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VIS
 _Tp*
 addressof(_Tp& __x) _NOEXCEPT
 {
-return (_Tp*)&reinterpret_cast(__x);
+  return reinterpret_cast<_Tp *>(
+  const_cast(&reinterpret_cast(__x)));
 }
 
 #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF


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


[libcxx] r290791 - system_error: use strerror_r only for threaded code

2016-12-31 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Dec 31 15:24:04 2016
New Revision: 290791

URL: http://llvm.org/viewvc/llvm-project?rev=290791&view=rev
Log:
system_error: use strerror_r only for threaded code

When building libc++ without threading, strerror_r is not used.  Define
the code only when threading is enabled.  This allows us to build
system_error for Windows, which ATM doesn't build with threading.

Modified:
libcxx/trunk/src/system_error.cpp

Modified: libcxx/trunk/src/system_error.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=290791&r1=290790&r2=290791&view=diff
==
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Sat Dec 31 15:24:04 2016
@@ -55,6 +55,7 @@ error_category::equivalent(const error_c
 return *this == code.category() && code.value() == condition;
 }
 
+#if !defined(_LIBCPP_HAS_NO_THREADS)
 namespace {
 
 //  GLIBC also uses 1024 as the maximum buffer size internally.
@@ -96,6 +97,7 @@ string do_strerror_r(int ev) {
 #endif
 
 } // end namespace
+#endif
 
 string
 __do_message::message(int ev) const


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


r290792 - [c++17] Implement P0522R0 as written. This allows a template template argument

2016-12-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Dec 31 15:41:23 2016
New Revision: 290792

URL: http://llvm.org/viewvc/llvm-project?rev=290792&view=rev
Log:
[c++17] Implement P0522R0 as written. This allows a template template argument
to be specified for a template template parameter whenever the parameter is at
least as specialized as the argument (when there's an obvious and correct
mapping from uses of the parameter to uses of the argument). For example, a
template with more parameters can be passed to a template template parameter
with fewer, if those trailing parameters have default arguments.

This is disabled by default, despite being a DR resolution, as it's fairly
broken in its current state: there are no partial ordering rules to cope with
template template parameters that have different parameter lists, meaning that
code that attempts to decompose template-ids based on arity can hit unavoidable
ambiguity issues.

The diagnostics produced on a non-matching argument are also pretty bad right
now, but I aim to improve them in a subsequent commit.

Added:
cfe/trunk/test/SemaTemplate/temp_arg_template_cxx1z.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/temp_arg_template.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=290792&r1=290791&r2=290792&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Sat Dec 31 15:41:23 2016
@@ -134,6 +134,7 @@ LANGOPT(NoBuiltin , 1, 0, "disab
 LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
 LANGOPT(GNUAsm, 1, 1, "GNU-style inline assembly")
 LANGOPT(CoroutinesTS  , 1, 0, "C++ coroutines TS")
+LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of tempalte 
template arguments")
 
 BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
 LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=290792&r1=290791&r2=290792&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sat Dec 31 15:41:23 2016
@@ -1088,6 +1088,11 @@ def fapplication_extension : Flag<["-"],
   HelpText<"Restrict code to those available for App Extensions">;
 def fno_application_extension : Flag<["-"], "fno-application-extension">,
   Group;
+def frelaxed_template_template_args : Flag<["-"], 
"frelaxed-template-template-args">,
+  Flags<[CC1Option]>, HelpText<"Enable C++17 relaxed template template 
argument matching">,
+  Group;
+def fno_relaxed_template_template_args : Flag<["-"], 
"fno-relaxed-template-template-args">,
+  Group;
 def fsized_deallocation : Flag<["-"], "fsized-deallocation">, 
Flags<[CC1Option]>,
   HelpText<"Enable C++14 sized global deallocation functions">, Group;
 def fno_sized_deallocation: Flag<["-"], "fno-sized-deallocation">, 
Group;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290792&r1=290791&r2=290792&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Dec 31 15:41:23 2016
@@ -6719,6 +6719,9 @@ public:
   bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl *T,
 sema::TemplateDeductionInfo &Info);
 
+  bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
+  TemplateParameterList *P, TemplateDecl *AArg, SourceLocation Loc);
+
   void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
   bool OnlyDeduced,
   unsigned Depth,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290792&r1=290791&r2=290792&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Dec 31 15:41:23 2016
@@ -6020,6 +6020,13 @@ void Clang::ConstructJob(Compilation &C,
 options::OPT_fno_assume_sane_operator_new))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // -frelaxed-template-template-args is off by default, as it 

r290795 - Fix typo in test case. NFC

2016-12-31 Thread Kelvin Li via cfe-commits
Author: kli
Date: Sat Dec 31 17:36:47 2016
New Revision: 290795

URL: http://llvm.org/viewvc/llvm-project?rev=290795&view=rev
Log:
Fix typo in test case.  NFC

Modified:

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp?rev=290795&r1=290794&r2=290795&view=diff
==
--- 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp 
(original)
+++ 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp 
Sat Dec 31 17:36:47 2016
@@ -24,8 +24,8 @@ T tmain(T argc, S **argv) { //expected-n
 #pragma omp target
 #pragma omp teams distribute parallel for simd collapse ( // expected-error 
{{expected expression}} expected-error {{expected ')'}} expected-note {{to 
match this '('}}
   for (int i = ST; i < N; i++)
-
 argv[0][i] = argv[0][i] - argv[0][i-ST];
+
 #pragma omp target
 #pragma omp teams distribute parallel for simd collapse () // expected-error 
{{expected expression}}
   for (int i = ST; i < N; i++)


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


Re: r290792 - [c++17] Implement P0522R0 as written. This allows a template template argument

2016-12-31 Thread Sean Silva via cfe-commits
On Sat, Dec 31, 2016 at 1:41 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Sat Dec 31 15:41:23 2016
> New Revision: 290792
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290792&view=rev
> Log:
> [c++17] Implement P0522R0 as written. This allows a template template
> argument
> to be specified for a template template parameter whenever the parameter
> is at
> least as specialized as the argument (when there's an obvious and correct
> mapping from uses of the parameter to uses of the argument). For example, a
> template with more parameters can be passed to a template template
> parameter
> with fewer, if those trailing parameters have default arguments.
>
> This is disabled by default, despite being a DR resolution, as it's fairly
> broken in its current state: there are no partial ordering rules to cope
> with
> template template parameters that have different parameter lists, meaning
> that
> code that attempts to decompose template-ids based on arity can hit
> unavoidable
> ambiguity issues.
>
> The diagnostics produced on a non-matching argument are also pretty bad
> right
> now, but I aim to improve them in a subsequent commit.
>
> Added:
> cfe/trunk/test/SemaTemplate/temp_arg_template_cxx1z.cpp
> Modified:
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/test/SemaTemplate/temp_arg_template.cpp
> cfe/trunk/www/cxx_status.html
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/LangOptions.def?rev=290792&r1=290791&r2=290792&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Sat Dec 31 15:41:23 2016
> @@ -134,6 +134,7 @@ LANGOPT(NoBuiltin , 1, 0, "disab
>  LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
>  LANGOPT(GNUAsm, 1, 1, "GNU-style inline assembly")
>  LANGOPT(CoroutinesTS  , 1, 0, "C++ coroutines TS")
> +LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of
> tempalte template arguments")
>

Typo: tempalte

-- Sean Silva


>
>  BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static
> initializers")
>  LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=290792&r1=290791&r2=290792&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Sat Dec 31 15:41:23 2016
> @@ -1088,6 +1088,11 @@ def fapplication_extension : Flag<["-"],
>HelpText<"Restrict code to those available for App Extensions">;
>  def fno_application_extension : Flag<["-"], "fno-application-extension">,
>Group;
> +def frelaxed_template_template_args : Flag<["-"],
> "frelaxed-template-template-args">,
> +  Flags<[CC1Option]>, HelpText<"Enable C++17 relaxed template template
> argument matching">,
> +  Group;
> +def fno_relaxed_template_template_args : Flag<["-"],
> "fno-relaxed-template-template-args">,
> +  Group;
>  def fsized_deallocation : Flag<["-"], "fsized-deallocation">,
> Flags<[CC1Option]>,
>HelpText<"Enable C++14 sized global deallocation functions">,
> Group;
>  def fno_sized_deallocation: Flag<["-"], "fno-sized-deallocation">,
> Group;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=290792&r1=290791&r2=290792&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Sat Dec 31 15:41:23 2016
> @@ -6719,6 +6719,9 @@ public:
>bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl
> *T,
>  sema::TemplateDeductionInfo &Info);
>
> +  bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
> +  TemplateParameterList *P, TemplateDecl *AArg, SourceLocation Loc);
> +
>void MarkUsedTemplateParameters(const TemplateArgumentList
> &TemplateArgs,
>bool OnlyDeduced,
>unsigned Depth,
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> Tools.cpp?rev=290792&r1=290791&r2=290792&view=diff
> 
> ==
> --- cfe/trun