[PATCH] D46386: Adding __atomic_fetch_min/max intrinsics to clang

2018-05-11 Thread Elena Demikhovsky via Phabricator via cfe-commits
delena updated this revision to Diff 146462.
delena added a comment.

Added a line about *load-store* semantics of these two intrinsics.
Removed the common description of memory modeling.


Repository:
  rC Clang

https://reviews.llvm.org/D46386

Files:
  LanguageExtensions.rst


Index: LanguageExtensions.rst
===
--- LanguageExtensions.rst
+++ LanguageExtensions.rst
@@ -1975,6 +1975,32 @@
 Support for constant expression evaluation for the above builtins be detected
 with ``__has_feature(cxx_constexpr_string_builtins)``.
 
+Atomic Min/Max builtins with memory ordering
+
+
+There are two atomic builtins with min/max in-memory comparison and swap.
+The syntax and semantics are similar to GCC-compatible __atomic_* builtins.
+
+* ``__atomic_fetch_min`` 
+* ``__atomic_fetch_max`` 
+
+The builtins work with signed and unsigned integers and require to specify 
memory ordering.
+The return value is the original value that was stored in memory before 
comparison.
+
+Example:
+
+.. code-block:: c
+
+  unsigned int val = __atomic_fetch_min(unsigned int *pi, unsigned int ui, 
__ATOMIC_RELAXED);
+
+The third argument is one of the memory ordering specifiers 
``__ATOMIC_RELAXED``,
+``__ATOMIC_CONSUME``, ``__ATOMIC_ACQUIRE``, ``__ATOMIC_RELEASE``,
+``__ATOMIC_ACQ_REL``, or ``__ATOMIC_SEQ_CST`` following C++11 memory model 
semantics.
+
+In terms or aquire-release ordering barriers these two operations are always
+considered as operations with *load-store* semantics, even when the original 
value
+is not actually modified after comparison.
+
 .. _langext-__c11_atomic:
 
 __c11_atomic builtins
@@ -2734,4 +2760,3 @@
 The ``#pragma comment(lib, ...)`` directive is supported on all ELF targets.
 The second parameter is the library name (without the traditional Unix prefix 
of
 ``lib``).  This allows you to provide an implicit link of dependent libraries.
-


Index: LanguageExtensions.rst
===
--- LanguageExtensions.rst
+++ LanguageExtensions.rst
@@ -1975,6 +1975,32 @@
 Support for constant expression evaluation for the above builtins be detected
 with ``__has_feature(cxx_constexpr_string_builtins)``.
 
+Atomic Min/Max builtins with memory ordering
+
+
+There are two atomic builtins with min/max in-memory comparison and swap.
+The syntax and semantics are similar to GCC-compatible __atomic_* builtins.
+
+* ``__atomic_fetch_min`` 
+* ``__atomic_fetch_max`` 
+
+The builtins work with signed and unsigned integers and require to specify memory ordering.
+The return value is the original value that was stored in memory before comparison.
+
+Example:
+
+.. code-block:: c
+
+  unsigned int val = __atomic_fetch_min(unsigned int *pi, unsigned int ui, __ATOMIC_RELAXED);
+
+The third argument is one of the memory ordering specifiers ``__ATOMIC_RELAXED``,
+``__ATOMIC_CONSUME``, ``__ATOMIC_ACQUIRE``, ``__ATOMIC_RELEASE``,
+``__ATOMIC_ACQ_REL``, or ``__ATOMIC_SEQ_CST`` following C++11 memory model semantics.
+
+In terms or aquire-release ordering barriers these two operations are always
+considered as operations with *load-store* semantics, even when the original value
+is not actually modified after comparison.
+
 .. _langext-__c11_atomic:
 
 __c11_atomic builtins
@@ -2734,4 +2760,3 @@
 The ``#pragma comment(lib, ...)`` directive is supported on all ELF targets.
 The second parameter is the library name (without the traditional Unix prefix of
 ``lib``).  This allows you to provide an implicit link of dependent libraries.
-
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-11 Thread Tom Rix via Phabricator via cfe-commits
trixirt created this revision.
trixirt added reviewers: echristo, jakehehrlich, emaste.
Herald added subscribers: cfe-commits, JDevlieghere, krytarowski, aprantl, 
mgorny.
Herald added a reviewer: alexshap.

Change CLANG_DEFAULT_OBJCOPY from objcopy to llvm-objcopy
Remove is-linux checks
Add dwarf splitting to FreeBSD's assembler job.


Repository:
  rC Clang

https://reviews.llvm.org/D46791

Files:
  CMakeLists.txt
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/split-debug.c
  test/Driver/split-debug.s

Index: test/Driver/split-debug.s
===
--- test/Driver/split-debug.s
+++ test/Driver/split-debug.s
@@ -6,12 +6,17 @@
 // CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
 // CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// RUN: %clang -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-CHECK-ACTIONS: llvm-objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-CHECK-ACTIONS: llvm-objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+// RUN: FileCheck -check-prefix=MACOSX-CHECK-ACTIONS < %t %s
 //
-// CHECK-NO-ACTIONS-NOT: -split-dwarf
-
+// MACOSX-CHECK-ACTIONS: llvm-objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// MACOSX-CHECK-ACTIONS: llvm-objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -o Bad.x -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-BAD < %t %s
Index: test/Driver/split-debug.c
===
--- test/Driver/split-debug.c
+++ test/Driver/split-debug.c
@@ -1,17 +1,31 @@
 // Check that we split debug output properly
 //
+// Linux
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
 // CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
 // CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// FreeBSD
+// RUN: %clang -fno-integrated-as -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-NOIA-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-NOIA-CHECK-ACTIONS: llvm-objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-NOIA-CHECK-ACTIONS: llvm-objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
+//
+// RUN: %clang -fintegrated-as -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-IA-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-IA-CHECK-ACTIONS: llvm-objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-IA-CHECK-ACTIONS: llvm-objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// Macosx
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+// RUN: FileCheck -check-prefix=MACOSX-CHECK-ACTIONS < %t %s
 //
-// CHECK-NO-ACTIONS-NOT: -split-dwarf
-
+// MACOSX-CHECK-ACTIONS: llvm-objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// MACOSX-CHECK-ACTIONS: llvm-objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -o Bad.x -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-BAD < %t %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -784,9 +784,7 @@
 
   // Handle the debug info splitting at object creation time if we're
   // creating an object.
-  // TODO: Currently only works on linux with newer objcopy.
-  if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux())
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
SplitDebugName(Args, Inputs[0]));
 }
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -115,6 +115,12 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+
+  // Handle the debug info splitting at object creation time if we're
+  // creating an object.
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(Args, Inputs[0]));
 }
 
 void freebsd::Linker::ConstructJob(Compilation , const JobAction ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3020,16 +3020,13 

r332164 - Add requirement of x86 target for test.

2018-05-11 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Fri May 11 17:39:17 2018
New Revision: 332164

URL: http://llvm.org/viewvc/llvm-project?rev=332164=rev
Log:
Add requirement of x86 target for test.


Modified:
cfe/trunk/test/Driver/clang-abi-compat.cpp

Modified: cfe/trunk/test/Driver/clang-abi-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-abi-compat.cpp?rev=332164=332163=332164=diff
==
--- cfe/trunk/test/Driver/clang-abi-compat.cpp (original)
+++ cfe/trunk/test/Driver/clang-abi-compat.cpp Fri May 11 17:39:17 2018
@@ -2,5 +2,7 @@
 // RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
 // RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
 
+// REQUIRES: x86-registered-target
+
 // CHECK-WARNING: warning: target requires clang ABI version 6, ignoring 
requested version
 


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


[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden

2018-05-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Everything old is new again. This was discussed when `-fclang-abi-compat` was 
introduced; see https://reviews.llvm.org/D36501 for the argument why this patch 
is the wrong way of modeling an ABI. Forcing the `ClangABICompat` language 
option as a way of "tricking" Clang into producing the PS4 ABI is a hack. The 
various ABI changes that `-fclang-abi-compat=` controls are simply part of the 
PS4 ABI, and that knowledge should idealistically be carried by the CodeGen 
(etc) code that knows about PS4, rather than by imagining that there is some 
other PS4 ABI that Clang would produces at version `Latest`, and that we're 
asking for a compatibility version of it.

That said, pragmatically speaking, that approach isn't working out well. We 
have systematically forgotten to special-case PS4 when adding ABI compatibility 
features, so I think I'm convinced that this hack is better than the status 
quo. This will go wrong if we ever release (or have ever released) a Clang 
version that fails to properly implement the PS4 ABI. In such a case, 
`-fclang-abi-compat` should be usable to request that we emulate past ABI bugs, 
but would actually have no effect on PS4. I think it's OK to cross that bridge 
if/when we come to it.

However, we should not issue a warning for use of the flag. Remember that the 
flag means "please be ABI-compatible with Clang version X.Y". Because all 
versions of Clang that target PS4 use the same ABI, the flag is a no-op on that 
target (at least for now, until we accidentally introduce an ABI break). So we 
should not be warning on it, just silently accepting it and doing what it says 
-- which for now is nothing.




Comment at: lib/Frontend/CompilerInvocation.cpp:2762
+}
+Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
+  }

Is `Ver6` really the right setting? When determining whether to pass objects of 
class type indirect, PS4 uses the Clang <= 4 rule, when determining how to pass 
a vector of 1 long long, it uses the Clang <= 3.8 rule, and so on. In 
SemaDeclCXX.cpp (in `paramCanBeDestoyedInCallee`), I found this comment:

  // The PS4 platform ABI follows the behavior of Clang 3.2.

So I *suspect* you should actually be setting this to `Ver3_8` (which is the 
oldest version we provide a compatibility flag for).


Repository:
  rC Clang

https://reviews.llvm.org/D46767



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


