[PATCH] D26960: [docs] Use x86_64 and i386 instead of x86 as arch for triples.

2016-12-01 Thread Sean Silva via Phabricator via cfe-commits
silvas added a comment.

LGTM. Do you need me to commit this for you?


https://reviews.llvm.org/D26960



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


Re: r288093 - Use ${:uid} to generate unique MS asm labels, not {:uid}

2016-12-01 Thread Sean Silva via cfe-commits
what is this ${:uid} thing? Could the comment
in Sema::GetOrCreateMSAsmLabel explain it?

-- Sean Silva

On Mon, Nov 28, 2016 at 4:39 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Mon Nov 28 18:39:37 2016
> New Revision: 288093
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288093&view=rev
> Log:
> Use ${:uid} to generate unique MS asm labels, not {:uid}
>
> Modified:
> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
> cfe/trunk/test/CodeGen/ms-inline-asm.c
> cfe/trunk/test/CodeGen/ms-inline-asm.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaStmtAsm.cpp?rev=288093&r1=288092&r2=288093&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Nov 28 18:39:37 2016
> @@ -753,7 +753,7 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
>  // Create an internal name for the label.  The name should not be a
> valid mangled
>  // name, and should be unique.  We use a dot to make the name an
> invalid mangled
>  // name.
> -OS << "__MSASMLABEL_.{:uid}__";
> +OS << "__MSASMLABEL_.${:uid}__";
>  for (char C : ExternalLabelName) {
>OS << C;
>// We escape '$' in asm strings by replacing it with "$$"
>
> Modified: cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGen/mozilla-ms-inline-asm.c?rev=288093&r1=288092&r2=288093&view=diff
> 
> ==
> --- cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c (original)
> +++ cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c Mon Nov 28 18:39:37
> 2016
> @@ -20,7 +20,7 @@ void invoke(void* that, unsigned methodI
>  // CHECK: call void asm sideeffect inteldialect
>  // CHECK: mov edx,dword ptr $1
>  // CHECK: test edx,edx
> -// CHECK: jz {{[^_]*}}__MSASMLABEL_.{:uid}__noparams
> +// CHECK: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
>  // ^ Can't use {{.*}} here because the matching is greedy.
>  // CHECK: mov eax,edx
>  // CHECK: shl eax,$$3
> @@ -28,7 +28,7 @@ void invoke(void* that, unsigned methodI
>  // CHECK: mov ecx,esp
>  // CHECK: push dword ptr $0
>  // CHECK: call dword ptr $2
> -// CHECK: {{.*}}__MSASMLABEL_.{:uid}__noparams:
> +// CHECK: {{.*}}__MSASMLABEL_.${:uid}__noparams:
>  // CHECK: mov ecx,dword ptr $3
>  // CHECK: push ecx
>  // CHECK: mov edx,[ecx]
>
> Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGen/ms-inline-asm.c?rev=288093&r1=288092&r2=288093&view=diff
> 
> ==
> --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
> +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Nov 28 18:39:37 2016
> @@ -249,7 +249,7 @@ void t23() {
>the_label:
>}
>  // CHECK: t23
> -// CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.{:uid}__the_label:", "~{dirflag},~{fpsr},~{flags}"()
> +// CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.${:uid}__the_label:", "~{dirflag},~{fpsr},~{flags}"()
>  }
>
>  void t24_helper(void) {}
> @@ -595,7 +595,7 @@ void label1() {
>  jmp label
>}
>// CHECK-LABEL: define void @label1()
> -  // CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.{:uid}__label:\0A\09jmp 
> {{.*}}__MSASMLABEL_.{:uid}__label",
> "~{dirflag},~{fpsr},~{flags}"() [[ATTR1:#[0-9]+]]
> +  // CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.${:uid}__label:\0A\09jmp
> {{.*}}__MSASMLABEL_.${:uid}__label", "~{dirflag},~{fpsr},~{flags}"()
> [[ATTR1:#[0-9]+]]
>  }
>
>  void label2() {
> @@ -604,7 +604,7 @@ void label2() {
>  label:
>}
>// CHECK-LABEL: define void @label2
> -  // CHECK: call void asm sideeffect inteldialect "jmp
> {{.*}}__MSASMLABEL_.{:uid}__label\0A\09{{.*}}__MSASMLABEL_.{:uid}__label:",
> "~{dirflag},~{fpsr},~{flags}"()
> +  // CHECK: call void asm sideeffect inteldialect "jmp
> {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:",
> "~{dirflag},~{fpsr},~{flags}"()
>  }
>
>  void label3() {
> @@ -613,7 +613,7 @@ void label3() {
>  mov eax, label
>}
>// CHECK-LABEL: define void @label3
> -  // CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.{:uid}__label:\0A\09mov eax,
> {{.*}}__MSASMLABEL_.{:uid}__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
> +  // CHECK: call void asm sideeffect inteldialect
> "{{.*}}__MSASMLABEL_.${:uid}__label:\0A\09mov eax,
> {{.*}}__MSASMLABEL_.${:uid}__label", "~{eax},~{dirflag},~{fpsr},~{
> flags}"()
>  }
>
>  void label4() {
> @@ -622,7 +622,7 @@ void label4() {
>  mov eax, [label]
>}
>// CHECK-LABEL: define void @label4
> -  // CHECK: call void asm sideeffec

[PATCH] D26960: [docs] Use x86_64 and i386 instead of x86 as arch for triples.

2016-12-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Thanks, I can commit it myself, I just wanted to be extra careful when changing 
something x86 related.


https://reviews.llvm.org/D26960



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


[PATCH] D26546: [PPC] Add vec_insert4b/vec_extract4b to altivec.h

2016-12-01 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:8193
+if (getTarget().isLittleEndian()) {
+  // Create a shuffle mask of (1, 0)
+  Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),

This will likely have to change when the wording is settled on for this 
builtin. Namely, the element to insert is in BE word element 1 for the 
instruction. So it is quite likely that the builtin will be made 
"endianness-neutral" by specifying the source element to be word element 1 (for 
both LE/BE).


Repository:
  rL LLVM

https://reviews.llvm.org/D26546



___
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-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a reviewer: hokein.
hokein added a comment.

It looks good to me, but you'd better wait for the approval from @aaron.ballman.




Comment at: clang-tidy/readability/DeleteNullPointerCheck.cpp:55
+  "'if' statement is unnecessary; deleting null pointer has no effect");
+  if (!IfWithDelete->getElse()) {
+std::string ReplacementText = Lexer::getSourceText(

I would use an early return `if (IfWithDelete->getElse()) return` here.


https://reviews.llvm.org/D21298



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


[PATCH] D27066: Fix crash with unsupported architectures in Linux/Gnu target triples.

2016-12-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 79883.
fhahn added a comment.
Herald added a subscriber: mehdi_amini.

Addressed @joerg's comment.


https://reviews.llvm.org/D27066

Files:
  lib/Driver/Tools.cpp
  test/Driver/unsupported-target-arch.c


Index: test/Driver/unsupported-target-arch.c
===
--- /dev/null
+++ test/Driver/unsupported-target-arch.c
@@ -0,0 +1,25 @@
+// Tests that clang does not crash with invalid architectures in target 
triples.
+//
+// RUN: not %clang --target=noarch-unknown-linux -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-LINUX %s
+// CHECK-NOARCH-LINUX: error: unknown target triple 'noarch-unknown-linux', 
please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-darwin -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-DARWIN %s
+// CHECK-NOARCH-DARWIN: error: unknown target triple 
'unknown-unknown-macosx{{.+}}', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-windows -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-WINDOWS %s
+// CHECK-NOARCH-WINDOWS: error: unknown target triple 
'noarch-unknown-windows-{{.+}}', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-freebsd -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-FREEBSD %s
+// CHECK-NOARCH-FREEBSD: error: unknown target triple 
'noarch-unknown-freebsd', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-netbsd -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NETBSD %s
+// CHECK-NOARCH-NETBSD: error: unknown target triple 'noarch-unknown-netbsd', 
please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-nacl -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NACL %s
+// CHECK-NOARCH-NACL:  error: the target architecture 'noarch' is not 
supported by the target 'Native Client'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9941,7 +9941,7 @@
   return "elf32_x86_64";
 return "elf_x86_64";
   default:
-llvm_unreachable("Unexpected arch");
+return nullptr;
   }
 }
 
@@ -10014,8 +10014,13 @@
 CmdArgs.push_back("--eh-frame-hdr");
   }
 
-  CmdArgs.push_back("-m");
-  CmdArgs.push_back(getLDMOption(ToolChain.getTriple(), Args));
+  if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) {
+CmdArgs.push_back("-m");
+CmdArgs.push_back(LDMOption);
+  } else {
+D.Diag(diag::err_target_unknown_triple) << Triple.str();
+return;
+  }
 
   if (Args.hasArg(options::OPT_static)) {
 if (Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb ||


Index: test/Driver/unsupported-target-arch.c
===
--- /dev/null
+++ test/Driver/unsupported-target-arch.c
@@ -0,0 +1,25 @@
+// Tests that clang does not crash with invalid architectures in target triples.
+//
+// RUN: not %clang --target=noarch-unknown-linux -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-LINUX %s
+// CHECK-NOARCH-LINUX: error: unknown target triple 'noarch-unknown-linux', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-darwin -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-DARWIN %s
+// CHECK-NOARCH-DARWIN: error: unknown target triple 'unknown-unknown-macosx{{.+}}', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-windows -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-WINDOWS %s
+// CHECK-NOARCH-WINDOWS: error: unknown target triple 'noarch-unknown-windows-{{.+}}', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-freebsd -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-FREEBSD %s
+// CHECK-NOARCH-FREEBSD: error: unknown target triple 'noarch-unknown-freebsd', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-netbsd -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NETBSD %s
+// CHECK-NOARCH-NETBSD: error: unknown target triple 'noarch-unknown-netbsd', please use -triple or -arch
+//
+// RUN: not %clang --target=noarch-unknown-nacl -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NACL %s
+// CHECK-NOARCH-NACL:  error: the target architecture 'noarch' is not supported by the target 'Native Client'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9941,7 +9941,7 @@
   return "elf32_x86_64";
 return "elf_x86_64";
   defaul

[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path

2016-12-01 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: mehdi_amini, bruno.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

The commit r126167 started passing the `First` index into `RemoveDuplicates`, 
but forgot to update `0` to `First` in the loop that looks for the duplicate. 
This resulted in a bug where an -iquoted search path was incorrectly removed if 
you passed in the same path into -iquote and more than one time into -isystem.


Repository:
  rL LLVM

https://reviews.llvm.org/D27298

Files:
  lib/Frontend/InitHeaderSearch.cpp
  test/Frontend/include-duplicate-removal.c


Index: test/Frontend/include-duplicate-removal.c
===
--- /dev/null
+++ test/Frontend/include-duplicate-removal.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix 
-isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 
2>&1 | FileCheck %s
+
+#include 
+
+// CHECK: ignoring duplicate directory
+// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}}
+
+// CHECK:  #include "..."
+// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}}
+// CHECK-NEXT: #include <...>
+// CHECK-NEXT: {{.*}}Inputs{{$}}
+// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}}
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -526,7 +526,7 @@
 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
   // Find the dir that this is the same of.
   unsigned FirstDir;
-  for (FirstDir = 0; ; ++FirstDir) {
+  for (FirstDir = First;; ++FirstDir) {
 assert(FirstDir != i && "Didn't find dupe?");
 
 const DirectoryLookup &SearchEntry = SearchList[FirstDir];


Index: test/Frontend/include-duplicate-removal.c
===
--- /dev/null
+++ test/Frontend/include-duplicate-removal.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 2>&1 | FileCheck %s
+
+#include 
+
+// CHECK: ignoring duplicate directory
+// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}}
+
+// CHECK:  #include "..."
+// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}}
+// CHECK-NEXT: #include <...>
+// CHECK-NEXT: {{.*}}Inputs{{$}}
+// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}}
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -526,7 +526,7 @@
 if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) {
   // Find the dir that this is the same of.
   unsigned FirstDir;
-  for (FirstDir = 0; ; ++FirstDir) {
+  for (FirstDir = First;; ++FirstDir) {
 assert(FirstDir != i && "Didn't find dupe?");
 
 const DirectoryLookup &SearchEntry = SearchList[FirstDir];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: Crash in MallocChecker

2016-12-01 Thread Dániel Krupp via cfe-commits
the fix seems fine. The new operator related test cases were placed in 
test/Analysis/out-of-bounds-new.cpp
You may consider that as well for the test case.

From: dcough...@apple.com [mailto:dcough...@apple.com]
Sent: 2016. december 1. 2:55
To: Abramo Bagnara 
Cc: cfe-commits ; Anna Zaks ; 
Dániel Krupp ; haoNoQ 
Subject: Re: Crash in MallocChecker

+ Artem and Daniel,

Thanks for the patch! This fix seems reasonable to me, although it would good 
to add the reproducer as test case! (tests/Analysis/malloc.cpp would be a fine 
place for it).

Devin


> On Nov 30, 2016, at 4:10 PM, Abramo Bagnara 
> mailto:abramo.bagn...@gmail.com>> wrote:
>
> Please consider to review and apply the attached patch.
>
> This is how to reproduce the bug:
>
> abramo@tester:~$ cat bug.cpp
> void f(int a, int b)
> {
>new char[a * b];
> }
> abramo@tester:~$ ~/llvm-build/bin/clang -cc1 -analyze
> -analyzer-checker=cplusplus.NewDeleteLeaks bug.cpp
> clang:
> /home/abramo/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:76:
> T clang::ento::SVal::castAs() const [with T = clang::ento::NonLoc]:
> Assertion `T::isKind(*this)' failed.
> #0 0x03689a0f llvm::sys::PrintStackTrace(llvm::raw_ostream&)
> /home/abramo/llvm/lib/Support/Unix/Signals.inc:402:0
> #1 0x03689d6a PrintStackTraceSignalHandler(void*)
> /home/abramo/llvm/lib/Support/Unix/Signals.inc:466:0
> #2 0x03687f30 llvm::sys::RunSignalHandlers()
> /home/abramo/llvm/lib/Support/Signals.cpp:44:0
> #3 0x036893a1 SignalHandler(int)
> /home/abramo/llvm/lib/Support/Unix/Signals.inc:256:0
> #4 0x7f7833b31330 __restore_rt
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
> #5 0x7f783291dc37 gsignal
> /build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
> #6 0x7f7832921028 abort
> /build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
> #7 0x7f7832916bf6 __assert_fail_base
> /build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
> #8 0x7f7832916ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
> #9 0x05b1769d clang::ento::NonLoc
> clang::ento::SVal::castAs() const
> /home/abramo/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:77:0
> #10 0x05bf5a20 (anonymous
> namespace)::MallocChecker::addExtentSize(clang::ento::CheckerContext&,
> clang::CXXNewExpr const*,
> llvm::IntrusiveRefCntPtr)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1036:0
> #11 0x05bf5601 (anonymous
> namespace)::MallocChecker::checkPostStmt(clang::CXXNewExpr const*,
> clang::ento::CheckerContext&) const
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:991:0
> #12 0x05c0aa29 void
> clang::ento::check::PostStmt::_checkStmt<(anonymous
> namespace)::MallocChecker>(void*, clang::Stmt const*,
> clang::ento::CheckerContext&)
> /home/abramo/llvm/tools/clang/include/clang/StaticAnalyzer/Core/Checker.h:105:0
> #13 0x05f0d9a8 clang::ento::CheckerFn clang::ento::CheckerContext&)>::operator()(clang::Stmt const*,
> clang::ento::CheckerContext&) const
> /home/abramo/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:60:0
> #14 0x05f08002 (anonymous
> namespace)::CheckStmtContext::runChecker(clang::ento::CheckerFn (clang::Stmt const*, clang::ento::CheckerContext&)>,
> clang::ento::NodeBuilder&, clang::ento::ExplodedNode*)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:161:0
> #15 0x05f0a761 void expandGraphWithCheckers<(anonymous
> namespace)::CheckStmtContext>((anonymous namespace)::CheckStmtContext,
> clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:121:0
> #16 0x05f080b2
> clang::ento::CheckerManager::runCheckersForStmt(bool,
> clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&,
> clang::Stmt const*, clang::ento::ExprEngine&, bool)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:175:0
> #17 0x05f40184
> clang::ento::CheckerManager::runCheckersForPostStmt(clang::ento::ExplodedNodeSet&,
> clang::ento::ExplodedNodeSet const&, clang::Stmt const*,
> clang::ento::ExprEngine&, bool)
> /home/abramo/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:206:0
> #18 0x05f3770a clang::ento::ExprEngine::Visit(clang::Stmt
> const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1151:0
> #19 0x05f341e4
> clang::ento::ExprEngine::ProcessStmt(clang::CFGStmt,
> clang::ento::ExplodedNode*)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:463:0
> #20 0x05f334e4
> clang::ento::ExprEngine::processCFGElement(clang::CFGElement,
> clang::ento::ExplodedNode*, unsigned int,
> clang::ento::NodeBuilderContext*)
> /home/abramo/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:311:0
>

r288332 - [OpenCL] Refactor read_only/write_only pipes.

2016-12-01 Thread Joey Gouly via cfe-commits
Author: joey
Date: Thu Dec  1 05:30:49 2016
New Revision: 288332

URL: http://llvm.org/viewvc/llvm-project?rev=288332&view=rev
Log:
[OpenCL] Refactor read_only/write_only pipes.

This adds the access qualifier to the Pipe Type, rather than using a class
hierarchy. 

It also fixes mergeTypes for Pipes, by disallowing merges. Only identical
pipe types can be merged. The test case in invalid-pipes-cl2.0.cl is added
to check that.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=288332&r1=288331&r2=288332&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Dec  1 05:30:49 2016
@@ -135,8 +135,7 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet AutoTypes;
   mutable llvm::FoldingSet AtomicTypes;
   llvm::FoldingSet AttributedTypes;
-  mutable llvm::FoldingSet ReadPipeTypes;
-  mutable llvm::FoldingSet WritePipeTypes;
+  mutable llvm::FoldingSet PipeTypes;
 
   mutable llvm::FoldingSet QualifiedTemplateNames;
   mutable llvm::FoldingSet DependentTemplateNames;
@@ -1012,6 +1011,8 @@ private:
 
   QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const;
 
+  QualType getPipeType(QualType T, bool ReadOnly) const;
+
 public:
   /// \brief Return the uniqued reference to the type for an address space
   /// qualified type with the specified type and address space.

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=288332&r1=288331&r2=288332&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Dec  1 05:30:49 2016
@@ -5285,7 +5285,6 @@ class AtomicType : public Type, public l
 
 /// PipeType - OpenCL20.
 class PipeType : public Type, public llvm::FoldingSetNode {
-protected:
   QualType ElementType;
   bool isRead;
 
@@ -5295,6 +5294,7 @@ protected:
  elemType->isVariablyModifiedType(),
  elemType->containsUnexpandedParameterPack()),
 ElementType(elemType), isRead(isRead) {}
+  friend class ASTContext;  // ASTContext creates these.
 
 public:
   QualType getElementType() const { return ElementType; }
@@ -5304,11 +5304,12 @@ public:
   QualType desugar() const { return QualType(this, 0); }
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-Profile(ID, getElementType());
+Profile(ID, getElementType(), isReadOnly());
   }
 
-  static void Profile(llvm::FoldingSetNodeID &ID, QualType T) {
+  static void Profile(llvm::FoldingSetNodeID &ID, QualType T, bool isRead) {
 ID.AddPointer(T.getAsOpaquePtr());
+ID.AddBoolean(isRead);
   }
 
   static bool classof(const Type *T) {
@@ -5318,18 +5319,6 @@ public:
   bool isReadOnly() const { return isRead; }
 };
 
-class ReadPipeType : public PipeType {
-  ReadPipeType(QualType elemType, QualType CanonicalPtr) :
-PipeType(elemType, CanonicalPtr, true) {}
-  friend class ASTContext;  // ASTContext creates these.
-};
-
-class WritePipeType : public PipeType {
-  WritePipeType(QualType elemType, QualType CanonicalPtr) :
-PipeType(elemType, CanonicalPtr, false) {}
-  friend class ASTContext;  // ASTContext creates these.
-};
-
 /// A qualifier set is used to build a set of qualifiers.
 class QualifierCollector : public Qualifiers {
 public:

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=288332&r1=288331&r2=288332&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Dec  1 05:30:49 2016
@@ -905,12 +905,10 @@ namespace clang {
   TYPE_DECAYED   = 41,
   /// \brief An AdjustedType record.
   TYPE_ADJUSTED  = 42,
-  /// \brief A ReadPipeType record.
-  TYPE_READ_PIPE = 43,
+  /// \brief A PipeType record.
+  TYPE_PIPE  = 43,
   /// \brief An ObjCTypeParamType record.
-  TYPE_OBJC_TYPE_PARAM   = 44,
-  /// \brief A WritePipeType record.
-  TYPE_WRITE_PIPE= 45,
+  TYPE_OBJC_TYPE_PARAM   = 44
 };
 
 /// \brief The type IDs for special types constructed by semantic

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp

[PATCH] D27049: [OpenCL] Refactor out ReadPipe/WritePipe

2016-12-01 Thread Joey Gouly via Phabricator via cfe-commits
joey closed this revision.
joey added a comment.

Committed in r288332. Thanks Yaron!


Repository:
  rL LLVM

https://reviews.llvm.org/D27049



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


[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2016-12-01 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 79891.
klimek added a comment.

Add multi-level using test.


https://reviews.llvm.org/D27207

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

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -247,6 +247,15 @@
   cxxNewExpr(hasDeclaration(functionDecl(parameterCountIs(1));
 }
 
+TEST(HasUnqualifiedDesugaredType, DesugarsUsing) {
+  EXPECT_TRUE(
+  matches("struct A {}; using B = A; B b;",
+  varDecl(hasType(hasUnqualifiedDesugaredType(recordType());
+  EXPECT_TRUE(
+  matches("struct A {}; using B = A; using C = B; C b;",
+  varDecl(hasType(hasUnqualifiedDesugaredType(recordType());
+}
+
 TEST(HasUnderlyingDecl, Matches) {
   EXPECT_TRUE(matches("namespace N { template  void f(T t); }"
   "template  void g() { using N::f; f(T()); }",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -270,6 +270,7 @@
   REGISTER_MATCHER(hasUnaryOperand);
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasUnderlyingDecl);
+  REGISTER_MATCHER(hasUnqualifiedDesugaredType);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
   REGISTER_MATCHER(ignoringImplicit);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2738,6 +2738,22 @@
   .matches(Node, Finder, Builder);
 }
 
+/// \brief Matches if the matched type matches the unqualified desugared
+/// type of the matched node.
+///
+/// For example, in:
+/// \code
+///   class A {};
+///   using B = A;
+/// \endcode
+/// The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
+/// both B and A.
+AST_MATCHER_P(Type, hasUnqualifiedDesugaredType, internal::Matcher,
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getUnqualifiedDesugaredType(), Finder,
+  Builder);
+}
+
 /// \brief Matches if the matched type is a reference type and the referenced
 /// type matches the specified matcher.
 ///
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3758,8 +3758,8 @@
 
 
 
-MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  InnerMatcher
-Matches a node if the declaration associated with that node
+MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  InnerMatcher
+Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -3772,13 +3772,13 @@
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
-Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
-  MatcherCXXNewExpr>,
-  MatcherDeclRefExpr>, MatcherEnumType>, MatcherInjectedClassNameType>,
-  MatcherLabelStmt>, MatcherAddrLabelExpr>, MatcherMemberExpr>,
-  MatcherQualType>, MatcherRecordType>, MatcherTagType>,
-  MatcherTemplateSpecializationType>, MatcherTemplateTypeParmType>,
-  MatcherTypedefType>, MatcherUnresolvedUsingType>
+Usable as: Matcher

[PATCH] D27138: Extend CompilationDatabase by a field for the output filename

2016-12-01 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D27138#607859, @joerg wrote:

> Which struct are we talking about, `CompileCommandRef` or `CompileCommand`? 
> It is a pointer in the former and a plain StringRef in the latter. I don't 
> think making it a pointer in both is an advantage, i.e. distinguishing empty 
> input from missing field is not valuable in my opinion.


Ok, you convinced me. LG then.


Repository:
  rL LLVM

https://reviews.llvm.org/D27138



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


[PATCH] D27299: [Sema] C++11 opaque enums should avoid the "case value not in enumerated type" switch warning

2016-12-01 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: rsmith, ahatanak.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch ensures that the switch warning "case value not in enumerated type" 
isn't shown for opaque enums. We don't know the actual list of values in opaque 
enums, so that warning is incorrect.


Repository:
  rL LLVM

https://reviews.llvm.org/D27299

Files:
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/switch.cpp


Index: test/SemaCXX/switch.cpp
===
--- test/SemaCXX/switch.cpp
+++ test/SemaCXX/switch.cpp
@@ -100,3 +100,33 @@
   }
   template void f(S); // expected-note {{instantiation of}}
 }
+
+// rdar://29230764
+namespace OpaqueEnumWarnings {
+
+enum Opaque : int;
+enum class OpaqueClass : int;
+
+enum class Defined : int;
+enum class Defined : int { a };
+
+void test(Opaque o, OpaqueClass oc, Defined d) {
+  // Don't warn that case value is not present in opaque enums.
+  switch (o) {
+  case (Opaque)1:
+break;
+  }
+  switch (oc) {
+  case (OpaqueClass)1:
+break;
+  }
+
+  switch (d) {
+  case Defined::a:
+break;
+  case (Defined)2: // expected-warning {{case value not in enumerated type 
'OpaqueEnumWarnings::Defined'}}
+break;
+  }
+}
+
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1070,7 +1070,8 @@
 const EnumType *ET = CondTypeBeforePromotion->getAs();
 
 // If switch has default case, then ignore it.
-if (!CaseListIsErroneous  && !HasConstantCond && ET) {
+if (!CaseListIsErroneous && !HasConstantCond && ET &&
+ET->getDecl()->isCompleteDefinition()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 


Index: test/SemaCXX/switch.cpp
===
--- test/SemaCXX/switch.cpp
+++ test/SemaCXX/switch.cpp
@@ -100,3 +100,33 @@
   }
   template void f(S); // expected-note {{instantiation of}}
 }
+
+// rdar://29230764
+namespace OpaqueEnumWarnings {
+
+enum Opaque : int;
+enum class OpaqueClass : int;
+
+enum class Defined : int;
+enum class Defined : int { a };
+
+void test(Opaque o, OpaqueClass oc, Defined d) {
+  // Don't warn that case value is not present in opaque enums.
+  switch (o) {
+  case (Opaque)1:
+break;
+  }
+  switch (oc) {
+  case (OpaqueClass)1:
+break;
+  }
+
+  switch (d) {
+  case Defined::a:
+break;
+  case (Defined)2: // expected-warning {{case value not in enumerated type 'OpaqueEnumWarnings::Defined'}}
+break;
+  }
+}
+
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1070,7 +1070,8 @@
 const EnumType *ET = CondTypeBeforePromotion->getAs();
 
 // If switch has default case, then ignore it.
-if (!CaseListIsErroneous  && !HasConstantCond && ET) {
+if (!CaseListIsErroneous && !HasConstantCond && ET &&
+ET->getDecl()->isCompleteDefinition()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2016-12-01 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

I added a test for multi-stage desugaring. Generally, we want to model Clang's 
AST where it makes sense. The AST has a getUnqualifiedDesugaredType, thus the 
matcher as it is is expected. We can add single step desugaring or 
hasAnyDeclaration or similar things when they are actually needed.

This question from my previous comment still stands:

> How about using hasUnqualifiedDesugaredType(recordType(hasDeclaration instead?




https://reviews.llvm.org/D27207



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


[PATCH] D27250: [OpenMP] TargetLibraryInfo from "declare simd".

2016-12-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D27250#609111, @fpetrogalli wrote:

> In https://reviews.llvm.org/D27250#609006, @ABataev wrote:
>
> >
>
>
> Hi! Thanks for your review!
>
> > 1. Please provide full context for your changes (check this document how to 
> > do this http://llvm.org/docs/Phabricator.html).
>
> I missed that out, should be done now.
>
> > 2. Use clang-format for all your changes.
>
> Done.
>
> > 3. Do not use backed infrastructure to mangle the name of the new function. 
> > Instead, you should build clang-based declaration and use clang 
> > infrastructure to ge
>
> The second part of the sentence is missing. I guess you are saying I should 
> use the infrastructure for name mangling in clang in llvm? Is that what you 
> mean? I think that the right place to keep something that need to be shared 
> between LLVM and clang is the LLVM codebase, not conversely. Can we wait for 
> other people feedback before deciding here?


Yes, that's what I meant. Clang supports both Microsoft and Itanium-based 
manglings and in clang you should use clang-based solution.

> 
> 
>> Also, I don't like the idea of the generation of real function profiles in 
>> the frontend. It was decided, that the frontend only provides a list of 
>> mangled names for vector functions, which must be generated in the backend.
> 
> I am just generating  a set of global variable with external linkage that are 
> deleted by LLVM before any code generation happens. The globals are used just 
> to populate the TargetLibraryInfoImpl class instance created in 
> BackendUtils.cpp. See the high level description of the functionality I have 
> provided in the RFC mail (see [1] below).I see this mechanisms being easier 
> rather than getting a name, de-mangle it, interpret the parameters section, 
> and then generate whatever information the vectorizer need to vectorize a 
> particular scalar function in a loop. Instead of introducing new structures 
> for matching what the vectorizer need swith what the TLI provides,  I just 
> use what llvm already has, the FunctionType class.

It does not matter. You should discuss it before trying to implement, 
especially if another solution was already accepted and implemented. Xinmin 
already answered you, please sync with him.

> This also avoid the complications of having to write a demangle function for 
> the vector names for each architecture, which might have completely different 
> names across architectures and ABI versions. With this FunctionType 
> mechanisms, ABI changes are transparent to vectorizer.
> 
>> But you're trying something different. If you're going to change the whole 
>> solution you should send an RFC to the community
> 
> I've sent out an email, apologies for not specifying RFC in the subject. You 
> can find a copy of it with the RFC in the mailing list now [1].
> 
> [1] http://lists.llvm.org/pipermail/llvm-dev/2016-November/107677.html




https://reviews.llvm.org/D27250



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


r288334 - [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression

2016-12-01 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  1 06:14:38 2016
New Revision: 288334

URL: http://llvm.org/viewvc/llvm-project?rev=288334&view=rev
Log:
[ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression

This patch ensures that the typo fixit for the @try/@finally/@autoreleasepool {}
directive is shown only when we're parsing an actual statement where such
directives can actually be present.

rdar://19669565

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

Added:
cfe/trunk/test/Parser/objc-at-directive-fixit.m
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=288334&r1=288333&r2=288334&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Dec  1 06:14:38 2016
@@ -2773,6 +2773,7 @@ StmtResult Parser::ParseObjCAtStatement(
 return Actions.ActOnNullStmt(Tok.getLocation());
   }
 
+  ExprStatementTokLoc = AtLoc;
   ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
   if (Res.isInvalid()) {
 // If the expression is invalid, skip ahead to the next semicolon. Not
@@ -2869,7 +2870,11 @@ ExprResult Parser::ParseObjCAtExpression
   return ParseAvailabilityCheckExpr(AtLoc);
   default: {
 const char *str = nullptr;
-if (GetLookAheadToken(1).is(tok::l_brace)) {
+// Only provide the @try/@finally/@autoreleasepool fixit when we're 
sure
+// that this is a proper statement where such directives could actually
+// occur.
+if (GetLookAheadToken(1).is(tok::l_brace) &&
+ExprStatementTokLoc == AtLoc) {
   char ch = Tok.getIdentifierInfo()->getNameStart()[0];
   str =  
 ch == 't' ? "try" 

Added: cfe/trunk/test/Parser/objc-at-directive-fixit.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-directive-fixit.m?rev=288334&view=auto
==
--- cfe/trunk/test/Parser/objc-at-directive-fixit.m (added)
+++ cfe/trunk/test/Parser/objc-at-directive-fixit.m Thu Dec  1 06:14:38 2016
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify 
-fobjc-exceptions %s
+// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 
-fdiagnostics-parseable-fixits -fobjc-exceptions %s 2>&1 | FileCheck %s
+
+// rdar://19669565
+
+void bar(int x);
+
+void f() {
+  @try { }
+  @finally { }
+  @autoreleasepool { }
+
+  // Provide a fixit when we are parsing a standalone statement
+  @tr { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:6}:"try"
+  @finaly { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:10}:"finally"
+  @autorelpool { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:15}:"autoreleasepool"
+
+  // Ensure that no fixit is given when parsing expressions
+  // CHECK-NOT: fix-it
+  id thing = @autoreleasepool { }; // expected-error {{unexpected '@' in 
program}}
+  (void)@tr { }; // expected-error {{unexpected '@' in program}}
+  bar(@final { }); // expected-error {{unexpected '@' in program}}
+  for(@auto;;) { } // expected-error {{unexpected '@' in program}}
+  [@try]; // expected-error {{unexpected '@' in program}}
+}


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


[PATCH] D26916: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression

2016-12-01 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288334: [ObjC] Avoid a @try/@finally/@autoreleasepool fixit 
when parsing an expression (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26916?vs=78728&id=79893#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26916

Files:
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/test/Parser/objc-at-directive-fixit.m


Index: cfe/trunk/test/Parser/objc-at-directive-fixit.m
===
--- cfe/trunk/test/Parser/objc-at-directive-fixit.m
+++ cfe/trunk/test/Parser/objc-at-directive-fixit.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify 
-fobjc-exceptions %s
+// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 
-fdiagnostics-parseable-fixits -fobjc-exceptions %s 2>&1 | FileCheck %s
+
+// rdar://19669565
+
+void bar(int x);
+
+void f() {
+  @try { }
+  @finally { }
+  @autoreleasepool { }
+
+  // Provide a fixit when we are parsing a standalone statement
+  @tr { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:6}:"try"
+  @finaly { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:10}:"finally"
+  @autorelpool { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:15}:"autoreleasepool"
+
+  // Ensure that no fixit is given when parsing expressions
+  // CHECK-NOT: fix-it
+  id thing = @autoreleasepool { }; // expected-error {{unexpected '@' in 
program}}
+  (void)@tr { }; // expected-error {{unexpected '@' in program}}
+  bar(@final { }); // expected-error {{unexpected '@' in program}}
+  for(@auto;;) { } // expected-error {{unexpected '@' in program}}
+  [@try]; // expected-error {{unexpected '@' in program}}
+}
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -2773,6 +2773,7 @@
 return Actions.ActOnNullStmt(Tok.getLocation());
   }
 
+  ExprStatementTokLoc = AtLoc;
   ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
   if (Res.isInvalid()) {
 // If the expression is invalid, skip ahead to the next semicolon. Not
@@ -2869,7 +2870,11 @@
   return ParseAvailabilityCheckExpr(AtLoc);
   default: {
 const char *str = nullptr;
-if (GetLookAheadToken(1).is(tok::l_brace)) {
+// Only provide the @try/@finally/@autoreleasepool fixit when we're 
sure
+// that this is a proper statement where such directives could actually
+// occur.
+if (GetLookAheadToken(1).is(tok::l_brace) &&
+ExprStatementTokLoc == AtLoc) {
   char ch = Tok.getIdentifierInfo()->getNameStart()[0];
   str =  
 ch == 't' ? "try" 


Index: cfe/trunk/test/Parser/objc-at-directive-fixit.m
===
--- cfe/trunk/test/Parser/objc-at-directive-fixit.m
+++ cfe/trunk/test/Parser/objc-at-directive-fixit.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify -fobjc-exceptions %s
+// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -fdiagnostics-parseable-fixits -fobjc-exceptions %s 2>&1 | FileCheck %s
+
+// rdar://19669565
+
+void bar(int x);
+
+void f() {
+  @try { }
+  @finally { }
+  @autoreleasepool { }
+
+  // Provide a fixit when we are parsing a standalone statement
+  @tr { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:6}:"try"
+  @finaly { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:10}:"finally"
+  @autorelpool { }; // expected-error {{unexpected '@' in program}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:15}:"autoreleasepool"
+
+  // Ensure that no fixit is given when parsing expressions
+  // CHECK-NOT: fix-it
+  id thing = @autoreleasepool { }; // expected-error {{unexpected '@' in program}}
+  (void)@tr { }; // expected-error {{unexpected '@' in program}}
+  bar(@final { }); // expected-error {{unexpected '@' in program}}
+  for(@auto;;) { } // expected-error {{unexpected '@' in program}}
+  [@try]; // expected-error {{unexpected '@' in program}}
+}
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -2773,6 +2773,7 @@
 return Actions.ActOnNullStmt(Tok.getLocation());
   }
 
+  ExprStatementTokLoc = AtLoc;
   ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
   if (Res.isInvalid()) {
 // If the expression is invalid, skip ahead to the next semicolon. Not
@@ -2869,7 +2870,11 @@
   return ParseAvailabilityC

[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2016-12-01 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This looks good to me. We can add finer-grained desugaring later if it's really 
needed.


https://reviews.llvm.org/D27207



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha marked 10 inline comments as done.
Alpha added inline comments.



Comment at: include/clang/Tooling/DiagnosticsYaml.h:79
+  for (auto &Diagnostic : Doc.Diagnostics) {
+if (Diagnostic.Fix.size() > 0) {
+  Diagnostics.push_back(Diagnostic);

alexfh wrote:
> Should we copy all diagnostics instead?
I am not sure about that. Copying all diagnostics will mean having empty 
entries in the replacement files with just a check name. This might seem 
useless, the problem being that at the moment, the only useful exported 
information in diagnostics are the replacements. I think that if all 
diagnostics are copied, it must be done in a different patch, with a proper 
export of all the meaningful information about the diagnostics.
Then, the exported info in clang-tidy will not solely be fixes, but every 
diagnostic info (which could mean changing the name and meaning of output file 
and option). What is your feeling about this?


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 79899.
Herald added a subscriber: JDevlieghere.

Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager &Sources,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel, StringRef BuildDirectory)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage &Message,
+   llvm::St

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 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.

LG with a comment.




Comment at: include/clang/Tooling/DiagnosticsYaml.h:79
+  for (auto &Diagnostic : Doc.Diagnostics) {
+if (Diagnostic.Fix.size() > 0) {
+  Diagnostics.push_back(Diagnostic);

Alpha wrote:
> alexfh wrote:
> > Should we copy all diagnostics instead?
> I am not sure about that. Copying all diagnostics will mean having empty 
> entries in the replacement files with just a check name. This might seem 
> useless, the problem being that at the moment, the only useful exported 
> information in diagnostics are the replacements. I think that if all 
> diagnostics are copied, it must be done in a different patch, with a proper 
> export of all the meaningful information about the diagnostics.
> Then, the exported info in clang-tidy will not solely be fixes, but every 
> diagnostic info (which could mean changing the name and meaning of output 
> file and option). What is your feeling about this?
Please add a FIXME to MappingTraits::mapping to 
properly export locations, messages, notes, diagnostic levels and all other 
fields. And a FIXME here to export all diagnostics, not just the ones with 
fixes.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D27300: [OpenCL] Fix SPIR version generation.

2016-12-01 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: cfe-commits, yaxunl, bader.

https://reviews.llvm.org/D27300

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/spir_version.cl


Index: test/CodeGenOpenCL/spir_version.cl
===
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -13,12 +13,12 @@
 
 // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0}
 // CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
+// CHECK-SPIR-CL12: [[SPIR]] = !{i32 1, i32 2}
+
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0}
@@ -28,4 +28,4 @@
 // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
\ No newline at end of file
+// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7778,8 +7778,10 @@
   // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
   // opencl.spir.version named metadata.
   llvm::Metadata *SPIRVerElts[] = {
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+  llvm::ConstantAsMetadata::get(
+  llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 
100)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))};
   llvm::NamedMDNode *SPIRVerMD =
   M.getOrInsertNamedMetadata("opencl.spir.version");
   SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));


Index: test/CodeGenOpenCL/spir_version.cl
===
--- test/CodeGenOpenCL/spir_version.cl
+++ test/CodeGenOpenCL/spir_version.cl
@@ -13,12 +13,12 @@
 
 // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0}
+// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0}
 // CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
+// CHECK-SPIR-CL12: [[SPIR]] = !{i32 1, i32 2}
+
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
 // CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0}
@@ -28,4 +28,4 @@
 // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
 // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
-// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
\ No newline at end of file
+// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7778,8 +7778,10 @@
   // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
   // opencl.spir.version named metadata.
   llvm::Metadata *SPIRVerElts[] = {
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
-  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+  llvm::ConstantAsMetadata::get(
+  llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))};
   llvm::NamedMDNode *SPIRVerMD =
   M.getOrInsertNamedMetadata("opencl.spir.version");
   SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Thank you for the new check! A few comments.




Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:22
+AST_MATCHER_P(Type, isBuiltinType, BuiltinType::Kind, Kind) {
+  if (const BuiltinType *BT = dyn_cast(&Node)) {
+return BT->getKind() == Kind;

`const auto *` is preferred to avoid duplication of the type name.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2),
+   hasBuiltinTyParam(0, DoubleTy),
+   hasBuiltinTyParam(1, DoubleTy))),
+   hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy))
+  .bind("call"),

I guess, functions with arbitrary number of parameters can all be handled using 
`forEachArgumentWithParam`. Roughly like this:

  forEachArgumentWithParam(
 hasType(isBuiltinType(FloatTy)),
 parmVarDecl(hasType(isBuiltinType(DoubleTy)))

One difference to your existing implementation will be that it will match calls 
where at least one parameter is double and argument is float, not all of them. 
Do you expect this to make the check more noisy? 



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145
+  // Skip the "::" following the qualifier.
+  FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2);
+}

`getLocWithOffset` makes the code quite brittle. Imagine whitespace around 
`::`, for example. Same below. In order to make this kind of code more robust, 
you can operate on tokens (using Lexer).

Same below.



Comment at: 
clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp:70
+  acosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh' promotes float 
to double [performance-type-promotion-in-math-fn]
+  // CHECK-FIXES: {{^}}  acoshf(a);{{$}}

We usually truncate repeated static parts of CHECK patterns (except for the 
first one) to make tests a bit less verbose. You can at least truncate the 
check name in all but the first check pattern.


https://reviews.llvm.org/D27284



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 79904.

Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager &Sources,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel, StringRef BuildDirectory)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage &Message,
+   llvm::StringMap &Fix,
+   Sma

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

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



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > What do we want to do, if anything, for people who have scripts using the 
> > > old name? Do we want to keep the old name as an alias to the new name for 
> > > some period of time?
> > An alias helps if the check was enabled by name, but not if it was disabled 
> > by name.
> > If the alias is temporary, would you want a deprecation warning?
> > I wouldn't want to warn about `-checks=modernize*`, but maybe warning for 
> > `-checks=modernize-use-default` would be useful.
> > An alias helps if the check was enabled by name, but not if it was disabled 
> > by name.
> 
> Oye, this is true and unfortunate.
> 
> > If the alias is temporary, would you want a deprecation warning?
> > I wouldn't want to warn about -checks=modernize*, but maybe warning for 
> > -checks=modernize-use-default would be useful.
> 
> I think a deprecation warning would be a helpful feature, but not required. I 
> do agree that I would not want a warning for wildcard matches.
> 
> I would also be fine if we simply had the documentation for 
> `modernize-use-default` forward to the documentation for 
> `modernize-use-equals-default` and put a note in there about the old name 
> being deprecated and leave in an alias to the old name.
> 
> To be complete, I would also be fine if we remove the old name as in this 
> patch. I am mostly thinking about what default policy we want to have when 
> this situation arises. FWIW, the check was exposed under this name around Oct 
> 2015, so it's been in the wild for over a year, and in a public release.
I'd personally prefer to leave the old documentation file with a redirect and a 
note about the renaming.  Similar to how we treat aliases. WDYT?


https://reviews.llvm.org/D26511



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/misc/StringCompareCheck.cpp:29
+
+  // First and second case: cast str.compare(str) to boolean
+  Finder->addMatcher(

Please add trailing periods here and elsewhere.



Comment at: clang-tidy/misc/StringCompareCheck.cpp:36-50
+  // Third case: str.compare(str) == 0
+  Finder->addMatcher(
+  binaryOperator(hasOperatorName("=="),
+ hasEitherOperand(strCompare),
+ 
hasEitherOperand(integerLiteral(equals(0
+  .bind("match"),
+  this);

These two matchers can be merged to avoid repetition.



Comment at: clang-tidy/misc/StringCompareCheck.cpp:55-57
+diag(Matched->getLocStart(),
+ "do not use compare to test equality of strings; "
+ "use the string equality operator instead");

It looks like it's relatively straightforward to implement fixit hints. WDYT?



Comment at: test/clang-tidy/misc-string-compare.cpp:29
+  if(!str1.compare(str2)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: do not use compare to test 
equality of strings; use the string equality operator instead 
[misc-string-compare]
+  if(str1.compare(str2) == 0) {}

Truncate all CHECK patterns after the first one after `of strings;`


https://reviews.llvm.org/D27210



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Do you have commit access? If you need me to commit the patch for you, please 
rebase it on top of HEAD.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D27248: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Looks like a strict improvement.


https://reviews.llvm.org/D27248



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Sorry for the delay. I'll try to get back to this patch soon.


https://reviews.llvm.org/D26418



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


[PATCH] D27068: Improve string::find

2016-12-01 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya updated this revision to Diff 79908.
hiraditya added a comment.

Updated the benchmark:
Without patch:
Run on (8 X 3400 MHz CPU s)
2016-12-01 09:20:38
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may 
be noisy and will incur extra overhead.

Benchmark   Time   CPU Iterations
-

BM_StringFindNoMatch/10 4 ns  4 ns  166421326
BM_StringFindNoMatch/6437 ns 37 ns   18754392
BM_StringFindNoMatch/512  268 ns268 ns2586060
BM_StringFindNoMatch/4k  2143 ns   2144 ns 328342
BM_StringFindNoMatch/32k16910 ns  16917 ns  40623
BM_StringFindNoMatch/128k   67577 ns  67602 ns  10138
BM_StringFindAllMatch/1 3 ns  3 ns  265163471
BM_StringFindAllMatch/8 6 ns  6 ns  112582467
BM_StringFindAllMatch/64   36 ns 36 ns   19566457
BM_StringFindAllMatch/512 209 ns209 ns3318893
BM_StringFindAllMatch/4k 1618 ns   1618 ns 432963
BM_StringFindAllMatch/32k   12909 ns  12914 ns  54317
BM_StringFindAllMatch/128k  48342 ns  48361 ns  13922
BM_StringFindMatch1/1   33777 ns  33790 ns  20698
BM_StringFindMatch1/8   33940 ns  33953 ns  20619
BM_StringFindMatch1/64  34038 ns  34051 ns  20571
BM_StringFindMatch1/512 34217 ns  34230 ns  20480
BM_StringFindMatch1/4k  35510 ns  35524 ns  19752
BM_StringFindMatch1/32k 46438 ns  46456 ns  15030
BM_StringFindMatch2/1   33839 ns  33852 ns  20648
BM_StringFindMatch2/8   33950 ns  33963 ns  20594
BM_StringFindMatch2/64  33846 ns  33859 ns  20668
BM_StringFindMatch2/512 34023 ns  34036 ns  20279
BM_StringFindMatch2/4k  35422 ns  35436 ns  19716
BM_StringFindMatch2/32k 46570 ns  46588 ns  15027

With patch:
Run on (8 X 3400 MHz CPU s)
2016-12-01 09:15:15
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may 
be noisy and will incur extra overhead.

Benchmark   Time   CPU Iterations
-

BM_StringFindNoMatch/10 5 ns  5 ns  133724346
BM_StringFindNoMatch/64 6 ns  6 ns  119312184
BM_StringFindNoMatch/512   13 ns 13 ns   51539628
BM_StringFindNoMatch/4k77 ns 77 ns8935934
BM_StringFindNoMatch/32k  551 ns551 ns1222808
BM_StringFindNoMatch/128k2684 ns   2685 ns 259957
BM_StringFindAllMatch/1 7 ns  7 ns   98017959
BM_StringFindAllMatch/8 7 ns  7 ns   91466911
BM_StringFindAllMatch/648 ns  8 ns   85707392
BM_StringFindAllMatch/512  20 ns 20 ns   34490895
BM_StringFindAllMatch/4k   93 ns 93 ns7360375
BM_StringFindAllMatch/32k 827 ns828 ns 829944
BM_StringFindAllMatch/128k   3593 ns   3594 ns 195815
BM_StringFindMatch1/11332 ns   1332 ns 516354
BM_StringFindMatch1/81336 ns   1336 ns 495876
BM_StringFindMatch1/64   1338 ns   1339 ns 516656
BM_StringFindMatch1/512  1357 ns   1357 ns 510717
BM_StringFindMatch1/4k   1485 ns   1486 ns 461228
BM_StringFindMatch1/32k  2235 ns   2236 ns 318253
BM_StringFindMatch2/11335 ns   1335 ns 517105
BM_StringFindMatch2/81336 ns   1337 ns 518004
BM_StringFindMatch2/64   1344 ns   1345 ns 511751
BM_StringFindMatch2/512  1361 ns   1361 ns 508150
BM_StringFindMatch2/4k   1611 ns   1611 ns 463388
BM_StringFindMatch2/32k  2187 ns   2187 ns 317532


https://reviews.llvm.org/D27068

Files:
  benchmarks/string.bench.cpp
  include/__string

Index: include/__string
===
--- include/__string
+++ include/__string
@@ -538,25 +538,63 @@
 return static_cast<_SizeT>(__r - __p);
 }
 
+template 
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+_RandomAccessIterator
+__search_substring(_RandomAccessIterator __first1, _RandomAccessIterator __last1,
+   _RandomAccessIterator __first2, _RandomAccessIterator __last2)
+{
+using __iterator_traits = iterator_traits<_RandomAccessIterator>;
+typedef typename __iterator_traits::difference_type __difference_type;
+
+// Take advantage of knowing source and pattern lengths.
+// Stop short when source is smaller than pattern.
+__difference_type __len2 = __last2 - __first2;
+if (__len2 == 0)
+return __first1;
+__difference_type __len1 = __last1 - __first1;
+if (__len1 < _

[PATCH] D27300: [OpenCL] Fix SPIR version generation.

2016-12-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/spir_version.cl:21
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}

why this is removed?


https://reviews.llvm.org/D27300



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


[libcxx] r288347 - Creating release directory for release_391.

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:15:38 2016
New Revision: 288347

URL: http://llvm.org/viewvc/llvm-project?rev=288347&view=rev
Log:
Creating release directory for release_391.

Added:
libcxx/tags/RELEASE_391/

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


[libcxx] r288348 - Creating release candidate rc1 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:15:39 2016
New Revision: 288348

URL: http://llvm.org/viewvc/llvm-project?rev=288348&view=rev
Log:
Creating release candidate rc1 from release_391 branch

Added:
libcxx/tags/RELEASE_391/rc1/   (props changed)
  - copied from r288347, libcxx/branches/release_39/

Propchange: libcxx/tags/RELEASE_391/rc1/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Dec  1 09:15:39 2016
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:278282,278357,278387,278904,279008


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


[libcxxabi] r288349 - Creating release directory for release_391.

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:15:40 2016
New Revision: 288349

URL: http://llvm.org/viewvc/llvm-project?rev=288349&view=rev
Log:
Creating release directory for release_391.

Added:
libcxxabi/tags/RELEASE_391/

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


[libunwind] r288361 - Creating release directory for release_391.

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:16:13 2016
New Revision: 288361

URL: http://llvm.org/viewvc/llvm-project?rev=288361&view=rev
Log:
Creating release directory for release_391.

Added:
libunwind/tags/RELEASE_391/

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


[libunwind] r288362 - Creating release candidate rc1 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:16:24 2016
New Revision: 288362

URL: http://llvm.org/viewvc/llvm-project?rev=288362&view=rev
Log:
Creating release candidate rc1 from release_391 branch

Added:
libunwind/tags/RELEASE_391/rc1/   (props changed)
  - copied from r288361, libunwind/branches/release_39/

Propchange: libunwind/tags/RELEASE_391/rc1/
--
svn:mergeinfo = /libunwind/trunk:276128,277868,278029


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


[libcxxabi] r288350 - Creating release candidate rc1 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 09:15:41 2016
New Revision: 288350

URL: http://llvm.org/viewvc/llvm-project?rev=288350&view=rev
Log:
Creating release candidate rc1 from release_391 branch

Added:
libcxxabi/tags/RELEASE_391/rc1/   (props changed)
  - copied from r288349, libcxxabi/branches/release_39/

Propchange: libcxxabi/tags/RELEASE_391/rc1/
--
svn:mergeinfo = /libcxxabi/trunk:278030,278579


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


[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.

https://reviews.llvm.org/D27302

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  test/change-namespace/Inputs/macro.h
  test/change-namespace/macro.cpp

Index: test/change-namespace/macro.cpp
===
--- /dev/null
+++ test/change-namespace/macro.cpp
@@ -0,0 +1,29 @@
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: cp %S/Inputs/macro.h %T/macro.h
+//
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
+//
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: cp %S/Inputs/macro.h %T/macro.h
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-CHANGED-HEADER %s
+#include "macro.h"
+namespace na { namespace nc { class X{}; } }
+
+namespace na {
+namespace nb {
+USING;
+}
+}
+// CHECK-CC: namespace x {
+// CHECK-CC: namespace y {
+// CHECK-CC: USING;
+// CHECK-CC: } // namespace y
+// CHECK-CC: } // namespace x
+
+// CHECK-HEADER: #define USING using na::nc::X
+
+// CHECK-CHANGED-HEADER: #define USING using ::na::nc::X
Index: test/change-namespace/Inputs/macro.h
===
--- /dev/null
+++ test/change-namespace/Inputs/macro.h
@@ -0,0 +1 @@
+#define USING using na::nc::X
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -41,7 +41,7 @@
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,15 +407,15 @@
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
  "base_initializer")) {
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -779,6 +779,12 @@
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto &Entry : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

alexfh wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > What do we want to do, if anything, for people who have scripts using 
> > > > the old name? Do we want to keep the old name as an alias to the new 
> > > > name for some period of time?
> > > An alias helps if the check was enabled by name, but not if it was 
> > > disabled by name.
> > > If the alias is temporary, would you want a deprecation warning?
> > > I wouldn't want to warn about `-checks=modernize*`, but maybe warning for 
> > > `-checks=modernize-use-default` would be useful.
> > > An alias helps if the check was enabled by name, but not if it was 
> > > disabled by name.
> > 
> > Oye, this is true and unfortunate.
> > 
> > > If the alias is temporary, would you want a deprecation warning?
> > > I wouldn't want to warn about -checks=modernize*, but maybe warning for 
> > > -checks=modernize-use-default would be useful.
> > 
> > I think a deprecation warning would be a helpful feature, but not required. 
> > I do agree that I would not want a warning for wildcard matches.
> > 
> > I would also be fine if we simply had the documentation for 
> > `modernize-use-default` forward to the documentation for 
> > `modernize-use-equals-default` and put a note in there about the old name 
> > being deprecated and leave in an alias to the old name.
> > 
> > To be complete, I would also be fine if we remove the old name as in this 
> > patch. I am mostly thinking about what default policy we want to have when 
> > this situation arises. FWIW, the check was exposed under this name around 
> > Oct 2015, so it's been in the wild for over a year, and in a public release.
> I'd personally prefer to leave the old documentation file with a redirect and 
> a note about the renaming.  Similar to how we treat aliases. WDYT?
If it has a redirect then add_new_check.py will add it to list.rst using the 
same wording as an alias.
Is that what you want?
Should it be an alias?


https://reviews.llvm.org/D26511



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

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



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

malcolm.parsons wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > malcolm.parsons wrote:
> > > > aaron.ballman wrote:
> > > > > What do we want to do, if anything, for people who have scripts using 
> > > > > the old name? Do we want to keep the old name as an alias to the new 
> > > > > name for some period of time?
> > > > An alias helps if the check was enabled by name, but not if it was 
> > > > disabled by name.
> > > > If the alias is temporary, would you want a deprecation warning?
> > > > I wouldn't want to warn about `-checks=modernize*`, but maybe warning 
> > > > for `-checks=modernize-use-default` would be useful.
> > > > An alias helps if the check was enabled by name, but not if it was 
> > > > disabled by name.
> > > 
> > > Oye, this is true and unfortunate.
> > > 
> > > > If the alias is temporary, would you want a deprecation warning?
> > > > I wouldn't want to warn about -checks=modernize*, but maybe warning for 
> > > > -checks=modernize-use-default would be useful.
> > > 
> > > I think a deprecation warning would be a helpful feature, but not 
> > > required. I do agree that I would not want a warning for wildcard matches.
> > > 
> > > I would also be fine if we simply had the documentation for 
> > > `modernize-use-default` forward to the documentation for 
> > > `modernize-use-equals-default` and put a note in there about the old name 
> > > being deprecated and leave in an alias to the old name.
> > > 
> > > To be complete, I would also be fine if we remove the old name as in this 
> > > patch. I am mostly thinking about what default policy we want to have 
> > > when this situation arises. FWIW, the check was exposed under this name 
> > > around Oct 2015, so it's been in the wild for over a year, and in a 
> > > public release.
> > I'd personally prefer to leave the old documentation file with a redirect 
> > and a note about the renaming.  Similar to how we treat aliases. WDYT?
> If it has a redirect then add_new_check.py will add it to list.rst using the 
> same wording as an alias.
> Is that what you want?
> Should it be an alias?
I don't care about leaving the old name for the check (probably, better to 
remove it right away), but leaving the old documentation page with a proper 
redirect seems useful as a means to resolve users' confusion. I wouldn't call 
it "alias" in this case though, and including it to the list doesn't seem to be 
useful (so the document will need to be marked orphan, IIUC).


https://reviews.llvm.org/D26511



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

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



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

alexfh wrote:
> malcolm.parsons wrote:
> > alexfh wrote:
> > > aaron.ballman wrote:
> > > > malcolm.parsons wrote:
> > > > > aaron.ballman wrote:
> > > > > > What do we want to do, if anything, for people who have scripts 
> > > > > > using the old name? Do we want to keep the old name as an alias to 
> > > > > > the new name for some period of time?
> > > > > An alias helps if the check was enabled by name, but not if it was 
> > > > > disabled by name.
> > > > > If the alias is temporary, would you want a deprecation warning?
> > > > > I wouldn't want to warn about `-checks=modernize*`, but maybe warning 
> > > > > for `-checks=modernize-use-default` would be useful.
> > > > > An alias helps if the check was enabled by name, but not if it was 
> > > > > disabled by name.
> > > > 
> > > > Oye, this is true and unfortunate.
> > > > 
> > > > > If the alias is temporary, would you want a deprecation warning?
> > > > > I wouldn't want to warn about -checks=modernize*, but maybe warning 
> > > > > for -checks=modernize-use-default would be useful.
> > > > 
> > > > I think a deprecation warning would be a helpful feature, but not 
> > > > required. I do agree that I would not want a warning for wildcard 
> > > > matches.
> > > > 
> > > > I would also be fine if we simply had the documentation for 
> > > > `modernize-use-default` forward to the documentation for 
> > > > `modernize-use-equals-default` and put a note in there about the old 
> > > > name being deprecated and leave in an alias to the old name.
> > > > 
> > > > To be complete, I would also be fine if we remove the old name as in 
> > > > this patch. I am mostly thinking about what default policy we want to 
> > > > have when this situation arises. FWIW, the check was exposed under this 
> > > > name around Oct 2015, so it's been in the wild for over a year, and in 
> > > > a public release.
> > > I'd personally prefer to leave the old documentation file with a redirect 
> > > and a note about the renaming.  Similar to how we treat aliases. WDYT?
> > If it has a redirect then add_new_check.py will add it to list.rst using 
> > the same wording as an alias.
> > Is that what you want?
> > Should it be an alias?
> I don't care about leaving the old name for the check (probably, better to 
> remove it right away), but leaving the old documentation page with a proper 
> redirect seems useful as a means to resolve users' confusion. I wouldn't call 
> it "alias" in this case though, and including it to the list doesn't seem to 
> be useful (so the document will need to be marked orphan, IIUC).
(So, we can do something close to clang/tools/extra/docs/clang-tidy.rst)


https://reviews.llvm.org/D26511



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


r288366 - Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2016-12-01 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Dec  1 09:45:06 2016
New Revision: 288366

URL: http://llvm.org/viewvc/llvm-project?rev=288366&view=rev
Log:
Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=288366&r1=288365&r2=288366&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Dec  1 09:45:06 2016
@@ -3758,8 +3758,8 @@ Example 2 (conditional binary operator):
 
 
 
-MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  
InnerMatcher
-Matches a node if 
the declaration associated with that node
+MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  
InnerMatcher
+Matches a node if 
the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -3772,13 +3772,13 @@ The associated declaration is:
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
-Usable as: MatcherCallExpr>,
 MatcherCXXConstructExpr>,
-  MatcherCXXNewExpr>,
-  MatcherDeclRefExpr>,
 MatcherEnumType>,
 MatcherInjectedClassNameType>,
-  MatcherLabelStmt>,
 MatcherAddrLabelExpr>,
 MatcherMemberExpr>,
-  MatcherQualType>,
 MatcherRecordType>,
 MatcherTagType>,
-  MatcherTemplateSpecializationType>,
 MatcherTemplateTypeParmType>,
-  MatcherTypedefType>,
 MatcherUnresolvedUsingType>
+Usable as: MatcherAddrLabelExpr>,
 MatcherCallExpr>,
+  MatcherCXXConstructExpr>,
 MatcherCXXNewExpr>,
 MatcherDeclRefExpr>,
+  MatcherEnumType>,
 MatcherInjectedClassNameType>,
 MatcherLabelStmt>,
+  MatcherMemberExpr>,
 MatcherQualType>,
 MatcherRecordType>,
+  MatcherTagType>,
 MatcherTemplateSpecializationType>,
+  MatcherTemplateTypeParmType>,
 MatcherTypedefType>,
+  MatcherUnresolvedUsingType>
 
 
 
@@ -4004,13 +4004,13 @@ The associated declaration is:
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
-Usable as: MatcherCallExpr>,
 Matcher

[PATCH] D27207: Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

2016-12-01 Thread Manuel Klimek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288366: Adds hasUnqualifiedDesugaredType to allow matching 
through type sugar. (authored by klimek).

Changed prior to commit:
  https://reviews.llvm.org/D27207?vs=79891&id=79912#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27207

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

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -3758,8 +3758,8 @@
 
 
 
-MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  InnerMatcher
-Matches a node if the declaration associated with that node
+MatcherAddrLabelExpr>hasDeclarationMatcherDecl>  InnerMatcher
+Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -3772,13 +3772,13 @@
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
-Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
-  MatcherCXXNewExpr>,
-  MatcherDeclRefExpr>, MatcherEnumType>, MatcherInjectedClassNameType>,
-  MatcherLabelStmt>, MatcherAddrLabelExpr>, MatcherMemberExpr>,
-  MatcherQualType>, MatcherRecordType>, MatcherTagType>,
-  MatcherTemplateSpecializationType>, MatcherTemplateTypeParmType>,
-  MatcherTypedefType>, MatcherUnresolvedUsingType>
+Usable as: MatcherAddrLabelExpr>, MatcherCallExpr>,
+  MatcherCXXConstructExpr>, MatcherCXXNewExpr>, MatcherDeclRefExpr>,
+  MatcherEnumType>, MatcherInjectedClassNameType>, MatcherLabelStmt>,
+  MatcherMemberExpr>, MatcherQualType>, MatcherRecordType>,
+  MatcherTagType>, MatcherTemplateSpecializationType>,
+  MatcherTemplateTypeParmType>, MatcherTypedefType>,
+  MatcherUnresolvedUsingType>
 
 
 
@@ -4004,13 +4004,13 @@
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
-Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
-  MatcherCXXNewExpr>,
-  MatcherDeclRefExpr>, Matcher

[PATCH] D27300: [OpenCL] Fix SPIR version generation.

2016-12-01 Thread Egor Churaev via Phabricator via cfe-commits
echuraev added inline comments.



Comment at: test/CodeGenOpenCL/spir_version.cl:21
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}

yaxunl wrote:
> why this is removed?
After my changes, value of SPIR version and OCL will be the same and so, it 
will be generate only one metadata (e.g. !1 = !{i32 1, i32 2}).
The same situation is for checking CL20 below.


https://reviews.llvm.org/D27300



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


[PATCH] D27211: [clang-format] Implement comment reflowing

2016-12-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: unittests/Format/FormatTest.cpp:1787
 
+TEST_F(FormatTest, ReflowsComments) {
+  // Break a long line and reflow with the full next line.

I think it is time that me moved a lot of the comment handling logic into a 
separate test file.


https://reviews.llvm.org/D27211



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


[PATCH] D27300: [OpenCL] Fix SPIR version generation.

2016-12-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/spir_version.cl:21
-// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0}
-// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2}
 // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}

echuraev wrote:
> yaxunl wrote:
> > why this is removed?
> After my changes, value of SPIR version and OCL will be the same and so, it 
> will be generate only one metadata (e.g. !1 = !{i32 1, i32 2}).
> The same situation is for checking CL20 below.
but line 19 still checking with OCL, shouldn't it be changed to the common 
version metadata shared between SPIR and OCL? How about rename SPIR in line 18 
to VER?


https://reviews.llvm.org/D27300



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 79918.
malcolm.parsons added a comment.
Herald added a subscriber: JDevlieghere.

Add documentation redirect.
Change add_new_check.py to ignore checks that are orphaned.


https://reviews.llvm.org/D26511

Files:
  clang-tidy/add_new_check.py
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tidy/modernize/UseDefaultCheck.h
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tidy/modernize/UseEqualsDefaultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-equals-default.rst
  test/clang-tidy/modernize-use-default-copy.cpp
  test/clang-tidy/modernize-use-default-delayed.cpp
  test/clang-tidy/modernize-use-default.cpp
  test/clang-tidy/modernize-use-equals-default-copy.cpp
  test/clang-tidy/modernize-use-equals-default-delayed.cpp
  test/clang-tidy/modernize-use-equals-default.cpp

Index: test/clang-tidy/modernize-use-equals-default.cpp
===
--- test/clang-tidy/modernize-use-equals-default.cpp
+++ test/clang-tidy/modernize-use-equals-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
 
 // Out of line definition.
 class OL {
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
Index: test/clang-tidy/modernize-use-equals-default-delayed.cpp
===
--- test/clang-tidy/modernize-use-equals-default-delayed.cpp
+++ test/clang-tidy/modernize-use-equals-default-delayed.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
+// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
 // Note: this test expects no diagnostics, but FileCheck cannot handle that,
 // hence the use of | count 0.
 
Index: test/clang-tidy/modernize-use-equals-default-copy.cpp
===
--- test/clang-tidy/modernize-use-equals-default-copy.cpp
+++ test/clang-tidy/modernize-use-equals-default-copy.cpp
@@ -1,19 +1,19 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
 
 // Out of line definition.
 struct OL {
   OL(const OL &);
   OL &operator=(const OL &);
   int Field;
 };
 OL::OL(const OL &Other) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL(const OL &Other)  = default;
 OL &OL::operator=(const OL &Other) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
 // CHECK-FIXES: OL &OL::operator=(const OL &Other) = default;
 
 // Inline.
Index: docs/clang-tidy/checks/modernize-use-equals-default.rst
===
--- docs/clang-tidy/checks/modernize-use-equals-default.rst
+++ docs/clang-tidy/checks/modernize-use-equals-default.rst
@@ -1,10 +1,10 @@
-.. title:: clang-tidy - modernize-use-default
+.. title:: clang-tidy - modernize-use-equals-default
 
-modernize-use-default
-=
+modernize-use-equals-default
+
 
 This check replaces default bodies of special member functions with ``=
-default;``. The explicitly defaulted function declarations enable more
+default;``.  The explicitly defaulted function declarations enable more
 opportunities in optimization, because the compiler might treat explicitly

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 79917.
Alpha added a comment.

Rebase on top of HEAD.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager &Sources,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel, StringRef BuildDirectory)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage &Message,
+   l

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 79919.
malcolm.parsons added a comment.

Re-remove doubled space in modernize-use-equals-default.rst.


https://reviews.llvm.org/D26511

Files:
  clang-tidy/add_new_check.py
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tidy/modernize/UseDefaultCheck.h
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tidy/modernize/UseEqualsDefaultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-equals-default.rst
  test/clang-tidy/modernize-use-default-copy.cpp
  test/clang-tidy/modernize-use-default-delayed.cpp
  test/clang-tidy/modernize-use-default.cpp
  test/clang-tidy/modernize-use-equals-default-copy.cpp
  test/clang-tidy/modernize-use-equals-default-delayed.cpp
  test/clang-tidy/modernize-use-equals-default.cpp

Index: test/clang-tidy/modernize-use-equals-default.cpp
===
--- test/clang-tidy/modernize-use-equals-default.cpp
+++ test/clang-tidy/modernize-use-equals-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
 
 // Out of line definition.
 class OL {
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
Index: test/clang-tidy/modernize-use-equals-default-delayed.cpp
===
--- test/clang-tidy/modernize-use-equals-default-delayed.cpp
+++ test/clang-tidy/modernize-use-equals-default-delayed.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
+// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
 // Note: this test expects no diagnostics, but FileCheck cannot handle that,
 // hence the use of | count 0.
 
Index: test/clang-tidy/modernize-use-equals-default-copy.cpp
===
--- test/clang-tidy/modernize-use-equals-default-copy.cpp
+++ test/clang-tidy/modernize-use-equals-default-copy.cpp
@@ -1,19 +1,19 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
 
 // Out of line definition.
 struct OL {
   OL(const OL &);
   OL &operator=(const OL &);
   int Field;
 };
 OL::OL(const OL &Other) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL(const OL &Other)  = default;
 OL &OL::operator=(const OL &Other) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
 // CHECK-FIXES: OL &OL::operator=(const OL &Other) = default;
 
 // Inline.
Index: docs/clang-tidy/checks/modernize-use-equals-default.rst
===
--- docs/clang-tidy/checks/modernize-use-equals-default.rst
+++ docs/clang-tidy/checks/modernize-use-equals-default.rst
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - modernize-use-default
+.. title:: clang-tidy - modernize-use-equals-default
 
-modernize-use-default
-=
+modernize-use-equals-default
+
 
 This check replaces default bodies of special member functions with ``=
 default;``. The explicitly defaulted function declarations enable more
Index: docs/clang-tidy/checks/modernize-use-default.rst
===
--- docs/clang-tidy/checks/modernize-use-default.rst
+++ docs/clang-tidy/checks/modernize-use-d

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha added a comment.

I don't have commit access.

Thank you for the review @alexfh


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via cfe-commits
Hi Alexander,

I have now implemented your suggestions - all but the fixit one. If I have
added bindings for str1 and str2 in ast matcher, how would I go about
creating a replacement for the entire implicitCastExpr or binaryOperator? I
can't find any example in the code for clang-tidy to suggest how I would
build a new node for the AST. Or I am looking at it from a wrong direction?

Could you hint me in the right direction as to how I would make the fixit?

Best regards,
Mads Ravn

On Thu, Dec 1, 2016 at 3:41 PM Alexander Kornienko via Phabricator <
revi...@reviews.llvm.org> wrote:

> alexfh requested changes to this revision.
> alexfh added inline comments.
> This revision now requires changes to proceed.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:29
> +
> +  // First and second case: cast str.compare(str) to boolean
> +  Finder->addMatcher(
> 
> Please add trailing periods here and elsewhere.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:36-50
> +  // Third case: str.compare(str) == 0
> +  Finder->addMatcher(
> +  binaryOperator(hasOperatorName("=="),
> + hasEitherOperand(strCompare),
> +
>  hasEitherOperand(integerLiteral(equals(0
> +  .bind("match"),
> +  this);
> 
> These two matchers can be merged to avoid repetition.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:55-57
> +diag(Matched->getLocStart(),
> + "do not use compare to test equality of strings; "
> + "use the string equality operator instead");
> 
> It looks like it's relatively straightforward to implement fixit hints.
> WDYT?
>
>
> 
> Comment at: test/clang-tidy/misc-string-compare.cpp:29
> +  if(!str1.compare(str2)) {}
> +  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: do not use compare to test
> equality of strings; use the string equality operator instead
> [misc-string-compare]
> +  if(str1.compare(str2) == 0) {}
> 
> Truncate all CHECK patterns after the first one after `of strings;`
>
>
> https://reviews.llvm.org/D27210
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Visoiu Mistrih Francis via Phabricator via cfe-commits
thegameg created this revision.
thegameg added reviewers: craig.topper, majnemer.
thegameg added a subscriber: cfe-commits.

The following program hits a fatal_error in the X86 backend, when the
program is compiled with -mno-sse or -mno-sse2, which is understandable
due to the calling convention:

> float f() { return 0.5f; };

since the error occurs in the backend, there are stack traces and bug
report messages that are generated.

This patch allows the compiler to avoid crashing and check in advance if
the code can be generated properly.

- include/clang/Basic/DiagnosticSemaKinds.td: Add the error.
- lib/Sema/SemaChecking.cpp: Check if the function returns a floating-point 
type.


https://reviews.llvm.org/D27304

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2474,6 +2474,17 @@
 CheckArgumentWithTypeTag(I, Args.data());
 }
   }
+
+  // Don't allow calls returning floating point scalars when
+  // target == x86_64 && SSE disabled.
+  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (!Context.getTargetInfo().hasFeature("sse") ||
+   !Context.getTargetInfo().hasFeature("sse2"))) {
+if (auto *ResultType = Proto->getReturnType().getTypePtrOrNull()) {
+  if (ResultType->isRealFloatingType())
+Diag(Loc, diag::err_x86_sse_register);
+}
+  }
 }
 
 /// CheckConstructorCall - Check a constructor call for correctness and safety
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7840,6 +7840,8 @@
   "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
+def err_x86_sse_register : Error<
+  "SSE register return with SSE disabled">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2474,6 +2474,17 @@
 CheckArgumentWithTypeTag(I, Args.data());
 }
   }
+
+  // Don't allow calls returning floating point scalars when
+  // target == x86_64 && SSE disabled.
+  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (!Context.getTargetInfo().hasFeature("sse") ||
+   !Context.getTargetInfo().hasFeature("sse2"))) {
+if (auto *ResultType = Proto->getReturnType().getTypePtrOrNull()) {
+  if (ResultType->isRealFloatingType())
+Diag(Loc, diag::err_x86_sse_register);
+}
+  }
 }
 
 /// CheckConstructorCall - Check a constructor call for correctness and safety
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7840,6 +7840,8 @@
   "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
+def err_x86_sse_register : Error<
+  "SSE register return with SSE disabled">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

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

LGTM with two nits.




Comment at: change-namespace/ChangeNamespace.cpp:786
+  for (auto &Entry : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();

How about creating `FilePatternRE` from `FilePattern` here? So that you don't 
need save `FilePatternRE` as a member variable.



Comment at: test/change-namespace/Inputs/macro.h:1
+#define USING using na::nc::X

For the simple file like this, I would use `echo "#define USING using 
na::nc::X" > macro.h` in `macro.cc` instead of creating a new file.


https://reviews.llvm.org/D27302



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via cfe-commits
On 1 December 2016 at 16:42, Mads Ravn  wrote:
> I have now implemented your suggestions - all but the fixit one. If I have
> added bindings for str1 and str2 in ast matcher, how would I go about
> creating a replacement for the entire implicitCastExpr or binaryOperator? I
> can't find any example in the code for clang-tidy to suggest how I would
> build a new node for the AST. Or I am looking at it from a wrong direction?

You create insertions, removals and replacements that affect the source code.
The AST is not changed.

Fix-it hints are documented here:
http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints

Source locations and ranges are documented here:
http://clang.llvm.org/docs/InternalsManual.html#sourcelocation

To turn str1.compare(str2) into str1 == str2 you need to replace
".compare(" with " == " and remove ")".

You can get the SourceLocation of the . by calling getOperatorLoc() on
the MemberExpr.
You can tell if you have a . or an -> by calling isArrow() on the MemberExpr.
You can get the SourceLocation of the ) by calling getRParenLoc() on
the CXXMemberCallExpr.

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


[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2016-12-01 Thread Kit Barton via Phabricator via cfe-commits
kbarton requested changes to this revision.
kbarton added a comment.
This revision now requires changes to proceed.

Please make explicit the signed for the parameters to the functions you are 
changing and remove unnecessary casts. I marked the first few that I found, but 
stopped marking them after the first several.




Comment at: lib/Headers/altivec.h:13928
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
-  (vector unsigned char)__a);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b,
+  (vector signed char)__a);

The cast for  __b is necessary, since it is already a vector signed char. 
I don't know whether this will generate superfluous warnings or not, but it's 
probably best to remove it.



Comment at: lib/Headers/altivec.h:13965
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
   vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__b,

It's better to make the parameter explicitly vector signed short, and remove 
the cast on the next line, for consistency with other builtins. 



Comment at: lib/Headers/altivec.h:14002
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
   vector int __b) {
+  return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__b,

same comment - explicitly vector signed int



Comment at: lib/Headers/altivec.h:14042
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
-  (vector unsigned long long)__a);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
+  (vector signed long long)__a);

No cast needed here



Comment at: lib/Headers/altivec.h:14099
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
-  (vector unsigned char)__b);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a,
+  (vector signed char)__b);

No cast needed here 



Comment at: lib/Headers/altivec.h:14136
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
   vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a,

Make signed explicit here


https://reviews.llvm.org/D27251



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


[PATCH] D26694: [analyzer] Drop explicit mention of range constraint solver

2016-12-01 Thread Dominic Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288372: [analyzer] Drop explicit mention of range constraint 
solver (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26694?vs=78060&id=79924#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26694

Files:
  cfe/trunk/test/Analysis/CFDateGC.m
  cfe/trunk/test/Analysis/CFNumber.c
  cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
  cfe/trunk/test/Analysis/CGColorSpace.c
  cfe/trunk/test/Analysis/CheckNSError.m
  cfe/trunk/test/Analysis/NSPanel.m
  cfe/trunk/test/Analysis/NSString.m
  cfe/trunk/test/Analysis/NSWindow.m
  cfe/trunk/test/Analysis/ObjCProperties.m
  cfe/trunk/test/Analysis/PR2599.m
  cfe/trunk/test/Analysis/PR3991.m
  cfe/trunk/test/Analysis/additive-folding-range-constraints.c
  cfe/trunk/test/Analysis/additive-folding.cpp
  cfe/trunk/test/Analysis/array-struct-region.c
  cfe/trunk/test/Analysis/array-struct.c
  cfe/trunk/test/Analysis/cfref_PR2519.c
  cfe/trunk/test/Analysis/cfref_rdar6080742.c
  cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
  cfe/trunk/test/Analysis/complex.c
  cfe/trunk/test/Analysis/dead-stores.c
  cfe/trunk/test/Analysis/dead-stores.cpp
  cfe/trunk/test/Analysis/misc-ps-64.m
  cfe/trunk/test/Analysis/misc-ps-eager-assume.m
  cfe/trunk/test/Analysis/misc-ps-ranges.m
  cfe/trunk/test/Analysis/misc-ps.m
  
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
  cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
  cfe/trunk/test/Analysis/null-deref-ps.c
  cfe/trunk/test/Analysis/rdar-6562655.m
  cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
  cfe/trunk/test/Analysis/reference.cpp
  cfe/trunk/test/Analysis/unions-region.m

Index: cfe/trunk/test/Analysis/CheckNSError.m
===
--- cfe/trunk/test/Analysis/CheckNSError.m
+++ cfe/trunk/test/Analysis/CheckNSError.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s
 
 
 typedef signed char BOOL;
Index: cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
===
--- cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
+++ cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
 // expected-no-diagnostics
 
 typedef struct Foo { int x; } Bar;
Index: cfe/trunk/test/Analysis/misc-ps-ranges.m
===
--- cfe/trunk/test/Analysis/misc-ps-ranges.m
+++ cfe/trunk/test/Analysis/misc-ps-ranges.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
 
 // 
 // main's 'argc' argument is always > 0
Index: cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
===
--- cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
+++ cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple i386-apple-darwin9 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple x86_64-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple i386-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple x86_64-apple-darwin9 -verify %s
 
 // This file runs in C++ mode so that the comparison type is 'bool', not 'int'.
 void clang_analyzer_eval(int);
Index: cfe/trunk/test/Analysis/PR2599.m
===
--- cfe/trunk/test/Analysis/PR2599.m
+++ cfe/trunk/test/Analysis/PR2599.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-constraints=range -analyzer-store=region -fobjc-gc -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -veri

r288372 - [analyzer] Drop explicit mention of range constraint solver

2016-12-01 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Thu Dec  1 11:06:39 2016
New Revision: 288372

URL: http://llvm.org/viewvc/llvm-project?rev=288372&view=rev
Log:
[analyzer] Drop explicit mention of range constraint solver

Summary: The basic constraint solver was dropped in rL162384, leaving the range 
constraint solver as the default and only constraint solver. Explicitly 
specifying it is unnecessary, and makes it difficult to test with other solver 
backends.

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Analysis/CFDateGC.m
cfe/trunk/test/Analysis/CFNumber.c
cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
cfe/trunk/test/Analysis/CGColorSpace.c
cfe/trunk/test/Analysis/CheckNSError.m
cfe/trunk/test/Analysis/NSPanel.m
cfe/trunk/test/Analysis/NSString.m
cfe/trunk/test/Analysis/NSWindow.m
cfe/trunk/test/Analysis/ObjCProperties.m
cfe/trunk/test/Analysis/PR2599.m
cfe/trunk/test/Analysis/PR3991.m
cfe/trunk/test/Analysis/additive-folding-range-constraints.c
cfe/trunk/test/Analysis/additive-folding.cpp
cfe/trunk/test/Analysis/array-struct-region.c
cfe/trunk/test/Analysis/array-struct.c
cfe/trunk/test/Analysis/cfref_PR2519.c
cfe/trunk/test/Analysis/cfref_rdar6080742.c
cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
cfe/trunk/test/Analysis/complex.c
cfe/trunk/test/Analysis/dead-stores.c
cfe/trunk/test/Analysis/dead-stores.cpp
cfe/trunk/test/Analysis/misc-ps-64.m
cfe/trunk/test/Analysis/misc-ps-eager-assume.m
cfe/trunk/test/Analysis/misc-ps-ranges.m
cfe/trunk/test/Analysis/misc-ps.m

cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Analysis/rdar-6562655.m
cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
cfe/trunk/test/Analysis/reference.cpp
cfe/trunk/test/Analysis/unions-region.m

Modified: cfe/trunk/test/Analysis/CFDateGC.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFDateGC.m?rev=288372&r1=288371&r2=288372&view=diff
==
--- cfe/trunk/test/Analysis/CFDateGC.m (original)
+++ cfe/trunk/test/Analysis/CFDateGC.m Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount 
-analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s  
-Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount 
-analyzer-store=region -verify -fobjc-gc %s  -Wno-implicit-function-declaration
 
 
//===--===//
 // The following code is reduced using delta-debugging from

Modified: cfe/trunk/test/Analysis/CFNumber.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFNumber.c?rev=288372&r1=288371&r2=288372&view=diff
==
--- cfe/trunk/test/Analysis/CFNumber.c (original)
+++ cfe/trunk/test/Analysis/CFNumber.c Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount 
-analyzer-store=region -analyzer-constraints=range -verify -triple 
x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount 
-analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
 
 typedef signed long CFIndex;
 typedef const struct __CFAllocator * CFAllocatorRef;

Modified: cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m?rev=288372&r1=288371&r2=288372&view=diff
==
--- cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m (original)
+++ cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m Thu Dec  1 
11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s 
-analyzer-constraints=range -analyzer-store=region
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s 
-analyzer-store=region
 // expected-no-diagnostics
 
 typedef struct objc_selector *SEL;

Modified: cfe/trunk/test/Analysis/CGColorSpace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CGColorSpace.c?rev=288372&r1=288371&r2=288372&view=diff
==
--- cfe/trunk/test/Analysis/CGColorSpace.c (original)
+++ cfe/trunk/test/Analysis/CGColorSpace.c Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -a

[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: docs/clang-tidy/checks/misc-string-compare.rst:21
+  
+  if(str1.compare(str2)) {} // use str1 != str2 instead
+  

Please clang-format this code.



Comment at: test/clang-tidy/misc-string-compare.cpp:15
+};
+  bool operator==(const basic_string lhs, const basic_string rhs);
+  bool operator!=(const basic_string lhs, const basic_string rhs);

Missing &s.
Please clang-format this file.


https://reviews.llvm.org/D27210



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 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.

LG. Thanks!


https://reviews.llvm.org/D26511



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


Re: Upgrade and fix clang-format-vs

2016-12-01 Thread Hans Wennborg via cfe-commits
Looks good to me!

Do you have commit access, or would you like me to commit it for you?

Thanks,
Hans

On Wed, Nov 30, 2016 at 8:10 PM, Antonio Maiorano  wrote:
> Updated version of patch attached with the changes you suggested. Let me
> know if there's anything else you'd like.
>
>
> On Tue, 29 Nov 2016 at 15:38 Hans Wennborg  wrote:
>>
>> On Tue, Nov 29, 2016 at 12:01 PM, Antonio Maiorano 
>> wrote:
>> > On Tue, 29 Nov 2016 at 13:42 Hans Wennborg  wrote:
>> >>
>> >> Very nice! I've tried this out and confirmed that the built plugin
>> >> also works with older Visual Studio versions.
>> >>
>> >> Some comments below:
>> >>
>> >> > --- /dev/null
>> >> > +++ b/tools/clang-format-vs/.gitignore
>> >> > @@ -0,0 +1,11 @@
>> >> > +# Visual Studio files
>> >> > +.vs/
>> >> > +/packages/
>> >> > +/ClangFormat/obj/
>> >> > +/ClangFormat/bin/
>> >>
>> >> Should there really be a leading slash in these paths? Same below.
>> >
>> >
>> > Without the leading slash, then it would match "ClangFormat/obj"
>> > anywhere in
>> > the tree, rather than explicitly the one and only folder from the root.
>> > In
>> > this case, it wouldn't matter much. If you prefer, I could just ignore
>> > "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk,
>> > license.txt, etc.
>>
>> Interesting. I was just comparing with LLVM's root .gitignore, which
>> doesn't have leading slashes for many dirs. Checking the gitignore
>> doc, it sounds like you've got it right :-)
>>
>>
>> >> > +# Generated and copied files
>> >> > +/ClangFormat/Key.snk
>> >> > +/ClangFormat/license.txt
>> >> > +/ClangFormat/clang-format.exe
>> >> > +/ClangFormat/source.extension.vsixmanifest
>> >> > diff --git a/tools/clang-format-vs/CMakeLists.txt
>> >> > b/tools/clang-format-vs/CMakeLists.txt
>> >> > index fd0d6b0..90f89d8 100644
>> >> > --- a/tools/clang-format-vs/CMakeLists.txt
>> >> > +++ b/tools/clang-format-vs/CMakeLists.txt
>> >> > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
>> >> >configure_file("source.extension.vsixmanifest.in"
>> >> >
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
>> >> >
>> >> > -  add_custom_target(clang_format_vsix ALL
>> >> > -  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build
>> >> > Release
>> >> > +  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH})
>> >> > +  if (NOT NUGET_EXE)
>> >> > + message(FATAL_ERROR "Could not find nuget.exe. Download from
>> >> > https://www.nuget.org/nuget.exe and add to PATH or pass path via
>> >> > NUGET_EXE_PATH var")
>> >>
>> >> Can you break this string over multiple lines? I know there are pretty
>> >> long lines in this file already, but it would be good to not make it
>> >> worse.
>> >
>> >
>> > Sure thing, I'll see what I can do :)
>> >
>> >>
>> >>
>> >> Maybe it could be clarified that NUGET_EXE_PATH is the path to a
>> >> directory containing nuget.exe, not to the file itself (I ran into
>> >> this). Maybe NUGET_EXE_DIR would be a better name?
>> >
>> >
>> > That would be a better name, will make that change.
>> >
>> >>
>> >>
>> >> > +  endif()
>> >> > +
>> >> > +  add_custom_target(clang_format_vsix ALL
>> >> > +  ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
>> >> > &
>> >> > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
>> >>
>> >> Is '&' a CMake thing, or should that be '&&'? Also, any chance of
>> >> breaking these long lines?
>> >
>> >
>> > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only
>> > runs
>> > the 2nd command if the first succeeds, while using '&' always runs both.
>> > I'll make the change, and will try to shorten this line as well.
>> >
>> >>
>> >>
>> >> >DEPENDS clang_format_exe_for_vsix
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
>> >> >COMMAND ${CMAKE_COMMAND} -E copy_if_different
>> >> >
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
>> >> > diff --git a/tools/clang-format-vs/README.txt
>> >> > b/tools/clang-format-vs/README.txt
>> >> > index b23355d..44a071b 100644
>> >> > --- a/tools/clang-format-vs/README.txt
>> >> > +++ b/tools/clang-format-vs/README.txt
>> >> > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to
>> >> > generate a Visual Studio extensio
>> >> >  for clang-format.
>> >> >
>> >> >  Build prerequisites are:
>> >> > -- Visual Studio 2013 Professional
>> >> > -- Visual Studio 2013 SDK
>> >> > -- Visual Studio 2010 Professional (?)
>> >> > -- Visual Studio 2010 SDK (?)
>> >> > +- Visual Studio 2015
>> >> > +- Extensions SDK (you'll be prompted to install it if you open
>> >> > ClangFormat.sln)
>> >>
>> >> A very nice simplification :-)
>> >
>> >
>> > Thanks :)
>> >
>> >>
>> >>
>> >> >
>> >> > -The extension is built using CMake by setting
>> >> > BUILD_CLANG_FORMAT_VS_PLUGIN=ON
>> >> > -when configuring a Clang build, and building the clang_format_vsix
>> >> > target.
>> >> > +The extension is built

[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 79927.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D27302

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  test/change-namespace/macro.cpp

Index: test/change-namespace/macro.cpp
===
--- /dev/null
+++ test/change-namespace/macro.cpp
@@ -0,0 +1,29 @@
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+//
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
+//
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-CHANGED-HEADER %s
+#include "macro.h"
+namespace na { namespace nc { class X{}; } }
+
+namespace na {
+namespace nb {
+USING;
+}
+}
+// CHECK-CC: namespace x {
+// CHECK-CC: namespace y {
+// CHECK-CC: USING;
+// CHECK-CC: } // namespace y
+// CHECK-CC: } // namespace x
+
+// CHECK-HEADER: #define USING using na::nc::X
+
+// CHECK-CHANGED-HEADER: #define USING using ::na::nc::X
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -41,7 +41,7 @@
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,15 +407,15 @@
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
  "base_initializer")) {
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto &Entry : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace
__

[PATCH] D24639: [Sema] Warn when returning a lambda that captures a local variable by reference

2016-12-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D24639



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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26453#592934, @flx wrote:

> In https://reviews.llvm.org/D26453#590720, @malcolm.parsons wrote:
>
> > Add ValuesOnly option to modernize-pass-by-value.
>
>
> Thanks for doing this. Alex, would this work for us?


ping.


https://reviews.llvm.org/D26453



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


[clang-tools-extra] r288375 - [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:24:42 2016
New Revision: 288375

URL: http://llvm.org/viewvc/llvm-project?rev=288375&view=rev
Log:
[clang-tidy] Rename modernize-use-default to modernize-use-equals-default

Reviewers: angelgarcia, aaron.ballman, alexfh

Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-default.rst
  - copied, changed from r288258, 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=288375&r1=288374&r2=288375&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Thu Dec  1 11:24:42 2016
@@ -226,8 +226,13 @@ def update_checks_list(clang_tidy_path):
   def format_link(doc_file):
 check_name = doc_file.replace('.rst', '')
 with open(os.path.join(docs_dir, doc_file), 'r') as doc:
+  content = doc.read()
+  match = re.search('.*:orphan:.*', content)
+  if match:
+return ''
+
   match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*',
-doc.read())
+content)
   if match:
 return '   %(check)s (redirects to %(target)s) <%(check)s>\n' % {
 'check': check_name,

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=288375&r1=288374&r2=288375&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Dec  1 
11:24:42 2016
@@ -16,8 +16,8 @@ add_clang_library(clangTidyModernizeModu
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
-  UseDefaultCheck.cpp
   UseEmplaceCheck.cpp
+  UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=288375&r1=288374&r2=288375&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Dec  1 11:24:42 2016
@@ -22,8 +22,8 @@
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
-#include "UseDefaultCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
@@ -56,8 +56,8 @@ public:
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
-CheckFactories.regist

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288375: [clang-tidy] Rename modernize-use-default to 
modernize-use-equals-default (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26511?vs=79919&id=79928#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26511

Files:
  clang-tools-extra/trunk/clang-tidy/add_new_check.py
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-default.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -0,0 +1,299 @@
+//===--- UseEqualsDefaultCheck.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 "UseEqualsDefaultCheck.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 {
+
+static const char SpecialFunction[] = "SpecialFunction";
+
+/// \brief Finds all the named non-static fields of \p Record.
+static std::set
+getAllNamedFields(const CXXRecordDecl *Record) {
+  std::set Result;
+  for (const auto *Field : Record->fields()) {
+// Static data members are not in this range.
+if (Field->isUnnamedBitfield())
+  continue;
+Result.insert(Field);
+  }
+  return Result;
+}
+
+/// \brief Returns the names of the direct bases of \p Record, both virtual and
+/// non-virtual.
+static std::set getAllDirectBases(const CXXRecordDecl *Record) {
+  std::set Result;
+  for (auto Base : Record->bases()) {
+// CXXBaseSpecifier.
+const auto *BaseType = Base.getTypeSourceInfo()->getType().getTypePtr();
+Result.insert(BaseType);
+  }
+  return Result;
+}
+
+/// \brief Returns a matcher that matches member expressions where the base is
+/// the variable declared as \p Var and the accessed member is the one declared
+/// as \p Field.
+internal::Matcher accessToFieldInVar(const FieldDecl *Field,
+   const ValueDecl *Var) {
+  return ignoringImpCasts(
+  memberExpr(hasObjectExpression(declRefExpr(to(varDecl(equalsNode(Var),
+ member(fieldDecl(equalsNode(Field);
+}
+
+/// \brief Check that the given constructor has copy signature and that it
+/// copy-initializes all its bases and members.
+static bool isCopyConstructorAndCanBeDefaulted(ASTContext *Context,
+   const CXXConstructorDecl *Ctor) {
+  // An explicitly-defaulted constructor cannot have default arguments.
+  if (Ctor->getMinRequiredArguments() != 1)
+return false;
+
+  const auto *Record = Ctor->getParent();
+  const auto *Param = Ctor->getParamDecl(0);
+
+  // Base classes and members that have to be copied.
+  auto BasesToInit = getAllDirectBases(Record);
+  auto FieldsToInit = getAllNamedFields(Record);
+
+  // Ensure that all the bases are copied.
+  for (const auto *Base : BasesToInit) {
+// The initialization of a base class should be a call to a copy
+// constructor of the base.
+if (match(
+cxxConstructorDecl(forEachConstructorInitializer(cxxCtorInitializer(
+isBaseInitializer(),
+withInitializer(cxxConstructExpr(allOf(
+hasType(equalsNode(Base)),
+hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
+argumentCountIs(1),
+hasArgument(
+

[clang-tools-extra] r288376 - [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Dec  1 11:25:55 2016
New Revision: 288376

URL: http://llvm.org/viewvc/llvm-project?rev=288376&view=rev
Log:
[change-namespace] don't generate replacements for files that don't match file 
pattern.

Reviewers: hokein

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/test/change-namespace/macro.cpp
Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/change-namespace/ChangeNamespace.h

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=288376&r1=288375&r2=288376&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Dec  1 
11:25:55 2016
@@ -41,7 +41,7 @@ SourceLocation startLocationForType(Type
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@ ChangeNamespaceTool::ChangeNamespaceTool
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,7 +407,7 @@ void ChangeNamespaceTool::run(
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
@@ -415,7 +415,7 @@ void ChangeNamespaceTool::run(
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@ void ChangeNamespaceTool::fixTypeLoc(
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@ void ChangeNamespaceTool::onEndOfTransla
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto &Entry : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=288376&r1=288375&r2=288376&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Thu Dec  1 
11:25:55 2016
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@ private:
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces

Added: clang-tools-extra/trunk/test/change-namespace/macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/change-namespace/macro.cpp?rev=288376&view=auto
==
--- clang-tools-extra/trunk/test/change-namespace/macro.cpp (added)
++

[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288376: [change-namespace] don't generate replacements for 
files that don't match file… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D27302?vs=79927&id=79929#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27302

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
  clang-tools-extra/trunk/test/change-namespace/macro.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -41,7 +41,7 @@
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,15 +407,15 @@
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
  "base_initializer")) {
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto &Entry : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace
Index: clang-tools-extra/trunk/test/change-namespace/macro.cpp
===
--- clang-tools-extra/trunk/test/change-namespace/macro.cpp
+++ clang-tools-extra/trunk/test/change-namespace/macro.cpp
@@ -0,0 +1,29 @@
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+//
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
+//
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

ping.


https://reviews.llvm.org/D26750



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


[libcxx] r288378 - Protect std::ostream::sentry test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:31:38 2016
New Revision: 288378

URL: http://llvm.org/viewvc/llvm-project?rev=288378&view=rev
Log:
Protect std::ostream::sentry test under libcpp-no-exceptions

Skip test that throws an exception.

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


Modified:

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp?rev=288378&r1=288377&r2=288378&view=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 Thu Dec  1 11:31:38 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@ int main()
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os(&sb);
@@ -73,4 +75,5 @@ int main()
 }
 assert(sync_called == 1);
 }
+#endif
 }


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


[PATCH] D27255: Protect std::ostream::sentry test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288378: Protect std::ostream::sentry test under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27255?vs=79720&id=79931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27255

Files:
  
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp


Index: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
===
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os(&sb);
@@ -73,4 +75,5 @@
 }
 assert(sync_called == 1);
 }
+#endif
 }


Index: libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
===
--- libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
+++ libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os(&sb);
@@ -73,4 +75,5 @@
 }
 assert(sync_called == 1);
 }
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27254: Protect optional test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288379: Protect optional test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27254?vs=79765&id=79932#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27254

Files:
  libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp


Index: 
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == 
y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }


Index: libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288379 - Protect optional test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:33:36 2016
New Revision: 288379

URL: http://llvm.org/viewvc/llvm-project?rev=288379&view=rev
Log:
Protect optional test under libcpp-no-exceptions

Replace throw with TEST_THROW and skip tests that throw exceptions

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


Modified:
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp?rev=288379&r1=288378&r2=288379&view=diff
==
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
(original)
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
Thu Dec  1 11:33:36 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@ class Z
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == 
y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@ int main()
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@ int main()
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }


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


[libcxx] r288382 - Protect futures test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:34:57 2016
New Revision: 288382

URL: http://llvm.org/viewvc/llvm-project?rev=288382&view=rev
Log:
Protect futures test under libcpp-no-exceptions

Skip tests that expect an exception be thrown.

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


Modified:
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp?rev=288382&r1=288381&r2=288382&view=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
Thu Dec  1 11:34:57 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);


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


[PATCH] D27253: Protect futures test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288382: Protect futures test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27253?vs=79718&id=79933#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27253

Files:
  libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp


Index: libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
===
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);


Index: libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
===
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288383 - Protect sequences test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:36:41 2016
New Revision: 288383

URL: http://llvm.org/viewvc/llvm-project?rev=288383&view=rev
Log:
Protect sequences test under libcpp-no-exceptions

Replace throw with TEST_THROW and protect tests that do throw. Also add missing 
assert(false).

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


Modified:

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp?rev=288383&r1=288382&r2=288383&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@ void test() {
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@ void test() {
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp?rev=288383&r1=288382&r2=288383&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void push_back(const value_type& x);
@@ -16,10 +15,10 @@
 #include 
 
 #include "asan_testing.h"
+#include "test_macros.h"
 
 // Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
 
 class CMyClass {
 public: CMyClass(int tag);
@@ -52,8 +51,8 @@ CMyClass::CMyClass(const CMyClass& iOthe
 fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
 {
 // If requested, throw an exception _before_ setting fMagicValue to 
kFinishedConstructionMagicValue
-if (gCopyConstructorShouldThow) {
-throw std::exception();
+if (gCopyConstructorShouldThrow) {
+TEST_THROW(std::exception());
 }
 // Signal that the constructor has finished running
 fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@ int main()
 assert(is_contiguous_container_asan_correct(vec));
 assert(is_contiguous_container_asan_correct(vec2));
 
-gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+gCopyConstructorShouldThrow = true;
 try {
 vec.push_back(instance);
+assert(false);
 }
 catch (...) {
 assert(vec==vec2);
 assert(is_contiguous_container_asan_correct(vec));
 }
+#endif
 }


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


[PATCH] D27252: Protect sequences test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288383: Protect sequences test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27252?vs=79717&id=79934#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27252

Files:
  
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp


Index: 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
===
--- 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+++ 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()
Index: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
===
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
@@ -7,19 +7,18 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void push_back(const value_type& x);
 
 #include 
 #include 
 
 #include "asan_testing.h"
+#include "test_macros.h"
 
 // Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
 
 class CMyClass {
 public: CMyClass(int tag);
@@ -52,8 +51,8 @@
 fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
 {
 // If requested, throw an exception _before_ setting fMagicValue to 
kFinishedConstructionMagicValue
-if (gCopyConstructorShouldThow) {
-throw std::exception();
+if (gCopyConstructorShouldThrow) {
+TEST_THROW(std::exception());
 }
 // Signal that the constructor has finished running
 fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@
 assert(is_contiguous_container_asan_correct(vec));
 assert(is_contiguous_container_asan_correct(vec2));
 
-gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+gCopyConstructorShouldThrow = true;
 try {
 vec.push_back(instance);
+assert(false);
 }
 catch (...) {
 assert(vec==vec2);
 assert(is_contiguous_container_asan_correct(vec));
 }
+#endif
 }


Index: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
===
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()
Index: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
===
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
+++ libcxx/trunk/test/std/containers/sequences/vector/

[clang-tools-extra] r288384 - Add a blank line to make sphinx happy.

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:38:54 2016
New Revision: 288384

URL: http://llvm.org/viewvc/llvm-project?rev=288384&view=rev
Log:
Add a blank line to make sphinx happy.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst?rev=288384&r1=288383&r2=288384&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
Thu Dec  1 11:38:54 2016
@@ -1,4 +1,5 @@
 :orphan:
+
 .. title:: clang-tidy - modernize-use-default
 .. meta::
:http-equiv=refresh: 5;URL=modernize-use-equals-default.html


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


[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path

2016-12-01 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D27298



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


r288388 - [TableGen] Ignore fake args for parsing-related arg counts.

2016-12-01 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec  1 11:52:39 2016
New Revision: 288388

URL: http://llvm.org/viewvc/llvm-project?rev=288388&view=rev
Log:
[TableGen] Ignore fake args for parsing-related arg counts.

We should complain about the following:

```
void foo() __attribute__((unavailable("a", "b")));
```

Instead, we currently just ignore "b". (...We also end up ignoring "a",
because we assume elsewhere that this attribute can only have 1 or 0
args.)

This happens because `unavailable` has a fake enum arg, and
`AttributeList::{getMinArgs,getMaxArgs}` include fake args in their
counts.

Modified:
cfe/trunk/test/Sema/attr-unavailable-message.c
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/test/Sema/attr-unavailable-message.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-unavailable-message.c?rev=288388&r1=288387&r2=288388&view=diff
==
--- cfe/trunk/test/Sema/attr-unavailable-message.c (original)
+++ cfe/trunk/test/Sema/attr-unavailable-message.c Thu Dec  1 11:52:39 2016
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // rdar: //6734520
 
+void tooManyArgs() __attribute__((unavailable("a", "b"))); // expected-error 
{{'unavailable' attribute takes no more than 1 argument}}
+
 int foo(int)  __attribute__((__unavailable__("USE IFOO INSTEAD"))); // 
expected-note {{'foo' has been explicitly marked unavailable here}}
 double dfoo(double)  __attribute__((__unavailable__("NO LONGER"))); // 
expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
 

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=288388&r1=288387&r2=288388&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Thu Dec  1 11:52:39 2016
@@ -2540,6 +2540,10 @@ static void emitArgInfo(const Record &R,
   unsigned ArgCount = 0, OptCount = 0;
   bool HasVariadic = false;
   for (const auto *Arg : Args) {
+// If the arg is fake, it's the user's job to supply it: general parsing
+// logic shouldn't need to know anything about it.
+if (Arg->getValueAsBit("Fake"))
+  continue;
 Arg->getValueAsBit("Optional") ? ++OptCount : ++ArgCount;
 if (!HasVariadic && isArgVariadic(*Arg, R.getName()))
   HasVariadic = true;


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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I think this is the absolutely wrong place to put such logic. It really can not 
be anywhere but the backend.


https://reviews.llvm.org/D27304



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


r288393 - Fix VS2015 build of clang-format-vsix by using NuGet to pull in required assemblies

2016-12-01 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Dec  1 12:05:41 2016
New Revision: 288393

URL: http://llvm.org/viewvc/llvm-project?rev=288393&view=rev
Log:
Fix VS2015 build of clang-format-vsix by using NuGet to pull in required 
assemblies

Also added a gitignore to help track the right items to commit.

Patch by Antonio Maiorano !

Added:
cfe/trunk/tools/clang-format-vs/.gitignore
cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config
Modified:
cfe/trunk/tools/clang-format-vs/CMakeLists.txt
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
cfe/trunk/tools/clang-format-vs/README.txt

Added: cfe/trunk/tools/clang-format-vs/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/.gitignore?rev=288393&view=auto
==
--- cfe/trunk/tools/clang-format-vs/.gitignore (added)
+++ cfe/trunk/tools/clang-format-vs/.gitignore Thu Dec  1 12:05:41 2016
@@ -0,0 +1,11 @@
+# Visual Studio files
+.vs/
+/packages/
+/ClangFormat/obj/
+/ClangFormat/bin/
+
+# Generated and copied files
+/ClangFormat/Key.snk
+/ClangFormat/license.txt
+/ClangFormat/clang-format.exe
+/ClangFormat/source.extension.vsixmanifest

Modified: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/CMakeLists.txt?rev=288393&r1=288392&r2=288393&view=diff
==
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt Thu Dec  1 12:05:41 2016
@@ -18,8 +18,15 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
   configure_file("source.extension.vsixmanifest.in"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
 
+  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_DIR})
+  if (NOT NUGET_EXE)
+message(FATAL_ERROR "Could not find nuget.exe. Download from 
https://www.nuget.org/nuget.exe";
+" and add parent directory to PATH or pass it via 
NUGET_EXE_DIR var.")
+  endif()
+
   add_custom_target(clang_format_vsix ALL
-  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
+  COMMAND ${NUGET_EXE} restore 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
+  COMMAND devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build 
Release
   DEPENDS clang_format_exe_for_vsix 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
   COMMAND ${CMAKE_COMMAND} -E copy_if_different
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj?rev=288393&r1=288392&r2=288393&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj Thu Dec  1 
12:05:41 2016
@@ -35,6 +35,7 @@
 false
 false
 true
+
   
   
 true
@@ -44,6 +45,7 @@
 DEBUG;TRACE
 prompt
 4
+false
   
   
 pdbonly
@@ -53,27 +55,87 @@
 prompt
 4
 true
+false
   
   
+
+  ..\packages\VSSDK.DTE.7.0.3\lib\net20\envdte.dll
+  False
+
 
-
-
-
-
-
-
+
+  
..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll
+  False
+
+
+  
..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll
+  False
+
+
+  
..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Shell.10.10.0.3\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll
+  False
+
+
+  
..\packages\VSSDK.Shell.Immutable.10.10.0.3\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll
+  True
+
+
+  
..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Shell.Interop.8.8.0.3\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll
+  True
+  False
+
 
-
-
-  false
-
-
-
-
-
-
-
+
+  
..\packages\VSSDK.Shell.Interop.9.9.0.3\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll
+  False
+
+
+ 

Re: Upgrade and fix clang-format-vs

2016-12-01 Thread Hans Wennborg via cfe-commits
Committed in r288393.

Cheers,
Hans

On Thu, Dec 1, 2016 at 9:22 AM, Hans Wennborg  wrote:
> Looks good to me!
>
> Do you have commit access, or would you like me to commit it for you?
>
> Thanks,
> Hans
>
> On Wed, Nov 30, 2016 at 8:10 PM, Antonio Maiorano  wrote:
>> Updated version of patch attached with the changes you suggested. Let me
>> know if there's anything else you'd like.
>>
>>
>> On Tue, 29 Nov 2016 at 15:38 Hans Wennborg  wrote:
>>>
>>> On Tue, Nov 29, 2016 at 12:01 PM, Antonio Maiorano 
>>> wrote:
>>> > On Tue, 29 Nov 2016 at 13:42 Hans Wennborg  wrote:
>>> >>
>>> >> Very nice! I've tried this out and confirmed that the built plugin
>>> >> also works with older Visual Studio versions.
>>> >>
>>> >> Some comments below:
>>> >>
>>> >> > --- /dev/null
>>> >> > +++ b/tools/clang-format-vs/.gitignore
>>> >> > @@ -0,0 +1,11 @@
>>> >> > +# Visual Studio files
>>> >> > +.vs/
>>> >> > +/packages/
>>> >> > +/ClangFormat/obj/
>>> >> > +/ClangFormat/bin/
>>> >>
>>> >> Should there really be a leading slash in these paths? Same below.
>>> >
>>> >
>>> > Without the leading slash, then it would match "ClangFormat/obj"
>>> > anywhere in
>>> > the tree, rather than explicitly the one and only folder from the root.
>>> > In
>>> > this case, it wouldn't matter much. If you prefer, I could just ignore
>>> > "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk,
>>> > license.txt, etc.
>>>
>>> Interesting. I was just comparing with LLVM's root .gitignore, which
>>> doesn't have leading slashes for many dirs. Checking the gitignore
>>> doc, it sounds like you've got it right :-)
>>>
>>>
>>> >> > +# Generated and copied files
>>> >> > +/ClangFormat/Key.snk
>>> >> > +/ClangFormat/license.txt
>>> >> > +/ClangFormat/clang-format.exe
>>> >> > +/ClangFormat/source.extension.vsixmanifest
>>> >> > diff --git a/tools/clang-format-vs/CMakeLists.txt
>>> >> > b/tools/clang-format-vs/CMakeLists.txt
>>> >> > index fd0d6b0..90f89d8 100644
>>> >> > --- a/tools/clang-format-vs/CMakeLists.txt
>>> >> > +++ b/tools/clang-format-vs/CMakeLists.txt
>>> >> > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
>>> >> >configure_file("source.extension.vsixmanifest.in"
>>> >> >
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
>>> >> >
>>> >> > -  add_custom_target(clang_format_vsix ALL
>>> >> > -  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build
>>> >> > Release
>>> >> > +  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH})
>>> >> > +  if (NOT NUGET_EXE)
>>> >> > + message(FATAL_ERROR "Could not find nuget.exe. Download from
>>> >> > https://www.nuget.org/nuget.exe and add to PATH or pass path via
>>> >> > NUGET_EXE_PATH var")
>>> >>
>>> >> Can you break this string over multiple lines? I know there are pretty
>>> >> long lines in this file already, but it would be good to not make it
>>> >> worse.
>>> >
>>> >
>>> > Sure thing, I'll see what I can do :)
>>> >
>>> >>
>>> >>
>>> >> Maybe it could be clarified that NUGET_EXE_PATH is the path to a
>>> >> directory containing nuget.exe, not to the file itself (I ran into
>>> >> this). Maybe NUGET_EXE_DIR would be a better name?
>>> >
>>> >
>>> > That would be a better name, will make that change.
>>> >
>>> >>
>>> >>
>>> >> > +  endif()
>>> >> > +
>>> >> > +  add_custom_target(clang_format_vsix ALL
>>> >> > +  ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
>>> >> > &
>>> >> > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
>>> >>
>>> >> Is '&' a CMake thing, or should that be '&&'? Also, any chance of
>>> >> breaking these long lines?
>>> >
>>> >
>>> > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only
>>> > runs
>>> > the 2nd command if the first succeeds, while using '&' always runs both.
>>> > I'll make the change, and will try to shorten this line as well.
>>> >
>>> >>
>>> >>
>>> >> >DEPENDS clang_format_exe_for_vsix
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
>>> >> >COMMAND ${CMAKE_COMMAND} -E copy_if_different
>>> >> >
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
>>> >> > diff --git a/tools/clang-format-vs/README.txt
>>> >> > b/tools/clang-format-vs/README.txt
>>> >> > index b23355d..44a071b 100644
>>> >> > --- a/tools/clang-format-vs/README.txt
>>> >> > +++ b/tools/clang-format-vs/README.txt
>>> >> > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to
>>> >> > generate a Visual Studio extensio
>>> >> >  for clang-format.
>>> >> >
>>> >> >  Build prerequisites are:
>>> >> > -- Visual Studio 2013 Professional
>>> >> > -- Visual Studio 2013 SDK
>>> >> > -- Visual Studio 2010 Professional (?)
>>> >> > -- Visual Studio 2010 SDK (?)
>>> >> > +- Visual Studio 2015
>>> >> > +- Extensions SDK (you'll be prompted to install it if you open
>>> >> > ClangFormat.sln)
>>> >>
>>> >> A very nice simplification :-)
>>> >
>>> >
>>> > Thanks :)
>>> >
>>>

r288394 - swiftcc: Add an api to query whether a target ABI stores swifterror in a register

2016-12-01 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Thu Dec  1 12:07:38 2016
New Revision: 288394

URL: http://llvm.org/viewvc/llvm-project?rev=288394&view=rev
Log:
swiftcc: Add an api to query whether a target ABI stores swifterror in a 
register

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

Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=288394&r1=288393&r2=288394&view=diff
==
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Thu Dec  1 12:07:38 2016
@@ -160,6 +160,9 @@ ABIArgInfo classifyArgumentType(CodeGenM
 /// private interface for Clang.
 void computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI);
 
+/// Is swifterror lowered to a register by the target ABI.
+bool isSwiftErrorLoweredInRegister(CodeGenModule &CGM);
+
 } // end namespace swiftcall
 } // end namespace CodeGen
 } // end namespace clang

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=288394&r1=288393&r2=288394&view=diff
==
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Dec  1 12:07:38 2016
@@ -142,6 +142,8 @@ namespace swiftcall {
llvm::Type *eltTy,
unsigned elts) const;
 
+virtual bool isSwiftErrorInRegister() const = 0;
+
 static bool classof(const ABIInfo *info) {
   return info->supportsSwift();
 }

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=288394&r1=288393&r2=288394&view=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Dec  1 12:07:38 2016
@@ -828,3 +828,8 @@ void swiftcall::computeABIInfo(CodeGenMo
 argInfo.info = classifyArgumentType(CGM, argInfo.type);
   }
 }
+
+// Is swifterror lowered to a register by the target ABI.
+bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule &CGM) {
+  return getSwiftABIInfo(CGM).isSwiftErrorInRegister();
+}

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=288394&r1=288393&r2=288394&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Dec  1 12:07:38 2016
@@ -958,6 +958,11 @@ public:
 // scalar registers.
 return occupiesMoreThan(CGT, scalars, /*total*/ 3);
   }  
+
+  bool isSwiftErrorInRegister() const override {
+// x86-32 lowering does not support passing swifterror in a register.
+return false;
+  }
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -2012,6 +2017,9 @@ public:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }  
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 /// WinX86_64ABIInfo - The Windows X86_64 ABI information.
@@ -2043,6 +2051,10 @@ public:
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
 
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
+
 private:
   ABIArgInfo classify(QualType Ty, unsigned &FreeSSERegs,
   bool IsReturnType) const;
@@ -4628,6 +4640,9 @@ private:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5181,6 +5196,9 @@ private:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5949,6 +5967,9 @@ public:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {


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


[PATCH] D27310: Handle tests for noexcept that expect a false value

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in 
the usual setting to return false. Wrap these tests in a convenience macro.


https://reviews.llvm.org/D27310

Files:
  test/libcxx/strings/iterators.exceptions.pass.cpp


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // 
 
 // __libcpp_is_trivial_iterator
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator > > ::value), "");
 
 //  iterators in the libc++ test suite
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 
 #if TEST_STD_VER >= 11
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
 #else
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 #endif
 
 //


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // 
 
 // __libcpp_is_trivial_iterator
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
 static_assert(( std::__libcpp_string_gets_noexcept_iterator > > ::value), "");
 
 //  iterators in the libc++ test suite
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 
 #if TEST_STD_VER >= 11
 static_

[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path

2016-12-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D27298



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


r288397 - [clang] Implement support for -defsym assembler option

2016-12-01 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Thu Dec  1 12:42:16 2016
New Revision: 288397

URL: http://llvm.org/viewvc/llvm-project?rev=288397&view=rev
Log:
[clang] Implement support for -defsym assembler option

Summary:
Adds support for -Wa,-defsym,abc=1 option.

Related llvm patch: https://reviews.llvm.org/D26214

Reviewers: rafael, t.p.northover, colinl, echristo, compnerd, rengolin

Subscribers: mehdi_amini

Tags: #clang-c

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

Added:
cfe/trunk/test/Driver/defsym.s
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=288397&r1=288396&r2=288397&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Dec  1 12:42:16 2016
@@ -743,4 +743,6 @@ def show_inst : Flag<["-"], "show-inst">
 def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
   HelpText<"The string to embed in the Dwarf debug AT_producer record.">;
 
+def defsym : Separate<["-"], "defsym">,
+  HelpText<"Define a value for a symbol">;
 } // let Flags = [CC1AsOption]

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288397&r1=288396&r2=288397&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec  1 12:42:16 2016
@@ -3115,6 +3115,9 @@ static void CollectArgsForIntegratedAsse
   } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") ||
  Value.startswith("-mhwdiv") || Value.startswith("-march")) {
 // Do nothing, we'll validate it later.
+  } else if (Value == "-defsym") {
+  CmdArgs.push_back(Value.data());
+  TakeNextArg = true;
   } else {
 D.Diag(diag::err_drv_unsupported_option_argument)
 << A->getOption().getName() << Value;

Added: cfe/trunk/test/Driver/defsym.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/defsym.s?rev=288397&view=auto
==
--- cfe/trunk/test/Driver/defsym.s (added)
+++ cfe/trunk/test/Driver/defsym.s Thu Dec  1 12:42:16 2016
@@ -0,0 +1,22 @@
+// RUN: %clang -### -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+
+// RUN: %clang -### -c -no-integrated-as %s \
+// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+
+// CHECK-DEFSYM1: "-defsym"
+// CHECK-DEFSYM1: "abc=5"
+// CHECK-DEFSYM1: "-defsym"
+// CHECK-DEFSYM1: "xyz=0xa"
+
+// RUN: not %clang -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc= \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
+// CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
+
+// RUN: not %clang -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
+// CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=288397&r1=288396&r2=288397&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Dec  1 12:42:16 2016
@@ -77,6 +77,9 @@ struct AssemblerInvocation {
   /// be a list of strings starting with '+' or '-'.
   std::vector Features;
 
+  /// The list of symbol definitions.
+  std::vector SymbolDefs;
+
   /// @}
   /// @name Language Options
   /// @{
@@ -252,6 +255,7 @@ bool AssemblerInvocation::CreateFromArgs
   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
   Opts.IncrementalLinkerCompatible =
   Args.hasArg(OPT_mincremental_linker_compatible);
+  Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
 
   return Success;
 }
@@ -420,6 +424,14 @@ static bool ExecuteAssembler(AssemblerIn
   if (!TAP)
 Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
 
+  // Set values for symbols, if any.
+  for (auto &S : Opts.SymbolDefs) {
+if (Ctx.setSymbolValue(Parser->getStreamer(), S)) {
+  Failed = true;
+  break;
+}
+  }
+
   if (!Failed) {
 Parser->setTargetParser(*TAP.get());
 Failed = Parser->Run(Opts.NoInitialTextSection);


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


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-01 Thread Justin Lebar via Phabricator via cfe-commits
jlebar updated this revision to Diff 79951.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Update test, use "auto".  Still need to figure out how to lex these function 
calls properly.


https://reviews.llvm.org/D27284

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
  clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp

Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
@@ -0,0 +1,326 @@
+// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t
+
+double acos(double);
+double acosh(double);
+double asin(double);
+double asinh(double);
+double atan2(double);
+double atan(double);
+double atanh(double);
+double cbrt(double);
+double ceil(double);
+double copysign(double, double);
+double cos(double);
+double cosh(double);
+double erfc(double);
+double erf(double);
+double exp2(double);
+double exp(double);
+double expm1(double);
+double fabs(double);
+double fdim(double, double);
+double floor(double);
+double fma(double, double, double);
+double fmax(double, double);
+double fmin(double, double);
+double fmod(double, double);
+double frexp(double, int *);
+double hypot(double, double);
+double ilogb(double);
+double ldexp(double, double);
+double lgamma(double);
+long long llrint(double);
+double log10(double);
+double log1p(double);
+double log2(double);
+double logb(double);
+double log(double);
+long lrint(double);
+double modf(double);
+double nearbyint(double);
+double nextafter(double, double);
+double nexttoward(double, long double);
+double pow(double, double);
+double remainder(double, double);
+double remquo(double, double, int *);
+double rint(double);
+double round(double);
+double scalbln(double, long);
+double scalbn(double, int);
+double sin(double);
+double sinh(double);
+double sqrt(double);
+double tan(double);
+double tanh(double);
+double tgamma(double);
+double trunc(double);
+long long llround(double);
+long lround(double);
+
+void check_all_fns() {
+  float a, b, c;
+  int i;
+  long l;
+  int *int_ptr;
+
+  acos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn]
+  // CHECK-FIXES: {{^}}  acosf(a);{{$}}
+  acosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh'
+  // CHECK-FIXES: {{^}}  acoshf(a);{{$}}
+  asin(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin'
+  // CHECK-FIXES: {{^}}  asinf(a);{{$}}
+  asinh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh'
+  // CHECK-FIXES: {{^}}  asinhf(a);{{$}}
+  atan2(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2'
+  // CHECK-FIXES: {{^}}  atan2f(a);{{$}}
+  atan(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan'
+  // CHECK-FIXES: {{^}}  atanf(a);{{$}}
+  atanh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh'
+  // CHECK-FIXES: {{^}}  atanhf(a);{{$}}
+  cbrt(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt'
+  // CHECK-FIXES: {{^}}  cbrtf(a);{{$}}
+  ceil(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil'
+  // CHECK-FIXES: {{^}}  ceilf(a);{{$}}
+  copysign(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign'
+  // CHECK-FIXES: {{^}}  copysignf(a, b);{{$}}
+  cos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos'
+  // CHECK-FIXES: {{^}}  cosf(a);{{$}}
+  cosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh'
+  // CHECK-FIXES: {{^}}  coshf(a);{{$}}
+  erf(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf'
+  // CHECK-FIXES: {{^}}  erff(a);{{$}}
+  erfc(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc'
+  // CHECK-FIXES: {{^}}  erfcf(a);{{$}}
+  exp2(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2'
+  // CHECK-FIXES: {{^}}  exp2f(a);{{$}}
+  exp(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp'
+  // CHECK-FIXES: {{^}}  expf(a);{{$}}
+  expm1(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1'
+  // CHECK-FIXES: {{^}}  expm1f(a);{{$}}
+  fabs(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs'
+  // CHECK-FIXES: {{^}}  fabsf(a);{{$}}
+  fdim(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fdim'
+  // CHECK-FIXES: {{^}}  fdimf(a, b);{{$}}
+  floor(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'floor'
+  // CHECK-FIXES: {{^}}  floorf(a);{{$}}
+  fma(a, b, c);
+ 

[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-01 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2),
+   hasBuiltinTyParam(0, DoubleTy),
+   hasBuiltinTyParam(1, DoubleTy))),
+   hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy))
+  .bind("call"),

alexfh wrote:
> I guess, functions with arbitrary number of parameters can all be handled 
> using `forEachArgumentWithParam`. Roughly like this:
> 
>   forEachArgumentWithParam(
>  hasType(isBuiltinType(FloatTy)),
>  parmVarDecl(hasType(isBuiltinType(DoubleTy)))
> 
> One difference to your existing implementation will be that it will match 
> calls where at least one parameter is double and argument is float, not all 
> of them. Do you expect this to make the check more noisy? 
> Do you expect this to make the check more noisy?

Yes, to the point of not being worth doing, I think.

Specifically, I think there is nothing wrong with calling a two-arg function 
double function with one float and one double arg and expecting the float arg 
to be promoted: `::hypot(3.f, 4.)` probably *should* call the double version.

So checking that the arg types are all `float` is important, I think.  Checking 
that the parameter types are all `double` is less important but also worth 
doing, I think, so if you declare some bizarre function in the global namespace 
called e.g. `::hypot`, we won't suggest changing that to `::hypotf`.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145
+  // Skip the "::" following the qualifier.
+  FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2);
+}

alexfh wrote:
> `getLocWithOffset` makes the code quite brittle. Imagine whitespace around 
> `::`, for example. Same below. In order to make this kind of code more 
> robust, you can operate on tokens (using Lexer).
> 
> Same below.
Hm.  I agree this is super-brittle.  But I am having a lot of difficulty using 
the Lexer successfully.

For one thing, there may be comments basically anywhere in this stream, and I 
have to skip over them.  I see getPreviousNonCommentToken, but it doesn't quite 
work if I need to go *forward* in the stream.  I looked at a bunch of other 
uses of the Lexer in clang-tidy and they all looked pretty different from what 
I'm trying to do here, which also suggested that maybe I'm doing the wrong 
thing.

Is there no way to get the source location of "sin" out of the DeclRefExpr for 
"::sin"?  I don't see it, but it seems bizarre that it wouldn't be there.

Any tips would be much appreciated.


https://reviews.llvm.org/D27284



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


[PATCH] D26691: [analyzer] Run clang-format and fix style

2016-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D26691#610292, @zaks.anna wrote:

> I am not a big fan of loosing svn blame only to fix formatting, but since you 
> are modifying this code anyway, it's fine by me.
>
> Artem and Devin, what is your opinion on this?


I agree that in general it is not good to lose the annotation information, but 
if you're fine with it I'm fine with it.


https://reviews.llvm.org/D26691



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 79958.
madsravn marked 5 inline comments as done.
madsravn added a comment.

Updated according to comments. Still missing fixit.


https://reviews.llvm.org/D27210

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringCompareCheck.cpp
  clang-tidy/misc/StringCompareCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-compare.rst
  test/clang-tidy/misc-string-compare.cpp

Index: test/clang-tidy/misc-string-compare.cpp
===
--- test/clang-tidy/misc-string-compare.cpp
+++ test/clang-tidy/misc-string-compare.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-string-compare %t -- -- -std=c++11
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  int compare(const basic_string &str);
+  bool empty();
+};
+bool operator==(const basic_string &lhs, const basic_string &rhs);
+bool operator!=(const basic_string &lhs, const basic_string &rhs);
+typedef basic_string string;
+}
+
+void func(bool b);
+
+void Test() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+
+  if (str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (!str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (0 == str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (0 != str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  func(str1.compare(str2));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: do not use compare to test equality of strings;
+  if (str2.empty() || str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: do not use compare to test equality of strings;
+}
+
+void Valid() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+  if (str1 == str2) {
+  }
+  if (str1 != str2) {
+  }
+  if (str1.compare(str2) == 1) {
+  }
+  if (str1.compare(str2) == str1.compare(str2)) {
+  }
+  if (0 == 0) {
+  }
+  if (1 == str1.compare(str2)) {
+  }
+  if (str1.compare(str2) > 0) {
+  }
+}
Index: docs/clang-tidy/checks/misc-string-compare.rst
===
--- docs/clang-tidy/checks/misc-string-compare.rst
+++ docs/clang-tidy/checks/misc-string-compare.rst
@@ -0,0 +1,47 @@
+.. title:: clang-tidy - misc-string-compare
+
+misc-string-compare
+===
+
+Finds string comparisons using the compare method.
+
+A common mistake is to use the string's ``compare`` method instead of using the 
+equality or inequality operators. The compare method is intended for sorting
+functions and thus returns ``-1``, ``0`` or ``1`` depending on the lexicographical 
+relationship between the strings compared. If an equality or inequality check
+can suffice, that is recommended.
+
+Examples:
+
+.. code-block:: c++
+
+  std::string str1{"a"};
+  std::string str2{"b"};
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (!str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (str1.compare(str2) == 0) {
+  }
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2) != 0) {
+  }
+
+  // use str1 == str2 instead.
+  if (0 == str1.compare(str2)) {
+  }
+
+  // use str1 != str2 instead.
+  if (0 != str1.compare(str2)) {
+  }
+
+The above code examples shows the list of if-statements that this check will
+give a warning for. All of them uses ``compare`` to check if equality or 
+inequality of two strings instead of using the correct operators.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -80,6 +80,7 @@
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
+   misc-string-compare
misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -75,6 +75,11 @@
 
 - `misc-pointer-and-integral-operation` check was removed.
 
+- New `misc-string-compare
+  

r288404 - [CodeGen][ARM] Make sure the value and type used to create a bitcast

2016-12-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Dec  1 13:25:14 2016
New Revision: 288404

URL: http://llvm.org/viewvc/llvm-project?rev=288404&view=rev
Log:
[CodeGen][ARM] Make sure the value and type used to create a bitcast
have the same size.

This fixes an asset that is triggered when an address of a boolean
variable is passed to __builtin_arm_ldrex or __builtin_arm_strex.

rdar://problem/29269006

Added:
cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=288404&r1=288403&r2=288404&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec  1 13:25:14 2016
@@ -4438,19 +4438,21 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 
 QualType Ty = E->getType();
 llvm::Type *RealResTy = ConvertType(Ty);
-llvm::Type *IntResTy = llvm::IntegerType::get(getLLVMContext(),
-  
getContext().getTypeSize(Ty));
-LoadAddr = Builder.CreateBitCast(LoadAddr, IntResTy->getPointerTo());
+llvm::Type *PtrTy = llvm::IntegerType::get(
+getLLVMContext(), getContext().getTypeSize(Ty))->getPointerTo();
+LoadAddr = Builder.CreateBitCast(LoadAddr, PtrTy);
 
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_ldaex
? Intrinsic::arm_ldaex
: Intrinsic::arm_ldrex,
-   LoadAddr->getType());
+   PtrTy);
 Value *Val = Builder.CreateCall(F, LoadAddr, "ldrex");
 
 if (RealResTy->isPointerTy())
   return Builder.CreateIntToPtr(Val, RealResTy);
 else {
+  llvm::Type *IntResTy = llvm::IntegerType::get(
+  getLLVMContext(), CGM.getDataLayout().getTypeSizeInBits(RealResTy));
   Val = Builder.CreateTruncOrBitCast(Val, IntResTy);
   return Builder.CreateBitCast(Val, RealResTy);
 }
@@ -4491,7 +4493,10 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 if (StoreVal->getType()->isPointerTy())
   StoreVal = Builder.CreatePtrToInt(StoreVal, Int32Ty);
 else {
-  StoreVal = Builder.CreateBitCast(StoreVal, StoreTy);
+  llvm::Type *IntTy = llvm::IntegerType::get(
+  getLLVMContext(),
+  CGM.getDataLayout().getTypeSizeInBits(StoreVal->getType()));
+  StoreVal = Builder.CreateBitCast(StoreVal, IntTy);
   StoreVal = Builder.CreateZExtOrBitCast(StoreVal, Int32Ty);
 }
 
@@ -5265,19 +5270,21 @@ Value *CodeGenFunction::EmitAArch64Built
 
 QualType Ty = E->getType();
 llvm::Type *RealResTy = ConvertType(Ty);
-llvm::Type *IntResTy = llvm::IntegerType::get(getLLVMContext(),
-  
getContext().getTypeSize(Ty));
-LoadAddr = Builder.CreateBitCast(LoadAddr, IntResTy->getPointerTo());
+llvm::Type *PtrTy = llvm::IntegerType::get(
+getLLVMContext(), getContext().getTypeSize(Ty))->getPointerTo();
+LoadAddr = Builder.CreateBitCast(LoadAddr, PtrTy);
 
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_ldaex
? Intrinsic::aarch64_ldaxr
: Intrinsic::aarch64_ldxr,
-   LoadAddr->getType());
+   PtrTy);
 Value *Val = Builder.CreateCall(F, LoadAddr, "ldxr");
 
 if (RealResTy->isPointerTy())
   return Builder.CreateIntToPtr(Val, RealResTy);
 
+llvm::Type *IntResTy = llvm::IntegerType::get(
+getLLVMContext(), CGM.getDataLayout().getTypeSizeInBits(RealResTy));
 Val = Builder.CreateTruncOrBitCast(Val, IntResTy);
 return Builder.CreateBitCast(Val, RealResTy);
   }
@@ -5316,7 +5323,10 @@ Value *CodeGenFunction::EmitAArch64Built
 if (StoreVal->getType()->isPointerTy())
   StoreVal = Builder.CreatePtrToInt(StoreVal, Int64Ty);
 else {
-  StoreVal = Builder.CreateBitCast(StoreVal, StoreTy);
+  llvm::Type *IntTy = llvm::IntegerType::get(
+  getLLVMContext(),
+  CGM.getDataLayout().getTypeSizeInBits(StoreVal->getType()));
+  StoreVal = Builder.CreateBitCast(StoreVal, IntTy);
   StoreVal = Builder.CreateZExtOrBitCast(StoreVal, Int64Ty);
 }
 

Added: cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp?rev=288404&view=auto
==
--- cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp Thu Dec  1 13:25:14 
2016
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -Wall -Werror -triple thumbv8-linux-gnueabi 
-fno-signed-char -emit-llvm -o - %s | FileCheck %s
+// RUN: %

r288406 - Send compiler output to /dev/null in defsym.s test.

2016-12-01 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Dec  1 13:34:35 2016
New Revision: 288406

URL: http://llvm.org/viewvc/llvm-project?rev=288406&view=rev
Log:
Send compiler output to /dev/null in defsym.s test.

Fixes test failures if tests are run in a read-only source tree.

Modified:
cfe/trunk/test/Driver/defsym.s

Modified: cfe/trunk/test/Driver/defsym.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/defsym.s?rev=288406&r1=288405&r2=288406&view=diff
==
--- cfe/trunk/test/Driver/defsym.s (original)
+++ cfe/trunk/test/Driver/defsym.s Thu Dec  1 13:34:35 2016
@@ -11,12 +11,12 @@
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "xyz=0xa"
 
-// RUN: not %clang -c -integrated-as %s \
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc= \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
 // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
 
-// RUN: not %clang -c -integrated-as %s \
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc=1a2b3c \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
 // CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c


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


[PATCH] D27068: Improve string::find

2016-12-01 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/__string:543
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+_RandomAccessIterator
+__search_substring(_RandomAccessIterator __first1, _RandomAccessIterator 
__last1,

A character traits class need only accept pointers, so the name 
`_RandomAccessIterator` is misleading when you are passing them directly to 
`_Traits::find`/`_Traits::compare`. Why not just `const _CharT*`? Then you can 
strip out all the `iterator_traits` circumlocution as well.



Comment at: include/__string:548
+using __iterator_traits = iterator_traits<_RandomAccessIterator>;
+typedef typename __iterator_traits::difference_type __difference_type;
+

For example, since `_RandomAccessIterator` must be a pointer type, this can't 
possibly be anything other than `ptrdiff_t`.



Comment at: include/__string:568
+  __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
+  if (__first1 == _RandomAccessIterator(0))
+return __last1;

The function-style cast is redundant.


https://reviews.llvm.org/D27068



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 79961.
madsravn added a comment.

Fixed broken tests.


https://reviews.llvm.org/D27210

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringCompareCheck.cpp
  clang-tidy/misc/StringCompareCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-compare.rst
  test/clang-tidy/misc-string-compare.cpp

Index: test/clang-tidy/misc-string-compare.cpp
===
--- test/clang-tidy/misc-string-compare.cpp
+++ test/clang-tidy/misc-string-compare.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-string-compare %t -- -- -std=c++11
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  int compare(const basic_string &str);
+  bool empty();
+};
+bool operator==(const basic_string &lhs, const basic_string &rhs);
+bool operator!=(const basic_string &lhs, const basic_string &rhs);
+typedef basic_string string;
+}
+
+void func(bool b);
+
+void Test() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+
+  if (str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (!str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (0 == str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (0 != str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  func(str1.compare(str2));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: do not use compare to test equality of strings;
+  if (str2.empty() || str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: do not use compare to test equality of strings;
+}
+
+void Valid() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+  if (str1 == str2) {
+  }
+  if (str1 != str2) {
+  }
+  if (str1.compare(str2) == 1) {
+  }
+  if (str1.compare(str2) == str1.compare(str2)) {
+  }
+  if (0 == 0) {
+  }
+  if (1 == str1.compare(str2)) {
+  }
+  if (str1.compare(str2) > 0) {
+  }
+}
Index: docs/clang-tidy/checks/misc-string-compare.rst
===
--- docs/clang-tidy/checks/misc-string-compare.rst
+++ docs/clang-tidy/checks/misc-string-compare.rst
@@ -0,0 +1,47 @@
+.. title:: clang-tidy - misc-string-compare
+
+misc-string-compare
+===
+
+Finds string comparisons using the compare method.
+
+A common mistake is to use the string's ``compare`` method instead of using the 
+equality or inequality operators. The compare method is intended for sorting
+functions and thus returns ``-1``, ``0`` or ``1`` depending on the lexicographical 
+relationship between the strings compared. If an equality or inequality check
+can suffice, that is recommended.
+
+Examples:
+
+.. code-block:: c++
+
+  std::string str1{"a"};
+  std::string str2{"b"};
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (!str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (str1.compare(str2) == 0) {
+  }
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2) != 0) {
+  }
+
+  // use str1 == str2 instead.
+  if (0 == str1.compare(str2)) {
+  }
+
+  // use str1 != str2 instead.
+  if (0 != str1.compare(str2)) {
+  }
+
+The above code examples shows the list of if-statements that this check will
+give a warning for. All of them uses ``compare`` to check if equality or 
+inequality of two strings instead of using the correct operators.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -80,6 +80,7 @@
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
+   misc-string-compare
misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -75,6 +75,11 @@
 
 - `misc-pointer-and-integral-operation` check was removed.
 
+- New `misc-string-compare
+  `_ check
+
+  Warns about using ``compare`` to te

[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen created this revision.
jhen added a reviewer: jlebar.
jhen added a subscriber: cfe-commits.

This adds to the work from https://reviews.llvm.org/rL281680. This patch
takes care of another execution path in which sanitizer arguments can be
considered for NVPTX because they are used for the corresponding host
code.


https://reviews.llvm.org/D27316

Files:
  lib/Driver/SanitizerArgs.cpp


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -206,6 +206,12 @@
 
   for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend();
I != E; ++I) {
+// NVPTX doesn't currently support sanitizers, but sanitizer arguments can
+// still appear on the command line for host code. This means that we must
+// explicitly ignore sanitizer flags here for device code compilation.
+if (TC.getTriple().isNVPTX()) {
+  break;
+}
 const auto *Arg = *I;
 if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) {
   Arg->claim();


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -206,6 +206,12 @@
 
   for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend();
I != E; ++I) {
+// NVPTX doesn't currently support sanitizers, but sanitizer arguments can
+// still appear on the command line for host code. This means that we must
+// explicitly ignore sanitizer flags here for device code compilation.
+if (TC.getTriple().isNVPTX()) {
+  break;
+}
 const auto *Arg = *I;
 if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) {
   Arg->claim();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288414 - Add a space in a run line. NFC.

2016-12-01 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec  1 14:16:56 2016
New Revision: 288414

URL: http://llvm.org/viewvc/llvm-project?rev=288414&view=rev
Log:
Add a space in a run line. NFC.

Modified:
cfe/trunk/test/CodeGenCXX/enable_if.cpp

Modified: cfe/trunk/test/CodeGenCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/enable_if.cpp?rev=288414&r1=288413&r2=288414&view=diff
==
--- cfe/trunk/test/CodeGenCXX/enable_if.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/enable_if.cpp Thu Dec  1 14:16:56 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu| FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
 
 // Test address-of overloading logic
 int test5(int);


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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Visoiu Mistrih Francis via Phabricator via cfe-commits
thegameg added a comment.

In https://reviews.llvm.org/D27304#610697, @joerg wrote:

> I think this is the absolutely wrong place to put such logic. It really can 
> not be anywhere but the backend.


I am aware of this. But the way the backend informs the Diagnostics looks like 
a crash, and asks for a bug report.

Are there any proper ways to inform the frontend about backend errors?


https://reviews.llvm.org/D27304



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via cfe-commits
Hi Malcolm,

Thanks for the suggestions, I have been reading up on the fixits.
My initial four cases has been reduced to two a little more general cases:
1 & 2: implicitCast to bool str1.compare(str2). This case covers both
!str1.compare(str2) and str1.compare(str2)
3 & 4: str1.compare(str2) == 0 and str1.compare(str2) != 0.

I see the idea for the fixit clearly for case 3 & 4. Just erase
.compare(str2) and replace 0 with str2. I have a quick question though:
Given the declRefExpr().bind("str2"), how do I read the name of it in
clang-tidy? Or should I just bind 0 as well and then create replacement
with str where const auto str = Result.Nodes.getNodeAs("str2") ?

Where I seem to find a little trouble is how to fixit case 1 & 2 now that
they are reduced to one case. How do I check whether or not there is a
unary operator in front of the implicitCast?

Thank you,
Mads Ravn

On Thu, Dec 1, 2016 at 8:53 PM Mads Ravn via Phabricator <
revi...@reviews.llvm.org> wrote:

> madsravn updated this revision to Diff 79961.
> madsravn added a comment.
>
> Fixed broken tests.
>
>
> https://reviews.llvm.org/D27210
>
> Files:
>   clang-tidy/misc/CMakeLists.txt
>   clang-tidy/misc/MiscTidyModule.cpp
>   clang-tidy/misc/StringCompareCheck.cpp
>   clang-tidy/misc/StringCompareCheck.h
>   docs/ReleaseNotes.rst
>   docs/clang-tidy/checks/list.rst
>   docs/clang-tidy/checks/misc-string-compare.rst
>   test/clang-tidy/misc-string-compare.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D27304#610944, @thegameg wrote:

> In https://reviews.llvm.org/D27304#610697, @joerg wrote:
>
> > I think this is the absolutely wrong place to put such logic. It really can 
> > not be anywhere but the backend.
>
>
> I am aware of this. But the way the backend informs the Diagnostics looks 
> like a crash, and asks for a bug report.
>
> Are there any proper ways to inform the frontend about backend errors?


Yes. Look at how we report inline asm errors, etc. grep for 
DiagnosticInfoStackSize (used in PEI) or DiagnosticInfoResourceLimit (used by 
the AMDGPU backend).


https://reviews.llvm.org/D27304



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


[PATCH] D26922: [ObjC++] Don't enter a C++ declarator context when the current context is an Objective-C declaration

2016-12-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

I think this is fine.

I guess we can print a more helpful error message than "error: property 
requires fields to be named", but we can probably do it later.


Repository:
  rL LLVM

https://reviews.llvm.org/D26922



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


  1   2   >