[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden

2018-05-11 Thread Douglas Yung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332160: Force the PS4 clang ABI version to 6. (authored by 
dyung, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46767

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/alignment.cpp
  test/Driver/clang-abi-compat.cpp


Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -150,6 +150,9 @@
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup;
+def warn_drv_ignored_clang_abi_version : Warning<
+  "target requires clang ABI version %0, ignoring requested version">,
+  InGroup;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,
Index: test/Driver/clang-abi-compat.cpp
===
--- test/Driver/clang-abi-compat.cpp
+++ test/Driver/clang-abi-compat.cpp
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted 
when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring 
requested version
+
Index: test/CodeGenCXX/alignment.cpp
===
--- test/CodeGenCXX/alignment.cpp
+++ test/CodeGenCXX/alignment.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | 
FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 
-fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
+// Check that the PS4 target uses the 6.0 compat settings.
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 
-fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
 
 extern int int_source();
 extern void int_sink(int x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2751,6 +2751,16 @@
   << A->getAsString(Args) << A->getValue();
 }
   }
+  // The PS4 requires version 6 of the clang ABI.
+  if (T.isPS4()) {
+// Issue a warning if another version of the ABI was requested.
+if (Args.getLastArg(OPT_fclang_abi_compat_EQ) &&
+Opts.getClangABICompat() != LangOptions::ClangABI::Ver6) {
+  Diags.Report(diag::warn_drv_ignored_clang_abi_version)
+<< 6;
+}
+Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
+  }
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {


Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -150,6 +150,9 @@
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup;
+def warn_drv_ignored_clang_abi_version : Warning<
+  "target requires clang ABI version %0, ignoring requested version">,
+  InGroup;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,
Index: test/Driver/clang-abi-compat.cpp
===
--- test/Driver/clang-abi-compat.cpp
+++ test/Driver/clang-abi-compat.cpp
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring requested version
+
Index: test/CodeGenCXX/alignment.cpp
===
--- test/CodeGenCXX/alignment.cpp
+++ test/CodeGenCXX/alignment.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s 

r332160 - Force the PS4 clang ABI version to 6.

2018-05-11 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Fri May 11 17:06:59 2018
New Revision: 332160

URL: http://llvm.org/viewvc/llvm-project?rev=332160=rev
Log:
Force the PS4 clang ABI version to 6.

The PS4 requires clang ABI version 6 for compatibility reasons. This change 
forces this and if the user specifies a different version when the PS4 target 
is specified, the compiler emits a warning that the specified version is being 
ignored.

Reviewers: probinson

Subscribers: cfe-commits

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


Added:
cfe/trunk/test/Driver/clang-abi-compat.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/alignment.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=332160=332159=332160=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 11 17:06:59 
2018
@@ -150,6 +150,9 @@ def warn_drv_unknown_argument_clang_cl :
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup;
+def warn_drv_ignored_clang_abi_version : Warning<
+  "target requires clang ABI version %0, ignoring requested version">,
+  InGroup;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=332160=332159=332160=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri May 11 17:06:59 2018
@@ -2751,6 +2751,16 @@ static void ParseLangArgs(LangOptions 
   << A->getAsString(Args) << A->getValue();
 }
   }
+  // The PS4 requires version 6 of the clang ABI.
+  if (T.isPS4()) {
+// Issue a warning if another version of the ABI was requested.
+if (Args.getLastArg(OPT_fclang_abi_compat_EQ) &&
+Opts.getClangABICompat() != LangOptions::ClangABI::Ver6) {
+  Diags.Report(diag::warn_drv_ignored_clang_abi_version)
+<< 6;
+}
+Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
+  }
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {

Modified: cfe/trunk/test/CodeGenCXX/alignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alignment.cpp?rev=332160=332159=332160=diff
==
--- cfe/trunk/test/CodeGenCXX/alignment.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alignment.cpp Fri May 11 17:06:59 2018
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | 
FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 
-fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
+// Check that the PS4 target uses the 6.0 compat settings.
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 
-fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
 
 extern int int_source();
 extern void int_sink(int x);

Added: cfe/trunk/test/Driver/clang-abi-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-abi-compat.cpp?rev=332160=auto
==
--- cfe/trunk/test/Driver/clang-abi-compat.cpp (added)
+++ cfe/trunk/test/Driver/clang-abi-compat.cpp Fri May 11 17:06:59 2018
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted 
when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring 
requested version
+


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


[libcxx] r332159 - [libcxx] [test] Update msvc_stdlib_force_include.hpp.

2018-05-11 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri May 11 16:57:32 2018
New Revision: 332159

URL: http://llvm.org/viewvc/llvm-project?rev=332159=rev
Log:
[libcxx] [test] Update msvc_stdlib_force_include.hpp.

Modified:
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=332159=332158=332159=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Fri May 11 16:57:32 
2018
@@ -55,10 +55,6 @@ const AssertionDialogAvoider assertion_d
 #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
 #define _MSVC_HAS_ATTRIBUTE_vector_size 0
 
-#ifdef _NOEXCEPT_TYPES_SUPPORTED
-#define __cpp_noexcept_function_type201510
-#endif // _NOEXCEPT_TYPES_SUPPORTED
-
 // Silence compiler warnings.
 #pragma warning(disable: 4180) // qualifier applied to function type has 
no meaning; ignored
 #pragma warning(disable: 4324) // structure was padded due to alignment 
specifier


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


[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden

2018-05-11 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D46767



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


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Emailed cfe-dev: http://lists.llvm.org/pipermail/cfe-dev/2018-May/057934.html


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45463#1096629, @rsmith wrote:

> In https://reviews.llvm.org/D45463#1096499, @jdenny wrote:
>
> > A few comments ago , I mentioned 
> > that IncludeTagDefinition's documentation and name is drifting farther from 
> > its functionality.  Should we do something about that?
>
>
> I think we should deprecate that flag, and change it to have no effect. It is 
> an implementation detail of the AST printer and should never have been 
> exposed by libclang in the first place.


Thanks.  I'll address that in a separate patch then.


https://reviews.llvm.org/D45463



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


[clang-tools-extra] r332152 - [clang-tidy] Fixing fuchsia-restrict-includes-headers test

2018-05-11 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri May 11 15:58:45 2018
New Revision: 332152

URL: http://llvm.org/viewvc/llvm-project?rev=332152=rev
Log:
[clang-tidy] Fixing fuchsia-restrict-includes-headers test

Removing filepaths so windows tests pass.

Modified:

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp?rev=332152=332151=332152=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
 Fri May 11 15:58:45 2018
@@ -10,12 +10,12 @@
 
 // transitive.h includes  and 
 #include 
-// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively 
included from 
{{(.*\/)*}}Headers/fuchsia-restrict-system-includes/system/transitive.h
-// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from 
{{(.*\/)*}}Headers/fuchsia-restrict-system-includes/system/transitive.h
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively 
included from {{.*}}
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from {{.*}}
 
 // transitive.h includes  and 
 #include "transitive2.h"
-// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from {{(.*\/)*}}Headers/fuchsia-restrict-system-includes/transitive2.h
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from {{.*}}
 // CHECK-FIXES-NOT: #include 
 
 int main() {


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


[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D45463#1096499, @jdenny wrote:

> A few comments ago , I mentioned 
> that IncludeTagDefinition's documentation and name is drifting farther from 
> its functionality.  Should we do something about that?


I think we should deprecate that flag, and change it to have no effect. It is 
an implementation detail of the AST printer and should never have been exposed 
by libclang in the first place.


https://reviews.llvm.org/D45463



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


[PATCH] D41241: [Solaris] Only define _REENTRANT if -pthread

2018-05-11 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev accepted this revision.
fedor.sergeev added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D41241



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


[clang-tools-extra] r332143 - [clang-tidy] Cleaning up test output (fuchsia-restrict-system-includes)

2018-05-11 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri May 11 14:28:34 2018
New Revision: 332143

URL: http://llvm.org/viewvc/llvm-project?rev=332143=rev
Log:
[clang-tidy] Cleaning up test output (fuchsia-restrict-system-includes)

This should fix the break in the fuchsia-restrict-system-includes-headers
test.

Modified:

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp?rev=332143=332142=332143=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
 Fri May 11 14:28:34 2018
@@ -1,20 +1,21 @@
-// RUN: mkdir %T/Inputs
-// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes 
%T/Inputs/fuchsia-restrict-system-includes
+// RUN: rm -rf %T/Headers
+// RUN: mkdir %T/Headers
+// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes 
%T/Headers/fuchsia-restrict-system-includes
 // RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
 // RUN:-- -config="{CheckOptions: [{key: 
fuchsia-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
 // RUN:   -system-headers -header-filter=.* \
-// RUN:   -- -std=c++11 -I %T/Inputs/fuchsia-restrict-system-includes -isystem 
%T/Inputs/fuchsia-restrict-system-includes/system
-// RUN: FileCheck 
-input-file=%T/Inputs/fuchsia-restrict-system-includes/transitive2.h %s 
-check-prefix=CHECK-FIXES
-// RUN: rm -rf %T/Inputs
+// RUN:   -- -std=c++11 -I %T/Headers/fuchsia-restrict-system-includes 
-isystem %T/Headers/fuchsia-restrict-system-includes/system
+// RUN: FileCheck 
-input-file=%T/Headers/fuchsia-restrict-system-includes/transitive2.h %s 
-check-prefix=CHECK-FIXES
+// RUN: rm -rf %T/Headers
 
 // transitive.h includes  and 
 #include 
-// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively 
included from 
{{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
-// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from 
{{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively 
included from 
{{(.*\/)*}}Headers/fuchsia-restrict-system-includes/system/transitive.h
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from 
{{(.*\/)*}}Headers/fuchsia-restrict-system-includes/system/transitive.h
 
 // transitive.h includes  and 
 #include "transitive2.h"
-// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/transitive2.h
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively 
included from {{(.*\/)*}}Headers/fuchsia-restrict-system-includes/transitive2.h
 // CHECK-FIXES-NOT: #include 
 
 int main() {


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


[clang-tools-extra] r332141 - Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"

2018-05-11 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri May 11 14:08:59 2018
New Revision: 332141

URL: http://llvm.org/viewvc/llvm-project?rev=332141=rev
Log:
Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"

This relands r332125 with a fixed test.

Added:
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=332141=332140=332141=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Fri May 11 
14:08:59 2018
@@ -5,6 +5,7 @@ add_clang_library(clangTidyFuchsiaModule
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp
   OverloadedOperatorCheck.cpp
+  RestrictSystemIncludesCheck.cpp
   StaticallyConstructedObjectsCheck.cpp
   TrailingReturnCheck.cpp
   VirtualInheritanceCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp?rev=332141=332140=332141=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp Fri May 11 
14:08:59 2018
@@ -14,6 +14,7 @@
 #include "DefaultArgumentsCheck.h"
 #include "MultipleInheritanceCheck.h"
 #include "OverloadedOperatorCheck.h"
+#include "RestrictSystemIncludesCheck.h"
 #include "StaticallyConstructedObjectsCheck.h"
 #include "TrailingReturnCheck.h"
 #include "VirtualInheritanceCheck.h"
@@ -36,6 +37,8 @@ public:
 "fuchsia-multiple-inheritance");
 CheckFactories.registerCheck(
 "fuchsia-overloaded-operator");
+CheckFactories.registerCheck(
+"fuchsia-restrict-system-includes");
 CheckFactories.registerCheck(
 "fuchsia-statically-constructed-objects");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp?rev=332141=auto
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
Fri May 11 14:08:59 2018
@@ -0,0 +1,118 @@
+//===--- RestrictSystemIncludesCheck.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 "RestrictSystemIncludesCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Path.h"
+#include 
+
+namespace clang {

[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45463#1096406, @rsmith wrote:

> LGTM, thanks!


Thanks.  I'll remove the fixme as you asked.

A few comments ago , I mentioned that 
IncludeTagDefinition's documentation and name is drifting farther from its 
functionality.  Should we do something about that?


https://reviews.llvm.org/D45463



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


[PATCH] D46768: [Driver] Only use -lc++ on Fuchsia

2018-05-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332138: [Driver] Only use -lc++ on Fuchsia (authored by 
phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46768?vs=146396=146408#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46768

Files:
  cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
  cfe/trunk/test/Driver/fuchsia.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:
Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
@@ -28,7 +28,7 @@
 // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 
2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC-NOT: "-Bstatic"
-// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-lc++"
 // CHECK-STATIC-NOT: "-Bdynamic"
 // CHECK-STATIC: "-lm"
 // CHECK-STATIC: "-lc"


Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:
Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
@@ -28,7 +28,7 @@
 // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC-NOT: "-Bstatic"
-// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-lc++"
 // CHECK-STATIC-NOT: "-Bdynamic"
 // CHECK-STATIC: "-lm"
 // CHECK-STATIC: "-lc"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332138 - [Driver] Only use -lc++ on Fuchsia

2018-05-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri May 11 13:42:31 2018
New Revision: 332138

URL: http://llvm.org/viewvc/llvm-project?rev=332138=rev
Log:
[Driver] Only use -lc++ on Fuchsia

The fact that libc++ depends on libc++abi and libunwind is an internal
detail that's captured by the libc++.so linker script.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=332138=332137=332138=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Fri May 11 13:42:31 2018
@@ -267,8 +267,6 @@ void Fuchsia::AddCXXStdlibLibArgs(const
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:

Modified: cfe/trunk/test/Driver/fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.cpp?rev=332138=332137=332138=diff
==
--- cfe/trunk/test/Driver/fuchsia.cpp (original)
+++ cfe/trunk/test/Driver/fuchsia.cpp Fri May 11 13:42:31 2018
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
@@ -28,7 +28,7 @@
 // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 
2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC-NOT: "-Bstatic"
-// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-lc++"
 // CHECK-STATIC-NOT: "-Bdynamic"
 // CHECK-STATIC: "-lm"
 // CHECK-STATIC: "-lc"


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


r332136 - [analyzer] Ignore the nullability quantifiers for autoreleasewritechecker

2018-05-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri May 11 13:39:19 2018
New Revision: 332136

URL: http://llvm.org/viewvc/llvm-project?rev=332136=rev
Log:
[analyzer] Ignore the nullability quantifiers for autoreleasewritechecker

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
cfe/trunk/test/Analysis/autoreleasewritechecker_test.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp?rev=332136=332135=332136=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp Fri 
May 11 13:39:19 2018
@@ -160,8 +160,8 @@ void ObjCAutoreleaseWriteChecker::checkA
   ));
 
   auto DoublePointerParamM =
-  parmVarDecl(hasType(pointerType(
-  pointee(hasCanonicalType(objcObjectPointerType())
+  parmVarDecl(hasType(hasCanonicalType(pointerType(
+  pointee(hasCanonicalType(objcObjectPointerType()))
   .bind(ParamBind);
 
   auto HasParamAndWritesAsyncM = allOf(

Modified: cfe/trunk/test/Analysis/autoreleasewritechecker_test.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/autoreleasewritechecker_test.m?rev=332136=332135=332136=diff
==
--- cfe/trunk/test/Analysis/autoreleasewritechecker_test.m (original)
+++ cfe/trunk/test/Analysis/autoreleasewritechecker_test.m Fri May 11 13:39:19 
2018
@@ -204,4 +204,11 @@ BOOL writeToErrorWithIterator(NSError *_
 }];
   return 0;
 }
+
+void writeToErrorWithIteratorNonnull(NSError *__autoreleasing* _Nonnull error, 
NSDictionary *a) {
+  [a enumerateKeysAndObjectsUsingBlock:^{
+ *error = [NSError errorWithDomain:1]; // expected-warning{{Write to 
autoreleasing out parameter}}
+  }];
+}
 #endif
+


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


r332135 - [analyzer] Fix the filename for the exploration_order test.

2018-05-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri May 11 13:38:39 2018
New Revision: 332135

URL: http://llvm.org/viewvc/llvm-project?rev=332135=rev
Log:
[analyzer] Fix the filename for the exploration_order test.

Ensures that the test is being run.

Added:
cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cpp
  - copied, changed from r331483, 
cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc
Removed:
cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc

Removed: cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc?rev=332134=auto
==
--- cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc (original)
+++ cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc (removed)
@@ -1,40 +0,0 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first -analyzer-output=text -verify %s | 
FileCheck %s
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first_queue -analyzer-output=text -verify %s | 
FileCheck %s
-
-extern int coin();
-
-int foo() {
-int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
-while (coin()) { // expected-note{{Loop condition is true}}
-if (coin())  // expected-note {{Taking true branch}}
-return *x; // expected-warning{{Dereference of null pointer 
(loaded from variable 'x')}}
-   // expected-note@-1{{Dereference of null pointer 
(loaded from variable 'x')}}
-}
-return 0;
-}
-
-void bar() {
-while(coin()) // expected-note{{Loop condition is true}}
-if (coin()) // expected-note {{Assuming the condition is true}}
-foo(); // expected-note{{Calling 'foo'}}
-}
-
-int foo2() {
-int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
-while (coin()) { // expected-note{{Loop condition is true}}
-if (coin())  // expected-note {{Taking false branch}}
-return false;
-else
-return *x; // expected-warning{{Dereference of null pointer 
(loaded from variable 'x')}}
-   // expected-note@-1{{Dereference of null pointer 
(loaded from variable 'x')}}
-}
-return 0;
-}
-
-void bar2() {
-while(coin()) // expected-note{{Loop condition is true}}
-if (coin()) // expected-note {{Assuming the condition is false}}
-  return false;
-else
-foo(); // expected-note{{Calling 'foo'}}
-}

Copied: cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cpp (from 
r331483, cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cpp?p2=cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cpp=cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc=331483=332135=332135=diff
==
--- cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cc (original)
+++ cfe/trunk/test/Analysis/exploration_order/prefer_unexplored.cpp Fri May 11 
13:38:39 2018
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first -analyzer-output=text -verify %s | 
FileCheck %s
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first_queue -analyzer-output=text -verify %s | 
FileCheck %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config 
exploration_strategy=unexplored_first_queue -analyzer-output=text -verify %s
 
 extern int coin();
 
@@ -7,6 +7,7 @@ int foo() {
 int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
 while (coin()) { // expected-note{{Loop condition is true}}
 if (coin())  // expected-note {{Taking true branch}}
+ // expected-note@-1 {{Assuming the condition is true}}
 return *x; // expected-warning{{Dereference of null pointer 
(loaded from variable 'x')}}
// expected-note@-1{{Dereference of null pointer 
(loaded from variable 'x')}}
 }
@@ -14,15 +15,16 @@ int foo() {
 }
 
 void bar() {
-while(coin()) // expected-note{{Loop condition is true}}
-if (coin()) // expected-note {{Assuming the condition is true}}
-foo(); // expected-note{{Calling 'foo'}}
+while(coin())
+if (coin())
+foo();
 }
 
 int foo2() {
 int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
 while (coin()) { // expected-note{{Loop condition is true}}
 

[PATCH] D46740: [Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.

2018-05-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thank you, I've been wanting this for ages but never got around to it :)

(I'd been thinking about doing this by adding custom enum -> text mappings, but 
I think your approach is at least somewhat more general.)




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3626-3634
+"%select{function|function|constructor|"
+"function |function |constructor |"
 "constructor (the implicit default constructor)|"
 "constructor (the implicit copy constructor)|"
 "constructor (the implicit move constructor)|"
 "function (the implicit copy assignment operator)|"
 "function (the implicit move assignment operator)|"

Why do some of these have trailing spaces and others not? That looks wrong to 
me.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3648
 def note_ovl_candidate_deleted : Note<
-"candidate %select{function|function|constructor|"
-"function |function |constructor |"
-"constructor (the implicit default constructor)|"
-"constructor (the implicit copy constructor)|"
-"constructor (the implicit move constructor)|"
-"function (the implicit copy assignment operator)|"
-"function (the implicit move assignment operator)|"
-"inherited constructor|"
-"inherited constructor }0%1 has been "
+"candidate %sub{select_ovl_template_kind}0%1 has been "
 "%select{explicitly made unavailable|explicitly deleted|"

... and this is the reason. `%1` is sometimes empty and sometimes non-empty, 
and we're "cunningly" passing that information through `%0`. Yuck.

It looks like this particular diagnostic refactoring can't work quite like this 
if we want it to be whitespace-correct (which I think we do), because some uses 
of your factored-out text also include a name and others don't. Perhaps adding 
another select on `%0` that either adds a space or not would work, or two 
separate substitutions for the "include name" and "don't include name" cases?

More generally I wonder if we actually want to renumber `%i`'s through a 
`%sub`, so that we could define the substitution as

TextSubstitution<
   "%select{function|function|constructor|function %1|function 
%1|constructor %1|...}0">

and then use it as, eg

"candidate %sub{select_ovl_candidate_kind_with_name}5,6 not viable"

and have it act as if we wrote

"candidate %select{function|function|constructor|function %6|function 
%6|constructor %6|...}5 not viable">

I expect we'll need that pretty much as soon as we have a substitution that 
takes more than one parameter, and I think we want a multi-parameter 
substitution for this refactoring :)


https://reviews.llvm.org/D46740



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


[clang-tools-extra] r332131 - Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"

2018-05-11 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri May 11 13:03:22 2018
New Revision: 332131

URL: http://llvm.org/viewvc/llvm-project?rev=332131=rev
Log:
Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"

This reverts commit r332125 for a failing test.

Removed:
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=332131=332130=332131=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Fri May 11 
13:03:22 2018
@@ -5,7 +5,6 @@ add_clang_library(clangTidyFuchsiaModule
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp
   OverloadedOperatorCheck.cpp
-  RestrictSystemIncludesCheck.cpp
   StaticallyConstructedObjectsCheck.cpp
   TrailingReturnCheck.cpp
   VirtualInheritanceCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp?rev=332131=332130=332131=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp Fri May 11 
13:03:22 2018
@@ -14,7 +14,6 @@
 #include "DefaultArgumentsCheck.h"
 #include "MultipleInheritanceCheck.h"
 #include "OverloadedOperatorCheck.h"
-#include "RestrictSystemIncludesCheck.h"
 #include "StaticallyConstructedObjectsCheck.h"
 #include "TrailingReturnCheck.h"
 #include "VirtualInheritanceCheck.h"
@@ -37,8 +36,6 @@ public:
 "fuchsia-multiple-inheritance");
 CheckFactories.registerCheck(
 "fuchsia-overloaded-operator");
-CheckFactories.registerCheck(
-"fuchsia-restrict-system-includes");
 CheckFactories.registerCheck(
 "fuchsia-statically-constructed-objects");
 CheckFactories.registerCheck(

Removed: 
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp?rev=332130=auto
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
(removed)
@@ -1,118 +0,0 @@
-//===--- RestrictSystemIncludesCheck.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 "RestrictSystemIncludesCheck.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/HeaderSearch.h"
-#include "clang/Lex/PPCallbacks.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Path.h"
-#include 
-
-namespace clang {

[PATCH] D46768: [Driver] Only use -lc++ on Fuchsia

2018-05-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 146396.

Repository:
  rC Clang

https://reviews.llvm.org/D46768

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.cpp


Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
@@ -28,7 +28,7 @@
 // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 
2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC-NOT: "-Bstatic"
-// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-lc++"
 // CHECK-STATIC-NOT: "-Bdynamic"
 // CHECK-STATIC: "-lm"
 // CHECK-STATIC: "-lc"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:


Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
@@ -28,7 +28,7 @@
 // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC-NOT: "-Bstatic"
-// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-lc++"
 // CHECK-STATIC-NOT: "-Bdynamic"
 // CHECK-STATIC: "-lm"
 // CHECK-STATIC: "-lc"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: include/clang/AST/Type.h:4903-4910
+  ///
+  /// FIXME: The TagDecl returned is not always exactly faithful to the
+  /// original source because, when building the AST, the parser drops
+  /// attributes declared on a tag type after a declaration of a member list
+  /// for that tag type.  When printing the AST, this change only loses
+  /// warnings about how an attribute cannot be declared after the member
+  /// list has been specified, and such attributes otherwise should have no

Please remove this FIXME. This function *is* returning the right `TagDecl`. 
This is the wrong place to call out any infelicities in attribute retention.


https://reviews.llvm.org/D45463



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


[PATCH] D46768: [Driver] Only use -lc++ on Fuchsia

2018-05-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich, juliehockett.
Herald added a subscriber: cfe-commits.

The fact that libc++ depends on libc++abi and libunwind is an internal
detail that's captured by the libc++.so linker script.


Repository:
  rC Clang

https://reviews.llvm.org/D46768

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.cpp


Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:


Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -15,7 +15,7 @@
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
 // CHECK: "-L[[SYSROOT]]{{/|}}lib"
-// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "-lc++" "-lm"
 // CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
 // CHECK: "-lc"
 // CHECK-NOT: crtend.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -267,8 +267,6 @@
   switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
-CmdArgs.push_back("-lc++abi");
-CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332130 - [libclang] Stop assuming that the internal C++ ABI ExceptionSpecificationType enumeration is the same as CXCursor_ExceptionSpecificationKind.

2018-05-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 11 12:46:31 2018
New Revision: 332130

URL: http://llvm.org/viewvc/llvm-project?rev=332130=rev
Log:
[libclang] Stop assuming that the internal C++ ABI ExceptionSpecificationType 
enumeration is the same as CXCursor_ExceptionSpecificationKind.

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=332130=332129=332130=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri May 11 12:46:31 2018
@@ -3586,6 +3586,7 @@ CINDEX_LINKAGE CXType clang_getResultTyp
 
 /**
  * Retrieve the exception specification type associated with a function type.
+ * This is a value of type CXCursor_ExceptionSpecificationKind.
  *
  * If a non-function type is passed in, an error code of -1 is returned.
  */
@@ -3621,6 +3622,7 @@ CINDEX_LINKAGE CXType clang_getCursorRes
 
 /**
  * Retrieve the exception specification type associated with a given cursor.
+ * This is a value of type CXCursor_ExceptionSpecificationKind.
  *
  * This only returns a valid result if the cursor refers to a function or 
method.
  */

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=332130=332129=332130=diff
==
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Fri May 11 12:46:31 2018
@@ -151,6 +151,8 @@ template  void f_computed_noexc
 void f_dynamic_noexcept_none() throw();
 void f_dynamic_noexcept() throw(int);
 void f_dynamic_noexcept_any() throw(...);
+void f_computed_noexcept_true() noexcept(true);
+void f_computed_noexcept_false() noexcept(false);
 
 enum EnumType { Enumerator };
 struct Z {
@@ -221,7 +223,7 @@ struct Z {
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck 
-check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of 
TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 
-cursor-at=%s:146:15 -cursor-at=%s:149:6 -cursor-at=%s:150:25 
-cursor-at=%s:151:6 -cursor-at=%s:152:6 -cursor-at=%s:153:6 -std=c++11 %s | 
FileCheck -check-prefix=CHECK-SPELLING %s
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 
-cursor-at=%s:146:15 -cursor-at=%s:149:6 -cursor-at=%s:150:25 
-cursor-at=%s:151:6 -cursor-at=%s:152:6 -cursor-at=%s:153:6 -cursor-at=%s:154:6 
-cursor-at=%s:155:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %s
 // CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 (default constructor) 
Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
 // CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 
70:15] Spelling=~A ([70:11 - 70:13])
 // CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] 
Spelling=operator= ([73:6 - 73:15])
@@ -274,12 +276,14 @@ struct Z {
 // CHECK-SPELLING: 151:6 FunctionDecl=f_dynamic_noexcept_none:151:6 

r332129 - [OPENMP, NVPTX] Do not use SPMD mode for target simd and target teams

2018-05-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri May 11 12:45:14 2018
New Revision: 332129

URL: http://llvm.org/viewvc/llvm-project?rev=332129=rev
Log:
[OPENMP, NVPTX] Do not use SPMD mode for target simd and target teams
distribute simd directives.

Directives `target simd` and `target teams distribute simd` must be
executed in non-SPMD mode.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=332129=332128=332129=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri May 11 12:45:14 2018
@@ -628,9 +628,8 @@ static bool hasNestedSPMDDirective(ASTCo
 OpenMPDirectiveKind DKind = NestedDir->getDirectiveKind();
 switch (D.getDirectiveKind()) {
 case OMPD_target:
-  if ((isOpenMPParallelDirective(DKind) &&
-   !hasParallelIfClause(Ctx, *NestedDir)) ||
-  isOpenMPSimdDirective(DKind))
+  if (isOpenMPParallelDirective(DKind) &&
+  !hasParallelIfClause(Ctx, *NestedDir))
 return true;
   if (DKind == OMPD_teams || DKind == OMPD_teams_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -639,9 +638,8 @@ static bool hasNestedSPMDDirective(ASTCo
 ChildStmt = getSingleCompoundChild(Body);
 if (const auto *NND = dyn_cast(ChildStmt)) {
   DKind = NND->getDirectiveKind();
-  if ((isOpenMPParallelDirective(DKind) &&
-   !hasParallelIfClause(Ctx, *NND)) ||
-  isOpenMPSimdDirective(DKind))
+  if (isOpenMPParallelDirective(DKind) &&
+  !hasParallelIfClause(Ctx, *NND))
 return true;
   if (DKind == OMPD_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -652,18 +650,16 @@ static bool hasNestedSPMDDirective(ASTCo
   return false;
 if (const auto *NND = dyn_cast(ChildStmt)) 
{
   DKind = NND->getDirectiveKind();
-  return (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NND)) ||
- isOpenMPSimdDirective(DKind);
+  return isOpenMPParallelDirective(DKind) &&
+ !hasParallelIfClause(Ctx, *NND);
 }
   }
 }
   }
   return false;
 case OMPD_target_teams:
-  if ((isOpenMPParallelDirective(DKind) &&
-   !hasParallelIfClause(Ctx, *NestedDir)) ||
-  isOpenMPSimdDirective(DKind))
+  if (isOpenMPParallelDirective(DKind) &&
+  !hasParallelIfClause(Ctx, *NestedDir))
 return true;
   if (DKind == OMPD_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -672,16 +668,14 @@ static bool hasNestedSPMDDirective(ASTCo
 ChildStmt = getSingleCompoundChild(Body);
 if (const auto *NND = dyn_cast(ChildStmt)) {
   DKind = NND->getDirectiveKind();
-  return (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NND)) ||
- isOpenMPSimdDirective(DKind);
+  return isOpenMPParallelDirective(DKind) &&
+ !hasParallelIfClause(Ctx, *NND);
 }
   }
   return false;
 case OMPD_target_teams_distribute:
-  return (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NestedDir)) ||
- isOpenMPSimdDirective(DKind);
+  return isOpenMPParallelDirective(DKind) &&
+ !hasParallelIfClause(Ctx, *NestedDir);
 case OMPD_target_simd:
 case OMPD_target_parallel:
 case OMPD_target_parallel_for:
@@ -755,7 +749,7 @@ static bool supportsSPMDExecutionMode(AS
 return !hasParallelIfClause(Ctx, D);
   case OMPD_target_simd:
   case OMPD_target_teams_distribute_simd:
-return true;
+return false;
   case OMPD_parallel:
   case OMPD_for:
   case OMPD_parallel_for:

Modified: cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp?rev=332129=332128=332129=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp Fri May 11 12:45:14 2018
@@ -8,11 +8,11 @@
 #ifndef HEADER
 #define HEADER
 
-// Check that the execution mode of all 2 target regions on the gpu is set to 
SPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l25}}_exec_mode = weak constant i8 0
-// CHECK-DAG: {{@__omp_offloading_.+l30}}_exec_mode = weak constant i8 0
-// CHECK-DAG: 

[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/CodeComplete.cpp:932
 Req.Query = Filter->pattern();
+Req.DeclContexts = {Decl::Kind::Namespace, Decl::Kind::TranslationUnit,
+Decl::Kind::LinkageSpec, Decl::Kind::Enum};

I want to add a comment here, but I want to make sure I understand why in the 
first place we were not indexing symbols outside these contexts for the purpose 
of code completion. Is it because those will be available by Sema code 
completion anyway?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146393.
ioeric added a comment.

- Rebase on https://reviews.llvm.org/D46758


Repository:
  rC Clang

https://reviews.llvm.org/D46496

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  lib/Format/Format.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -0,0 +1,527 @@
+//===- unittest/Tooling/CleanupTest.cpp - Include insertion/deletion tests ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "../Tooling/ReplacementTest.h"
+#include "../Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class HeaderIncludesTest : public ::testing::Test {
+protected:
+  std::string insert(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto R = Includes.insert(Header.trim("\"<>"), Header.startswith("<"));
+if (!R)
+  return Code;
+auto Result = applyAllReplacements(Code, Replacements(*R));
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  std::string remove(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto Replaces = Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  const std::string FileName = "fix.cpp";
+  IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
+};
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  EXPECT_EQ(Expected, insert(Code, ""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"z.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertAfterSystemHeaderGoogle) {
+  std::string Code = "#include \n"
+ "\n"
+   

[PATCH] D44954: [clangd] [RFC] Add more symbols to the index

2018-05-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 146391.
malaperle added a comment.
Herald added a subscriber: jkorous.

Rework to include member vars/functions and scoped enumerators.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954

Files:
  clangd/CodeComplete.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -67,6 +67,9 @@
   Pos.end.character);
 }
 MATCHER_P(Refs, R, "") { return int(arg.References) == R; }
+MATCHER_P(InScopedEnum, InScopedEnum, "") {
+  return arg.InScopedEnum == InScopedEnum;
+}
 
 namespace clang {
 namespace clangd {
@@ -198,25 +201,28 @@
 } // namespace foo
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAreArray(
-  {QName("Foo"), QName("f1"), QName("f2"), QName("KInt"),
-   QName("kStr"), QName("foo"), QName("foo::bar"),
-   QName("foo::int32"), QName("foo::int32_t"), QName("foo::v1"),
-   QName("foo::bar::v2"), QName("foo::baz")}));
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAreArray(
+  {QName("Foo"), QName("Foo::f"), QName("f1"), QName("f2"),
+   QName("KInt"), QName("kStr"), QName("foo"), QName("foo::bar"),
+   QName("foo::int32"), QName("foo::int32_t"), QName("foo::v1"),
+   QName("foo::bar::v2"), QName("foo::baz")}));
 }
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(
 // Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T x = 0;};
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
 template <> struct Tmpl {};
 extern template struct Tmpl;
 template struct Tmpl;
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAreArray({AllOf(
-   QName("Tmpl"), DeclRange(Header.range()))}));
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAreArray(
+  {AllOf(QName("Tmpl"), DeclRange(Header.range())),
+   AllOf(QName("Tmpl::x"), DeclRange(Header.range("xdecl")))}));
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
@@ -334,29 +340,30 @@
   Green
 };
 enum class Color2 {
-  Yellow // ignore
+  Yellow
 };
 namespace ns {
 enum {
   Black
 };
 }
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
-QName("Green"), QName("Color2"),
-QName("ns"), QName("ns::Black")));
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Red"), QName("Color"), QName("Green"),
+   QName("Color2"), QName("Color2::Yellow"),
+   QName("ns"), QName("ns::Black")));
 }
 
-TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+TEST_F(SymbolCollectorTest, NamelessSymbols) {
   const std::string Header = R"(
 struct {
   int a;
 } Foo;
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"),
+QName("(anonymous struct)::a")));
 }
 
 TEST_F(SymbolCollectorTest, SymbolFormedFromMacro) {
@@ -417,7 +424,7 @@
   UnorderedElementsAre(QName("Foo"), QName("f1"), QName("f2")));
 }
 
-TEST_F(SymbolCollectorTest, IgnoreClassMembers) {
+TEST_F(SymbolCollectorTest, ClassMembers) {
   const std::string Header = R"(
 class Foo {
   void f() {}
@@ -432,7 +439,10 @@
 void Foo::ssf() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo")));
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
+   QName("Foo::g"), QName("Foo::sf"),
+   QName("Foo::ssf"), QName("Foo::x")));
 }
 
 TEST_F(SymbolCollectorTest, Scopes) {
@@ -531,6 +541,7 @@
   End:
 Line: 1
 Column: 1
+InScopedEnum:true
 CompletionLabel:'Foo1-label'
 CompletionFilterText:'filter'
 CompletionPlainInsertText:'plain'
@@ -555,6 +566,7 @@
   End:
 Line: 1
 Column: 1
+InScopedEnum:false
 CompletionLabel:'Foo2-label'
 CompletionFilterText:'filter'
 CompletionPlainInsertText:'plain'
@@ -565,13 +577,15 @@
   auto Symbols1 = SymbolsFromYAML(YAML1);
 
   EXPECT_THAT(Symbols1,
-

[PATCH] D46767: Force the PS4 clang ABI version to 6, and add a warning if this is attempted to be overridden

2018-05-11 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.
dyung added a reviewer: probinson.

For compatibility reasons, the PS4 clang ABI must use version 6, so we force 
the compiler to use this version if the PS4 target triple is specified. We also 
emit a new warning now if a clang abi version was specified which is not 6 to 
let the user know we are ignoring their request.


Repository:
  rC Clang

https://reviews.llvm.org/D46767

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/alignment.cpp
  test/Driver/clang-abi-compat.cpp


Index: test/Driver/clang-abi-compat.cpp
===
--- test/Driver/clang-abi-compat.cpp
+++ test/Driver/clang-abi-compat.cpp
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted 
when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring 
requested version
+
Index: test/CodeGenCXX/alignment.cpp
===
--- test/CodeGenCXX/alignment.cpp
+++ test/CodeGenCXX/alignment.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | 
FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 
-fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
+// Check that the PS4 target uses the 6.0 compat settings.
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 
-fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
 
 extern int int_source();
 extern void int_sink(int x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2751,6 +2751,16 @@
   << A->getAsString(Args) << A->getValue();
 }
   }
+  // The PS4 requires version 6 of the clang ABI.
+  if (T.isPS4()) {
+// Issue a warning if another version of the ABI was requested.
+if (Args.getLastArg(OPT_fclang_abi_compat_EQ) &&
+Opts.getClangABICompat() != LangOptions::ClangABI::Ver6) {
+  Diags.Report(diag::warn_drv_ignored_clang_abi_version)
+<< 6;
+}
+Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
+  }
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -149,6 +149,9 @@
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup;
+def warn_drv_ignored_clang_abi_version : Warning<
+  "target requires clang ABI version %0, ignoring requested version">,
+  InGroup;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,


Index: test/Driver/clang-abi-compat.cpp
===
--- test/Driver/clang-abi-compat.cpp
+++ test/Driver/clang-abi-compat.cpp
@@ -0,0 +1,6 @@
+// PS4 target requires clang ABI version 6, check that a warning is emitted when a version other than 6 is requested.
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
+
+// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring requested version
+
Index: test/CodeGenCXX/alignment.cpp
===
--- test/CodeGenCXX/alignment.cpp
+++ test/CodeGenCXX/alignment.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 -fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// Check that the PS4 target uses the 6.0 compat settings.
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 -fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK 

[PATCH] D46758: [clang-format] Move #include related style to libToolingCore

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146390.
ioeric marked an inline comment as done.
ioeric added a comment.
Herald added a subscriber: mgorny.

- also moved yaml traits.


Repository:
  rC Clang

https://reviews.llvm.org/D46758

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/IncludeStyle.h
  lib/Format/Format.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/IncludeStyle.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -26,12 +26,12 @@
 
   std::string sort(StringRef Code, std::vector Ranges,
StringRef FileName = "input.cc") {
-auto Replaces = sortIncludes(Style, Code, Ranges, FileName);
+auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
-*Sorted, reformat(Style, *Sorted, Ranges, FileName));
+*Sorted, reformat(FmtStyle, *Sorted, Ranges, FileName));
 EXPECT_TRUE(static_cast(Result));
 return *Result;
   }
@@ -41,12 +41,12 @@
   }
 
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
-sortIncludes(Style, Code, GetCodeRange(Code), "input.cpp", );
+sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.cpp", );
 return Cursor;
   }
 
-  FormatStyle Style = getLLVMStyle();
-
+  FormatStyle FmtStyle = getLLVMStyle();
+  tooling::IncludeStyle  = FmtStyle.IncludeStyle;
 };
 
 TEST_F(SortIncludesTest, BasicSorting) {
@@ -74,11 +74,11 @@
  "#include \n"
  "#include \n"
  "#include \n";
-  EXPECT_TRUE(sortIncludes(Style, Code, GetCodeRange(Code), "a.cc").empty());
+  EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -88,7 +88,7 @@
  "\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -119,7 +119,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  Style.SortIncludes = false;
+  FmtStyle.SortIncludes = false;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -182,7 +182,7 @@
 }
 
 TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -202,7 +202,7 @@
  "// comment\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "// comment\n"
@@ -212,7 +212,7 @@
  "// comment\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "// comment\n"
@@ -233,7 +233,7 @@
  "#include \"c.h\"\n"
  "#include \"a.h\"\n"));
 
-  Style = getGoogleStyle(FormatStyle::LK_Cpp);
+  FmtStyle = getGoogleStyle(FormatStyle::LK_Cpp);
   EXPECT_EQ("#include \n"
 "#include \n"
 "#include \"a.h\"\n"
@@ -245,7 +245,7 @@
 }
 
 TEST_F(SortIncludesTest, RegroupsAngledIncludesInSeparateBlocks) {
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "\n"
@@ -345,7 +345,7 @@
 
 TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
 
   EXPECT_EQ("#include \"c.h\"\n"
 "#include \"a.h\"\n"
@@ -359,7 +359,7 @@
 
 TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
 
   EXPECT_EQ("#include 

[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146385.
ioeric added a comment.

- Revert commit on wrong branch.


Repository:
  rC Clang

https://reviews.llvm.org/D46496

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  include/clang/Tooling/Core/IncludeStyle.h
  lib/Format/Format.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -0,0 +1,527 @@
+//===- unittest/Tooling/CleanupTest.cpp - Include insertion/deletion tests ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "../Tooling/ReplacementTest.h"
+#include "../Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class HeaderIncludesTest : public ::testing::Test {
+protected:
+  std::string insert(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto R = Includes.insert(Header.trim("\"<>"), Header.startswith("<"));
+if (!R)
+  return Code;
+auto Result = applyAllReplacements(Code, Replacements(*R));
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  std::string remove(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto Replaces = Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  const std::string FileName = "fix.cpp";
+  IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
+};
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  EXPECT_EQ(Expected, insert(Code, ""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"z.h\""));
+}
+

[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146384.
ioeric added a comment.

- Also moved yaml traits.


Repository:
  rC Clang

https://reviews.llvm.org/D46496

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  include/clang/Tooling/Core/IncludeStyle.h
  lib/Format/Format.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  lib/Tooling/Core/IncludeStyle.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -0,0 +1,527 @@
+//===- unittest/Tooling/CleanupTest.cpp - Include insertion/deletion tests ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "../Tooling/ReplacementTest.h"
+#include "../Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class HeaderIncludesTest : public ::testing::Test {
+protected:
+  std::string insert(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto R = Includes.insert(Header.trim("\"<>"), Header.startswith("<"));
+if (!R)
+  return Code;
+auto Result = applyAllReplacements(Code, Replacements(*R));
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  std::string remove(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto Replaces = Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  const std::string FileName = "fix.cpp";
+  IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
+};
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  EXPECT_EQ(Expected, insert(Code, ""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"z.h\""));

[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-11 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332125: [clang-tidy] Adding RestrictSystemIncludes check to 
Fuchsia module (authored by juliehockett, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D43778?vs=146349=146382#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43778

Files:
  clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h
  
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp
  
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp
  
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
  clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes.cpp

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -110,8 +110,13 @@
   Checks whether a ``std::string::find()`` result is compared with 0, and
   suggests replacing with ``absl::StartsWith()``.
 
-- New :doc:`fuchsia-statically-constructed-objects
-  ` check.
+- New `fuchsia-restrict-system-includes
+  `_ check
+
+  Checks for allowed system includes and suggests removal of any others.
+
+- New `fuchsia-statically-constructed-objects
+  `_ check
 
   Warns if global, non-trivial objects with static storage are constructed,
   unless the object is statically initialized with a ``constexpr`` constructor
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
@@ -95,6 +95,7 @@
fuchsia-default-arguments
fuchsia-multiple-inheritance
fuchsia-overloaded-operator
+   fuchsia-restrict-system-includes
fuchsia-statically-constructed-objects
fuchsia-trailing-return
fuchsia-virtual-inheritance
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - fuchsia-restrict-system-includes
+
+fuchsia-restrict-system-includes
+
+
+Checks for allowed system includes and suggests removal of any others.
+
+It is important to note that running this check with fixes may break code, as
+the fix removes headers. Fixes are applied to source and header files, but not
+to system headers.
+
+For example, given the allowed system includes 'a.h,b*':
+
+.. code-block:: c++
+
+  #include 
+  #include 
+  #include 
+  #include // Warning, as c.h is not explicitly allowed
+  
+All system includes can be allowed with '*', and all can be disallowed with an
+empty string ('').
+  
+Options
+---
+
+.. option:: Includes
+
+   A string containing a comma separated glob list of allowed include filenames.
+   Similar to the -checks glob list for running clang-tidy itself, the two
+   wildcard characters are '*' and '-', to include and exclude globs,
+   respectively.The default is '*', which allows all includes.
Index: clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes.cpp

[clang-tools-extra] r332125 - [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module

2018-05-11 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri May 11 12:23:15 2018
New Revision: 332125

URL: http://llvm.org/viewvc/llvm-project?rev=332125=rev
Log:
[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module

Adding a check to restrict system includes to a whitelist. Given a list
of includes that are explicitly allowed, the check issues a fixit to
remove any system include not on that list from the source file.

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

Added:
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h

clang-tools-extra/trunk/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-restrict-system-includes.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=332125=332124=332125=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Fri May 11 
12:23:15 2018
@@ -5,6 +5,7 @@ add_clang_library(clangTidyFuchsiaModule
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp
   OverloadedOperatorCheck.cpp
+  RestrictSystemIncludesCheck.cpp
   StaticallyConstructedObjectsCheck.cpp
   TrailingReturnCheck.cpp
   VirtualInheritanceCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp?rev=332125=332124=332125=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp Fri May 11 
12:23:15 2018
@@ -14,6 +14,7 @@
 #include "DefaultArgumentsCheck.h"
 #include "MultipleInheritanceCheck.h"
 #include "OverloadedOperatorCheck.h"
+#include "RestrictSystemIncludesCheck.h"
 #include "StaticallyConstructedObjectsCheck.h"
 #include "TrailingReturnCheck.h"
 #include "VirtualInheritanceCheck.h"
@@ -36,6 +37,8 @@ public:
 "fuchsia-multiple-inheritance");
 CheckFactories.registerCheck(
 "fuchsia-overloaded-operator");
+CheckFactories.registerCheck(
+"fuchsia-restrict-system-includes");
 CheckFactories.registerCheck(
 "fuchsia-statically-constructed-objects");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp?rev=332125=auto
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp 
Fri May 11 12:23:15 2018
@@ -0,0 +1,118 @@
+//===--- RestrictSystemIncludesCheck.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 "RestrictSystemIncludesCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include 

[PATCH] D46475: [HIP] Set proper triple and offload kind for the toolchain

2018-05-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332123: [HIP] Set proper triple and offload kind for the 
toolchain (authored by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46475?vs=145699=146381#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46475

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/Types.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Types.cpp
  cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/a.cu
  cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/b.hip
  cfe/trunk/test/Driver/hip-inputs.hip

Index: cfe/trunk/test/Driver/hip-inputs.hip
===
--- cfe/trunk/test/Driver/hip-inputs.hip
+++ cfe/trunk/test/Driver/hip-inputs.hip
@@ -0,0 +1,23 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -ccc-print-phases -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 -c \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip 2>&1 \
+// RUN: | FileCheck %s
+
+// RUN: not %clang -ccc-print-phases -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 -c \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip 2>&1 \
+// RUN: | FileCheck -check-prefix=MIX %s
+
+// RUN: not %clang -ccc-print-phases -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 -c \
+// RUN:   --hip-link %S/Inputs/hip_multiple_inputs/a.cu 2>&1 \
+// RUN: | FileCheck -check-prefix=MIX %s
+
+// CHECK-NOT: error: Mixed Cuda and HIP compilation is not supported.
+// MIX: error: Mixed Cuda and HIP compilation is not supported.
Index: cfe/trunk/lib/Driver/Types.cpp
===
--- cfe/trunk/lib/Driver/Types.cpp
+++ cfe/trunk/lib/Driver/Types.cpp
@@ -172,6 +172,15 @@
   case TY_CUDA:
   case TY_PP_CUDA:
   case TY_CUDA_DEVICE:
+return true;
+  }
+}
+
+bool types::isHIP(ID Id) {
+  switch (Id) {
+  default:
+return false;
+
   case TY_HIP:
   case TY_PP_HIP:
   case TY_HIP_DEVICE:
@@ -230,6 +239,7 @@
.Case("fpp", TY_Fortran)
.Case("FPP", TY_Fortran)
.Case("gch", TY_PCH)
+   .Case("hip", TY_HIP)
.Case("hpp", TY_CXXHeader)
.Case("iim", TY_PP_CXXModule)
.Case("lib", TY_Object)
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -538,24 +538,46 @@
   InputList ) {
 
   //
-  // CUDA
+  // CUDA/HIP
   //
-  // We need to generate a CUDA toolchain if any of the inputs has a CUDA type.
-  if (llvm::any_of(Inputs, [](std::pair ) {
+  // We need to generate a CUDA toolchain if any of the inputs has a CUDA
+  // or HIP type. However, mixed CUDA/HIP compilation is not supported.
+  bool IsCuda =
+  llvm::any_of(Inputs, [](std::pair ) {
 return types::isCuda(I.first);
-  })) {
+  });
+  bool IsHIP =
+  llvm::any_of(Inputs,
+   [](std::pair ) {
+ return types::isHIP(I.first);
+   }) ||
+  C.getInputArgs().hasArg(options::OPT_hip_link);
+  if (IsCuda && IsHIP) {
+Diag(clang::diag::err_drv_mix_cuda_hip);
+return;
+  }
+  if (IsCuda || IsHIP) {
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple  = HostTC->getTriple();
-llvm::Triple CudaTriple(HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
- : "nvptx-nvidia-cuda");
-// Use the CUDA and host triples as the key into the ToolChains map, because
-// the device toolchain we create depends on both.
+StringRef DeviceTripleStr;
+auto OFK = IsHIP ? Action::OFK_HIP : Action::OFK_Cuda;
+if (IsHIP) {
+  // HIP is only supported on amdgcn.
+  DeviceTripleStr = "amdgcn-amd-amdhsa";
+} else {
+  // CUDA is only supported on nvptx.
+  DeviceTripleStr = HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda";
+}
+llvm::Triple CudaTriple(DeviceTripleStr);
+// Use the CUDA/HIP and host triples as the key into the ToolChains map,
+// because the device toolchain we create depends on both.
 auto  = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
 if (!CudaTC) {
   CudaTC = llvm::make_unique(
-  *this, CudaTriple, *HostTC, C.getInputArgs(), Action::OFK_Cuda);
+  *this, CudaTriple, *HostTC, C.getInputArgs(), OFK);

r332123 - [HIP] Set proper triple and offload kind for the toolchain

2018-05-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 11 12:21:39 2018
New Revision: 332123

URL: http://llvm.org/viewvc/llvm-project?rev=332123=rev
Log:
[HIP] Set proper triple and offload kind for the toolchain

Also introduce --hip-link option to indicate HIP for linking.

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

Added:
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/a.cu
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/b.hip
cfe/trunk/test/Driver/hip-inputs.hip
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/Types.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Types.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=332123=332122=332123=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 11 12:21:39 
2018
@@ -41,6 +41,7 @@ def err_drv_cuda_version_unsupported : E
   "install, pass a different GPU arch with --cuda-gpu-arch, or pass "
   "--no-cuda-version-check.">;
 def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host 
compilation.">;
+def err_drv_mix_cuda_hip : Error<"Mixed Cuda and HIP compilation is not 
supported.">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332123=332122=332123=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri May 11 12:21:39 2018
@@ -557,6 +557,8 @@ def no_cuda_include_ptx_EQ : Joined<["--
   HelpText<"Do not include PTX for the follwing GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than 
once.">;
+def hip_link : Flag<["--"], "hip-link">,
+  HelpText<"Link clang-offload-bundler bundles for HIP">;
 def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Remove GPU architecture (e.g. sm_35) from the list of GPUs to 
compile for. "
"'all' resets the list to its default value.">;

Modified: cfe/trunk/include/clang/Driver/Types.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.h?rev=332123=332122=332123=diff
==
--- cfe/trunk/include/clang/Driver/Types.h (original)
+++ cfe/trunk/include/clang/Driver/Types.h Fri May 11 12:21:39 2018
@@ -77,6 +77,9 @@ namespace types {
   /// isCuda - Is this a CUDA input.
   bool isCuda(ID Id);
 
+  /// isHIP - Is this a HIP input.
+  bool isHIP(ID Id);
+
   /// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
   bool isObjC(ID Id);
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=332123=332122=332123=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri May 11 12:21:39 2018
@@ -538,24 +538,46 @@ void Driver::CreateOffloadingDeviceToolC
   InputList ) {
 
   //
-  // CUDA
+  // CUDA/HIP
   //
-  // We need to generate a CUDA toolchain if any of the inputs has a CUDA type.
-  if (llvm::any_of(Inputs, [](std::pair ) 
{
+  // We need to generate a CUDA toolchain if any of the inputs has a CUDA
+  // or HIP type. However, mixed CUDA/HIP compilation is not supported.
+  bool IsCuda =
+  llvm::any_of(Inputs, [](std::pair ) 
{
 return types::isCuda(I.first);
-  })) {
+  });
+  bool IsHIP =
+  llvm::any_of(Inputs,
+   [](std::pair ) {
+ return types::isHIP(I.first);
+   }) ||
+  C.getInputArgs().hasArg(options::OPT_hip_link);
+  if (IsCuda && IsHIP) {
+Diag(clang::diag::err_drv_mix_cuda_hip);
+return;
+  }
+  if (IsCuda || IsHIP) {
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple  = HostTC->getTriple();
-llvm::Triple CudaTriple(HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
- : "nvptx-nvidia-cuda");
-// Use the CUDA 

[PATCH] D46487: [HIP] Diagnose unsupported host triple

2018-05-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332122: [HIP] Diagnose unsupported host triple (authored by 
yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46487?vs=145346=146379#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46487

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cuda-bad-arch.cu


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -40,7 +40,7 @@
   "but installation at %3 is %4.  Use --cuda-path to specify a different CUDA "
   "install, pass a different GPU arch with --cuda-gpu-arch, or pass "
   "--no-cuda-version-check.">;
-def err_drv_cuda_nvptx_host : Error<"unsupported use of NVPTX for host 
compilation.">;
+def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host 
compilation.">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<
Index: cfe/trunk/test/Driver/cuda-bad-arch.cu
===
--- cfe/trunk/test/Driver/cuda-bad-arch.cu
+++ cfe/trunk/test/Driver/cuda-bad-arch.cu
@@ -2,6 +2,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
+// REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
@@ -25,9 +26,12 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 
-// We don't allow using NVPTX for host compilation.
+// We don't allow using NVPTX/AMDGCN for host compilation.
 // RUN: %clang -### --cuda-host-only -target nvptx-nvidia-cuda -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix HOST_NVPTX %s
+// RUN: %clang -### --cuda-host-only -target amdgcn-amd-amdhsa -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix HOST_AMDGCN %s
 
 // OK-NOT: error: Unsupported CUDA gpu architecture
-// HOST_NVPTX: error: unsupported use of NVPTX for host compilation.
+// HOST_NVPTX: error: unsupported architecture 'nvptx' for host compilation.
+// HOST_AMDGCN: error: unsupported architecture 'amdgcn' for host compilation.
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2338,11 +2338,13 @@
 
   const ToolChain *HostTC = 
C.getSingleOffloadToolChain();
   assert(HostTC && "No toolchain for host compilation.");
-  if (HostTC->getTriple().isNVPTX()) {
-// We do not support targeting NVPTX for host compilation. Throw
+  if (HostTC->getTriple().isNVPTX() ||
+  HostTC->getTriple().getArch() == llvm::Triple::amdgcn) {
+// We do not support targeting NVPTX/AMDGCN for host compilation. Throw
 // an error and abort pipeline construction early so we don't trip
 // asserts that assume device-side compilation.
-C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);
+C.getDriver().Diag(diag::err_drv_cuda_host_arch)
+<< HostTC->getTriple().getArchName();
 return true;
   }
 


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -40,7 +40,7 @@
   "but installation at %3 is %4.  Use --cuda-path to specify a different CUDA "
   "install, pass a different GPU arch with --cuda-gpu-arch, or pass "
   "--no-cuda-version-check.">;
-def err_drv_cuda_nvptx_host : Error<"unsupported use of NVPTX for host compilation.">;
+def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host compilation.">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<
Index: cfe/trunk/test/Driver/cuda-bad-arch.cu
===
--- cfe/trunk/test/Driver/cuda-bad-arch.cu
+++ cfe/trunk/test/Driver/cuda-bad-arch.cu
@@ -2,6 +2,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
+// REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
@@ -25,9 +26,12 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 
-// We don't allow using NVPTX for host compilation.
+// We don't allow using 

r332122 - [HIP] Diagnose unsupported host triple

2018-05-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 11 12:14:34 2018
New Revision: 332122

URL: http://llvm.org/viewvc/llvm-project?rev=332122=rev
Log:
[HIP] Diagnose unsupported host triple

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cuda-bad-arch.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=332122=332121=332122=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 11 12:14:34 
2018
@@ -40,7 +40,7 @@ def err_drv_cuda_version_unsupported : E
   "but installation at %3 is %4.  Use --cuda-path to specify a different CUDA "
   "install, pass a different GPU arch with --cuda-gpu-arch, or pass "
   "--no-cuda-version-check.">;
-def err_drv_cuda_nvptx_host : Error<"unsupported use of NVPTX for host 
compilation.">;
+def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host 
compilation.">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=332122=332121=332122=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri May 11 12:14:34 2018
@@ -2338,11 +2338,13 @@ class OffloadingActionBuilder final {
 
   const ToolChain *HostTC = 
C.getSingleOffloadToolChain();
   assert(HostTC && "No toolchain for host compilation.");
-  if (HostTC->getTriple().isNVPTX()) {
-// We do not support targeting NVPTX for host compilation. Throw
+  if (HostTC->getTriple().isNVPTX() ||
+  HostTC->getTriple().getArch() == llvm::Triple::amdgcn) {
+// We do not support targeting NVPTX/AMDGCN for host compilation. Throw
 // an error and abort pipeline construction early so we don't trip
 // asserts that assume device-side compilation.
-C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);
+C.getDriver().Diag(diag::err_drv_cuda_host_arch)
+<< HostTC->getTriple().getArchName();
 return true;
   }
 

Modified: cfe/trunk/test/Driver/cuda-bad-arch.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bad-arch.cu?rev=332122=332121=332122=diff
==
--- cfe/trunk/test/Driver/cuda-bad-arch.cu (original)
+++ cfe/trunk/test/Driver/cuda-bad-arch.cu Fri May 11 12:14:34 2018
@@ -2,6 +2,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
+// REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
@@ -25,9 +26,12 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 
-// We don't allow using NVPTX for host compilation.
+// We don't allow using NVPTX/AMDGCN for host compilation.
 // RUN: %clang -### --cuda-host-only -target nvptx-nvidia-cuda -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix HOST_NVPTX %s
+// RUN: %clang -### --cuda-host-only -target amdgcn-amd-amdhsa -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix HOST_AMDGCN %s
 
 // OK-NOT: error: Unsupported CUDA gpu architecture
-// HOST_NVPTX: error: unsupported use of NVPTX for host compilation.
+// HOST_NVPTX: error: unsupported architecture 'nvptx' for host compilation.
+// HOST_AMDGCN: error: unsupported architecture 'amdgcn' for host compilation.


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


r332121 - [HIP] Let clang-offload-bundler support HIP

2018-05-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 11 12:02:18 2018
New Revision: 332121

URL: http://llvm.org/viewvc/llvm-project?rev=332121=rev
Log:
[HIP] Let clang-offload-bundler support HIP

When bundle/unbundle intermediate files for HIP, there may be multiple
sub archs, therefore BoundArch needs to be included in the target
and output file names for clang-offload-bundler.

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=332121=332120=332121=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri May 11 12:02:18 2018
@@ -3736,9 +3736,12 @@ InputInfo Driver::BuildJobsForActionNoCa
   UI.DependentToolChain->getTriple().normalize(),
   /*CreatePrefixForHost=*/true);
   auto CurI = InputInfo(
-  UA, GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
- /*AtTopLevel=*/false, MultipleArchs,
- OffloadingPrefix),
+  UA,
+  GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
+ /*AtTopLevel=*/false,
+ MultipleArchs ||
+ UI.DependentOffloadKind == Action::OFK_HIP,
+ OffloadingPrefix),
   BaseInput);
   // Save the unbundling result.
   UnbundlingResults.push_back(CurI);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=332121=332120=332121=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri May 11 12:02:18 2018
@@ -5542,6 +5542,10 @@ void OffloadBundler::ConstructJob(Compil
 Triples += Action::GetOffloadKindName(CurKind);
 Triples += '-';
 Triples += CurTC->getTriple().normalize();
+if (CurKind == Action::OFK_HIP && CurDep->getOffloadingArch()) {
+  Triples += '-';
+  Triples += CurDep->getOffloadingArch();
+}
   }
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));
 
@@ -5611,6 +5615,11 @@ void OffloadBundler::ConstructJobMultipl
 Triples += Action::GetOffloadKindName(Dep.DependentOffloadKind);
 Triples += '-';
 Triples += Dep.DependentToolChain->getTriple().normalize();
+if (Dep.DependentOffloadKind == Action::OFK_HIP &&
+!Dep.DependentBoundArch.empty()) {
+  Triples += '-';
+  Triples += Dep.DependentBoundArch;
+}
   }
 
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=332121=332120=332121=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Fri May 11 
12:02:18 2018
@@ -969,11 +969,11 @@ int main(int argc, const char **argv) {
 getOffloadKindAndTriple(Target, Kind, Triple);
 
 bool KindIsValid = !Kind.empty();
-KindIsValid = KindIsValid &&
-  StringSwitch(Kind)
-  .Case("host", true)
-  .Case("openmp", true)
-  .Default(false);
+KindIsValid = KindIsValid && StringSwitch(Kind)
+ .Case("host", true)
+ .Case("openmp", true)
+ .Case("hip", true)
+ .Default(false);
 
 bool TripleIsValid = !Triple.empty();
 llvm::Triple T(Triple);


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


[PATCH] D46473: [HIP] Let clang-offload-bundler support HIP

2018-05-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332121: [HIP] Let clang-offload-bundler support HIP 
(authored by yaxunl, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46473

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -969,11 +969,11 @@
 getOffloadKindAndTriple(Target, Kind, Triple);
 
 bool KindIsValid = !Kind.empty();
-KindIsValid = KindIsValid &&
-  StringSwitch(Kind)
-  .Case("host", true)
-  .Case("openmp", true)
-  .Default(false);
+KindIsValid = KindIsValid && StringSwitch(Kind)
+ .Case("host", true)
+ .Case("openmp", true)
+ .Case("hip", true)
+ .Default(false);
 
 bool TripleIsValid = !Triple.empty();
 llvm::Triple T(Triple);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5542,6 +5542,10 @@
 Triples += Action::GetOffloadKindName(CurKind);
 Triples += '-';
 Triples += CurTC->getTriple().normalize();
+if (CurKind == Action::OFK_HIP && CurDep->getOffloadingArch()) {
+  Triples += '-';
+  Triples += CurDep->getOffloadingArch();
+}
   }
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));
 
@@ -5611,6 +5615,11 @@
 Triples += Action::GetOffloadKindName(Dep.DependentOffloadKind);
 Triples += '-';
 Triples += Dep.DependentToolChain->getTriple().normalize();
+if (Dep.DependentOffloadKind == Action::OFK_HIP &&
+!Dep.DependentBoundArch.empty()) {
+  Triples += '-';
+  Triples += Dep.DependentBoundArch;
+}
   }
 
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -3736,9 +3736,12 @@
   UI.DependentToolChain->getTriple().normalize(),
   /*CreatePrefixForHost=*/true);
   auto CurI = InputInfo(
-  UA, GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
- /*AtTopLevel=*/false, MultipleArchs,
- OffloadingPrefix),
+  UA,
+  GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
+ /*AtTopLevel=*/false,
+ MultipleArchs ||
+ UI.DependentOffloadKind == Action::OFK_HIP,
+ OffloadingPrefix),
   BaseInput);
   // Save the unbundling result.
   UnbundlingResults.push_back(CurI);


Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -969,11 +969,11 @@
 getOffloadKindAndTriple(Target, Kind, Triple);
 
 bool KindIsValid = !Kind.empty();
-KindIsValid = KindIsValid &&
-  StringSwitch(Kind)
-  .Case("host", true)
-  .Case("openmp", true)
-  .Default(false);
+KindIsValid = KindIsValid && StringSwitch(Kind)
+ .Case("host", true)
+ .Case("openmp", true)
+ .Case("hip", true)
+ .Default(false);
 
 bool TripleIsValid = !Triple.empty();
 llvm::Triple T(Triple);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5542,6 +5542,10 @@
 Triples += Action::GetOffloadKindName(CurKind);
 Triples += '-';
 Triples += CurTC->getTriple().normalize();
+if (CurKind == Action::OFK_HIP && CurDep->getOffloadingArch()) {
+  Triples += '-';
+  Triples += CurDep->getOffloadingArch();
+}
   }
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));
 
@@ -5611,6 +5615,11 @@
 Triples += Action::GetOffloadKindName(Dep.DependentOffloadKind);
 Triples += '-';
 Triples += Dep.DependentToolChain->getTriple().normalize();
+if (Dep.DependentOffloadKind == Action::OFK_HIP &&
+!Dep.DependentBoundArch.empty()) {
+  Triples += '-';
+  Triples += Dep.DependentBoundArch;
+}
   }
 
   CmdArgs.push_back(TCArgs.MakeArgString(Triples));
Index: 

[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, I think this can be simplified a bit but this looks like the right fix.




Comment at: lib/Sema/SemaDecl.cpp:12609-12610
   return false;
+// We can't simply call Type::isUndeducedType here, because it returns
+// false on C++14's auto return type without trailing return type.
+DeducedType *DT = FD->getReturnType()->getContainedDeducedType();

I don't think this comment captures the problem. Rather, I think the problem is 
that in a template we deduce the `auto` to a dependent type, so it's not 
considered "undeduced" at the point when we ask this question.



Comment at: lib/Sema/SemaDecl.cpp:12612-12613
+DeducedType *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())
+  return false;
+  }

Is there any need to check whether the type has been deduced here? It seems 
simpler (and equivalent) to turn off skipping for functions whose return type 
involves a deduced type regardless of whether deduction has been performed 
already (which it hasn't).


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/fuchsia/RestrictSystemIncludesCheck.h:35
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
+  bool contains(StringRef FileName) {
+return AllowedIncludesGlobList.contains(FileName);

juliehockett wrote:
> aaron.ballman wrote:
> > Function can be marked `const`.
> GlobList::contains isn't `const`, so it can't...
Bah, I didn't see that. You can ignore, sorry for the noise.


https://reviews.llvm.org/D43778



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


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-11 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/RestrictSystemIncludesCheck.h:35
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
+  bool contains(StringRef FileName) {
+return AllowedIncludesGlobList.contains(FileName);

aaron.ballman wrote:
> Function can be marked `const`.
GlobList::contains isn't `const`, so it can't...


https://reviews.llvm.org/D43778



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Expounding on my concerns a bit -- I'm worried about all the other places 
calling `isUndeducedType()` and whether they're also at risk and thus a better 
fix is to change `isUndeducedType()` to pay attention to the language mode.




Comment at: lib/Sema/SemaDecl.cpp:12611
+// false on C++14's auto return type without trailing return type.
+DeducedType *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())

This can be marked `const`.


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-11 Thread Raoul Wols via Phabricator via cfe-commits
rwols added a comment.

Can we get this merged soon? I'm experiencing a lot of false positive 
diagnostics with this library  at work.


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


[PATCH] D45835: Add new driver mode for dumping compiler options

2018-05-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Frontend/FrontendActions.cpp:779
+  {
+std::string Str;
+#define FEATURE(Name, Predicate)   
\

This is likely to do an allocation for each feature.
Maybe consider `llvm::SmallString<64>`



Comment at: lib/Frontend/FrontendActions.cpp:781
+#define FEATURE(Name, Predicate)   
\
+  Str += "\t{\"" #Name "\" : " + std::string(Predicate ? "true" : "false") +   
\
+ "},\n";

Similarly, you may want to explicitly use `llvm::Twine` here



Comment at: lib/Frontend/FrontendActions.cpp:791
+
+  OS << "\n\"extensions\" : [\n";
+  {

same


https://reviews.llvm.org/D45835



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


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

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

Thank you for adding the glob feature, I think that will be very powerful in 
practice. Aside from a minor nit, this LGTM!




Comment at: clang-tidy/fuchsia/RestrictSystemIncludesCheck.h:35
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
+  bool contains(StringRef FileName) {
+return AllowedIncludesGlobList.contains(FileName);

Function can be marked `const`.


https://reviews.llvm.org/D43778



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


[PATCH] D45835: Add new driver mode for dumping compiler options

2018-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D45835



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


[PATCH] D46651: [OpenCL] Support placement new/delete in Sema

2018-05-11 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:2030
+  }
+}
 

rjmccall wrote:
> I think a better interpretation of this rule would be to just error on 
> attempts to use the standard non-placement operator new/delete instead of 
> trying to outlaw the operator declarations.  For example, I don't know why a 
> user-defined non-global operator new would be problematic.
Good point, I have raised this with Khronos, so I will hold this off until we 
have clarification.


Repository:
  rC Clang

https://reviews.llvm.org/D46651



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


[PATCH] D46740: [Clang Tablegen][RFC] Allow Early Textual Substitutions in `Diagnostic` messages.

2018-05-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

This seems like a good idea to me.  I wonder if it would be better to take 
advantage of this to shrink the string tables by preserving the substitution 
structure until runtime, but that really doesn't need to be part of this first 
try.




Comment at: utils/TableGen/ClangDiagnosticsEmitter.cpp:514
+  std::vector Diags = Records.getAllDerivedDefinitions("Diagnostic");
+  llvm::for_each(Diags, [&](Record *R) { substituteDiagText(R, SubsMap); });
 

I see why this has to be done separately, I think, but it should at least go in 
a helper function.

Also, please check for substitution-name conflicts.


https://reviews.llvm.org/D46740



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


r332108 - [X86] Fix the file header name on fmaintrin.h

2018-05-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri May 11 10:37:40 2018
New Revision: 332108

URL: http://llvm.org/viewvc/llvm-project?rev=332108=rev
Log:
[X86] Fix the file header name on fmaintrin.h

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

Modified: cfe/trunk/lib/Headers/fmaintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/fmaintrin.h?rev=332108=332107=332108=diff
==
--- cfe/trunk/lib/Headers/fmaintrin.h (original)
+++ cfe/trunk/lib/Headers/fmaintrin.h Fri May 11 10:37:40 2018
@@ -1,4 +1,4 @@
-/*=== fma4intrin.h - FMA4 intrinsics ---===
+/*=== fmaintrin.h - FMA intrinsics -===
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to 
deal


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


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-05-11 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling updated this revision to Diff 146355.
rkirsling added a comment.

Updated patch to resolve conflict and include full diff context.


Repository:
  rC Clang

https://reviews.llvm.org/D46024

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6864,6 +6864,67 @@
   verifyFormat("vector foo = { ::SomeGlobalFunction() };", ExtraSpaces);
   verifyFormat("const struct A a = { .a = 1, .b = 2 };", ExtraSpaces);
   verifyFormat("const struct A a = { [0] = 1, [1] = 2 };", ExtraSpaces);
+
+  FormatStyle SpaceBeforeBrace = getLLVMStyle();
+  SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
+  verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
+  verifyFormat("vector x {\n"
+   "1,\n"
+   "2,\n"
+   "3,\n"
+   "4,\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("vector x {{}, {}, {}, {}};", SpaceBeforeBrace);
+  verifyFormat("f({1, 2});", SpaceBeforeBrace);
+  verifyFormat("auto v = Foo {-1};", SpaceBeforeBrace);
+  verifyFormat("f({1, 2}, {{2, 3}, {4, 5}}, c, {d});", SpaceBeforeBrace);
+  verifyFormat("Class::Class : member {1, 2, 3} {}", SpaceBeforeBrace);
+  verifyFormat("new vector {1, 2, 3};", SpaceBeforeBrace);
+  verifyFormat("new int[3] {1, 2, 3};", SpaceBeforeBrace);
+  verifyFormat("new int {1};", SpaceBeforeBrace);
+  verifyFormat("return {arg1, arg2};", SpaceBeforeBrace);
+  verifyFormat("return {arg1, SomeType {parameter}};", SpaceBeforeBrace);
+  verifyFormat("int count = set {f(), g(), h()}.size();",
+   SpaceBeforeBrace);
+  verifyFormat("new T {arg1, arg2};", SpaceBeforeBrace);
+  verifyFormat("f(MyMap[{composite, key}]);", SpaceBeforeBrace);
+  verifyFormat("class Class {\n"
+   "  T member = {arg1, arg2};\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("vector foo = {::SomeGlobalFunction()};",
+   SpaceBeforeBrace);
+  verifyFormat("const struct A a = {.a = 1, .b = 2};", SpaceBeforeBrace);
+  verifyFormat("const struct A a = {[0] = 1, [1] = 2};", SpaceBeforeBrace);
+  verifyFormat("static_assert(std::is_integral {} + 0, \"\");",
+   SpaceBeforeBrace);
+  verifyFormat("int a = std::is_integral {} + 0;", SpaceBeforeBrace);
+  verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace);
+  verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace);
+  verifyFormat("auto i = decltype(x) {};", SpaceBeforeBrace);
+  verifyFormat("std::vector v = {1, 0 /* comment */};",
+   SpaceBeforeBrace);
+  verifyFormat("Node n {1, Node {1000}, //\n"
+   "2};",
+   SpaceBeforeBrace);
+  verifyFormat("Aaaa aaa {\n"
+   "{\n"
+   ",\n"
+   "},\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("class C : public D {\n"
+   "  SomeClass SC {2};\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("class C : public A {\n"
+   "  class D : public B {\n"
+   "void f() { int i {2}; }\n"
+   "  };\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("#define A {a, a},", SpaceBeforeBrace);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
@@ -10446,6 +10507,7 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2538,6 +2538,9 @@
   if (Style.isCpp()) {
 if (Left.is(tok::kw_operator))
   return Right.is(tok::coloncolon);
+if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit &&
+!Left.opensScope() && Style.SpaceBeforeCpp11BracedList)
+  return true;
   } else if (Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Right.is(tok::period) &&
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -413,6 +413,8 @@
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
+IO.mapOptional("SpaceBeforeCpp11BracedList",
+  

[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: lib/AST/DeclPrinter.cpp:218
 for (auto *A : Attrs) {
+  if (A->isInherited())
+continue;

I implemented inherited attribute suppression in this function with the 
expectation that the test suite would reveal a use case where that's wrong.  
However, the test suite behaved.  If you know of a use case, please let me know.


https://reviews.llvm.org/D45463



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


[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 146351.
jdenny marked 10 inline comments as done.
jdenny edited the summary of this revision.
jdenny added a comment.

Made the suggested changes.  Thanks.


https://reviews.llvm.org/D45463

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/Misc/ast-print-enum-decl.c
  test/Misc/ast-print-record-decl.c

Index: test/Misc/ast-print-record-decl.c
===
--- /dev/null
+++ test/Misc/ast-print-record-decl.c
@@ -0,0 +1,235 @@
+// Check struct:
+//
+//   First check compiling and printing of this file.
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES= -o - %s \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s \
+//   RUN:   --input-file %t.c
+//
+//   Now check compiling and printing of the printed file.
+//
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.c
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print %t.c \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s
+
+// Repeat for union:
+//
+//   First check compiling and printing of this file.
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=union -DBASES= -o - %s \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print -DKW=union -DBASES= %s > %t.c
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s \
+//   RUN:   --input-file %t.c
+//
+//   Now check compiling and printing of the printed file.
+//
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.c
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print %t.c \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s
+
+// Repeat for C++ (BASES helps ensure we're printing as C++ not as C):
+//
+//   First check compiling and printing of this file.
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES=' : B' -o - \
+//   RUN:-xc++ %s \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN: > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   Now check compiling and printing of the printed file.
+//
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.cpp
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+
+// END.
+
+#ifndef KW
+# error KW undefined
+# define KW struct // help syntax checkers
+#endif
+
+#ifndef BASES
+# error BASES undefined
+# define BASES // help syntax checkers
+#endif
+
+struct B {};
+
+// CHECK-LABEL: defFirst
+void defFirst() {
+  // PRINT-NEXT: [[KW]]
+  // PRINT-DAG:  __attribute__((aligned(16)))
+  // PRINT-DAG:  __attribute__((deprecated("")))
+  // PRINT-NOT:  __attribute__
+  // PRINT-SAME: T[[BASES]] {
+  // PRINT-NEXT:   int i;
+  // PRINT-NEXT: } *p0;
+  // expected-warning@+2 {{'T' is deprecated}}
+  // expected-note@+1 2 {{'T' has been explicitly marked deprecated here}}
+  KW __attribute__((aligned(16))) __attribute__((deprecated(""))) T BASES {
+int i;
+  } *p0;
+
+  // PRINT-NEXT: [[KW]] T *p1;
+  KW T *p1; // expected-warning {{'T' is deprecated}}
+
+  // LLVM: store i64 16
+  long s0 = sizeof *p0;
+  // LLVM-NEXT: store i64 16
+  long s1 = sizeof *p1;
+}
+
+// CHECK-LABEL: defLast
+void defLast() {
+  // PRINT-NEXT: [[KW]] __attribute__((aligned(16))) T *p0;
+  KW __attribute__((aligned(16))) T *p0;
+
+  // PRINT-NEXT: [[KW]] __attribute__((deprecated(""))) T[[BASES]] {
+  // PRINT-NEXT:   int i;
+  // PRINT-NEXT: } *p1;
+  // expected-warning@+2 {{'T' is deprecated}}
+  // expected-note@+1 {{'T' has been explicitly marked deprecated here}}
+  KW __attribute__((deprecated(""))) T BASES { int i; } *p1;
+
+  

[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

2018-05-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D46685



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


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-11 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 146349.
juliehockett added a comment.

Updating parameter list to be a glob-style list.


https://reviews.llvm.org/D43778

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp
  clang-tidy/fuchsia/RestrictSystemIncludesCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h
  test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h
  test/clang-tidy/fuchsia-restrict-system-includes-all.cpp
  test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp
  test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
  test/clang-tidy/fuchsia-restrict-system-includes.cpp

Index: test/clang-tidy/fuchsia-restrict-system-includes.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-system-includes.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 's.h'}]}" \
+// RUN:   -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system
+
+#include "a.h"
+
+#include 
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed
+// CHECK-FIXES-NOT: #include 
+
+#include "s.h"
+#include "t.h"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed
+// CHECK-FIXES-NOT: #include "t.h"
+
+#define foo 
+
+#include foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: #include foo
+
+#/* comment */ include /* comment */ foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: # /* comment */ include /* comment */ foo
Index: test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
@@ -0,0 +1,20 @@
+// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes %T/Inputs
+// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
+// RUN:   -system-headers -header-filter=.* \
+// RUN:   -- -std=c++11 -I %T/Inputs/fuchsia-restrict-system-includes -isystem %T/Inputs/fuchsia-restrict-system-includes/system
+// RUN: FileCheck -input-file=%T/Inputs/transitive2.h %s -check-prefix=CHECK-HEADER-FIXES
+
+// transitive.h includes  and 
+#include 
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
+
+// transitive.h includes  and 
+#include "transitive2.h"
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/transitive2.h
+// CHECK-HEADER-FIXES-NOT: #include 
+
+int main() {
+  // f() is declared in r.h
+}
Index: test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'cstd*'}]}" \
+// RUN:   -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system
+
+#include 
+#include 
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed
+// CHECK-FIXES-NOT: #include 
Index: test/clang-tidy/fuchsia-restrict-system-includes-all.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-system-includes-all.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: ''}]}" \
+// 

r332105 - [Hexagon] Implement checking arguments of builtin calls

2018-05-11 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri May 11 09:41:51 2018
New Revision: 332105

URL: http://llvm.org/viewvc/llvm-project?rev=332105=rev
Log:
[Hexagon] Implement checking arguments of builtin calls

Added:
cfe/trunk/test/CodeGen/hexagon-check-builtins.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=332105=332104=332105=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 11 09:41:51 2018
@@ -10380,6 +10380,7 @@ private:
   bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
 
   bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=332105=332104=332105=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri May 11 09:41:51 2018
@@ -1295,6 +1295,10 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
   return ExprError();
 break;
+  case llvm::Triple::hexagon:
+if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
+  return ExprError();
+break;
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
@@ -1671,6 +1675,225 @@ bool Sema::CheckAArch64BuiltinFunctionCa
   return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
 }
 
+bool Sema::CheckHexagonBuiltinFunctionCall(unsigned BuiltinID,
+   CallExpr *TheCall) {
+  struct ArgInfo {
+ArgInfo(unsigned O, bool S, unsigned W, unsigned A)
+  : OpNum(O), IsSigned(S), BitWidth(W), Align(A) {}
+unsigned OpNum = 0;
+bool IsSigned = false;
+unsigned BitWidth = 0;
+unsigned Align = 0;
+  };
+
+  static const std::map Infos = {
+{ Hexagon::BI__builtin_circ_ldd,  {{ 3, true,  4,  3 }} },
+{ Hexagon::BI__builtin_circ_ldw,  {{ 3, true,  4,  2 }} },
+{ Hexagon::BI__builtin_circ_ldh,  {{ 3, true,  4,  1 }} },
+{ Hexagon::BI__builtin_circ_lduh, {{ 3, true,  4,  0 }} },
+{ Hexagon::BI__builtin_circ_ldb,  {{ 3, true,  4,  0 }} },
+{ Hexagon::BI__builtin_circ_ldub, {{ 3, true,  4,  0 }} },
+{ Hexagon::BI__builtin_circ_std,  {{ 3, true,  4,  3 }} },
+{ Hexagon::BI__builtin_circ_stw,  {{ 3, true,  4,  2 }} },
+{ Hexagon::BI__builtin_circ_sth,  {{ 3, true,  4,  1 }} },
+{ Hexagon::BI__builtin_circ_sthhi,{{ 3, true,  4,  1 }} },
+{ Hexagon::BI__builtin_circ_stb,  {{ 3, true,  4,  0 }} },
+
+{ Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci,{{ 1, true,  4,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1, true,  4,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci,{{ 1, true,  4,  1 }} },
+{ Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1, true,  4,  1 }} },
+{ Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1, true,  4,  2 }} },
+{ Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1, true,  4,  3 }} },
+{ Hexagon::BI__builtin_HEXAGON_S2_storerb_pci,{{ 1, true,  4,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_S2_storerh_pci,{{ 1, true,  4,  1 }} },
+{ Hexagon::BI__builtin_HEXAGON_S2_storerf_pci,{{ 1, true,  4,  1 }} },
+{ Hexagon::BI__builtin_HEXAGON_S2_storeri_pci,{{ 1, true,  4,  2 }} },
+{ Hexagon::BI__builtin_HEXAGON_S2_storerd_pci,{{ 1, true,  4,  3 }} },
+
+{ Hexagon::BI__builtin_HEXAGON_A2_combineii,  {{ 1, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfrih,  {{ 1, false, 16, 0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfril,  {{ 1, false, 16, 0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfrpi,  {{ 0, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_bitspliti,  {{ 1, false, 5,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi,{{ 1, false, 8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cmpbgti,{{ 1, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cround_ri,  {{ 1, false, 5,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_round_ri,   {{ 1, 

[PATCH] D46758: [clang-format] Move #include related style to libToolingCore

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Format/Format.cpp:461
+
+template <> struct MappingTraits {
+  static void mapping(IO , IncludeStyle::IncludeCategory ) {

Should we move this to `tooling::Core` too?
If we need to specialize `MappingTraits`, we should probably do it close to the 
class definitions. To avoid accidental ODR violations...


Repository:
  rC Clang

https://reviews.llvm.org/D46758



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> Here :)
>  
> http://www.sidefx.com/docs/hdk/_s_o_p___bone_capture_lines_8proto_8h_source.html

Didn't take along to find an example. Thanks for digging this up. That looks 
like a good enough reason to not apply proto-specific filtering based solely on 
the filename...

> I like the idea that things work "out of the box", we have to make sure that 
> it doesn't make it buggy for certain code bases and impossible to work around.

Totally agree, we should only enable something that we all agree is good enough 
at detecting the frameworks that it never guesses wrong on real code.

> If handling for other libraries is added later it would be good to split out 
> this code a bit. A collection of "filters" could be passed to symbol 
> collector. Each filter/framework-handling could be in it's own source file. 
> Later...

That LG, I guess we can iterate on the design in a CL, design doc or an email 
thread. However, it's outside the scope of this patch probably.

> I'm not a big fan of parsing file comment in proto. It seems a bit cumbersome 
> and we might not be able (or too expensive) to do so for completion results 
> from sema (if we do want to filter at completion time).

Why do you feel it's cubersome? Getting the first line of the file from 
SourceManager and looking at it seems easy.
I certainly don't see why this should be expensive if we do it at the right 
time (perhaps it means doing that when building the preamble and stashing the 
results alongside it, but that's also easy in our current setup).




Comment at: clangd/index/SymbolCollector.cpp:156
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;
+

ioeric wrote:
> ilya-biryukov wrote:
> > We should also run the same code to filter our those decls coming from sema 
> > completions.
> > Otherwise, they might still pop up in completion results if internal proto 
> > symbols were deserialized from preamble by clang before running the code 
> > completion.
> Just want to clarify before going further. IIUC, in *index-based* completion, 
> the preamble could still contain symbols from headers such that sema 
> completion could still give you symbols from headers. 
> 
> If we do need to build the filter into code completion, we would need more 
> careful design as code completion code path is more latency sensitive.
For reference. As discussed outside this thread, we might have decls from 
headers in the sema completion items.
It does not seem too hard to add filtering for those as well: essentially, we 
just need to call the same function at code completion time.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

The moving of IncludeStyle has been split into a separate patch 
https://reviews.llvm.org/D46758.




Comment at: include/clang/Format/Format.h:1818
 ///   from \p Code if it exists.
+/// See documentation for `tooling::HeaderIncludes` for the behavior.
 llvm::Expected

ilya-biryukov wrote:
> `for the behavior` is a little confusing. Could we try elaborating on what 
> 'behavior' is a bit more? E.g. `the include manipulation is done via 
> tooling::HeaderInclude, see its documentation for more details on how include 
> insertion points are found and which edits are produced`.
Sure. Thanks for the suggestion!



Comment at: include/clang/Tooling/Core/HeaderIncludes.h:22
+
+struct IncludeStyle {
+  /// Styles for sorting multiple ``#include`` blocks.

ilya-biryukov wrote:
> This struct looks big enough to justify putting it into a separate header. 
> For the sake of keeping `HeaderIncludes` the first thing that people see when 
> they open a file.
> WDYT?
Good point. Branched into D46758



Comment at: include/clang/Tooling/Core/HeaderIncludes.h:112
+/// priorities for headers.
+/// FIXME(ioeric): move this class into implementation file when clang-format's
+/// include sorting functions are also moved here.

ilya-biryukov wrote:
> Can we move them in the current commit too?
> `IncludeCategoryManager` does look like something that should not be in the 
> public header.
Not yet... include sorting logics would also require refactoring in order to be 
moved from clang-format.


Repository:
  rC Clang

https://reviews.llvm.org/D46496



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


[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146339.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Rebase on https://reviews.llvm.org/D46758
- Addressed comments.


Repository:
  rC Clang

https://reviews.llvm.org/D46496

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  include/clang/Tooling/Core/IncludeStyle.h
  lib/Format/Format.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -0,0 +1,527 @@
+//===- unittest/Tooling/CleanupTest.cpp - Include insertion/deletion tests ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "../Tooling/ReplacementTest.h"
+#include "../Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+using clang::tooling::ReplacementTest;
+using clang::tooling::toReplacements;
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class HeaderIncludesTest : public ::testing::Test {
+protected:
+  std::string insert(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto R = Includes.insert(Header.trim("\"<>"), Header.startswith("<"));
+if (!R)
+  return Code;
+auto Result = applyAllReplacements(Code, Replacements(*R));
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  std::string remove(llvm::StringRef Code, llvm::StringRef Header) {
+HeaderIncludes Includes(FileName, Code, Style);
+assert(Header.startswith("\"") || Header.startswith("<"));
+auto Replaces = Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  const std::string FileName = "fix.cpp";
+  IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
+};
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
+}
+
+TEST_F(HeaderIncludesTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  EXPECT_EQ(Expected, insert(Code, ""));
+}
+
+TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  EXPECT_EQ(Expected, insert(Code, "\"z.h\""));
+}
+

[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Thanks for sharing the example Marc! It's a bit surprising to see files that 
are not protobuf-generated named proto.h.

I'm not a big fan of parsing file comment in proto. It seems a bit cumbersome 
and we might not be able (or too expensive) to do so for completion results 
from sema (if we do want to filter at completion time).

Pattern-based filtering could be an option as it wouldn't require code 
modification and could support potentially more filters, although I'm a bit 
worries about rules getting too complicated (e.g. filters on symbol kinds etc) 
or running into limitation.

But for now, it seems to me that the easiest approach is putting an option 
around proto heuristic for the symbol collector, until we need more filters.




Comment at: clangd/index/SymbolCollector.cpp:156
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;
+

ilya-biryukov wrote:
> We should also run the same code to filter our those decls coming from sema 
> completions.
> Otherwise, they might still pop up in completion results if internal proto 
> symbols were deserialized from preamble by clang before running the code 
> completion.
Just want to clarify before going further. IIUC, in *index-based* completion, 
the preamble could still contain symbols from headers such that sema completion 
could still give you symbols from headers. 

If we do need to build the filter into code completion, we would need more 
careful design as code completion code path is more latency sensitive.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:713
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),

ilya-biryukov wrote:
> Maybe also test that the same symbol is not excluded in the  file that does 
> not end with `.proto.h`?
Sounds good.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146338.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Addressed a few comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -697,6 +697,39 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
+TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
+  TestHeaderName = testPath("x.proto.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+class TopLevel {};
+enum Kind {
+  KIND_OK,
+  Kind_Not_Ok,
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),
+QName("nx::KIND_OK")));
+}
+
+TEST_F(SymbolCollectorTest, DontFilterNonProtoSymbols) {
+  TestHeaderName = testPath("x.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+enum Kind {
+  Kind_Fine
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
+   QName("nx::Kind"), QName("nx::Kind_Fine")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -90,6 +90,24 @@
   return llvm::None;
 }
 
+bool isPrivateProtoSymbol(const NamedDecl *ND, const SourceManager ) {
+  auto FileName = SM.getFilename(findNameLoc(ND));
+  if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
+return false;
+  auto Name = ND->getName();
+  if (!Name.contains('_'))
+return false;
+  // Nested proto entities (e.g. Message::Nested) have top-level decls
+  // that shouldn't be used (Message_Nested). Ignore them completely.
+  // The nested entities are dangling type aliases, we may want to reconsider
+  // including them in the future.
+  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
+  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
+  // will include OUTER_INNER and exclude some_enum_constant.
+  return (ND->getKind() != Decl::EnumConstant) ||
+ std::any_of(Name.begin(), Name.end(), islower);
+}
+
 bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
   const SymbolCollector::Options ) {
   using namespace clang::ast_matchers;
@@ -130,6 +148,10 @@
   .empty())
 return true;
 
+  // Avoid indexing internal symbols in protobuf generated headers.
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;
+
   return false;
 }
 


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -697,6 +697,39 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
+TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
+  TestHeaderName = testPath("x.proto.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+class TopLevel {};
+enum Kind {
+  KIND_OK,
+  Kind_Not_Ok,
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),
+QName("nx::KIND_OK")));
+}
+
+TEST_F(SymbolCollectorTest, DontFilterNonProtoSymbols) {
+  TestHeaderName = testPath("x.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+enum Kind {
+  Kind_Fine
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
+   QName("nx::Kind"), QName("nx::Kind_Fine")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -90,6 +90,24 @@
   return llvm::None;
 }
 
+bool isPrivateProtoSymbol(const NamedDecl *ND, const SourceManager ) {
+  auto FileName = SM.getFilename(findNameLoc(ND));
+  if (!FileName.endswith(".proto.h") && !FileName.endswith(".pb.h"))
+return false;
+  auto Name = ND->getName();
+  if (!Name.contains('_'))
+

[PATCH] D46758: [clang-format] Move #include related style to libToolingCore

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, klimek.

This will be shared by include insertion/deletion library.


Repository:
  rC Clang

https://reviews.llvm.org/D46758

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/IncludeStyle.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -26,12 +26,12 @@
 
   std::string sort(StringRef Code, std::vector Ranges,
StringRef FileName = "input.cc") {
-auto Replaces = sortIncludes(Style, Code, Ranges, FileName);
+auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
-*Sorted, reformat(Style, *Sorted, Ranges, FileName));
+*Sorted, reformat(FmtStyle, *Sorted, Ranges, FileName));
 EXPECT_TRUE(static_cast(Result));
 return *Result;
   }
@@ -41,12 +41,12 @@
   }
 
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
-sortIncludes(Style, Code, GetCodeRange(Code), "input.cpp", );
+sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.cpp", );
 return Cursor;
   }
 
-  FormatStyle Style = getLLVMStyle();
-
+  FormatStyle FmtStyle = getLLVMStyle();
+  tooling::IncludeStyle  = FmtStyle.IncludeStyle;
 };
 
 TEST_F(SortIncludesTest, BasicSorting) {
@@ -74,11 +74,11 @@
  "#include \n"
  "#include \n"
  "#include \n";
-  EXPECT_TRUE(sortIncludes(Style, Code, GetCodeRange(Code), "a.cc").empty());
+  EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -88,7 +88,7 @@
  "\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -119,7 +119,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  Style.SortIncludes = false;
+  FmtStyle.SortIncludes = false;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -182,7 +182,7 @@
 }
 
 TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -202,7 +202,7 @@
  "// comment\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "// comment\n"
@@ -212,7 +212,7 @@
  "// comment\n"
  "#include \"b.h\"\n"));
 
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "// comment\n"
@@ -233,7 +233,7 @@
  "#include \"c.h\"\n"
  "#include \"a.h\"\n"));
 
-  Style = getGoogleStyle(FormatStyle::LK_Cpp);
+  FmtStyle = getGoogleStyle(FormatStyle::LK_Cpp);
   EXPECT_EQ("#include \n"
 "#include \n"
 "#include \"a.h\"\n"
@@ -245,7 +245,7 @@
 }
 
 TEST_F(SortIncludesTest, RegroupsAngledIncludesInSeparateBlocks) {
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "\n"
@@ -345,7 +345,7 @@
 
 TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
-  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge;
 
   EXPECT_EQ("#include \"c.h\"\n"
 "#include \"a.h\"\n"
@@ -359,7 +359,7 @@
 
 TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
-  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
 
   EXPECT_EQ("#include \"a.h\"\n"
 "\n"
@@ -417,7 +417,7 @@
 
 

[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous planned changes to this revision.
jkorous added a comment.

Sorry, my bad. I tried to get rid of dependency on Foundation.h and didn't 
check the test is relevant for the fix after that.

  #import 
  
  @interface foo
  - (void) method NS_AVAILABLE_MAC(10_12);
  @end
  
  int main() {
  [foo method];
  return 0;
  }

Looks like NS_AVAILABLE_MAC is not equivalent to the attribute.

Interesting question about UsesUnderscores, thanks! It looks like it must be 
set through constructor somewhere - will figure this out.


Repository:
  rC Clang

https://reviews.llvm.org/D46747



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


[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

That test passes for me without this patch applied, why is UsesUnderscores 
actually getting set in the radar?


Repository:
  rC Clang

https://reviews.llvm.org/D46747



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


[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files

2018-05-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D46602#1095960, @alexfh wrote:

> In https://reviews.llvm.org/D46602#1092902, @lebedev.ri wrote:
>
> > In https://reviews.llvm.org/D46602#1092890, @alexfh wrote:
> >
> > > Roman, it looks to me that a simpler storage scheme would be sufficient. 
> > > For example, MMDDhhmmss-InputFileName.cpp.csv.
> > >  Main things are:
> > >
> > > 1. include a timestamp, so there's no need to overwrite old results,
> >
> >
> > Of the input source file?
>
>
> No, current timestamp, when each profile gets dumped.


Ah.
Then i don't understand this at all. Why would we want to do that, exactly?
Just so that we can avoid creating directory structure? Why do we want to avoid 
that?

>>> 2. include just the name of the file without any parent directories,
>> 
>> That won't work, there are duplicate filenames even in LLVM.
> 
> That's why I suggested to include a timestamp. Each result file will get a 
> unique timestamp as a part of its name (unless the resolution of the 
> timestamp is too coarse - compared to clang-tidy run time - to allow 
> collisions).
> 
>> $ find -iname Path.cpp
>>  ./lib/Support/Path.cpp
>>  ./unittests/Support/Path.cpp
>> 
>>   > 3. put all outputs into the same directory. This way we wouldn't have to 
>> create a directory structure and think about stripping a certain prefix 
>> (btw, utilities like patch just specify the number of path components to 
>> remove from the start, not the actual substring). WDYT?
>>
>>I'm not particularly looking forward to having being forced to have n 
>> thousands of reports in a single directory :)
> 
> What kind of problems do you expect to have with this? Are you going to look 
> at the result files manually or use a script to aggregate them?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46602



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D46751#1095923, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D46751#1095894, @malaperle wrote:
>
> > Can there be an option for this? This seems very library specific and could 
> > break other code bases. Ideally, there would be a generic mechanism for 
> > this kind of filtering, i.e. specify a pattern of excluded files or symbol 
> > names. But I understand this would be cumbersome because you want to filter 
> > only *some* symbol names in *some* files, so it would be difficult for 
> > users to specify this intersection of conditions on command-line arguments, 
> > for example. I think this needs to be discussed a bit more or have this 
> > turned off by default (with an option to turn on!) until there is a more 
> > general solution for this kind of filtering.
>
>
> Having user-configurable filtering may certainly be useful, but requires some 
> design to get right.
>  And even if we have it, I think there's value in automatically handling 
> popular frameworks, unless we know it might break other code **in practice**.


Here :)
http://www.sidefx.com/docs/hdk/_s_o_p___bone_capture_lines_8proto_8h_source.html

> I feel it's better to have the filtering for protos **enabled** by default

I like the idea that things work "out of the box", we have to make sure that it 
doesn't make it buggy for certain code bases and impossible to work around.

In https://reviews.llvm.org/D46751#1095926, @ilya-biryukov wrote:

> So, the first line of the file generated by proto compiler seems to be 
> something like this:
>
>   // Generated by the protocol buffer compiler.  DO NOT EDIT!
>
> If we check the symbol comes from a file with this comment, there will be 
> zero chance that we guess it wrong.
>  And we can always filter, in addition to the user-provided filters that 
> @malaperle proposed (which also sound like a very useful feature to me!)
>
> @ioeric, @malaperle, @sammccall, WDYT?


I think this is good if that's true that the comment is always there. I think 
it would be OK for this to be enabled by default, with a general option to turn 
heuristics off. Not sure what to call it... `-use-symbol-filtering-heuristics` 
:)

If handling for other libraries is added later it would be good to split out 
this code a bit. A collection of "filters" could be passed to symbol collector. 
Each filter/framework-handling could be in it's own source file. Later...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46757: [clang-format] Break inside submessages containing a submessage and something else

2018-05-11 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

TODO


Repository:
  rC Clang

https://reviews.llvm.org/D46757

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestRawStrings.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -171,17 +171,48 @@
   verifyFormat("msg_field < field_a < field_b <> > >");
   verifyFormat("msg_field: < field_a < field_b: <> > >");
   verifyFormat("msg_field < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field < field_a { field_b: 1 }, field_c: < f_d: 2 > >");
   verifyFormat("msg_field: < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field: < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field: < field_a { field_b: 1 }, field_c: < fd_d: 2 > >");
-  verifyFormat("field_a: \"OK\", msg_field: < field_b: 123 >, field_c: {}");
-  verifyFormat("field_a < field_b: 1 >, msg_fid: < fiel_b: 123 >, field_c <>");
-  verifyFormat("field_a < field_b: 1 > msg_fied: < field_b: 123 > field_c <>");
-  verifyFormat("field < field < field: <> >, field <> > field: < field: 1 >");
-
   // Multiple lines tests
+  verifyFormat("msg_field <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < f_d: 2 >\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < fd_d: 2 >\n"
+   ">");
+
+  verifyFormat("field_a: \"OK\",\n"
+   "msg_field: < field_b: 123 >,\n"
+   "field_c: {}");
+
+  verifyFormat("field_a < field_b: 1 >,\n"
+   "msg_fid: < fiel_b: 123 >,\n" 
+   "field_c <>");
+
+  verifyFormat("field_a < field_b: 1 >\n"
+   "msg_fied: < field_b: 123 >\n"
+   "field_c <>");
+
+  verifyFormat("field <\n"
+   "  field < field: <> >,\n"
+   "  field <>\n"
+   ">\n"
+   "field: < field: 1 >");
+
   verifyFormat("msg_field <\n"
"  field_a: OK\n"
"  field_b: \"OK\"\n"
@@ -242,7 +273,10 @@
"  field_d: ok\n"
"}");
 
-  verifyFormat("field_a: < f1: 1, f2: <> >\n"
+  verifyFormat("field_a: <\n"
+   "  f1: 1,\n"
+   "  f2: <>\n"
+   ">\n"
"field_b <\n"
"  field_b1: <>\n"
"  field_b2: ok,\n"
@@ -507,5 +541,102 @@
">");
 }
 
+TEST_F(FormatTestTextProto, BreaksEntriesOfSubmessagesContainingSubmessages) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+  Style.ColumnLimit = 60;
+  // The column limit allows for the keys submessage to be put on 1 line, but we
+  // break it since it contains a submessage an another entry.
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub <>\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub {}\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  sub: <>\n"
+   "  sub: []\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub < msg: 1 >\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: [ msg: 1 ]\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: <\n"
+   "  item: 'aaa'\n"
+   "  sub: [ 1, 2 ]\n"
+   ">");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  item: ''\n"
+   "}");
+  verifyFormat("key: 

[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/AST/RawCommentList.h:138
+  /// the overload with ASTContext in the rest of the code.
+  std::string getFormattedText(const SourceManager ,
+   DiagnosticsEngine ) const;

ioeric wrote:
> I think we can get rid of the interface that takes `ASTContext`? If 
> `SourceManager` and `Diags` are sufficient, I don't see why we would want 
> another interface for ASTContext.
Two reasons that come to mind: it's simpler to use and follows the API of 
`getBriefText`. If not for mocking the tests, I would totally only keep the 
`ASTContext`-based one, since it does not really make any sense to create 
`RawComment` without `ASTContext` for any reason other than testing.



Comment at: lib/AST/RawCommentList.cpp:352
+  // comments::Lexer. Therefore, we just use default-constructed options.
+  CommentOptions DefOpts;
+  comments::CommandTraits EmptyTraits(Allocator, DefOpts);

ioeric wrote:
> I'm not quite sure about this. Could we just require a `CommandTraits` in the 
> interface? And only make this assumption in tests?
I think we shouldn't add this to params, the whole point of this function is to 
do parsing that ignores the commands and the `CommandTraits`. The fact that 
lexer still needs them is because we haven't extracted a simpler interface from 
`Lexer` that doesn't rely on unused params, i.e. `CommandTraits` and 
`Allocator`.



Comment at: unittests/AST/CommentTextTest.cpp:32
+  std::string formatComment(llvm::StringRef CommentText) {
+llvm::IntrusiveRefCntPtr EmptyFS(
+new vfs::InMemoryFileSystem);

ioeric wrote:
> `SourceManagerForFile` added in D46176 should save you a few lines here. (I'm 
> landing it right now...)
Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D46000



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


[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 146326.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Simplify test code with SourceManagerForFile.


Repository:
  rC Clang

https://reviews.llvm.org/D46000

Files:
  include/clang/AST/CommentLexer.h
  include/clang/AST/RawCommentList.h
  lib/AST/CommentLexer.cpp
  lib/AST/RawCommentList.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/CommentTextTest.cpp

Index: unittests/AST/CommentTextTest.cpp
===
--- /dev/null
+++ unittests/AST/CommentTextTest.cpp
@@ -0,0 +1,122 @@
+//===- unittest/AST/CommentTextTest.cpp - Comment text extraction test ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for user-friendly output formatting of comments, i.e.
+// RawComment::getFormattedText().
+//
+//===--===//
+
+#include "clang/AST/RawCommentList.h"
+#include "clang/Basic/CommentOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+
+namespace clang {
+
+class CommentTextTest : public ::testing::Test {
+protected:
+  std::string formatComment(llvm::StringRef CommentText) {
+SourceManagerForFile FileSourceMgr("comment-test.cpp", CommentText);
+SourceManager& SourceMgr = FileSourceMgr.get();
+
+auto CommentStartOffset = CommentText.find("/");
+assert(CommentStartOffset != llvm::StringRef::npos);
+FileID File = SourceMgr.getMainFileID();
+
+SourceRange CommentRange(
+SourceMgr.getLocForStartOfFile(File).getLocWithOffset(
+CommentStartOffset),
+SourceMgr.getLocForEndOfFile(File));
+CommentOptions EmptyOpts;
+// FIXME: technically, merged that we set here is incorrect, but that
+// shouldn't matter.
+RawComment Comment(SourceMgr, CommentRange, EmptyOpts, /*Merged=*/true);
+DiagnosticsEngine Diags(new DiagnosticIDs, new DiagnosticOptions);
+return Comment.getFormattedText(SourceMgr, Diags);
+  }
+};
+
+TEST_F(CommentTextTest, FormattedText) {
+  // clang-format off
+  auto ExpectedOutput =
+R"(This function does this and that.
+For example,
+   Runnning it in that case will give you
+   this result.
+That's about it.)";
+  // Two-slash comments.
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+// This function does this and that.
+// For example,
+//Runnning it in that case will give you
+//this result.
+// That's about it.)cpp"));
+
+  // Three-slash comments.
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+/// This function does this and that.
+/// For example,
+///Runnning it in that case will give you
+///this result.
+/// That's about it.)cpp"));
+
+  // Block comments.
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+/* This function does this and that.
+ * For example,
+ *Runnning it in that case will give you
+ *this result.
+ * That's about it.*/)cpp"));
+
+  // Doxygen-style block comments.
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+/** This function does this and that.
+  * For example,
+  *Runnning it in that case will give you
+  *this result.
+  * That's about it.*/)cpp"));
+
+  // Weird indentation.
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+   // This function does this and that.
+  //  For example,
+  // Runnning it in that case will give you
+//   this result.
+   // That's about it.)cpp"));
+  // clang-format on
+}
+
+TEST_F(CommentTextTest, KeepsDoxygenControlSeqs) {
+  // clang-format off
+  auto ExpectedOutput =
+R"(\brief This is the brief part of the comment.
+\param a something about a.
+@param b something about b.)";
+
+  EXPECT_EQ(ExpectedOutput, formatComment(
+R"cpp(
+/// \brief This is the brief part of the comment.
+/// \param a something about a.
+/// @param b something about b.)cpp"));
+  // clang-format on
+}
+
+} // namespace clang
Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -9,6 +9,7 @@
   ASTVectorTest.cpp
   CommentLexer.cpp
   CommentParser.cpp
+  CommentTextTest.cpp
   DataCollectionTest.cpp
   DeclPrinterTest.cpp
   DeclTest.cpp
Index: lib/AST/RawCommentList.cpp
===
--- lib/AST/RawCommentList.cpp
+++ lib/AST/RawCommentList.cpp
@@ -335,3 +335,98 @@
  BeforeThanCompare(SourceMgr));
   

[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files

2018-05-11 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D46602#1092902, @lebedev.ri wrote:

> In https://reviews.llvm.org/D46602#1092890, @alexfh wrote:
>
> > Roman, it looks to me that a simpler storage scheme would be sufficient. 
> > For example, MMDDhhmmss-InputFileName.cpp.csv.
> >  Main things are:
> >
> > 1. include a timestamp, so there's no need to overwrite old results,
>
>
> Of the input source file?


No, current timestamp, when each profile gets dumped.

>> 2. include just the name of the file without any parent directories,
> 
> That won't work, there are duplicate filenames even in LLVM.

That's why I suggested to include a timestamp. Each result file will get a 
unique timestamp as a part of its name (unless the resolution of the timestamp 
is too coarse - compared to clang-tidy run time - to allow collisions).

> $ find -iname Path.cpp
>  ./lib/Support/Path.cpp
>  ./unittests/Support/Path.cpp
> 
>   > 3. put all outputs into the same directory. This way we wouldn't have to 
> create a directory structure and think about stripping a certain prefix (btw, 
> utilities like patch just specify the number of path components to remove 
> from the start, not the actual substring). WDYT?
>
>I'm not particularly looking forward to having being forced to have n 
> thousands of reports in a single directory :)

What kind of problems do you expect to have with this? Are you going to look at 
the result files manually or use a script to aggregate them?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46602



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


[PATCH] D33844: [clang-tidy] terminating continue check

2018-05-11 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.

In https://reviews.llvm.org/D33844#1095862, @koldaniel wrote:

> In https://reviews.llvm.org/D33844#1086565, @alexfh wrote:
>
> >
>
>
> Which comments do you think are still relevant?


Weird. When I was writing the comment, the code looked identical to the version 
from Mar 27. It may have been something wrong with my browser, with the 
Phabricator, or with the way I used it. Anyway, looks good now. Sorry for the 
confusion.

Do you need someone to commit the patch for you?


https://reviews.llvm.org/D33844



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


[PATCH] D46683: [X86] Assume alignment of movdir64b dst argument

2018-05-11 Thread Gabor Buella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332091: [X86] Assume alignment of movdir64b dst argument 
(authored by GBuella, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46683

Files:
  cfe/trunk/lib/Headers/movdirintrin.h
  cfe/trunk/test/CodeGen/builtin-movdir.c


Index: cfe/trunk/test/CodeGen/builtin-movdir.c
===
--- cfe/trunk/test/CodeGen/builtin-movdir.c
+++ cfe/trunk/test/CodeGen/builtin-movdir.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple 
x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s 
-emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86 --check-prefix=CHECK
 
 #include 
 #include 
@@ -22,6 +22,11 @@
 
 void test_dir64b(void *dst, const void *src) {
   // CHECK-LABEL: test_dir64b
+  // CHECK: [[PTRINT1:%.+]] = ptrtoint
+  // X86: [[MASKEDPTR1:%.+]] = and i32 [[PTRINT1]], 63
+  // X86: [[MASKCOND1:%.+]] = icmp eq i32 [[MASKEDPTR1]], 0
+  // X86_64: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
+  // X86_64: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
   // CHECK: call void @llvm.x86.movdir64b
   _movdir64b(dst, src);
 }
Index: cfe/trunk/lib/Headers/movdirintrin.h
===
--- cfe/trunk/lib/Headers/movdirintrin.h
+++ cfe/trunk/lib/Headers/movdirintrin.h
@@ -47,10 +47,15 @@
 
 #endif /* __x86_64__ */
 
-// Move 64 bytes as direct store
+/*
+ * movdir64b - Move 64 bytes as direct store.
+ * The destination must be 64 byte aligned, and the store is atomic.
+ * The source address has no alignment requirement, and the load from
+ * the source address is not atomic.
+ */
 static __inline__ void
 __attribute__((__always_inline__, __nodebug__,  __target__("movdir64b")))
-_movdir64b (void *__dst, const void *__src)
+_movdir64b (void *__dst __attribute__((align_value(64))), const void *__src)
 {
   __builtin_ia32_movdir64b(__dst, __src);
 }


Index: cfe/trunk/test/CodeGen/builtin-movdir.c
===
--- cfe/trunk/test/CodeGen/builtin-movdir.c
+++ cfe/trunk/test/CodeGen/builtin-movdir.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86 --check-prefix=CHECK
 
 #include 
 #include 
@@ -22,6 +22,11 @@
 
 void test_dir64b(void *dst, const void *src) {
   // CHECK-LABEL: test_dir64b
+  // CHECK: [[PTRINT1:%.+]] = ptrtoint
+  // X86: [[MASKEDPTR1:%.+]] = and i32 [[PTRINT1]], 63
+  // X86: [[MASKCOND1:%.+]] = icmp eq i32 [[MASKEDPTR1]], 0
+  // X86_64: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
+  // X86_64: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
   // CHECK: call void @llvm.x86.movdir64b
   _movdir64b(dst, src);
 }
Index: cfe/trunk/lib/Headers/movdirintrin.h
===
--- cfe/trunk/lib/Headers/movdirintrin.h
+++ cfe/trunk/lib/Headers/movdirintrin.h
@@ -47,10 +47,15 @@
 
 #endif /* __x86_64__ */
 
-// Move 64 bytes as direct store
+/*
+ * movdir64b - Move 64 bytes as direct store.
+ * The destination must be 64 byte aligned, and the store is atomic.
+ * The source address has no alignment requirement, and the load from
+ * the source address is not atomic.
+ */
 static __inline__ void
 __attribute__((__always_inline__, __nodebug__,  __target__("movdir64b")))
-_movdir64b (void *__dst, const void *__src)
+_movdir64b (void *__dst __attribute__((align_value(64))), const void *__src)
 {
   __builtin_ia32_movdir64b(__dst, __src);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332091 - [X86] Assume alignment of movdir64b dst argument

2018-05-11 Thread Gabor Buella via cfe-commits
Author: gbuella
Date: Fri May 11 07:22:04 2018
New Revision: 332091

URL: http://llvm.org/viewvc/llvm-project?rev=332091=rev
Log:
[X86] Assume alignment of movdir64b dst argument

Reviewers: craig.topper

Reviewed By: craig.topper

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

Modified:
cfe/trunk/lib/Headers/movdirintrin.h
cfe/trunk/test/CodeGen/builtin-movdir.c

Modified: cfe/trunk/lib/Headers/movdirintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/movdirintrin.h?rev=332091=332090=332091=diff
==
--- cfe/trunk/lib/Headers/movdirintrin.h (original)
+++ cfe/trunk/lib/Headers/movdirintrin.h Fri May 11 07:22:04 2018
@@ -47,10 +47,15 @@ _directstoreu_u64 (void *__dst, unsigned
 
 #endif /* __x86_64__ */
 
-// Move 64 bytes as direct store
+/*
+ * movdir64b - Move 64 bytes as direct store.
+ * The destination must be 64 byte aligned, and the store is atomic.
+ * The source address has no alignment requirement, and the load from
+ * the source address is not atomic.
+ */
 static __inline__ void
 __attribute__((__always_inline__, __nodebug__,  __target__("movdir64b")))
-_movdir64b (void *__dst, const void *__src)
+_movdir64b (void *__dst __attribute__((align_value(64))), const void *__src)
 {
   __builtin_ia32_movdir64b(__dst, __src);
 }

Modified: cfe/trunk/test/CodeGen/builtin-movdir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-movdir.c?rev=332091=332090=332091=diff
==
--- cfe/trunk/test/CodeGen/builtin-movdir.c (original)
+++ cfe/trunk/test/CodeGen/builtin-movdir.c Fri May 11 07:22:04 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple 
x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s 
-emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86 --check-prefix=CHECK
 
 #include 
 #include 
@@ -22,6 +22,11 @@ void test_directstore64(void *dst, uint6
 
 void test_dir64b(void *dst, const void *src) {
   // CHECK-LABEL: test_dir64b
+  // CHECK: [[PTRINT1:%.+]] = ptrtoint
+  // X86: [[MASKEDPTR1:%.+]] = and i32 [[PTRINT1]], 63
+  // X86: [[MASKCOND1:%.+]] = icmp eq i32 [[MASKEDPTR1]], 0
+  // X86_64: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
+  // X86_64: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
   // CHECK: call void @llvm.x86.movdir64b
   _movdir64b(dst, src);
 }


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


[PATCH] D46684: [Frontend] Don't skip function body when the return type is dependent on the template parameter.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12645
+if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType() ||
+FD->getReturnType()->isInstantiationDependentType())
   return false;

rsmith wrote:
> This is a lot broader than necessary; what we should do is to look for a 
> deduced type in the return type. `isUndeducedType` doesn't quite do that for 
> a template because we "deduce" the `auto` as a dependent type early.
My change from some time ago (D44480) seem to do exactly that. Could you take a 
look?


Repository:
  rC Clang

https://reviews.llvm.org/D46684



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


[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LG when all the dependencies are done




Comment at: unittests/clangd/ClangdTests.cpp:941
 
-TEST_F(ClangdVFSTest, InsertIncludes) {
-  MockFSProvider FS;

ioeric wrote:
> ilya-biryukov wrote:
> > Do we test the same thing somewhere else  (e.g. code completion) in one of 
> > the dependent changes?
> > Maybe it's worth noting in the commit description that this test was not 
> > removed completely, but instead moved to ?
> Sure thing.
> 
> This is tested in code completion unit tests in D46497. Noted this in patch 
> summary.
Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46676



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a subscriber: sammccall.
ilya-biryukov added a comment.

So, the first line of the file generated by proto compiler seems to be 
something like this:

  // Generated by the protocol buffer compiler.  DO NOT EDIT!

If we check the symbol comes from a file with this comment, there will be zero 
chance that we guess it wrong.
And we can always filter, in addition to the user-provided filters that 
@malaperle proposed (which also sound like a very useful feature to me!)

@ioeric, @malaperle, @sammccall, WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D46751#1095894, @malaperle wrote:

> Can there be an option for this? This seems very library specific and could 
> break other code bases. Ideally, there would be a generic mechanism for this 
> kind of filtering, i.e. specify a pattern of excluded files or symbol names. 
> But I understand this would be cumbersome because you want to filter only 
> *some* symbol names in *some* files, so it would be difficult for users to 
> specify this intersection of conditions on command-line arguments, for 
> example. I think this needs to be discussed a bit more or have this turned 
> off by default (with an option to turn on!) until there is a more general 
> solution for this kind of filtering.


Having user-configurable filtering may certainly be useful, but requires some 
design to get right.
And even if we have it, I think there's value in automatically handling popular 
frameworks, unless we know it might break other code **in practice**.

E.g., for protobuf, we know that generated headers always end with `.proto.h`. 
We could also check for comments that proto compiler tends to put into the 
generated files to be sure. If we do that, I feel it's better to have the 
filtering for protos **enabled** by default, since there's almost zero chance 
that people had a file that ends with `.proto.h` and put a proto compiler 
comment into it.
But even the `.proto.h` ending seems like a good enough indication.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric marked an inline comment as done.
ioeric added inline comments.



Comment at: unittests/clangd/ClangdTests.cpp:941
 
-TEST_F(ClangdVFSTest, InsertIncludes) {
-  MockFSProvider FS;

ilya-biryukov wrote:
> Do we test the same thing somewhere else  (e.g. code completion) in one of 
> the dependent changes?
> Maybe it's worth noting in the commit description that this test was not 
> removed completely, but instead moved to ?
Sure thing.

This is tested in code completion unit tests in D46497. Noted this in patch 
summary.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46676



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


[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: unittests/clangd/ClangdTests.cpp:941
 
-TEST_F(ClangdVFSTest, InsertIncludes) {
-  MockFSProvider FS;

Do we test the same thing somewhere else  (e.g. code completion) in one of the 
dependent changes?
Maybe it's worth noting in the commit description that this test was not 
removed completely, but instead moved to ?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46676



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Can there be an option for this? This seems very library specific and could 
break other code bases. Ideally, there would be a generic mechanism for this 
kind of filtering, i.e. specify a pattern of excluded files or symbol names. 
But I understand this would be cumbersome because you want to filter only 
*some* symbol names in *some* files, so it would be difficult for users to 
specify this intersection of conditions on command-line arguments, for example. 
I think this needs to be discussed a bit more or have this turned off by 
default (with an option to turn on!) until there is a more general solution for 
this kind of filtering.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46496: [Tooling] Pull #include manipulation code from clangFormat into libToolingCore.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This change is big enough to be somewhat hard to grasp.
Maybe we could split it into two, to make it easier for review?
I.e.

- Extraction of IncludeStyle into a separate subclass.
- Moving stuff around without other refactorings.




Comment at: include/clang/Format/Format.h:1818
 ///   from \p Code if it exists.
+/// See documentation for `tooling::HeaderIncludes` for the behavior.
 llvm::Expected

`for the behavior` is a little confusing. Could we try elaborating on what 
'behavior' is a bit more? E.g. `the include manipulation is done via 
tooling::HeaderInclude, see its documentation for more details on how include 
insertion points are found and which edits are produced`.



Comment at: include/clang/Tooling/Core/HeaderIncludes.h:22
+
+struct IncludeStyle {
+  /// Styles for sorting multiple ``#include`` blocks.

This struct looks big enough to justify putting it into a separate header. For 
the sake of keeping `HeaderIncludes` the first thing that people see when they 
open a file.
WDYT?



Comment at: include/clang/Tooling/Core/HeaderIncludes.h:112
+/// priorities for headers.
+/// FIXME(ioeric): move this class into implementation file when clang-format's
+/// include sorting functions are also moved here.

Can we move them in the current commit too?
`IncludeCategoryManager` does look like something that should not be in the 
public header.



Comment at: include/clang/Tooling/Core/HeaderIncludes.h:127
+
+  const IncludeStyle Style;
+  bool IsMainFile;

Do we want `const&` here, i.e. have we accidentally lost `&`?


Repository:
  rC Clang

https://reviews.llvm.org/D46496



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:95
+  auto FileName = SM.getFilename(findNameLoc(ND));
+  if (FileName.endswith(".proto.h") || FileName.endswith(".pb.h")) {
+auto Name = ND->getName();

NIT: reduce nesting by inverting if condition (see 
[[https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code|LLVM
 style guide]])



Comment at: clangd/index/SymbolCollector.cpp:155
 
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;

Maybe add a comment mentioning that we remove internal symbols from protobuf 
code generator here?
I can easily decipher what happens here, because I know of protos, but I can 
imagine the comment might be very helpful to someone reading the code and being 
unfamiliar with protos.



Comment at: clangd/index/SymbolCollector.cpp:156
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;
+

We should also run the same code to filter our those decls coming from sema 
completions.
Otherwise, they might still pop up in completion results if internal proto 
symbols were deserialized from preamble by clang before running the code 
completion.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:713
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),

Maybe also test that the same symbol is not excluded in the  file that does not 
end with `.proto.h`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2018-05-11 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel added a comment.

Do you have any other comments? Could this checker be delivered into `security`?


https://reviews.llvm.org/D35068



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


[PATCH] D33844: [clang-tidy] terminating continue check

2018-05-11 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel added a comment.

In https://reviews.llvm.org/D33844#1086565, @alexfh wrote:

> Which comments do you think are still relevant?





https://reviews.llvm.org/D33844



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jkorous, MaskRay, klimek.

This uses heuristics to identify private proto symbols. For example,
top-level symbols whose name contains "_" are considered private. These symbols
are not expected to be used by users.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -697,6 +697,23 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
+TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
+  TestHeaderName = testPath("x.proto.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+class TopLevel {};
+enum Kind {
+  KIND_OK,
+  Kind_Not_Ok,
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),
+QName("nx::KIND_OK")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -90,6 +90,28 @@
   return llvm::None;
 }
 
+bool isPrivateProtoSymbol(const NamedDecl *ND, const SourceManager ) {
+  auto FileName = SM.getFilename(findNameLoc(ND));
+  if (FileName.endswith(".proto.h") || FileName.endswith(".pb.h")) {
+auto Name = ND->getName();
+// Nested proto entities (e.g. Message::Nested) have top-level decls
+// that shouldn't be used (Message_Nested). Ignore them completely.
+// The nested entities are dangling type aliases, we may want to reconsider
+// including them in the future
+if (Name.contains('_')) {
+  if (ND->getKind() == Decl::EnumConstant) {
+// SOME_ENUM_CONSTANT is not private and should be indexed.
+// Outer_INNER is private.
+// This heuristic relies on naming style, it will include OUTER_INNER
+// and exclude some_enum_constant.
+return std::any_of(Name.begin(), Name.end(), islower);
+  }
+  return true;
+}
+  }
+  return false;
+}
+
 bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
   const SymbolCollector::Options ) {
   using namespace clang::ast_matchers;
@@ -130,6 +152,9 @@
   .empty())
 return true;
 
+  if (isPrivateProtoSymbol(ND, ASTCtx->getSourceManager()))
+return true;
+
   return false;
 }
 


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -697,6 +697,23 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
+TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
+  TestHeaderName = testPath("x.proto.h");
+  const std::string Header = R"(
+  namespace nx {
+class Top_Level {};
+class TopLevel {};
+enum Kind {
+  KIND_OK,
+  Kind_Not_Ok,
+};
+  }
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),
+QName("nx::KIND_OK")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -90,6 +90,28 @@
   return llvm::None;
 }
 
+bool isPrivateProtoSymbol(const NamedDecl *ND, const SourceManager ) {
+  auto FileName = SM.getFilename(findNameLoc(ND));
+  if (FileName.endswith(".proto.h") || FileName.endswith(".pb.h")) {
+auto Name = ND->getName();
+// Nested proto entities (e.g. Message::Nested) have top-level decls
+// that shouldn't be used (Message_Nested). Ignore them completely.
+// The nested entities are dangling type aliases, we may want to reconsider
+// including them in the future
+if (Name.contains('_')) {
+  if (ND->getKind() == Decl::EnumConstant) {
+// SOME_ENUM_CONSTANT is not private and should be indexed.
+// Outer_INNER is private.
+// This heuristic relies on naming style, it will include OUTER_INNER
+// and exclude some_enum_constant.
+return std::any_of(Name.begin(), Name.end(), islower);
+  }
+  return true;
+}
+  }
+  return false;
+}
+
 bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
   const 

[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

2018-05-11 Thread Pavel Labath via Phabricator via cfe-commits
labath updated this revision to Diff 146309.
labath added a comment.

Yes we can do that. Only the RAUW optimization is nasty, I've checked that the
debugger is able to use the alias with no problem.

Updated the patch the reflect that.


Repository:
  rC Clang

https://reviews.llvm.org/D46685

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/float16-declarations.cpp


Index: test/CodeGenCXX/float16-declarations.cpp
===
--- test/CodeGenCXX/float16-declarations.cpp
+++ test/CodeGenCXX/float16-declarations.cpp
@@ -103,7 +103,7 @@
 
   C1 c1(f1l);
 // CHECK-DAG:  [[F1L:%[a-z0-9]+]] = load half, half* %{{.*}}, align 2
-// CHECK-DAG:  call void @_ZN2C1C2EDF16_(%class.C1* %{{.*}}, half %{{.*}})
+// CHECK-DAG:  call void @_ZN2C1C1EDF16_(%class.C1* %{{.*}}, half %{{.*}})
 
   S1<_Float16> s1 = { 132.f16 };
 // CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { half 
0xH5820 }, align 2
Index: test/CodeGenCXX/ctor-dtor-alias.cpp
===
--- test/CodeGenCXX/ctor-dtor-alias.cpp
+++ test/CodeGenCXX/ctor-dtor-alias.cpp
@@ -77,11 +77,12 @@
   // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
   // CHECK1: define linkonce_odr void @_ZN5test41AD2Ev({{.*}} comdat align
 
-  // test that we don't do this optimization at -O0 so that the debugger can
-  // see both destructors.
+  // test that we don't do this optimization at -O0 and call the complete
+  // destructor for B instead. This enables the debugger to see both
+  // destructors.
+  // NOOPT: @_ZN5test41BD1Ev = linkonce_odr alias void {{.*}} @_ZN5test41BD2Ev
   // NOOPT: define internal void @__cxx_global_var_init.2()
-  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
-  // NOOPT: define linkonce_odr void @_ZN5test41BD2Ev({{.*}} comdat align
+  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD1Ev
   struct A {
 virtual ~A() {}
   };
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -3625,12 +3625,16 @@
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
-return StructorCodegen::RAUW;
-
-  // FIXME: Should we allow available_externally aliases?
-  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
-return StructorCodegen::RAUW;
+  // Only use RAUW in optimized code, as it makes the complete structor symbol
+  // disappear completely, which degrades debugging experience.
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
+if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
+  return StructorCodegen::RAUW;
+
+// FIXME: Should we allow available_externally aliases?
+if (!llvm::GlobalAlias::isValidLinkage(Linkage))
+  return StructorCodegen::RAUW;
+  }
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).


Index: test/CodeGenCXX/float16-declarations.cpp
===
--- test/CodeGenCXX/float16-declarations.cpp
+++ test/CodeGenCXX/float16-declarations.cpp
@@ -103,7 +103,7 @@
 
   C1 c1(f1l);
 // CHECK-DAG:  [[F1L:%[a-z0-9]+]] = load half, half* %{{.*}}, align 2
-// CHECK-DAG:  call void @_ZN2C1C2EDF16_(%class.C1* %{{.*}}, half %{{.*}})
+// CHECK-DAG:  call void @_ZN2C1C1EDF16_(%class.C1* %{{.*}}, half %{{.*}})
 
   S1<_Float16> s1 = { 132.f16 };
 // CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { half 0xH5820 }, align 2
Index: test/CodeGenCXX/ctor-dtor-alias.cpp
===
--- test/CodeGenCXX/ctor-dtor-alias.cpp
+++ test/CodeGenCXX/ctor-dtor-alias.cpp
@@ -77,11 +77,12 @@
   // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
   // CHECK1: define linkonce_odr void @_ZN5test41AD2Ev({{.*}} comdat align
 
-  // test that we don't do this optimization at -O0 so that the debugger can
-  // see both destructors.
+  // test that we don't do this optimization at -O0 and call the complete
+  // destructor for B instead. This enables the debugger to see both
+  // destructors.
+  // NOOPT: @_ZN5test41BD1Ev = linkonce_odr alias void {{.*}} @_ZN5test41BD2Ev
   // NOOPT: define internal void @__cxx_global_var_init.2()
-  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
-  // NOOPT: define linkonce_odr void @_ZN5test41BD2Ev({{.*}} comdat align
+  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD1Ev
   struct A {
 virtual ~A() {}
   };
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -3625,12 +3625,16 @@
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  if 

[PATCH] D46670: [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332089: [clangd] Move helpers that convert Replacements to 
TextEdits to SourceCode.h (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46670

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/clangd/SourceCode.h


Index: clang-tools-extra/trunk/clangd/SourceCode.cpp
===
--- clang-tools-extra/trunk/clangd/SourceCode.cpp
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp
@@ -166,5 +166,20 @@
   return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
 }
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
+  Range ReplacementRange = {
+  offsetToPosition(Code, R.getOffset()),
+  offsetToPosition(Code, R.getOffset() + R.getLength())};
+  return {ReplacementRange, R.getReplacementText()};
+}
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements ) {
+  std::vector Edits;
+  for (const auto  : Repls)
+Edits.push_back(replacementToEdit(Code, R));
+  return Edits;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/SourceCode.h
===
--- clang-tools-extra/trunk/clangd/SourceCode.h
+++ clang-tools-extra/trunk/clangd/SourceCode.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
 
 namespace clang {
 class SourceManager;
@@ -55,6 +56,11 @@
 std::pair
 splitQualifiedName(llvm::StringRef QName);
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement );
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements );
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -60,32 +60,6 @@
 static URISchemeRegistry::Add
 X("test", "Test scheme for clangd lit tests.");
 
-TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
-  Range ReplacementRange = {
-  offsetToPosition(Code, R.getOffset()),
-  offsetToPosition(Code, R.getOffset() + R.getLength())};
-  return {ReplacementRange, R.getReplacementText()};
-}
-
-std::vector
-replacementsToEdits(StringRef Code,
-const std::vector ) {
-  // Turn the replacements into the format specified by the Language Server
-  // Protocol. Fuse them into one big JSON array.
-  std::vector Edits;
-  for (const auto  : Replacements)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
-std::vector replacementsToEdits(StringRef Code,
-  const tooling::Replacements ) {
-  std::vector Edits;
-  for (const auto  : Repls)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
 SymbolKindBitset defaultSymbolKinds() {
   SymbolKindBitset Defaults;
   for (size_t I = SymbolKindMin; I <= static_cast(SymbolKind::Array);
@@ -291,7 +265,11 @@
   return replyError(ErrorCode::InternalError,
 llvm::toString(Replacements.takeError()));
 
-std::vector Edits = replacementsToEdits(*Code, 
*Replacements);
+// Turn the replacements into the format specified by the Language
+// Server Protocol. Fuse them into one big JSON array.
+std::vector Edits;
+for (const auto  : *Replacements)
+  Edits.push_back(replacementToEdit(*Code, R));
 WorkspaceEdit WE;
 WE.changes = {{Params.textDocument.uri.uri(), Edits}};
 reply(WE);


Index: clang-tools-extra/trunk/clangd/SourceCode.cpp
===
--- clang-tools-extra/trunk/clangd/SourceCode.cpp
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp
@@ -166,5 +166,20 @@
   return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
 }
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
+  Range ReplacementRange = {
+  offsetToPosition(Code, R.getOffset()),
+  offsetToPosition(Code, R.getOffset() + R.getLength())};
+  return {ReplacementRange, R.getReplacementText()};
+}
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements ) {
+  std::vector Edits;
+  for (const auto  : Repls)
+Edits.push_back(replacementToEdit(Code, R));
+  return Edits;
+}
+
 } // namespace clangd
 } // namespace clang
Index: 

[clang-tools-extra] r332089 - [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

2018-05-11 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 11 05:12:08 2018
New Revision: 332089

URL: http://llvm.org/viewvc/llvm-project?rev=332089=rev
Log:
[clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=332089=332088=332089=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri May 11 05:12:08 2018
@@ -60,32 +60,6 @@ public:
 static URISchemeRegistry::Add
 X("test", "Test scheme for clangd lit tests.");
 
-TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
-  Range ReplacementRange = {
-  offsetToPosition(Code, R.getOffset()),
-  offsetToPosition(Code, R.getOffset() + R.getLength())};
-  return {ReplacementRange, R.getReplacementText()};
-}
-
-std::vector
-replacementsToEdits(StringRef Code,
-const std::vector ) {
-  // Turn the replacements into the format specified by the Language Server
-  // Protocol. Fuse them into one big JSON array.
-  std::vector Edits;
-  for (const auto  : Replacements)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
-std::vector replacementsToEdits(StringRef Code,
-  const tooling::Replacements ) {
-  std::vector Edits;
-  for (const auto  : Repls)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
 SymbolKindBitset defaultSymbolKinds() {
   SymbolKindBitset Defaults;
   for (size_t I = SymbolKindMin; I <= static_cast(SymbolKind::Array);
@@ -291,7 +265,11 @@ void ClangdLSPServer::onRename(RenamePar
   return replyError(ErrorCode::InternalError,
 llvm::toString(Replacements.takeError()));
 
-std::vector Edits = replacementsToEdits(*Code, 
*Replacements);
+// Turn the replacements into the format specified by the Language
+// Server Protocol. Fuse them into one big JSON array.
+std::vector Edits;
+for (const auto  : *Replacements)
+  Edits.push_back(replacementToEdit(*Code, R));
 WorkspaceEdit WE;
 WE.changes = {{Params.textDocument.uri.uri(), Edits}};
 reply(WE);

Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.cpp?rev=332089=332088=332089=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.cpp (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp Fri May 11 05:12:08 2018
@@ -166,5 +166,20 @@ splitQualifiedName(llvm::StringRef QName
   return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
 }
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
+  Range ReplacementRange = {
+  offsetToPosition(Code, R.getOffset()),
+  offsetToPosition(Code, R.getOffset() + R.getLength())};
+  return {ReplacementRange, R.getReplacementText()};
+}
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements ) {
+  std::vector Edits;
+  for (const auto  : Repls)
+Edits.push_back(replacementToEdit(Code, R));
+  return Edits;
+}
+
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/SourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.h?rev=332089=332088=332089=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.h (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.h Fri May 11 05:12:08 2018
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
 
 namespace clang {
 class SourceManager;
@@ -55,6 +56,11 @@ std::pair offsetToClangL
 std::pair
 splitQualifiedName(llvm::StringRef QName);
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement );
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements );
+
 } // namespace clangd
 } // namespace clang
 #endif


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


[PATCH] D46670: [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/SourceCode.h:62
+std::vector
+replacementsToEdits(StringRef Code,
+const std::vector );

ilya-biryukov wrote:
> Do we really need to expose separate functions for 
> `vector` and `tooling::Replacements`, given that both 
> are trivial: loop over the array, convert each item?
> Having them in `.cpp` file didn't hurt, but they seems redundant in the 
> public header.
> WDYT?
Good point. Use of `std::vector` should be discouraged anyway. I 
removed this function and inline the conversion for `std::vector` 
as this is only used in rename (which should probably be fixed to use 
`tooling::Replacements` instead).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46670



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


[PATCH] D46670: [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146303.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Got rid of a helper for std::vector


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46670

Files:
  clangd/ClangdLSPServer.cpp
  clangd/SourceCode.cpp
  clangd/SourceCode.h


Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
 
 namespace clang {
 class SourceManager;
@@ -55,6 +56,11 @@
 std::pair
 splitQualifiedName(llvm::StringRef QName);
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement );
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements );
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -166,5 +166,20 @@
   return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
 }
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
+  Range ReplacementRange = {
+  offsetToPosition(Code, R.getOffset()),
+  offsetToPosition(Code, R.getOffset() + R.getLength())};
+  return {ReplacementRange, R.getReplacementText()};
+}
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements ) {
+  std::vector Edits;
+  for (const auto  : Repls)
+Edits.push_back(replacementToEdit(Code, R));
+  return Edits;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -60,32 +60,6 @@
 static URISchemeRegistry::Add
 X("test", "Test scheme for clangd lit tests.");
 
-TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
-  Range ReplacementRange = {
-  offsetToPosition(Code, R.getOffset()),
-  offsetToPosition(Code, R.getOffset() + R.getLength())};
-  return {ReplacementRange, R.getReplacementText()};
-}
-
-std::vector
-replacementsToEdits(StringRef Code,
-const std::vector ) {
-  // Turn the replacements into the format specified by the Language Server
-  // Protocol. Fuse them into one big JSON array.
-  std::vector Edits;
-  for (const auto  : Replacements)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
-std::vector replacementsToEdits(StringRef Code,
-  const tooling::Replacements ) {
-  std::vector Edits;
-  for (const auto  : Repls)
-Edits.push_back(replacementToEdit(Code, R));
-  return Edits;
-}
-
 SymbolKindBitset defaultSymbolKinds() {
   SymbolKindBitset Defaults;
   for (size_t I = SymbolKindMin; I <= static_cast(SymbolKind::Array);
@@ -291,7 +265,11 @@
   return replyError(ErrorCode::InternalError,
 llvm::toString(Replacements.takeError()));
 
-std::vector Edits = replacementsToEdits(*Code, 
*Replacements);
+// Turn the replacements into the format specified by the Language
+// Server Protocol. Fuse them into one big JSON array.
+std::vector Edits;
+for (const auto  : *Replacements)
+  Edits.push_back(replacementToEdit(*Code, R));
 WorkspaceEdit WE;
 WE.changes = {{Params.textDocument.uri.uri(), Edits}};
 reply(WE);


Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
 
 namespace clang {
 class SourceManager;
@@ -55,6 +56,11 @@
 std::pair
 splitQualifiedName(llvm::StringRef QName);
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement );
+
+std::vector replacementsToEdits(StringRef Code,
+  const tooling::Replacements );
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -166,5 +166,20 @@
   return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
 }
 
+TextEdit replacementToEdit(StringRef Code, const tooling::Replacement ) {
+  Range ReplacementRange = {
+  offsetToPosition(Code, R.getOffset()),
+  offsetToPosition(Code, R.getOffset() + R.getLength())};
+  return {ReplacementRange, R.getReplacementText()};
+}
+
+std::vector 

[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: arphaman, erik.pilkington, vsapsai.
jkorous added a project: clang.
Herald added a subscriber: cfe-commits.

E. g. use "10.11" instead of "10_11".

This is just a consistency fix - the dotted format is already used everywhere 
else.

rdar://problem/39845032


Repository:
  rC Clang

https://reviews.llvm.org/D46747

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/FixIt/fixit-availability-method.mm


Index: test/FixIt/fixit-availability-method.mm
===
--- /dev/null
+++ test/FixIt/fixit-availability-method.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability 
-fdiagnostics-parseable-fixits -fsyntax-only -verify %s
+
+@interface foo
+- (void) method_bar __attribute__((availability(macos, introduced = 10.12))); 
// expected-note {{'method_bar' has been explicitly marked partial here}}
+@end
+
+int main() {
+[foo method_bar]; // \
+// expected-warning {{'method_bar' is only available on macOS 10.12 or 
newer}} \
+// expected-note {{enclose 'method_bar' in an @available check to silence 
this warning}} \
+// CHECK: "fix-it:.*if (@available(macOS 10.12, *))"
+return 0;
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7467,6 +7467,7 @@
 const AvailabilityAttr *AA =
   getAttrForPlatform(SemaRef.getASTContext(), OffendingDecl);
 VersionTuple Introduced = AA->getIntroduced();
+Introduced.UseDotAsSeparator();
 
 if (AvailabilityStack.back() >= Introduced)
   return;


Index: test/FixIt/fixit-availability-method.mm
===
--- /dev/null
+++ test/FixIt/fixit-availability-method.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability -fdiagnostics-parseable-fixits -fsyntax-only -verify %s
+
+@interface foo
+- (void) method_bar __attribute__((availability(macos, introduced = 10.12))); // expected-note {{'method_bar' has been explicitly marked partial here}}
+@end
+
+int main() {
+[foo method_bar]; // \
+// expected-warning {{'method_bar' is only available on macOS 10.12 or newer}} \
+// expected-note {{enclose 'method_bar' in an @available check to silence this warning}} \
+// CHECK: "fix-it:.*if (@available(macOS 10.12, *))"
+return 0;
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7467,6 +7467,7 @@
 const AvailabilityAttr *AA =
   getAttrForPlatform(SemaRef.getASTContext(), OffendingDecl);
 VersionTuple Introduced = AA->getIntroduced();
+Introduced.UseDotAsSeparator();
 
 if (AvailabilityStack.back() >= Introduced)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-11 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D46676#1095713, @ilya-biryukov wrote:

> This LG, but we should first roll out the `additionalEdits` change.
>  Aren't the dependencies reversed in the dependency stack, i.e. this change 
> should be the last one?


You are right ;) I got the dependency reversed. My plan was to land this and 
the other patch at the "same" time.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46676



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


[PATCH] D46742: [X86] Use __builtin_convertvector to replace some of the avx512 truncate builtins.

2018-05-11 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added a comment.

In https://reviews.llvm.org/D46742#1095658, @tkrupa wrote:

> There are four other similar intrinsics which convert to 128/256-bit vectors:
>
> __m128i _mm256_cvtepi32_epi8 (__m256i a)
>  __m128i _mm256_cvtepi64_epi16 (__m256i a)
>  __m128i _mm256_cvtepi64_epi8 (__m256i a)
>  __m128i _mm512_cvtepi64_epi8 (__m512i a)
>
> Can you also include them?


Probably these should be possible, but e.g. with the _mm256_cvtepi32_epi8 case, 
I can only get this far:

  vpmovdw %ymm0, %xmm0
  vpshufb .LCPI2_0(%rip), %xmm0, %xmm0 # xmm0 = 
xmm0[0,2,4,6,8,10,12,14],zero,zero,zero,zero,zero,zero,zero,zero
  vzeroupper
  retq

While the expected result is a `vpmovdb` instruction, without the extra 
shuffling.


Repository:
  rC Clang

https://reviews.llvm.org/D46742



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


[PATCH] D46742: [X86] Use __builtin_convertvector to replace some of the avx512 truncate builtins.

2018-05-11 Thread Tomasz Krupa via Phabricator via cfe-commits
tkrupa added a comment.

Nevermind - these four are not strictly truncating. Sorry for the confusion.


Repository:
  rC Clang

https://reviews.llvm.org/D46742



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


[PATCH] D46670: [clangd] Move helpers that convert Replacements to TextEdits to SourceCode.h

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM, just a few non-blocking NITs with questions.




Comment at: clangd/SourceCode.cpp:180
+  // Turn the replacements into the format specified by the Language Server
+  // Protocol. Fuse them into one big JSON array.
+  std::vector Edits;

NIT: the comment about json array does not make any sense, given that we merely 
return a vector.
(that was true before the change too)



Comment at: clangd/SourceCode.h:62
+std::vector
+replacementsToEdits(StringRef Code,
+const std::vector );

Do we really need to expose separate functions for 
`vector` and `tooling::Replacements`, given that both are 
trivial: loop over the array, convert each item?
Having them in `.cpp` file didn't hurt, but they seems redundant in the public 
header.
WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46670



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


[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This LG, but we should first roll out the `additionalEdits` change.
Aren't the dependencies reversed in the dependency stack, i.e. this change 
should be the last one?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46676



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


  1   2   >