[clang-tools-extra] r346638 - [clangd] Fix compile on very old glibc

2018-11-12 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Nov 12 00:17:49 2018
New Revision: 346638

URL: http://llvm.org/viewvc/llvm-project?rev=346638&view=rev
Log:
[clangd] Fix compile on very old glibc

Modified:
clang-tools-extra/trunk/clangd/Threading.cpp

Modified: clang-tools-extra/trunk/clangd/Threading.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Threading.cpp?rev=346638&r1=346637&r2=346638&view=diff
==
--- clang-tools-extra/trunk/clangd/Threading.cpp (original)
+++ clang-tools-extra/trunk/clangd/Threading.cpp Mon Nov 12 00:17:49 2018
@@ -101,7 +101,8 @@ void wait(std::unique_lock &
 }
 
 void setThreadPriority(std::thread &T, ThreadPriority Priority) {
-#ifdef __linux__
+  // Some *really* old glibcs are missing SCHED_IDLE.
+#if defined(__linux__) && defined(SCHED_IDLE)
   sched_param priority;
   priority.sched_priority = 0;
   pthread_setschedparam(


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


r346639 - clang-cl: Add documentation for /Zc:dllexportInlines-

2018-11-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Nov 12 00:38:10 2018
New Revision: 346639

URL: http://llvm.org/viewvc/llvm-project?rev=346639&view=rev
Log:
clang-cl: Add documentation for /Zc:dllexportInlines-

Differential revision: https://reviews.llvm.org/D54319

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346639&r1=346638&r2=346639&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Nov 12 00:38:10 2018
@@ -2947,6 +2947,8 @@ Execute ``clang-cl /?`` to see a list of
   /Yc   Generate a pch file for all code up to and 
including 
   /Yu   Load a pch file and use it instead of all code 
up to and including 
   /Z7 Enable CodeView debug information in object files
+  /Zc:dllexportInlines-   Don't dllexport/import inline member functions 
of dllexport/import classes
+  /Zc:dllexportInlinesdllexport/import inline member functions of 
dllexport/import classes (default)
   /Zc:sizedDealloc-   Disable C++14 sized global deallocation functions
   /Zc:sizedDeallocEnable C++14 sized global deallocation functions
   /Zc:strictStrings   Treat string literals as const
@@ -3096,6 +3098,80 @@ driver. Regardless of where they appear
 arguments are treated as if they were passed at the end of the clang-cl command
 line.
 
+The /Zc:dllexportInlines- Option
+
+
+This causes the class-level `dllexport` and `dllimport` attributes not to be
+applied to inline member functions, as they otherwise would. For example, in
+the code below `S::foo()` would normally be defined and exported by the DLL,
+but when using the ``/Zc:dllexportInlines-`` flag it is not:
+
+.. code-block:: c
+
+  struct __declspec(dllexport) S {
+void foo() {}
+  }
+
+This has the benefit that the compiler doesn't need to emit a definition of
+`S::foo()` in every translation unit where the declaration is included, as it
+would otherwise do to ensure there's a definition in the DLL even if it's not
+used there. If the declaration occurs in a header file that's widely used, this
+can save significant compilation time and output size. It also reduces the
+number of functions exported by the DLL similarly to what
+``-fvisibility-inlines-hidden`` does for shared objects on ELF and Mach-O.
+Since the function declaration comes with an inline definition, users of the
+library can use that definition directly instead of importing it from the DLL.
+
+Note that the Microsoft Visual C++ compiler does not support this option, and
+if code in a DLL is compiled with ``/Zc:dllexportInlines-``, the code using the
+DLL must be compiled in the same way so that it doesn't attempt to dllimport
+the inline member functions. The reverse scenario should generally work though:
+a DLL compiled without this flag (such as a system library compiled with Visual
+C++) can be referenced from code compiled using the flag, meaning that the
+referencing code will use the inline definitions instead of importing them from
+the DLL.
+
+Also note that like when using ``-fvisibility-inlines-hidden``, the address of
+`S::foo()` will be different inside and outside the DLL, breaking the C/C++
+standard requirement that functions have a unique address.
+
+The flag does not apply to explicit class template instantiation definitions or
+declarations, as those are typically used to explicitly provide a single
+definition in a DLL, (dllexported instantiation definition) or to signal that
+the definition is available elsewhere (dllimport instantiation declaration). It
+also doesn't apply to inline members with static local variables, to ensure
+that the same instance of the variable is used inside and outside the DLL.
+
+Using this flag can cause problems when inline functions that would otherwise
+be dllexported refer to internal symbols of a DLL. For example:
+
+.. code-block:: c
+
+  void internal();
+
+  struct __declspec(dllimport) S {
+void foo() { internal(); }
+  }
+
+Normally, references to `S::foo()` would use the definition in the DLL from
+which it was exported, and which presumably also has the definition of
+`internal()`. However, when using ``/Zc:dllexportInlines-``, the inline
+definition of `S::foo()` is used directly, resulting in a link error since
+`internal()` is not available. Even worse, if there is an inline definition of
+`internal()` containing a static local variable, we will now refer to a
+different instance of that variable than in the DLL:
+
+.. code-block:: c
+
+  inline int internal() { static int x; return x++; }
+
+  struct __declspec(dllimport) S {
+int foo() { return internal(); }
+  }
+
+This could lead to very subtle bugs. Using ``-fvisibility-inlines-hidden`` can
+lead 

[PATCH] D54319: clang-cl: Add documentation for /Zc:dllexportInlines-

2018-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346639: clang-cl: Add documentation for 
/Zc:dllexportInlines- (authored by hans, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54319?vs=173338&id=173621#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54319

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/CLCompatOptions.td

Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -335,8 +335,10 @@
   MetaVarName<"">;
 def _SLASH_Y_ : CLFlag<"Y-">,
   HelpText<"Disable precompiled headers, overrides /Yc and /Yu">;
-def _SLASH_Zc_dllexportInlines : CLFlag<"Zc:dllexportInlines">;
-def _SLASH_Zc_dllexportInlines_ : CLFlag<"Zc:dllexportInlines-">;
+def _SLASH_Zc_dllexportInlines : CLFlag<"Zc:dllexportInlines">,
+  HelpText<"dllexport/import inline member functions of dllexport/import classes (default)">;
+def _SLASH_Zc_dllexportInlines_ : CLFlag<"Zc:dllexportInlines-">,
+  HelpText<"Don't dllexport/import inline member functions of dllexport/import classes">;
 def _SLASH_Fp : CLJoined<"Fp">,
   HelpText<"Set pch filename (with /Yc and /Yu)">, MetaVarName<"">;
 
Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2947,6 +2947,8 @@
   /Yc   Generate a pch file for all code up to and including 
   /Yu   Load a pch file and use it instead of all code up to and including 
   /Z7 Enable CodeView debug information in object files
+  /Zc:dllexportInlines-   Don't dllexport/import inline member functions of dllexport/import classes
+  /Zc:dllexportInlinesdllexport/import inline member functions of dllexport/import classes (default)
   /Zc:sizedDealloc-   Disable C++14 sized global deallocation functions
   /Zc:sizedDeallocEnable C++14 sized global deallocation functions
   /Zc:strictStrings   Treat string literals as const
@@ -3096,6 +3098,80 @@
 arguments are treated as if they were passed at the end of the clang-cl command
 line.
 
+The /Zc:dllexportInlines- Option
+
+
+This causes the class-level `dllexport` and `dllimport` attributes not to be
+applied to inline member functions, as they otherwise would. For example, in
+the code below `S::foo()` would normally be defined and exported by the DLL,
+but when using the ``/Zc:dllexportInlines-`` flag it is not:
+
+.. code-block:: c
+
+  struct __declspec(dllexport) S {
+void foo() {}
+  }
+
+This has the benefit that the compiler doesn't need to emit a definition of
+`S::foo()` in every translation unit where the declaration is included, as it
+would otherwise do to ensure there's a definition in the DLL even if it's not
+used there. If the declaration occurs in a header file that's widely used, this
+can save significant compilation time and output size. It also reduces the
+number of functions exported by the DLL similarly to what
+``-fvisibility-inlines-hidden`` does for shared objects on ELF and Mach-O.
+Since the function declaration comes with an inline definition, users of the
+library can use that definition directly instead of importing it from the DLL.
+
+Note that the Microsoft Visual C++ compiler does not support this option, and
+if code in a DLL is compiled with ``/Zc:dllexportInlines-``, the code using the
+DLL must be compiled in the same way so that it doesn't attempt to dllimport
+the inline member functions. The reverse scenario should generally work though:
+a DLL compiled without this flag (such as a system library compiled with Visual
+C++) can be referenced from code compiled using the flag, meaning that the
+referencing code will use the inline definitions instead of importing them from
+the DLL.
+
+Also note that like when using ``-fvisibility-inlines-hidden``, the address of
+`S::foo()` will be different inside and outside the DLL, breaking the C/C++
+standard requirement that functions have a unique address.
+
+The flag does not apply to explicit class template instantiation definitions or
+declarations, as those are typically used to explicitly provide a single
+definition in a DLL, (dllexported instantiation definition) or to signal that
+the definition is available elsewhere (dllimport instantiation declaration). It
+also doesn't apply to inline members with static local variables, to ensure
+that the same instance of the variable is used inside and outside the DLL.
+
+Using this flag can cause problems when inline functions that would otherwise
+be dllexported refer to internal symbols of a DLL. For example:
+
+.. code-block:: c
+
+  void internal();
+
+  struct __declspec(dllimp

r346640 - Release notes: Mention clang-cl's /Zc:dllexportInlines- flag

2018-11-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Nov 12 00:42:21 2018
New Revision: 346640

URL: http://llvm.org/viewvc/llvm-project?rev=346640&view=rev
Log:
Release notes: Mention clang-cl's /Zc:dllexportInlines- flag

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=346640&r1=346639&r2=346640&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Nov 12 00:42:21 2018
@@ -102,6 +102,11 @@ Windows Support
   filename, a `#pragma hdrstop` inside the source marks the end of the
   precompiled code.
 
+- clang-cl has a new command-line option, ``/Zc:dllexportInlines-``, similar to
+  ``-fvisibility-inlines-hidden`` on non-Windows, that makes class-level
+  `dllexport` and `dllimport` attributes not apply to inline member functions.
+  This can significantly reduce compile and link times. See the `User's Manual
+  `_ for more info.
 - ...
 
 


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


[PATCH] D52034: [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov

2018-11-12 Thread calixte via Phabricator via cfe-commits
calixte updated this revision to Diff 173622.
calixte added a comment.

Update ReleaseNotes


Repository:
  rC Clang

https://reviews.llvm.org/D52034

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/code-coverage-filter1.h
  test/CodeGen/Inputs/code-coverage-filter2.h
  test/CodeGen/code-coverage-filter.c

Index: test/CodeGen/code-coverage-filter.c
===
--- /dev/null
+++ test/CodeGen/code-coverage-filter.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes %s -o - \
+// RUN:| FileCheck -check-prefix=ALL %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$;.*1\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER2 %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*2\.h$;.*1\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=JUST-C %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*code\-coverage\-filter\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=NONE %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=JUST-C %s
+
+#include "Inputs/code-coverage-filter1.h"
+#include "Inputs/code-coverage-filter2.h"
+
+void test() {
+  test1();
+  test2();
+}
+
+// ALL: define void @test1() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: define void @test2() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: define void @test() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+
+// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+
+// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+
+// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+
+// HEADER: define void @test1() #0 {{.*}}
+// HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+// HEADER: define void @test2() #0 {{.*}}
+// HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+// HEADER: define void @test() #0 {{.*}}
+// HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+
+// NONE: define void @test1() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
+// NONE: define void @test2() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
+// NONE: define void @test() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
Index: test/CodeGen/Inputs/code-coverage-filter2.h
===
--- /dev/null
+++ test/CodeGen/Inputs/code-coverage-filter2.h
@@ -0,0 +1 @@
+void test2() {}
Index: test/CodeGen/Inputs/code-coverage-filter1.h
===
--- /dev/null
+++ test/CodeGen/Inputs/code-coverage-filter1.h
@@ -0,0 +1 @@
+void test1() {}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -811,6 +811,10 @@
 Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
 Opts.CoverageNoFunctionNamesInData =
 Args.hasArg(OPT_coverage_no_function_names_in_data);
+Opts.ProfileFilterFiles =
+

[PATCH] D52034: [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov

2018-11-12 Thread calixte via Phabricator via cfe-commits
calixte updated this revision to Diff 173623.
calixte added a comment.

Forgot the ellipsis in the release notes.


Repository:
  rC Clang

https://reviews.llvm.org/D52034

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/code-coverage-filter1.h
  test/CodeGen/Inputs/code-coverage-filter2.h
  test/CodeGen/code-coverage-filter.c

Index: test/CodeGen/code-coverage-filter.c
===
--- /dev/null
+++ test/CodeGen/code-coverage-filter.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes %s -o - \
+// RUN:| FileCheck -check-prefix=ALL %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$;.*1\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=NO-HEADER2 %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*2\.h$;.*1\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=JUST-C %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-exclude-files=".*code\-coverage\-filter\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=HEADER %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.c$" %s -o - \
+// RUN:| FileCheck -check-prefix=NONE %s
+// RUN: %clang_cc1 -emit-llvm -femit-coverage-data -femit-coverage-notes -fprofile-filter-files=".*\.c$" -fprofile-exclude-files=".*\.h$" %s -o - \
+// RUN:| FileCheck -check-prefix=JUST-C %s
+
+#include "Inputs/code-coverage-filter1.h"
+#include "Inputs/code-coverage-filter2.h"
+
+void test() {
+  test1();
+  test2();
+}
+
+// ALL: define void @test1() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: define void @test2() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+// ALL: define void @test() #0 {{.*}}
+// ALL: {{.*}}__llvm_gcov_ctr{{.*}}
+// ALL: ret void
+
+// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER: ret void
+
+// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
+// NO-HEADER2: ret void
+
+// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: {{.*}}__llvm_gcov_ctr{{.*}}
+// JUST-C: ret void
+
+// HEADER: define void @test1() #0 {{.*}}
+// HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+// HEADER: define void @test2() #0 {{.*}}
+// HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+// HEADER: define void @test() #0 {{.*}}
+// HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// HEADER: ret void
+
+// NONE: define void @test1() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
+// NONE: define void @test2() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
+// NONE: define void @test() #0 {{.*}}
+// NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
+// NONE: ret void
Index: test/CodeGen/Inputs/code-coverage-filter2.h
===
--- /dev/null
+++ test/CodeGen/Inputs/code-coverage-filter2.h
@@ -0,0 +1 @@
+void test2() {}
Index: test/CodeGen/Inputs/code-coverage-filter1.h
===
--- /dev/null
+++ test/CodeGen/Inputs/code-coverage-filter1.h
@@ -0,0 +1 @@
+void test1() {}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -811,6 +811,10 @@
 Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
 Opts.CoverageNoFunctionNamesInData =
 Args.hasArg(OPT_coverage_no_function_names_in_data);
+Opts.

[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2018-11-12 Thread Richard Membarth via Phabricator via cfe-commits
richardmembarth added a comment.

There are external tools (e.g. hipacc ) that generate 
Clang AST. This AST uses `LangAS` annotations and emits incorrect memory space 
specifiers for CUDA when pretty-printed.


Repository:
  rC Clang

https://reviews.llvm.org/D54258



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


r346642 - [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov

2018-11-12 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Mon Nov 12 01:12:27 2018
New Revision: 346642

URL: http://llvm.org/viewvc/llvm-project?rev=346642&view=rev
Log:
[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to 
filter the files to instrument with gcov

Summary:
These options are taking regex separated by colons to filter files.
- if both are empty then all files are instrumented
- if -fprofile-filter-files is empty then all the filenames matching any of the 
regex from exclude are not instrumented
- if -fprofile-exclude-files is empty then all the filenames matching any of 
the regex from filter are instrumented
- if both aren't empty then all the filenames which match any of the regex in 
filter and which don't match all the regex in filter are instrumented
- this patch is a follow-up of https://reviews.llvm.org/D52033

Reviewers: marco-c, vsk

Reviewed By: marco-c, vsk

Subscribers: cfe-commits, sylvestre.ledru

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

Added:
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter1.h
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter2.h
cfe/trunk/test/CodeGen/code-coverage-filter.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=346642&r1=346641&r2=346642&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Nov 12 01:12:27 2018
@@ -64,6 +64,12 @@ Non-comprehensive list of changes in thi
 New Compiler Flags
 --
 
+- ``-fprofile-filter-files=[regexes]`` and 
``-fprofile-exclude-files=[regexes]``.
+
+  Clang has now options to filter or exclude some files when
+  instrumenting for gcov-based profiling.
+  See the :doc:`UsersManual` for details.
+
 - ...
 
 Deprecated Compiler Flags

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346642&r1=346641&r2=346642&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Nov 12 01:12:27 2018
@@ -1871,6 +1871,55 @@ using the ``llvm-cxxmap`` and ``llvm-pro
   following the Itanium C++ ABI mangling scheme. This covers all C++ targets
   supported by Clang other than Windows.
 
+GCOV-based Profiling
+
+
+GCOV is a test coverage program, it helps to know how often a line of code
+is executed. When instrumenting the code with ``--coverage`` option, some
+counters are added for each edge linking basic blocks.
+
+At compile time, gcno files are generated containing information about
+blocks and edges between them. At runtime the counters are incremented and at
+exit the counters are dumped in gcda files.
+
+The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate
+a report ``.c.gcov``.
+
+.. option:: -fprofile-filter-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name matches any of the regexes then the file is instrumented.
+
+   .. code-block:: console
+
+ $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c
+
+  For example, this will only instrument files finishing with ``.c``, skipping 
``.h`` files.
+
+.. option:: -fprofile-exclude-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name doesn't match all the regexes then the file is instrumented.
+
+  .. code-block:: console
+
+ $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c
+
+  For example, this will instrument all the files except the ones in 
``/usr/include``.
+
+If both options are used then a file is instrumented if its name matches any
+of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes
+from ``-fprofile-exclude-list``.
+
+.. code-block:: console
+
+   $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \
+   -fprofile-filter-files="^/usr/.*$"
+  
+In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter 
regex and
+doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it 
matches
+the exclude regex.
+
 Controlling Debug Information
 -
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=346642&r1=346641&r2=346642&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Option

[PATCH] D52034: [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov

2018-11-12 Thread calixte via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346642: [Clang] Add options -fprofile-filter-files and 
-fprofile-exclude-files to… (authored by calixte, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52034?vs=173623&id=173627#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52034

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/code-coverage-filter1.h
  test/CodeGen/Inputs/code-coverage-filter2.h
  test/CodeGen/code-coverage-filter.c

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1871,6 +1871,55 @@
   following the Itanium C++ ABI mangling scheme. This covers all C++ targets
   supported by Clang other than Windows.
 
+GCOV-based Profiling
+
+
+GCOV is a test coverage program, it helps to know how often a line of code
+is executed. When instrumenting the code with ``--coverage`` option, some
+counters are added for each edge linking basic blocks.
+
+At compile time, gcno files are generated containing information about
+blocks and edges between them. At runtime the counters are incremented and at
+exit the counters are dumped in gcda files.
+
+The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate
+a report ``.c.gcov``.
+
+.. option:: -fprofile-filter-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name matches any of the regexes then the file is instrumented.
+
+   .. code-block:: console
+
+ $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c
+
+  For example, this will only instrument files finishing with ``.c``, skipping ``.h`` files.
+
+.. option:: -fprofile-exclude-files=[regexes]
+
+  Define a list of regexes separated by a semi-colon.
+  If a file name doesn't match all the regexes then the file is instrumented.
+
+  .. code-block:: console
+
+ $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c
+
+  For example, this will instrument all the files except the ones in ``/usr/include``.
+
+If both options are used then a file is instrumented if its name matches any
+of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes
+from ``-fprofile-exclude-list``.
+
+.. code-block:: console
+
+   $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \
+   -fprofile-filter-files="^/usr/.*$"
+  
+In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter regex and
+doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it matches
+the exclude regex.
+
 Controlling Debug Information
 -
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,12 @@
 New Compiler Flags
 --
 
+- ``-fprofile-filter-files=[regexes]`` and ``-fprofile-exclude-files=[regexes]``.
+
+  Clang has now options to filter or exclude some files when
+  instrumenting for gcov-based profiling.
+  See the :doc:`UsersManual` for details.
+
 - ...
 
 Deprecated Compiler Flags
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -768,6 +768,12 @@
 HelpText<"Disable using instrumentation data for profile-guided optimization">;
 def fno_profile_use : Flag<["-"], "fno-profile-use">,
 Alias;
+def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
+Group, Flags<[CC1Option, CoreOption]>,
+HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">;
+def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
+Group, Flags<[CC1Option, CoreOption]>,
+HelpText<"Instrument only functions from files where names don't match all the regexes separated by a semi-colon">;
 
 def faddrsig : Flag<["-"], "faddrsig">, Group, Flags<[CoreOption, CC1Option]>,
   HelpText<"Emit an address-significance table">;
Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -127,6 +127,12 @@
   /// The filename with path we use for coverage notes files.
   std::string CoverageNotesFile;
 
+  /// Regexes separated by a semi-colon to filter the files to instrument.
+  std::string ProfileFilterFiles;
+
+  /// Regexes separated by a semi-colon to filter the files to not instrument.
+  std::string ProfileExcludeFiles;
+
   /// The version string to put into coverage files.
   char CoverageVersion[4];
 

[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/Background.cpp:252
+
+auto Hash = FilesToUpdate.lookup(Path);
+// Put shards into storage for subsequent use.

nit: i'd suggest doing the writes *after* updating the index, as the latter is 
user-facing



Comment at: clangd/index/Background.cpp:326
   return Error::success();
+} else if (IndexShardStorage) { // Check if shard storage has the index.
+  auto Shard = IndexShardStorage->retrieveShard(AbsolutePath, Hash);

I don't think this is the right place to be reading shards, vs on startup. It 
means we're doing extra IO whenever a file is reindexed, and more importantly 
we don't make the index contents available on startup (if any file needs 
reindexing, reads may get stuck behind it).

(as discussed, we can also leave reading out of this patch entirely)



Comment at: clangd/index/Background.h:31
 
+// Base class for Shard Storage operations. See DiskShardStorage for more info.
+class ShardStorage {

nit: prefer the other way around: doc on the interface, the disk implementation 
can defer to the interface when there's nothing special to say.
That way callers don't have to be confused about what the semantics are in the 
general case.



Comment at: clangd/index/Background.h:35
+  using FileDigest = decltype(llvm::SHA1::hash({}));
+  virtual bool storeShard(llvm::StringRef ShardIdentifier,
+  IndexFileOut Shard) const = 0;

nit: we probably don't need "shard" both in the interface name and the method 
names.

Consider either BackgroundIndexStorage/storeShard or ShardStorage/store



Comment at: clangd/index/Background.h:38
+  virtual llvm::Expected
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;

this signature looks surprising to me, expected something like 
`Expected> retrieveShard(ShardID).

e.g. if we have a stale shard for a file when initializing, maybe we want to 
use it until we can reindex the file? Current interface doesn't allow this.

As discussed offline, it'd also be fine to leave retrieve out of the initial 
patch.



Comment at: clangd/index/Background.h:39
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;
+};

Why not use the constructor? what does "directory" mean in the general case?



Comment at: clangd/index/Background.h:51
   const FileSystemProvider &, ArrayRef URISchemes,
+  std::unique_ptr IndexShardStorage = nullptr,
   size_t ThreadPoolSize = llvm::hardware_concurrency());

So we have several possible designs on a collision course:
1. One instance of `BackgroundIndex` for clangd, which has a ShardStorage, 
which is used for every CDB
2. One instance of `BackgroundIndex`, which has many ShardStorages, one-per-CDB
3. Many instances of `BackgroundIndex`, one per CDB, each with a ShardStorage
4. One `BackgroundIndex` for everything, and one ShardStorage for everything 
(storage in $HOME/.clangd-index)

What are we aiming for here?

The design of ShardStorage in this patch precludes 1, taking unique_ptr here 
precludes 2. 3 requires us to revisit some aspects of BackgroundIndex (which is 
possible). With 4 it isn't obvious how we do multi-config, or how users can 
manage the storage.

(I'd been assuming 1 or 2, but I don't think we ever discussed it)



Comment at: clangd/index/Background.h:107
+// thread-safe.
+class DiskShardStorage : public ShardStorage {
+  mutable std::mutex DiskShardRootMu;

This class can be hidden in the cpp file.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269



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


[PATCH] D52273: [clangd] Initial implementation of expected types

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

In https://reviews.llvm.org/D52273#1294767, @malaperle wrote:

> What is the goal for doing this without the AST? Is the goal to not have to 
> keep the AST and save memory?


We don't have AST for index completions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:11
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"

should this be `"command":"clang++"...` with clang++ on the PATH?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311



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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:13
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy "%t/test.cpp"
+

This should check a diagnostic rather than rely on the error code, I think


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311



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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 173630.
ilya-biryukov added a comment.

- Updated the test


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311

Files:
  test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
  test/clang-tidy/clang-tidy-mac-libcxx.cpp


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy "%t/test.cpp" | FileCheck %s
+// CHECK-NOT: error
+
+#include 
+vector v;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1 @@
+class vector {};


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy "%t/test.cpp" | FileCheck %s
+// CHECK-NOT: error
+
+#include 
+vector v;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1 @@
+class vector {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:11
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"

sammccall wrote:
> should this be `"command":"clang++"...` with clang++ on the PATH?
Both the relative and the absolute path should work, but cmake produces 
absolute paths. Hence the test.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:13
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy "%t/test.cpp"
+

sammccall wrote:
> This should check a diagnostic rather than rely on the error code, I think
Done. We rely on the absence of a diagnostic (the unresolved error for vector), 
error-code seemed like a simpler way to do this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311



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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:11
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"

ilya-biryukov wrote:
> sammccall wrote:
> > should this be `"command":"clang++"...` with clang++ on the PATH?
> Both the relative and the absolute path should work, but cmake produces 
> absolute paths. Hence the test.
Is there a test for the other case? (In the clang repo rather than here is fine)



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:13
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy "%t/test.cpp"
+

ilya-biryukov wrote:
> sammccall wrote:
> > This should check a diagnostic rather than rely on the error code, I think
> Done. We rely on the absence of a diagnostic (the unresolved error for 
> vector), error-code seemed like a simpler way to do this.
I think emitting a diagnostic would make this a much more robust test, but up 
to you.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311



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


[PATCH] D54416: [GCOV] fix test after patch rL346642

2018-11-12 Thread calixte via Phabricator via cfe-commits
calixte created this revision.
calixte added a reviewer: marco-c.
Herald added a subscriber: cfe-commits.

Test is failing under windows, so fix it


Repository:
  rC Clang

https://reviews.llvm.org/D54416

Files:
  test/CodeGen/code-coverage-filter.c


Index: test/CodeGen/code-coverage-filter.c
===
--- test/CodeGen/code-coverage-filter.c
+++ test/CodeGen/code-coverage-filter.c
@@ -23,62 +23,62 @@
   test2();
 }
 
-// ALL: define void @test1() #0 {{.*}}
+// ALL: void @test1() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test2() #0 {{.*}}
+// ALL: void @test2() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test() #0 {{.*}}
+// ALL: void @test() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
 
-// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER: void @test1() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER: void @test2() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: void @test() #0 {{.*}}
 // NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
 
-// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: void @test1() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2: void @test2() #0 {{.*}}
 // NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: void @test() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
 
-// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C: void @test1() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C: void @test2() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: void @test() #0 {{.*}}
 // JUST-C: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
 
-// HEADER: define void @test1() #0 {{.*}}
+// HEADER: void @test1() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test2() #0 {{.*}}
+// HEADER: void @test2() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test() #0 {{.*}}
+// HEADER: void @test() #0 {{.*}}
 // HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
 
-// NONE: define void @test1() #0 {{.*}}
+// NONE: void @test1() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test2() #0 {{.*}}
+// NONE: void @test2() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test() #0 {{.*}}
+// NONE: void @test() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void


Index: test/CodeGen/code-coverage-filter.c
===
--- test/CodeGen/code-coverage-filter.c
+++ test/CodeGen/code-coverage-filter.c
@@ -23,62 +23,62 @@
   test2();
 }
 
-// ALL: define void @test1() #0 {{.*}}
+// ALL: void @test1() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test2() #0 {{.*}}
+// ALL: void @test2() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test() #0 {{.*}}
+// ALL: void @test() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
 
-// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER: void @test1() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER: void @test2() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: void @test() #0 {{.*}}
 // NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
 
-// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: void @test1() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2: void @test2() #0 {{.*}}
 // NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: void @test() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
 
-// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C: void @test1() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C: void @test2() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: void @test() #0 {{.*}}
 // JUST-C: {{.*}}__llvm

r346644 - [GCOV] fix test after patch rL346642

2018-11-12 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Mon Nov 12 01:52:14 2018
New Revision: 346644

URL: http://llvm.org/viewvc/llvm-project?rev=346644&view=rev
Log:
[GCOV] fix test after patch rL346642

Summary:
Test is failing under windows, so fix it.
Should fix:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/1390/steps/stage%201%20check/logs/stdio

Reviewers: marco-c

Reviewed By: marco-c

Subscribers: cfe-commits, sylvestre.ledru, marco-c

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

Modified:
cfe/trunk/test/CodeGen/code-coverage-filter.c

Modified: cfe/trunk/test/CodeGen/code-coverage-filter.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/code-coverage-filter.c?rev=346644&r1=346643&r2=346644&view=diff
==
--- cfe/trunk/test/CodeGen/code-coverage-filter.c (original)
+++ cfe/trunk/test/CodeGen/code-coverage-filter.c Mon Nov 12 01:52:14 2018
@@ -23,62 +23,62 @@ void test() {
   test2();
 }
 
-// ALL: define void @test1() #0 {{.*}}
+// ALL: void @test1() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test2() #0 {{.*}}
+// ALL: void @test2() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test() #0 {{.*}}
+// ALL: void @test() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
 
-// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER: void @test1() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER: void @test2() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: void @test() #0 {{.*}}
 // NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
 
-// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: void @test1() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2: void @test2() #0 {{.*}}
 // NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: void @test() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
 
-// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C: void @test1() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C: void @test2() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: void @test() #0 {{.*}}
 // JUST-C: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
 
-// HEADER: define void @test1() #0 {{.*}}
+// HEADER: void @test1() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test2() #0 {{.*}}
+// HEADER: void @test2() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test() #0 {{.*}}
+// HEADER: void @test() #0 {{.*}}
 // HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
 
-// NONE: define void @test1() #0 {{.*}}
+// NONE: void @test1() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test2() #0 {{.*}}
+// NONE: void @test2() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test() #0 {{.*}}
+// NONE: void @test() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void


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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: test/clang-tidy/clang-tidy-mac-libcxx.cpp:11
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > should this be `"command":"clang++"...` with clang++ on the PATH?
> > Both the relative and the absolute path should work, but cmake produces 
> > absolute paths. Hence the test.
> Is there a test for the other case? (In the clang repo rather than here is 
> fine)
No, will add one in the clang repo.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311



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


[PATCH] D54416: [GCOV] fix test after patch rL346642

2018-11-12 Thread calixte via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346644: [GCOV] fix test after patch rL346642 (authored by 
calixte, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54416

Files:
  cfe/trunk/test/CodeGen/code-coverage-filter.c


Index: cfe/trunk/test/CodeGen/code-coverage-filter.c
===
--- cfe/trunk/test/CodeGen/code-coverage-filter.c
+++ cfe/trunk/test/CodeGen/code-coverage-filter.c
@@ -23,62 +23,62 @@
   test2();
 }
 
-// ALL: define void @test1() #0 {{.*}}
+// ALL: void @test1() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test2() #0 {{.*}}
+// ALL: void @test2() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test() #0 {{.*}}
+// ALL: void @test() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
 
-// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER: void @test1() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER: void @test2() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: void @test() #0 {{.*}}
 // NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
 
-// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: void @test1() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2: void @test2() #0 {{.*}}
 // NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: void @test() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
 
-// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C: void @test1() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C: void @test2() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test() #0 {{.*}}
+// JUST-C: void @test() #0 {{.*}}
 // JUST-C: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
 
-// HEADER: define void @test1() #0 {{.*}}
+// HEADER: void @test1() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test2() #0 {{.*}}
+// HEADER: void @test2() #0 {{.*}}
 // HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
-// HEADER: define void @test() #0 {{.*}}
+// HEADER: void @test() #0 {{.*}}
 // HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // HEADER: ret void
 
-// NONE: define void @test1() #0 {{.*}}
+// NONE: void @test1() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test2() #0 {{.*}}
+// NONE: void @test2() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void
-// NONE: define void @test() #0 {{.*}}
+// NONE: void @test() #0 {{.*}}
 // NONE-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NONE: ret void


Index: cfe/trunk/test/CodeGen/code-coverage-filter.c
===
--- cfe/trunk/test/CodeGen/code-coverage-filter.c
+++ cfe/trunk/test/CodeGen/code-coverage-filter.c
@@ -23,62 +23,62 @@
   test2();
 }
 
-// ALL: define void @test1() #0 {{.*}}
+// ALL: void @test1() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test2() #0 {{.*}}
+// ALL: void @test2() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
-// ALL: define void @test() #0 {{.*}}
+// ALL: void @test() #0 {{.*}}
 // ALL: {{.*}}__llvm_gcov_ctr{{.*}}
 // ALL: ret void
 
-// NO-HEADER: define void @test1() #0 {{.*}}
+// NO-HEADER: void @test1() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test2() #0 {{.*}}
+// NO-HEADER: void @test2() #0 {{.*}}
 // NO-HEADER-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
-// NO-HEADER: define void @test() #0 {{.*}}
+// NO-HEADER: void @test() #0 {{.*}}
 // NO-HEADER: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER: ret void
 
-// NO-HEADER2: define void @test1() #0 {{.*}}
+// NO-HEADER2: void @test1() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test2() #0 {{.*}}
+// NO-HEADER2: void @test2() #0 {{.*}}
 // NO-HEADER2-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
-// NO-HEADER2: define void @test() #0 {{.*}}
+// NO-HEADER2: void @test() #0 {{.*}}
 // NO-HEADER2: {{.*}}__llvm_gcov_ctr{{.*}}
 // NO-HEADER2: ret void
 
-// JUST-C: define void @test1() #0 {{.*}}
+// JUST-C: void @test1() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm_gcov_ctr{{.*}}
 // JUST-C: ret void
-// JUST-C: define void @test2() #0 {{.*}}
+// JUST-C: void @test2() #0 {{.*}}
 // JUST-C-NOT: {{.*}}__llvm

Re: r346491 - [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with /fallback

2018-11-12 Thread Hans Wennborg via cfe-commits
Hmm, maybe I misunderstood your initial request for this.

The current implementation does what the warnings says: If the
compiler falls back to cl.exe, /Zc:dllexportInlines- will be ignored.
This suggests to the user that it's a bad idea, but they can go ahead
if they want to.

It sounds like you're suggesting we should always ignore
/Zc:dllexportInlines- when used together with the /fallback flag? I'm
not sure that's necessarily better.. it depends on why they're using
/fallback I guess. If it's because the user has one file that clang-cl
can't handle for some reason, but they still want
/Zc:dllexportInlines- for the rest, then ignoring it would break that.

In general, I'm not sure how widely used /fallback is anymore. I
wonder if it would be possible to remove it...

On Fri, Nov 9, 2018 at 9:52 PM, Nico Weber  wrote:
> Ah cool. But the diagnostic is "option /dllexportInlines- is ignored when
> /fallback happens" – shouldn't it be ignored regardless of if fallback
> happens? Does that happen and the warning text is wrong?
>
> On Fri, Nov 9, 2018 at 11:20 AM Hans Wennborg  wrote:
>>
>> On Fri, Nov 9, 2018 at 4:53 PM, Nico Weber  wrote:
>> > This only prints the warning when /fallback actually happens, right?
>>
>> No, it prints it when the fallback job is created, not when (or if) it
>> runs. I.e. it prints if the /fallback flag is used, regardless of
>> whether it actually falls back or not. This is reflected by the test
>> which uses -###, i.e. nothing is getting run.
>>
>> So I think we're good :-)
>>
>> > I don't
>> > think that's good enough: If we build a few TUs with /dllexportInlines-
>> > and
>> > don't fall back, those .obj files are not abi compatible with the
>> > cl-built
>> > ones. (Consider all dllexport TUs of a header being built with clang-cl
>> > but
>> > all dllimport versions of the same header being built by cl – I think
>> > this
>> > will cause link errors). SO I think we should error out if
>> > /dllexportIlnlines- /fallback is on the same line, even if the fallback
>> > doesn't actually happen.
>> >
>> > On Fri, Nov 9, 2018 at 8:28 AM Takuto Ikuta via cfe-commits
>> >  wrote:
>> >>
>> >> Author: tikuta
>> >> Date: Fri Nov  9 05:25:45 2018
>> >> New Revision: 346491
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=346491&view=rev
>> >> Log:
>> >> [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used
>> >> with /fallback
>> >>
>> >> Summary:
>> >> This is followup of
>> >> https://reviews.llvm.org/D51340
>> >>
>> >> Reviewers: hans, thakis
>> >>
>> >> Reviewed By: hans
>> >>
>> >> Subscribers: cfe-commits, llvm-commits
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D54298
>> >>
>> >> Modified:
>> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> >> cfe/trunk/test/Driver/cl-options.c
>> >>
>> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=346491&r1=346490&r2=346491&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Nov  9
>> >> 05:25:45 2018
>> >> @@ -161,6 +161,10 @@ def warn_drv_yc_multiple_inputs_clang_cl
>> >>"support for '/Yc' with more than one source file not implemented
>> >> yet;
>> >> flag ignored">,
>> >>InGroup;
>> >>
>> >> +def warn_drv_non_fallback_argument_clang_cl : Warning<
>> >> +  "option '%0' is ignored when /fallback happens">,
>> >> +  InGroup;
>> >> +
>> >>  def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
>> >>  def err_drv_invalid_int_value : Error<"invalid integral value '%1' in
>> >> '%0'">;
>> >>  def err_drv_invalid_remap_file : Error<
>> >>
>> >> Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=346491&r1=346490&r2=346491&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
>> >> +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Nov  9 05:25:45 2018
>> >> @@ -669,6 +669,12 @@ std::unique_ptr visualstudio::C
>> >>// them too.
>> >>Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
>> >>
>> >> +  // Warning for ignored flag.
>> >> +  if (const Arg *dllexportInlines =
>> >> +  Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
>> >> +
>> >>
>> >> C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
>> >> +  << dllexportInlines->getAsString(Args);
>> >> +
>> >>// Input filename.
>> >>assert(Inputs.size() == 1);
>> >>const InputInfo &II = Inputs[0];
>> >>
>> >> Modified: cfe/trunk/test/Driver/cl-options.c
>> >> URL:
>> >>
>> >

[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 173633.
gchatelet marked 2 inline comments as done.
gchatelet added a comment.

- Address comments + fix hex values display


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488

Files:
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp

Index: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
===
--- test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
+++ test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t -config="{CheckOptions: [{key: "cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion", value: 1}]}" -- -target x86_64-unknown-linux
 
 float ceil(float);
 namespace std {
@@ -9,47 +9,290 @@
 namespace floats {
 
 struct ConvertsToFloat {
-  operator float() const { return 0.5; }
+  operator float() const { return 0.5f; }
 };
 
-float operator "" _Pa(unsigned long long);
+float operator"" _float(unsigned long long);
 
-void not_ok(double d) {
+void narrow_double_to_int_not_ok(double d) {
   int i = 0;
   i = d;
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = static_cast(d);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = ConvertsToFloat();
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
-  i = 15_Pa;
+  i = 15_float;
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
 }
 
-void not_ok_binary_ops(double d) {
+void narrow_double_to_int_not_ok_binary_ops(double d) {
   int i = 0;
   i += 0.5;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += d;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   // We warn on the following even though it's not dangerous because there is no
   // reason to use a double literal here.
-  // TODO(courbet): Provide an automatic fix.
+  // TODO: Provide an automatic fix if the number is exactly representable in the destination type.
   i += 2.0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += 2.0f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
 
   i *= 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i /= 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += (double)0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+}
+
+double operator"" _double(unsigned long long);
+
+float nar

[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2018-11-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: unittests/clang-tidy/AddConstTest.cpp:733
+  StringRef T = "template  void f(T v) \n";
+  StringRef S = "{ T target = v; }";
+  auto Cat = [&T](StringRef S) { return (T + S).str(); };

It would be interesting to see test cases with multiple instantiations of the 
template the fix applies to.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54395



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


[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

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

- Check for a diagnostic inside the found library


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311

Files:
  test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
  test/clang-tidy/clang-tidy-mac-libcxx.cpp


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: not clang-tidy "%t/test.cpp" | FileCheck %s
+// CHECK: error: static_assert failed "mock libcxx found"
+
+#include 
+vector v;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,3 @@
+class vector {
+  static_assert(false, "mock libcxx found");
+};


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: not clang-tidy "%t/test.cpp" | FileCheck %s
+// CHECK: error: static_assert failed "mock libcxx found"
+
+#include 
+vector v;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,3 @@
+class vector {
+  static_assert(false, "mock libcxx found");
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:178
+  return;
+// Conversions to unsigned integer are well defined and follow modulo 2
+// arithmetic.

JonasToth wrote:
> gchatelet wrote:
> > JonasToth wrote:
> > > I am surprised by `following modulo 2 arithmetic` and think it's a bit 
> > > misleading. Writing just `module arithmetic` is probably better, as 
> > > `module 2` somewhat implies there a only 2 valid values (0, 1).
> > > 
> > > Is this the `int` -> `unsigned int` case path? That seems worth 
> > > diagnosing too.
> > Yes, thx for noticing. I updated the comment, I think it's better now.
> > 
> > Indeed this is the `int` -> `unsigned int` case path. Warning here would 
> > lead to a lot of noise for everybody doing bitwise operations since `-1` is 
> > a compact way to represent the maximum value. Since the semantic is valid 
> > and well defined by the standard I'm unsure it's worth the pain. I'm open 
> > to suggestions though.
> > 
> > Maybe a good way to figure out is what would be the correct fix for say 
> > `unsigned long AllBits = -1;`
> Comment is fine :)
> 
> I though that we have check that diagnoses `unsigned i = -1;` but I don't 
> find it right now (maybe its still in review or so, i belive it was related 
> to introducing `std::numeric_limits<>`).
> As its well defined and not narrowing and not mentionend by the CPPCG in that 
> section its ok, maybe worth an option in the future?
An Option to warn on these sound like a good idea.
I added TODOs.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D52273: [clangd] Initial implementation of expected types

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



Comment at: clangd/ExpectedTypes.cpp:27
+return llvm::None;
+  auto *VD = llvm::dyn_cast(R.Declaration);
+  if (!VD)

maybe add a comment what `ValueDecl` covers roughly? E.g. functions, classes, 
variables etc.



Comment at: clangd/ExpectedTypes.cpp:40
+
+llvm::Optional encodeType(ASTContext &Ctx, QualType T) {
+  assert(!T.isNull());

IIUC, we also encode the qualifiers into the final representation? If so, have 
you considered the underlying type without qualifiers? It seems to me this 
might be too restrictive for type-based boosting. For code completion ranking, 
I think type qualifiers (`const` etc) can be separate signals.



Comment at: clangd/ExpectedTypes.h:10
+// A simplified model of C++ types that can be used to check whether they are
+// convertible between each other without looking at the ASTs.
+// Used for code completion ranking.

We might want to formalize what "convertible" means here. E.g. does it cover 
conversion between base and derived class? Does it cover double <-> int 
conversion?



Comment at: clangd/ExpectedTypes.h:29
+namespace clangd {
+/// An opaque representation of a type that can be computed based on clang AST
+/// and compared for equality. The encoding is stable between different ASTs,

The name seems opaque ;) Why is it `opaque`? 



Comment at: clangd/ExpectedTypes.h:37
+  fromCompletionResult(ASTContext &Ctx, const CodeCompletionResult &R);
+  static llvm::Optional fromPreferredType(ASTContext &Ctx,
+  QualType Type);

why "preferred type"? maybe add a comment?



Comment at: clangd/ExpectedTypes.h:40
+
+  /// Get the raw byte representation of the type. Bitwise equality of the raw
+  /// data is equivalent to equality operators of SType itself. The raw

What is the raw representation? A hash or the type name or USR?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Background.cpp:252
+
+auto Hash = FilesToUpdate.lookup(Path);
+// Put shards into storage for subsequent use.

sammccall wrote:
> nit: i'd suggest doing the writes *after* updating the index, as the latter 
> is user-facing
but updating index consumes slabs. Is it worth making a copy?



Comment at: clangd/index/Background.cpp:326
   return Error::success();
+} else if (IndexShardStorage) { // Check if shard storage has the index.
+  auto Shard = IndexShardStorage->retrieveShard(AbsolutePath, Hash);

sammccall wrote:
> I don't think this is the right place to be reading shards, vs on startup. It 
> means we're doing extra IO whenever a file is reindexed, and more importantly 
> we don't make the index contents available on startup (if any file needs 
> reindexing, reads may get stuck behind it).
> 
> (as discussed, we can also leave reading out of this patch entirely)
What exactly you mean by startup exactly from BackgroundIndex's perspective. Is 
it enqueueAll ?



Comment at: clangd/index/Background.h:38
+  virtual llvm::Expected
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;

sammccall wrote:
> this signature looks surprising to me, expected something like 
> `Expected> retrieveShard(ShardID).
> 
> e.g. if we have a stale shard for a file when initializing, maybe we want to 
> use it until we can reindex the file? Current interface doesn't allow this.
> 
> As discussed offline, it'd also be fine to leave retrieve out of the initial 
> patch.
I thought it would be better to get rid of disk io if the file was out-of-date, 
but using the stale file and deferring indexing also seems like a good idea. 
Moving with it.



Comment at: clangd/index/Background.h:39
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;
+};

sammccall wrote:
> Why not use the constructor? what does "directory" mean in the general case?
Directory refers to the one specified in CompilationDatabase(which is usually 
the build directory?), sorry for the inconvenience.
I wasn't sure about where we plan to instantiate BackgroundIndex. If you plan 
to do that initialization at a point in which we already know the build 
directory we can move that to constructor, especially only to the constructor 
of DiskBackedIndexStorage.



Comment at: clangd/index/Background.h:51
   const FileSystemProvider &, ArrayRef URISchemes,
+  std::unique_ptr IndexShardStorage = nullptr,
   size_t ThreadPoolSize = llvm::hardware_concurrency());

sammccall wrote:
> So we have several possible designs on a collision course:
> 1. One instance of `BackgroundIndex` for clangd, which has a ShardStorage, 
> which is used for every CDB
> 2. One instance of `BackgroundIndex`, which has many ShardStorages, 
> one-per-CDB
> 3. Many instances of `BackgroundIndex`, one per CDB, each with a ShardStorage
> 4. One `BackgroundIndex` for everything, and one ShardStorage for everything 
> (storage in $HOME/.clangd-index)
> 
> What are we aiming for here?
> 
> The design of ShardStorage in this patch precludes 1, taking unique_ptr here 
> precludes 2. 3 requires us to revisit some aspects of BackgroundIndex (which 
> is possible). With 4 it isn't obvious how we do multi-config, or how users 
> can manage the storage.
> 
> (I'd been assuming 1 or 2, but I don't think we ever discussed it)
The aim was more like 2. But I forgot the fact that we could be working with 
multiple CDBs :D

So it might be better to just pass a factory to BackgroundIndex and let it 
create one ShardStorage for each CDB(which is distinguished by the build 
directory?) WDYT?



Comment at: clangd/index/Background.h:107
+// thread-safe.
+class DiskShardStorage : public ShardStorage {
+  mutable std::mutex DiskShardRootMu;

sammccall wrote:
> This class can be hidden in the cpp file.
But it needs to be passed into the constructor of BackgroundIndex, possibly by 
the ClangdServer, do you suggest hiding inside ClangdServer?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269



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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-11-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp:33-36
+  anyOf(hasAncestor(
+functionTemplateDecl(HasMatchingDependentDescendant)),
+hasAncestor(
+classTemplateDecl(HasMatchingDependentDescendant

astrelni wrote:
> alexfh wrote:
> > The hasAncestor and hasDescendant matchers frequently have non-trivial 
> > performance implications. Especially the latter, especially when called on 
> > a large number of nodes with a large number of transitive children (this 
> > obviously depends on the code being analyzed). I don't know how likely is 
> > this to cause problems here (the matcher seems to only be used when the 
> > check is about to issue a diagnostic), but it's always good to be aware of 
> > the possible issues.
> > 
> > Frequently there's a more efficient (and easier to understand) alternative. 
> > For example, instead of trying to evaluate certain conditions while 
> > traversing the code (which may require a large number of lookups into 
> > relatively distant parts of the AST), it's sometimes more efficient to 
> > split the analysis into two or more stages. During the AST traversal (i.e. 
> > when AST matchers run) the check could collect some raw information about 
> > all potentially problematic places in the code and then (for example, in 
> > `onEndOfTranslationUnit`) analyze the collected information together in a 
> > second stage. This works best if there's a way to arrange the data gathered 
> > on the first pass such that the second pass can efficiently look up 
> > necessary information.
> Thanks, gave it a try, what do you think of this?
From a cursory look this should be less likely to be slw. In any case, 
makes sense to profile the check on a number of large files (at least against 
other checks, using clang-tidy's -enable-check-profile option).



Comment at: clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp:43
+  unless(hasTemplateArgument(0, refersToType(builtinType(,
+  anyOf(hasName("operator*="), hasName("operator/="),
+  this);

hasAnyName, please. It's more efficient. A few more instances below.


https://reviews.llvm.org/D53830



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


Re: r346491 - [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with /fallback

2018-11-12 Thread Nico Weber via cfe-commits
On Mon, Nov 12, 2018 at 4:58 AM Hans Wennborg  wrote:

> Hmm, maybe I misunderstood your initial request for this.
>
> The current implementation does what the warnings says: If the
> compiler falls back to cl.exe, /Zc:dllexportInlines- will be ignored.
> This suggests to the user that it's a bad idea, but they can go ahead
> if they want to.
>
> It sounds like you're suggesting we should always ignore
> /Zc:dllexportInlines- when used together with the /fallback flag?


I thought we'd always emit an error if both flags are present, actually,
something like "/dllexportInlines- is ABI-changing and not compatible with
/fallback". If you still need /fallback, you can't really use
/dllexportInlines-.


> I'm
> not sure that's necessarily better.. it depends on why they're using
> /fallback I guess. If it's because the user has one file that clang-cl
> can't handle for some reason, but they still want
> /Zc:dllexportInlines- for the rest, then ignoring it would break that.
>
> In general, I'm not sure how widely used /fallback is anymore. I
> wonder if it would be possible to remove it...
>
> On Fri, Nov 9, 2018 at 9:52 PM, Nico Weber  wrote:
> > Ah cool. But the diagnostic is "option /dllexportInlines- is ignored when
> > /fallback happens" – shouldn't it be ignored regardless of if fallback
> > happens? Does that happen and the warning text is wrong?
> >
> > On Fri, Nov 9, 2018 at 11:20 AM Hans Wennborg  wrote:
> >>
> >> On Fri, Nov 9, 2018 at 4:53 PM, Nico Weber  wrote:
> >> > This only prints the warning when /fallback actually happens, right?
> >>
> >> No, it prints it when the fallback job is created, not when (or if) it
> >> runs. I.e. it prints if the /fallback flag is used, regardless of
> >> whether it actually falls back or not. This is reflected by the test
> >> which uses -###, i.e. nothing is getting run.
> >>
> >> So I think we're good :-)
> >>
> >> > I don't
> >> > think that's good enough: If we build a few TUs with
> /dllexportInlines-
> >> > and
> >> > don't fall back, those .obj files are not abi compatible with the
> >> > cl-built
> >> > ones. (Consider all dllexport TUs of a header being built with
> clang-cl
> >> > but
> >> > all dllimport versions of the same header being built by cl – I think
> >> > this
> >> > will cause link errors). SO I think we should error out if
> >> > /dllexportIlnlines- /fallback is on the same line, even if the
> fallback
> >> > doesn't actually happen.
> >> >
> >> > On Fri, Nov 9, 2018 at 8:28 AM Takuto Ikuta via cfe-commits
> >> >  wrote:
> >> >>
> >> >> Author: tikuta
> >> >> Date: Fri Nov  9 05:25:45 2018
> >> >> New Revision: 346491
> >> >>
> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=346491&view=rev
> >> >> Log:
> >> >> [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is
> used
> >> >> with /fallback
> >> >>
> >> >> Summary:
> >> >> This is followup of
> >> >> https://reviews.llvm.org/D51340
> >> >>
> >> >> Reviewers: hans, thakis
> >> >>
> >> >> Reviewed By: hans
> >> >>
> >> >> Subscribers: cfe-commits, llvm-commits
> >> >>
> >> >> Differential Revision: https://reviews.llvm.org/D54298
> >> >>
> >> >> Modified:
> >> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >> >> cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
> >> >> cfe/trunk/test/Driver/cl-options.c
> >> >>
> >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >> >> URL:
> >> >>
> >> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=346491&r1=346490&r2=346491&view=diff
> >> >>
> >> >>
> >> >>
> ==
> >> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> >> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Nov  9
> >> >> 05:25:45 2018
> >> >> @@ -161,6 +161,10 @@ def warn_drv_yc_multiple_inputs_clang_cl
> >> >>"support for '/Yc' with more than one source file not implemented
> >> >> yet;
> >> >> flag ignored">,
> >> >>InGroup;
> >> >>
> >> >> +def warn_drv_non_fallback_argument_clang_cl : Warning<
> >> >> +  "option '%0' is ignored when /fallback happens">,
> >> >> +  InGroup;
> >> >> +
> >> >>  def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
> >> >>  def err_drv_invalid_int_value : Error<"invalid integral value '%1'
> in
> >> >> '%0'">;
> >> >>  def err_drv_invalid_remap_file : Error<
> >> >>
> >> >> Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
> >> >> URL:
> >> >>
> >> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=346491&r1=346490&r2=346491&view=diff
> >> >>
> >> >>
> >> >>
> ==
> >> >> --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
> >> >> +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Nov  9 05:25:45 2018
> >> >> @@ -669,6 +669,12 @@ std::unique_ptr visualstudio::C
> >> >>// them too.
> >> >>Args.AddAllArgs

[PATCH] D52296: [Clang] - Add '-gsplit-dwarf[=split, =single]' version for '-gsplit-dwarf' option.

2018-11-12 Thread George Rimar via Phabricator via cfe-commits
grimar updated this revision to Diff 173643.
grimar retitled this revision from "[Clang] - Add -fdwarf-fission=split,single 
option." to "[Clang] - Add '-gsplit-dwarf[=split,=single]' version for 
'-gsplit-dwarf' option.".
grimar edited the summary of this revision.
grimar added a comment.

Thanks, David!

Changed:

- Introduced a -gsplit-dwarf[=split,=single] version for '-gsplit-dwarf' option


https://reviews.llvm.org/D52296

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/split-debug-single-file.c
  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
@@ -5,6 +5,13 @@
 //
 // CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"
 
+// Check we pass -split-dwarf-file to `as` if -gsplit-dwarf=split.
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
+
+// Check we do not pass any -split-dwarf* commands to `as` if -gsplit-dwarf=single.
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
Index: test/Driver/split-debug.c
===
--- test/Driver/split-debug.c
+++ test/Driver/split-debug.c
@@ -5,6 +5,21 @@
 //
 // CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=split -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-ACTIONS-SINGLE-SPLIT < %t %s
+//
+// CHECK-ACTIONS-SINGLE-SPLIT: "-enable-split-dwarf=single"
+// CHECK-ACTIONS-SINGLE-SPLIT: "-split-dwarf-file" "split-debug.o"
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### -o %tfoo.o %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-SINGLE-SPLIT-FILENAME < %t %s
+//
+// CHECK-SINGLE-SPLIT-FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
Index: test/CodeGen/split-debug-single-file.c
===
--- test/CodeGen/split-debug-single-file.c
+++ test/CodeGen/split-debug-single-file.c
@@ -0,0 +1,17 @@
+// REQUIRES: x86-registered-target
+
+// Testing to ensure -enable-split-dwarf=single allows to place .dwo sections into regular output object.
+//  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
+//  RUN:   -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s
+//  RUN: llvm-objdump -section-headers %t.o | FileCheck --check-prefix=MODE-SINGLE %s
+//  MODE-SINGLE: .dwo
+
+// Testing to ensure -enable-split-dwarf=single allows to place .dwo sections into regular output object.
+//  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
+//  RUN:   -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o %s
+//  RUN: llvm-objdump -section-headers %t.o | FileCheck --check-prefix=MODE-SPLIT %s
+//  MODE-SPLIT-NOT: .dwo
+
+int main (void) {
+  return 0;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -596,9 +596,25 @@
   Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
   Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
-  Opts.EnableSplitDwarf = Args.hasArg(OPT_enable_split_dwarf);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
+
+  if (Arg *A =
+  Args.getLastArg(OPT_enable_split_dwarf, OPT_enable_split_dwarf_EQ)) {
+if (A->getOption().matches(options::OPT_enable_split_dwarf)) {
+  Opts.setSplitDwarfMode(CodeGenOptions::SplitFileFission);
+} else {
+  StringRef Name = A->getValue();
+  if (Name == "single")
+Opts.setSplitDwarfMode(CodeGenOptions::Singl

[PATCH] D54253: [OpenCL][NFC] Improve test coverage of test/Index/opencl-types.cl

2018-11-12 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov added a comment.

If I understand correctly, not all extensions are available on non-x86 targets 
and some declarations are marked as `(invalid)` - that is the only difference I 
saw


Repository:
  rC Clang

https://reviews.llvm.org/D54253



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


[clang-tools-extra] r346648 - [clangd] Remember to serialize AnyScope in FuzzyFindRequest json.

2018-11-12 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Nov 12 04:24:08 2018
New Revision: 346648

URL: http://llvm.org/viewvc/llvm-project?rev=346648&view=rev
Log:
[clangd] Remember to serialize AnyScope in FuzzyFindRequest json.

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=346648&r1=346647&r2=346648&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Mon Nov 12 04:24:08 2018
@@ -207,7 +207,7 @@ bool fromJSON(const json::Value &Paramet
   int64_t Limit;
   bool OK =
   O && O.map("Query", Request.Query) && O.map("Scopes", Request.Scopes) &&
-  O.map("Limit", Limit) &&
+  O.map("AnyScope", Request.AnyScope) && O.map("Limit", Limit) &&
   O.map("RestrictForCodeCompletion", Request.RestrictForCodeCompletion) &&
   O.map("ProximityPaths", Request.ProximityPaths);
   if (OK && Limit <= std::numeric_limits::max())
@@ -219,6 +219,7 @@ json::Value toJSON(const FuzzyFindReques
   return json::Object{
   {"Query", Request.Query},
   {"Scopes", json::Array{Request.Scopes}},
+  {"AnyScope", Request.AnyScope},
   {"Limit", Request.Limit},
   {"RestrictForCodeCompletion", Request.RestrictForCodeCompletion},
   {"ProximityPaths", json::Array{Request.ProximityPaths}},


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


[PATCH] D54326: [AST] Pack CXXThrowExpr, CXXDefaultArgExpr and CXXDefaultInitExpr

2018-11-12 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 173652.

Repository:
  rC Clang

https://reviews.llvm.org/D54326

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  lib/AST/ExprCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp

Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1480,21 +1480,21 @@
 
 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
   VisitExpr(E);
-  E->ThrowLoc = ReadSourceLocation();
-  E->Op = Record.readSubExpr();
-  E->IsThrownVariableInScope = Record.readInt();
+  E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation();
+  E->Operand = Record.readSubExpr();
+  E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
 }
 
 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
   VisitExpr(E);
   E->Param = ReadDeclAs();
-  E->Loc = ReadSourceLocation();
+  E->CXXDefaultArgExprBits.Loc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
   VisitExpr(E);
   E->Field = ReadDeclAs();
-  E->Loc = ReadSourceLocation();
+  E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -749,14 +749,15 @@
   return cast(getCalleeDecl())->getLiteralIdentifier();
 }
 
-CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc,
-   FieldDecl *Field, QualType T)
-: Expr(CXXDefaultInitExprClass, T.getNonLValueExprType(C),
-   T->isLValueReferenceType() ? VK_LValue : T->isRValueReferenceType()
+CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
+   FieldDecl *Field, QualType Ty)
+: Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
+   Ty->isLValueReferenceType() ? VK_LValue : Ty->isRValueReferenceType()
 ? VK_XValue
 : VK_RValue,
/*FIXME*/ OK_Ordinary, false, false, false, false),
-  Field(Field), Loc(Loc) {
+  Field(Field) {
+  CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 }
 
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -596,6 +596,39 @@
 SourceLocation Loc;
   };
 
+  class CXXThrowExprBitfields {
+friend class ASTStmtReader;
+friend class CXXThrowExpr;
+
+unsigned : NumExprBits;
+
+/// Whether the thrown variable (if any) is in scope.
+unsigned IsThrownVariableInScope : 1;
+
+/// The location of the "throw".
+SourceLocation ThrowLoc;
+  };
+
+  class CXXDefaultArgExprBitfields {
+friend class ASTStmtReader;
+friend class CXXDefaultArgExpr;
+
+unsigned : NumExprBits;
+
+/// The location where the default argument expression was used.
+SourceLocation Loc;
+  };
+
+  class CXXDefaultInitExprBitfields {
+friend class ASTStmtReader;
+friend class CXXDefaultInitExpr;
+
+unsigned : NumExprBits;
+
+/// The location where the default initializer expression was used.
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -687,6 +720,9 @@
 CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
 CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
 CXXThisExprBitfields CXXThisExprBits;
+CXXThrowExprBitfields CXXThrowExprBits;
+CXXDefaultArgExprBitfields CXXDefaultArgExprBits;
+CXXDefaultInitExprBitfields CXXDefaultInitExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -1003,42 +1003,43 @@
 class CXXThrowExpr : public Expr {
   friend class ASTStmtReader;
 
-  Stmt *Op;
-  SourceLocation ThrowLoc;
-
-  /// Whether the thrown variable (if any) is in scope.
-  unsigned IsThrownVariableInScope : 1;
+  /// The optional expression in the throw statement.
+  Stmt *Operand;
 
 public:
   // \p Ty is the void type which is used as the result type of the
-  // expression.  The \p l is the location of the throw keyword.  \p expr
-  // can by null, if the optional expression to throw isn't present.
-  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l,
+  // expression. The \p Loc is the location of the throw keyword.
+  // \p Operand is the expression in the throw statement, and can be
+  // null if not present.
+  CXXThrowExpr(Expr *Operand, QualType Ty, Sou

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-11-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 173653.
JonasToth added a comment.

- Merge branch 'master' into check_const


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,563 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared 'const'
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be d

[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/Background.cpp:252
+
+auto Hash = FilesToUpdate.lookup(Path);
+// Put shards into storage for subsequent use.

kadircet wrote:
> sammccall wrote:
> > nit: i'd suggest doing the writes *after* updating the index, as the latter 
> > is user-facing
> but updating index consumes slabs. Is it worth making a copy?
Oh, true - probably not. Add a comment?



Comment at: clangd/index/Background.cpp:326
   return Error::success();
+} else if (IndexShardStorage) { // Check if shard storage has the index.
+  auto Shard = IndexShardStorage->retrieveShard(AbsolutePath, Hash);

kadircet wrote:
> sammccall wrote:
> > I don't think this is the right place to be reading shards, vs on startup. 
> > It means we're doing extra IO whenever a file is reindexed, and more 
> > importantly we don't make the index contents available on startup (if any 
> > file needs reindexing, reads may get stuck behind it).
> > 
> > (as discussed, we can also leave reading out of this patch entirely)
> What exactly you mean by startup exactly from BackgroundIndex's perspective. 
> Is it enqueueAll ?
Yes. (Or rather, a task scheduled there)



Comment at: clangd/index/Background.h:39
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;
+};

kadircet wrote:
> sammccall wrote:
> > Why not use the constructor? what does "directory" mean in the general case?
> Directory refers to the one specified in CompilationDatabase(which is usually 
> the build directory?), sorry for the inconvenience.
> I wasn't sure about where we plan to instantiate BackgroundIndex. If you plan 
> to do that initialization at a point in which we already know the build 
> directory we can move that to constructor, especially only to the constructor 
> of DiskBackedIndexStorage.
tooling::CompileCommand::WorkingDirectory? That doesn't seem especially 
relevant here.
Or the directory that the CDB was discovered in?

Yes, this seems to be only relevant to DiskBackedIndexStorage



Comment at: clangd/index/Background.h:51
   const FileSystemProvider &, ArrayRef URISchemes,
+  std::unique_ptr IndexShardStorage = nullptr,
   size_t ThreadPoolSize = llvm::hardware_concurrency());

kadircet wrote:
> sammccall wrote:
> > So we have several possible designs on a collision course:
> > 1. One instance of `BackgroundIndex` for clangd, which has a ShardStorage, 
> > which is used for every CDB
> > 2. One instance of `BackgroundIndex`, which has many ShardStorages, 
> > one-per-CDB
> > 3. Many instances of `BackgroundIndex`, one per CDB, each with a 
> > ShardStorage
> > 4. One `BackgroundIndex` for everything, and one ShardStorage for 
> > everything (storage in $HOME/.clangd-index)
> > 
> > What are we aiming for here?
> > 
> > The design of ShardStorage in this patch precludes 1, taking unique_ptr 
> > here precludes 2. 3 requires us to revisit some aspects of BackgroundIndex 
> > (which is possible). With 4 it isn't obvious how we do multi-config, or how 
> > users can manage the storage.
> > 
> > (I'd been assuming 1 or 2, but I don't think we ever discussed it)
> The aim was more like 2. But I forgot the fact that we could be working with 
> multiple CDBs :D
> 
> So it might be better to just pass a factory to BackgroundIndex and let it 
> create one ShardStorage for each CDB(which is distinguished by the build 
> directory?) WDYT?
Yep, that works for me.



Comment at: clangd/index/Background.h:107
+// thread-safe.
+class DiskShardStorage : public ShardStorage {
+  mutable std::mutex DiskShardRootMu;

kadircet wrote:
> sammccall wrote:
> > This class can be hidden in the cpp file.
> But it needs to be passed into the constructor of BackgroundIndex, possibly 
> by the ClangdServer, do you suggest hiding inside ClangdServer?
We can expose a factory function (e.g. static on ShardStorage)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269



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


[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-11-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 173654.
xazax.hun added a comment.

- Use the term `checker` instead of `check`.


https://reviews.llvm.org/D52984

Files:
  www/analyzer/checker_dev_manual.html

Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -675,6 +675,111 @@
 (gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump()
 
 
+Making Your Check Better
+
+User facing documentation is important for adoption! Make sure the checker list is updated
+at the homepage of the analyzer. Also ensure the description is clear to
+non-analyzer-developers in Checkers.td.
+Warning and note messages should be clear and easy to understand, even if a bit long.
+
+  Messages should start with a capital letter (unlike Clang warnings!) and should not
+  end with ..
+  Articles are usually omitted, eg. Dereference of a null pointer ->
+  Dereference of null pointer.
+  Introduce BugReporterVisitors to emit additional notes that explain the warning
+  to the user better. There are some existing visitors that might be useful for your check,
+  e.g. trackNullOrUndefValue. For example, SimpleStreamChecker should highlight
+  the event of opening the file when reporting a file descriptor leak.
+
+If the check tracks anything in the program state, it needs to implement the
+checkDeadSymbolscallback to clean the state up.
+The check should conservatively assume that the program is correct when a tracked symbol
+is passed to a function that is unknown to the analyzer.
+checkPointerEscape callback could help you handle that case.
+Use safe and convenient APIs!
+
+  Always use CheckerContext::generateErrorNode and
+CheckerContext::generateNonFatalErrorNode for emitting bug reports.
+Most importantly, never emit report against CheckerContext::getPredecessor.
+  Prefer checkPreCall and checkPostCall to
+checkPreStmt and checkPostStmt.
+  Use CallDescription to detect hardcoded API calls in the program.
+  Simplify C.getState()->getSVal(E, C.getLocationContext()) to C.getSVal(E).
+
+Common sources of crashes:
+
+  CallEvent::getOriginExpr is nullable - for example, it returns null for an
+automatic destructor of a variable. The same applies to some values generated while the
+call was modeled, eg. SymbolConjured::getStmt is nullable.
+  CallEvent::getDecl is nullable - for example, it returns null for a
+  call of symbolic function pointer.
+  addTransition, generateSink, generateNonFatalErrorNode,
+generateErrorNode are nullable because you can transition to a node that you have already visited.
+  Methods of CallExpr/FunctionDecl/CallEvent that
+return arguments crash when the argument is out-of-bounds. If you checked the function name,
+it doesn't mean that the function has the expected number of arguments!
+Which is why you should use CallDescription.
+  Nullability of different entities within different kinds of symbols and regions is usually
+  documented via assertions in their constructors.
+  NamedDecl::getName will fail if the name of the declaration is not a single token,
+e.g. for destructors. You could use NamedDecl::getNameAsString for those cases.
+Note that this method is much slower and should be used sparringly, e.g. only when generating reports
+but not during analysis.
+  Is -analyzer-checker=core included in all test RUN: lines? It was never supported
+to run the analyzer with the core checks disabled. It might cause unexpected behavior and
+crashes. You should do all your testing with the core checks enabled.
+
+
+Patterns that you should most likely avoid even if they're not technically wrong:
+
+  BugReporterVisitor should most likely not match the AST of the current program point
+  to decide when to emit a note. It is much easier to determine that by observing changes in
+  the program state.
+  In State->getSVal(Region), Region is not necessarily a TypedValueRegion
+  and the optional type argument is not specified. It is likely that the checker
+  may accidentally try to dereference a void pointer.
+  Checker logic depends on whether a certain value is a Loc or NonLoc.
+It should be immediately obvious whether the SVal is a Loc or a
+NonLoc depending on the AST that is being checked. Checking whether a value
+is Loc or Unknown/Undefined or whether the value is
+NonLoc or Unknown/Undefined is totally fine.
+  New symbols are constructed in the checker via direct calls to SymbolManager,
+unless they are of SymbolMetadata class tagged by the checker,
+or they represent newly created values such as the return value in evalCall.
+For modeling arithmetic/bitwise/comparison operations, SValBuilder should be used.
+  Custom ProgramPointTags are created within the checker. There is usually
+no goo

[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 173659.
ilya-biryukov added a comment.

- Check with a clang-tidy warning instead of a clang error


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311

Files:
  test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
  test/clang-tidy/clang-tidy-mac-libcxx.cpp


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers 
-checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 
'typedef'
+
+#include 
+typedef vector* vec_ptr;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers -checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 'typedef'
+
+#include 
+typedef vector* vec_ptr;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54310: Make clang-based tools find libc++ on MacOS

2018-11-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 173660.
ilya-biryukov added a comment.

- Added a test with a compiler path relative to the working dir


Repository:
  rC Clang

https://reviews.llvm.org/D54310

Files:
  include/clang/Lex/HeaderSearchOptions.h
  lib/Frontend/CreateInvocationFromCommandLine.cpp
  lib/Frontend/InitHeaderSearch.cpp
  lib/Tooling/Tooling.cpp
  test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
  test/Tooling/clang-check-mac-libcxx-abspath.cpp
  test/Tooling/clang-check-mac-libcxx-relpath.cpp

Index: test/Tooling/clang-check-mac-libcxx-relpath.cpp
===
--- /dev/null
+++ test/Tooling/clang-check-mac-libcxx-relpath.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// clang-check will produce an error code if the mock library is not found.
+// RUN: clang-check -p "%t" "%t/test.cpp"
+
+#include 
+vector v;
Index: test/Tooling/clang-check-mac-libcxx-abspath.cpp
===
--- /dev/null
+++ test/Tooling/clang-check-mac-libcxx-abspath.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// clang-check will produce an error code if the mock library is not found.
+// RUN: clang-check -p "%t" "%t/test.cpp"
+
+#include 
+vector v;
Index: test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1 @@
+class vector {};
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -327,6 +327,9 @@
 Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
   Input.release());
   }
+  // Patch up the install dir, so we find the same standard library as the
+  // original compiler on MacOS.
+  Invocation->getHeaderSearchOpts().InstallDir = Driver->getInstalledDir();
   return runInvocation(BinaryName, Compilation.get(), std::move(Invocation),
std::move(PCHContainerOps));
 }
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -476,14 +476,9 @@
   if (triple.isOSDarwin()) {
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-if (!HSOpts.ResourceDir.empty()) {
-  // Remove version from foo/lib/clang/version
-  StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
-  // Remove clang from foo/lib/clang
-  StringRef Lib = llvm::sys::path::parent_path(NoVer);
-  // Remove lib from foo/lib
-  SmallString<128> P = llvm::sys::path::parent_path(Lib);
-
+if (!HSOpts.InstallDir.empty()) {
+  // Get from foo/bin to foo.
+  SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir));
   // Get foo/include/c++/v1
   llvm::sys::path::append(P, "include", "c++", "v1");
   AddUnmappedPath(P, CXXSystem, false);
Index: lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -11,17 +11,18 @@
 //
 //===--===//
 
-#include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/Action.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver

[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

2018-11-12 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

I'm totally fine with this patch personally. However I am not familiar with 
this part, so can't give substantial help :).




Comment at: lib/StaticAnalyzer/Core/CheckerRegistry.cpp:51
 
-/// Collects the checkers for the supplied \p opt option into \p collected.
-static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers,
-const llvm::StringMap &packageSizes,
-CheckerOptInfo &opt, CheckerInfoSet &collected) {
-  // Use a binary search to find the possible start of the package.
-  CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
-  auto end = checkers.cend();
-  auto i = std::lower_bound(checkers.cbegin(), end, packageInfo, 
checkerNameLT);
-
-  // If we didn't even find a possible package, give up.
-  if (i == end)
-return;
-
-  // If what we found doesn't actually start the package, give up.
-  if (!isInPackage(*i, opt.getName()))
-return;
-
-  // There is at least one checker in the package; claim the option.
-  opt.claim();
-
-  // See how large the package is.
-  // If the package doesn't exist, assume the option refers to a single 
checker.
-  size_t size = 1;
-  llvm::StringMap::const_iterator packageSize =
-packageSizes.find(opt.getName());
-  if (packageSize != packageSizes.end())
-size = packageSize->getValue();
-
-  // Step through all the checkers in the package.
-  for (auto checkEnd = i+size; i != checkEnd; ++i)
-if (opt.isEnabled())
-  collected.insert(&*i);
-else
-  collected.remove(&*i);
+static CheckerInfoSet getEnabledCheckers(
+const CheckerRegistry::CheckerInfoList &checkers,

I just curious about the reason why you move the `CheckerInfoSet` from the 
parameter passing by reference to the return value, keep the number of 
parameter at a lower value? Or make the code at the caller cite cleaner?


https://reviews.llvm.org/D54401



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


[PATCH] D54300: [clangd] Respect shouldIndexFile when collecting symbols.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 173662.
hokein marked 3 inline comments as done.
hokein added a comment.

Update the patch based on offline discussion.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54300

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

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -98,6 +98,13 @@
 HaveRanges(const std::vector Ranges) {
   return testing::UnorderedPointwise(RefRange(), Ranges);
 }
+MATCHER_P(RefsInFiles, Files, "") {
+  for (const Ref &R : arg) {
+if (!Files.count(R.Location.FileURI))
+  return false;
+  }
+  return true;
+}
 
 class ShouldCollectSymbolTest : public ::testing::Test {
 public:
@@ -523,6 +530,82 @@
AllOf(QName("Z"), RefCount(0)), QName("y")));
 }
 
+TEST_F(SymbolCollectorTest, FileFilter) {
+  const std::string NonIndexedHeader = R"(
+// non-indexed symbols, didn't see any decl/def in indexed files.
+class Foo1 {};
+void k();
+inline void k() {}
+#define GLOBAL_Z(name) Z name;
+
+// indexed symbols
+class Foo2;// def in indexed .h file
+class Foo3;// def in indexed .cc file
+void fun1();   // def in indexed .cc file
+  )";
+
+  Annotations IndexedHeader(R"(
+// indexed symbols
+class Bar1 {};
+class Bar2;
+class Foo2 {};
+  )");
+  Annotations Main(R"(
+#include "nonindexed_header.h"
+#include "indexed_header.h"
+
+class Foo3 {};
+class Bar2 {};
+void fun1() {}
+  )");
+  const std::string NonIndexedHeaderPath = testPath("nonindexed_header.h");
+  const std::string IndexedHeaderPath = testPath("indexed_header.h");
+  const std::string NonIndexedHeaderURI =
+  URI::createFile(NonIndexedHeaderPath).toString();
+  const std::string IndexedHeaderURI =
+  URI::createFile(IndexedHeaderPath).toString();
+
+  InMemoryFileSystem->addFile(NonIndexedHeaderPath, 0,
+  MemoryBuffer::getMemBuffer(NonIndexedHeader));
+  InMemoryFileSystem->addFile(IndexedHeaderPath, 0,
+  MemoryBuffer::getMemBuffer(IndexedHeader.code()));
+  CollectorOpts.FileFilter = [](const SourceManager &SM, FileID FID) {
+if (const auto *F = SM.getFileEntryForID(FID))
+  return !F->getName().contains("nonindexed_header.h");
+return true;
+  };
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.RefsInHeaders = true;
+  runSymbolCollector("", Main.code());
+
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo2"), DeclURI(IndexedHeaderURI),
+ DefURI(IndexedHeaderURI)),
+   AllOf(QName("Foo3"), DeclURI(NonIndexedHeaderURI),
+ DefURI(TestFileURI)),
+   AllOf(QName("fun1"), DeclURI(NonIndexedHeaderURI),
+ DefURI(TestFileURI)),
+   AllOf(QName("Bar1"), DeclURI(IndexedHeaderURI),
+ DefURI(IndexedHeaderURI)),
+   AllOf(QName("Bar2"), DeclURI(IndexedHeaderURI),
+ DefURI(TestFileURI;
+  auto Files = [](const std::initializer_list &Files) {
+return llvm::StringSet<>(Files);
+  };
+  EXPECT_THAT(Refs,
+  UnorderedElementsAre(
+  Pair(findSymbol(Symbols, "Foo2").ID,
+   RefsInFiles(Files({IndexedHeaderURI}))),
+  Pair(findSymbol(Symbols, "Foo3").ID,
+   RefsInFiles(Files({TestFileURI}))),
+  Pair(findSymbol(Symbols, "fun1").ID,
+   RefsInFiles(Files({TestFileURI}))),
+  Pair(findSymbol(Symbols, "Bar1").ID,
+   RefsInFiles(Files({IndexedHeaderURI}))),
+  Pair(findSymbol(Symbols, "Bar2").ID,
+   RefsInFiles(Files({IndexedHeaderURI, TestFileURI});
+}
+
 TEST_F(SymbolCollectorTest, SymbolRelativeNoFallback) {
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -78,6 +78,9 @@
 bool CollectMacro = false;
 /// If this is set, only collect symbols/references from a file if
 /// `FileFilter(SM, FID)` is true. If not set, all files are indexed.
+/// Note that a symbol can be redeclared in multiple files, a complete
+/// symbol will be constructed if this symbol is declared in one of indexed
+/// files.
 std::function FileFilter = nullptr;
   };
 
@@ -110,8 +113,8 @@
   void finish() override;
 
 private:
-  const Symbol *add

[PATCH] D54425: [AArch64] Add aarch64_vector_pcs function attribute to Clang

2018-11-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: ributzka, rjmccall, rnk, aaron.ballman.
Herald added subscribers: arphaman, kristof.beyls, javed.absar.

This is the Clang patch to complement the following LLVM patches:

  https://reviews.llvm.org/D51477
  https://reviews.llvm.org/D51479

More information describing the vector ABI and procedure call standard
can be found here:

https://developer.arm.com/products/software-development-tools/\

  hpc/arm-compiler-for-hpc/vector-function-abi

Patch by Kerry McLaughlin.


https://reviews.llvm.org/D54425

Files:
  include/clang-c/Index.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Specifiers.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets/AArch64.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/aarch64-vpcs.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -651,6 +651,7 @@
   TCALLINGCONV(X86Pascal);
   TCALLINGCONV(X86RegCall);
   TCALLINGCONV(X86VectorCall);
+  TCALLINGCONV(AArch64VectorCall);
   TCALLINGCONV(Win64);
   TCALLINGCONV(X86_64SysV);
   TCALLINGCONV(AAPCS);
Index: test/CodeGen/aarch64-vpcs.c
===
--- /dev/null
+++ test/CodeGen/aarch64-vpcs.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECKC
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -x c++ -o - %s | FileCheck %s -check-prefix=CHECKCXX
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -verify %s
+
+void __attribute__((aarch64_vector_pcs)) f(int *); // expected-warning {{calling convention 'aarch64_vector_pcs' ignored for this target}}
+
+// CHECKC: define void @g(
+// CHECKCXX: define void @_Z1gPi(
+void g(int *a) {
+
+// CHECKC: call aarch64_vector_pcs void @f(
+// CHECKCXX: call aarch64_vector_pcs void @_Z1fPi
+  f(a);
+}
+
+// CHECKC: declare aarch64_vector_pcs void @f(
+// CHECKCXX: declare aarch64_vector_pcs void @_Z1fPi
+
+void __attribute__((aarch64_vector_pcs)) h(int *a){ // expected-warning {{calling convention 'aarch64_vector_pcs' ignored for this target}}
+// CHECKC: define aarch64_vector_pcs void @h(
+// CHECKCXX: define aarch64_vector_pcs void @_Z1hPi(
+  f(a);
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -116,6 +116,7 @@
   case ParsedAttr::AT_Pascal:  \
   case ParsedAttr::AT_SwiftCall:   \
   case ParsedAttr::AT_VectorCall:  \
+  case ParsedAttr::AT_AArch64VectorPcs:\
   case ParsedAttr::AT_MSABI:   \
   case ParsedAttr::AT_SysVABI: \
   case ParsedAttr::AT_Pcs: \
@@ -6657,6 +6658,8 @@
 return createSimpleAttr(Ctx, Attr);
   case ParsedAttr::AT_VectorCall:
 return createSimpleAttr(Ctx, Attr);
+  case ParsedAttr::AT_AArch64VectorPcs:
+return createSimpleAttr(Ctx, Attr);
   case ParsedAttr::AT_Pcs: {
 // The attribute may have had a fixit applied where we treated an
 // identifier as a string literal.  The contents of the string are valid,
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4291,6 +4291,11 @@
AL.getAttributeSpellingListIndex()));
 return;
   }
+  case ParsedAttr::AT_AArch64VectorPcs:
+D->addAttr(::new(S.Context)
+   AArch64VectorPcsAttr(AL.getRange(), S.Context,
+AL.getAttributeSpellingListIndex()));
+return;
   case ParsedAttr::AT_IntelOclBicc:
 D->addAttr(::new (S.Context)
IntelOclBiccAttr(AL.getRange(), S.Context,
@@ -4368,6 +4373,9 @@
   case ParsedAttr::AT_VectorCall:
 CC = CC_X86VectorCall;
 break;
+  case ParsedAttr::AT_AArch64VectorPcs:
+CC = CC_AArch64VectorCall;
+break;
   case ParsedAttr::AT_RegCall:
 CC = CC_X86RegCall;
 break;
@@ -5840,14 +5848,14 @@
   if (AL.isDeclspecAttribute() || AL.isCXX11Attribute())
 checkAttributeAtMostNumArgs(S, AL, 1);
   else if (AL.isArgExpr(1) && AL.getArgAsExpr(1) &&
-   !S.checkStringLiteralArgumentAttr(AL, 1, Replacement))
-return;
-
-  if (!S.getLangOpts().CPlusPlus14 && AL.isCXX11Attribute() && !AL.isGNUScope())
-S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL;
-
-  D->addAttr(::new (S.Context)
- DeprecatedAttr(AL.getRange

[PATCH] D54300: [clangd] Respect shouldIndexFile when collecting symbols.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:217
 
+bool shouldIndexFile(const Decl& D, const SymbolCollector::Options &Opts,
+ llvm::DenseMap *FilesToIndexCache) {

ioeric wrote:
> nit: this is very easily confused with the callback with the same name on the 
> call sites.
removed it.



Comment at: clangd/index/SymbolCollector.cpp:220
+  auto &SM = D.getASTContext().getSourceManager();
+  auto Loc = findNameLoc(&D);
+  return shouldIndexFile(SM, SM.getFileID(Loc), Opts, FilesToIndexCache);

ioeric wrote:
> This is following the implementation detail of how location is generated in 
> `addDeclaration`/`addDefinition`. I think we could put the filtering into 
> `addDeclaration`/`addDeclaration` to avoid the duplicate here (i.e. return 
> nullptr if decl is filtered like what you did in the previous revision?).
as discussed, we decide to move the filter logic out of 
`addDeclaration`/`addDefinition`, and also move out the `findNameLoc` logic.



Comment at: clangd/index/SymbolCollector.cpp:410
+if (!BasicSymbol)
+  BasicSymbol = addDeclaration(
+  *cast(OriginalDecl.getCanonicalDecl()), *ID);

ioeric wrote:
> `OriginalDecl.getCanonicalDecl()` might not be the one we prefer. I think we 
> should check all `redecls` and pick the preferred one? 
As discussed, `canonicalDecl` is always the decl we preferred here. If the 
definition `decl` is preferred, it will be handled in above 
`isPreferredDeclaration` code.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:526
 
+TEST_F(SymbolCollectorTest, ShouldIndexFile) {
+  const std::string IgnoredHeader = R"(

ioeric wrote:
> It's not trivial to tell what are the cases we are testing here. Maybe add 
> some comments?
> 
> There are a few cases that are interesting. For examples:
> - Symbol is declared in a filtered header and defined in a index file.
> - Symbol is declared in a indexed file and defined in a filter file.
> - Symbol has forward declaration and canonical declaration in filtered header 
> and definition in indexed file.
> - ...
> 
> It might be clearer to split them into multiple cases.
Added comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54300



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


r346652 - Make clang-based tools find libc++ on MacOS

2018-11-12 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Nov 12 05:55:55 2018
New Revision: 346652

URL: http://llvm.org/viewvc/llvm-project?rev=346652&view=rev
Log:
Make clang-based tools find libc++ on MacOS

Summary:
When they read compiler args from compile_commands.json.
This change allows to run clang-based tools, like clang-tidy or clangd,
built from head using the compile_commands.json file produced for XCode
toolchains.

On MacOS clang can find the C++ standard library relative to the
compiler installation dir.

The logic to do this was based on resource dir as an approximation of
where the compiler is installed. This broke the tools that read
'compile_commands.json' and don't ship with the compiler, as they
typically change resource dir.

To workaround this, we now use compiler install dir detected by the driver
to better mimic the behavior of the original compiler when replaying the
compilations using other tools.

Reviewers: sammccall, arphaman, EricWF

Reviewed By: sammccall

Subscribers: ioeric, christof, kadircet, cfe-commits

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

Added:
cfe/trunk/test/Tooling/Inputs/mock-libcxx/
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652&r1=346651&r2=346652&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12 05:55:55 2018
@@ -108,6 +108,13 @@ public:
   /// etc.).
   std::string ResourceDir;
 
+  /// Compiler install dir as detected by the Driver.
+  /// This is typically the directory that contains the clang executable, i.e.
+  /// the 'bin/' subdir of a clang distribution.
+  /// Only used to add include dirs for libc++ on Darwin. Please avoid relying
+  /// on this field for other purposes.
+  std::string InstallDir;
+
   /// The directory used for the module cache.
   std::string ModuleCachePath;
 

Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346652&r1=346651&r2=346652&view=diff
==
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov 12 
05:55:55 2018
@@ -11,17 +11,18 @@
 //
 
//===--===//
 
-#include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/Action.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/Utils.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
 using namespace clang;
 using namespace llvm::opt;
 
@@ -102,5 +103,8 @@ std::unique_ptr clan
  CCArgs.size(),
  *Diags))
 return nullptr;
+  // Patch up the install dir, so we find the same standard library as the
+  // original compiler on MacOS.
+  CI->getHeaderSearchOpts().InstallDir = TheDriver.getInstalledDir();
   return CI;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=346652&r1=346651&r2=346652&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Nov 12 05:55:55 2018
@@ -476,14 +476,9 @@ void InitHeaderSearch::AddDefaultInclude
   if (triple.isOSDarwin()) {
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-if (!HSOpts.ResourceDir.empty()) {
-  // Remove version from foo/lib/clang/version
-  StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
-  // Remove clang from foo/lib/clang
-  StringRef Lib = llvm::sys::path::parent_path(NoVer

[PATCH] D54425: [AArch64] Add aarch64_vector_pcs function attribute to Clang

2018-11-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:1101
   case CC_AAPCS:
+  case CC_AArch64VectorCall:
 return llvm::dwarf::DW_CC_LLVM_AAPCS;

I wasn't really sure whether this requires a corresponding DW_CC_LLVM_AAVPCS 
record in LLVM, as I couldn't find much about the DW_CC_LLVM_  encodings, 
specifically whether they align with some agreed encoding that is implemented 
by GDB/LLDB. Is this defined anywhere, or is it ignored by debuggers at the 
moment?


https://reviews.llvm.org/D54425



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


[PATCH] D54310: Make clang-based tools find libc++ on MacOS

2018-11-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346652: Make clang-based tools find libc++ on MacOS 
(authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54310

Files:
  cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
  cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
  cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
  cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
  cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp

Index: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
===
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
@@ -476,14 +476,9 @@
   if (triple.isOSDarwin()) {
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-if (!HSOpts.ResourceDir.empty()) {
-  // Remove version from foo/lib/clang/version
-  StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
-  // Remove clang from foo/lib/clang
-  StringRef Lib = llvm::sys::path::parent_path(NoVer);
-  // Remove lib from foo/lib
-  SmallString<128> P = llvm::sys::path::parent_path(Lib);
-
+if (!HSOpts.InstallDir.empty()) {
+  // Get from foo/bin to foo.
+  SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir));
   // Get foo/include/c++/v1
   llvm::sys::path::append(P, "include", "c++", "v1");
   AddUnmappedPath(P, CXXSystem, false);
Index: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -11,17 +11,18 @@
 //
 //===--===//
 
-#include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/Action.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/Utils.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
 using namespace clang;
 using namespace llvm::opt;
 
@@ -102,5 +103,8 @@
  CCArgs.size(),
  *Diags))
 return nullptr;
+  // Patch up the install dir, so we find the same standard library as the
+  // original compiler on MacOS.
+  CI->getHeaderSearchOpts().InstallDir = TheDriver.getInstalledDir();
   return CI;
 }
Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -327,6 +327,9 @@
 Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
   Input.release());
   }
+  // Patch up the install dir, so we find the same standard library as the
+  // original compiler on MacOS.
+  Invocation->getHeaderSearchOpts().InstallDir = Driver->getInstalledDir();
   return runInvocation(BinaryName, Compilation.get(), std::move(Invocation),
std::move(PCHContainerOps));
 }
Index: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
===
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
@@ -108,6 +108,13 @@
   /// etc.).
   std::string ResourceDir;
 
+  /// Compiler install dir as detected by the Driver.
+  /// This is typically the directory that contains the clang executable, i.e.
+  /// the 'bin/' subdir of a clang distribution.
+  /// Only used to add include dirs for libc++ on Darwin. Please avoid relying
+  /// on this field for other purposes.
+  std::string InstallDir;
+
   /// The directory used for the module cache.
   std::string ModuleCachePath;
 
Index: cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
===
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+

[PATCH] D54311: Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE346653: Add a test checking clang-tidy can find libc++ on 
Mac (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54311?vs=173659&id=173664#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54311

Files:
  test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
  test/clang-tidy/clang-tidy-mac-libcxx.cpp


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- test/clang-tidy/clang-tidy-mac-libcxx.cpp
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers 
-checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 
'typedef'
+
+#include 
+typedef vector* vec_ptr;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;


Index: test/clang-tidy/clang-tidy-mac-libcxx.cpp
===
--- test/clang-tidy/clang-tidy-mac-libcxx.cpp
+++ test/clang-tidy/clang-tidy-mac-libcxx.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers -checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 'typedef'
+
+#include 
+typedef vector* vec_ptr;
Index: test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
+++ test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r346653 - Add a test checking clang-tidy can find libc++ on Mac

2018-11-12 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Nov 12 05:56:09 2018
New Revision: 346653

URL: http://llvm.org/viewvc/llvm-project?rev=346653&view=rev
Log:
Add a test checking clang-tidy can find libc++ on Mac

Reviewers: sammccall, arphaman, EricWF

Reviewed By: sammccall

Subscribers: christof, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/

clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp

Added: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c%2B%2B/v1/mock_vector?rev=346653&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
 Mon Nov 12 05:56:09 2018
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;

Added: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp?rev=346653&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp Mon Nov 
12 05:56:09 2018
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers 
-checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 
'typedef'
+
+#include 
+typedef vector* vec_ptr;


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


[PATCH] D54402: Extract method to allow re-use

2018-11-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I think this commit is fine without tests. The new method remains internal to 
the file but follow-up commits add public interface and tests.

I'll push the commits separately. I'll not be squashing them.


Repository:
  rC Clang

https://reviews.llvm.org/D54402



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


[PATCH] D52273: [clangd] Initial implementation of expected types

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

@ioeric, thanks for the review round!
Answering the most important comments, will shortly send changes to actually 
address the rest.




Comment at: clangd/ExpectedTypes.cpp:40
+
+llvm::Optional encodeType(ASTContext &Ctx, QualType T) {
+  assert(!T.isNull());

ioeric wrote:
> IIUC, we also encode the qualifiers into the final representation? If so, 
> have you considered the underlying type without qualifiers? It seems to me 
> this might be too restrictive for type-based boosting. For code completion 
> ranking, I think type qualifiers (`const` etc) can be separate signals.
This function's responsibility is to encode the type. There is code to strip 
the qualifiers from the types in `toEquivClass`.
The initial patch does not take qualifiers into account as none of the 
complicated conversion logic (qualifiers were taken into account there) the 
original patch had made much difference in the ranking measurements I made.
That said, this change does not aim to finalize the type encoding. I'll be 
looking into improving the type-based ranking after this lands, might re-add 
qualifiers if they turn out to be an improvement. Want to prove this with 
measurements, though.



Comment at: clangd/ExpectedTypes.h:10
+// A simplified model of C++ types that can be used to check whether they are
+// convertible between each other without looking at the ASTs.
+// Used for code completion ranking.

ioeric wrote:
> We might want to formalize what "convertible" means here. E.g. does it cover 
> conversion between base and derived class? Does it cover double <-> int 
> conversion?
I want to leave it vague for now. Convertible means whatever we think is good 
for code completion ranking.
Formalizing means we'll either dig into the C++ encoding or be imprecise. 

Happy to add the docs, but they'll probably get outdated on every change. 
Reading the code is actually simpler to get what's going on at this point.



Comment at: clangd/ExpectedTypes.h:37
+  fromCompletionResult(ASTContext &Ctx, const CodeCompletionResult &R);
+  static llvm::Optional fromPreferredType(ASTContext &Ctx,
+  QualType Type);

ioeric wrote:
> why "preferred type"? maybe add a comment?
That's the terminology that clang uses for completion's context type. Will add 
a comment, thanks!



Comment at: clangd/ExpectedTypes.h:40
+
+  /// Get the raw byte representation of the type. Bitwise equality of the raw
+  /// data is equivalent to equality operators of SType itself. The raw

ioeric wrote:
> What is the raw representation? A hash or the type name or USR?
A string representation of the usr, but users shouldn't rely on it.
The contract is: you can use it to compare for equality and nothing else, so 
the comment is actually accurate :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D54404: Exclude matchers which can have multiple results

2018-11-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I acknowledge and share the future-proofing concern.

We could possibly use something trait-based instead and put the trait beside 
the matcher definition in ASTMatchers.h, but that doesn't really solve the 
problem. It only moves the problem.


Repository:
  rC Clang

https://reviews.llvm.org/D54404



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


[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Background.h:39
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;
+};

sammccall wrote:
> kadircet wrote:
> > sammccall wrote:
> > > Why not use the constructor? what does "directory" mean in the general 
> > > case?
> > Directory refers to the one specified in CompilationDatabase(which is 
> > usually the build directory?), sorry for the inconvenience.
> > I wasn't sure about where we plan to instantiate BackgroundIndex. If you 
> > plan to do that initialization at a point in which we already know the 
> > build directory we can move that to constructor, especially only to the 
> > constructor of DiskBackedIndexStorage.
> tooling::CompileCommand::WorkingDirectory? That doesn't seem especially 
> relevant here.
> Or the directory that the CDB was discovered in?
> 
> Yes, this seems to be only relevant to DiskBackedIndexStorage
I suppose you meant `tooling::CompileCommand::Directory` rather than 
`WorkingDirectory` ? That is the one I was talking about, why do you think it 
is irrelevant ?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269



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


Re: r346491 - [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with /fallback

2018-11-12 Thread 生田拓人
Hmm, I see. Then I think /Zc:dllexportInlines- and /fallback should
not be used  at the same time.
https://reviews.llvm.org/D54426

Or will you remove /fallback?
2018年11月12日(月) 19:59 Nico Weber :
>
> On Mon, Nov 12, 2018 at 4:58 AM Hans Wennborg  wrote:
>>
>> Hmm, maybe I misunderstood your initial request for this.
>>
>> The current implementation does what the warnings says: If the
>> compiler falls back to cl.exe, /Zc:dllexportInlines- will be ignored.
>> This suggests to the user that it's a bad idea, but they can go ahead
>> if they want to.
>>
>> It sounds like you're suggesting we should always ignore
>> /Zc:dllexportInlines- when used together with the /fallback flag?
>
>
> I thought we'd always emit an error if both flags are present, actually, 
> something like "/dllexportInlines- is ABI-changing and not compatible with 
> /fallback". If you still need /fallback, you can't really use 
> /dllexportInlines-.
>
>>
>> I'm
>> not sure that's necessarily better.. it depends on why they're using
>> /fallback I guess. If it's because the user has one file that clang-cl
>> can't handle for some reason, but they still want
>> /Zc:dllexportInlines- for the rest, then ignoring it would break that.
>>
>> In general, I'm not sure how widely used /fallback is anymore. I
>> wonder if it would be possible to remove it...
>>
>> On Fri, Nov 9, 2018 at 9:52 PM, Nico Weber  wrote:
>> > Ah cool. But the diagnostic is "option /dllexportInlines- is ignored when
>> > /fallback happens" – shouldn't it be ignored regardless of if fallback
>> > happens? Does that happen and the warning text is wrong?
>> >
>> > On Fri, Nov 9, 2018 at 11:20 AM Hans Wennborg  wrote:
>> >>
>> >> On Fri, Nov 9, 2018 at 4:53 PM, Nico Weber  wrote:
>> >> > This only prints the warning when /fallback actually happens, right?
>> >>
>> >> No, it prints it when the fallback job is created, not when (or if) it
>> >> runs. I.e. it prints if the /fallback flag is used, regardless of
>> >> whether it actually falls back or not. This is reflected by the test
>> >> which uses -###, i.e. nothing is getting run.
>> >>
>> >> So I think we're good :-)
>> >>
>> >> > I don't
>> >> > think that's good enough: If we build a few TUs with /dllexportInlines-
>> >> > and
>> >> > don't fall back, those .obj files are not abi compatible with the
>> >> > cl-built
>> >> > ones. (Consider all dllexport TUs of a header being built with clang-cl
>> >> > but
>> >> > all dllimport versions of the same header being built by cl – I think
>> >> > this
>> >> > will cause link errors). SO I think we should error out if
>> >> > /dllexportIlnlines- /fallback is on the same line, even if the fallback
>> >> > doesn't actually happen.
>> >> >
>> >> > On Fri, Nov 9, 2018 at 8:28 AM Takuto Ikuta via cfe-commits
>> >> >  wrote:
>> >> >>
>> >> >> Author: tikuta
>> >> >> Date: Fri Nov  9 05:25:45 2018
>> >> >> New Revision: 346491
>> >> >>
>> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=346491&view=rev
>> >> >> Log:
>> >> >> [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used
>> >> >> with /fallback
>> >> >>
>> >> >> Summary:
>> >> >> This is followup of
>> >> >> https://reviews.llvm.org/D51340
>> >> >>
>> >> >> Reviewers: hans, thakis
>> >> >>
>> >> >> Reviewed By: hans
>> >> >>
>> >> >> Subscribers: cfe-commits, llvm-commits
>> >> >>
>> >> >> Differential Revision: https://reviews.llvm.org/D54298
>> >> >>
>> >> >> Modified:
>> >> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> >> cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> >> >> cfe/trunk/test/Driver/cl-options.c
>> >> >>
>> >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> >> URL:
>> >> >>
>> >> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=346491&r1=346490&r2=346491&view=diff
>> >> >>
>> >> >>
>> >> >> ==
>> >> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> >> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Nov  9
>> >> >> 05:25:45 2018
>> >> >> @@ -161,6 +161,10 @@ def warn_drv_yc_multiple_inputs_clang_cl
>> >> >>"support for '/Yc' with more than one source file not implemented
>> >> >> yet;
>> >> >> flag ignored">,
>> >> >>InGroup;
>> >> >>
>> >> >> +def warn_drv_non_fallback_argument_clang_cl : Warning<
>> >> >> +  "option '%0' is ignored when /fallback happens">,
>> >> >> +  InGroup;
>> >> >> +
>> >> >>  def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
>> >> >>  def err_drv_invalid_int_value : Error<"invalid integral value '%1' in
>> >> >> '%0'">;
>> >> >>  def err_drv_invalid_remap_file : Error<
>> >> >>
>> >> >> Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> >> >> URL:
>> >> >>
>> >> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=346491&r1=346490&r2=346491&view=diff
>> >> >>
>> >> >>
>> >> >> ===

[PATCH] D54426: [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

2018-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:164
 
-def warn_drv_non_fallback_argument_clang_cl : Warning<
-  "option '%0' is ignored when /fallback happens">,
-  InGroup;
+def err_drv_both_fallback_and_dllexport_inlines_cannot_be_used_clang_cl : 
Error<
+  "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with 
'/fallback'">;

Let's make the name shorter. I think "err_drv_dllexport_inlines_and_fallback" 
or something is descriptive enough.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5529
+  false)) {
+   Arg *dllexportInlines = 
Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_);
+   if (Args.hasArg(options::OPT__SLASH_fallback) && dllexportInlines) {

We know there must be a OPT__SLASH_Zc_dllexportInlines_ flag at this point 
(because it's checked in the if above), so I think think you need "&& 
dllexportInlines" below.

In the previous version, you output the getAsString() of the arg to the 
diagnostic. Don't you want to do this still?


Repository:
  rL LLVM

https://reviews.llvm.org/D54426



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


[PATCH] D54414: [Sema] Make sure we substitute an instantiation-dependent default template parameter

2018-11-12 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete accepted this revision.
Rakete added a comment.
This revision is now accepted and ready to land.

LGTM, thanks :)




Comment at: clang/test/SemaCXX/alias-template.cpp:188
+template >
+int sfinae_me() { return 0; } // expected-note{{candidate template ignored: 
substitution failure}}
+

Very nit: The whole file has a space between the expected string and {{.


Repository:
  rC Clang

https://reviews.llvm.org/D54414



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


r346659 - Revert rL346644, rL346642: the added test test/CodeGen/code-coverage-filter.c is failing under windows

2018-11-12 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Mon Nov 12 06:57:17 2018
New Revision: 346659

URL: http://llvm.org/viewvc/llvm-project?rev=346659&view=rev
Log:
Revert rL346644, rL346642: the added test test/CodeGen/code-coverage-filter.c 
is failing under windows

Removed:
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter1.h
cfe/trunk/test/CodeGen/Inputs/code-coverage-filter2.h
cfe/trunk/test/CodeGen/code-coverage-filter.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=346659&r1=346658&r2=346659&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Nov 12 06:57:17 2018
@@ -64,12 +64,6 @@ Non-comprehensive list of changes in thi
 New Compiler Flags
 --
 
-- ``-fprofile-filter-files=[regexes]`` and 
``-fprofile-exclude-files=[regexes]``.
-
-  Clang has now options to filter or exclude some files when
-  instrumenting for gcov-based profiling.
-  See the :doc:`UsersManual` for details.
-
 - ...
 
 Deprecated Compiler Flags

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346659&r1=346658&r2=346659&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Nov 12 06:57:17 2018
@@ -1871,55 +1871,6 @@ using the ``llvm-cxxmap`` and ``llvm-pro
   following the Itanium C++ ABI mangling scheme. This covers all C++ targets
   supported by Clang other than Windows.
 
-GCOV-based Profiling
-
-
-GCOV is a test coverage program, it helps to know how often a line of code
-is executed. When instrumenting the code with ``--coverage`` option, some
-counters are added for each edge linking basic blocks.
-
-At compile time, gcno files are generated containing information about
-blocks and edges between them. At runtime the counters are incremented and at
-exit the counters are dumped in gcda files.
-
-The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate
-a report ``.c.gcov``.
-
-.. option:: -fprofile-filter-files=[regexes]
-
-  Define a list of regexes separated by a semi-colon.
-  If a file name matches any of the regexes then the file is instrumented.
-
-   .. code-block:: console
-
- $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c
-
-  For example, this will only instrument files finishing with ``.c``, skipping 
``.h`` files.
-
-.. option:: -fprofile-exclude-files=[regexes]
-
-  Define a list of regexes separated by a semi-colon.
-  If a file name doesn't match all the regexes then the file is instrumented.
-
-  .. code-block:: console
-
- $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c
-
-  For example, this will instrument all the files except the ones in 
``/usr/include``.
-
-If both options are used then a file is instrumented if its name matches any
-of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes
-from ``-fprofile-exclude-list``.
-
-.. code-block:: console
-
-   $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \
-   -fprofile-filter-files="^/usr/.*$"
-  
-In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter 
regex and
-doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it 
matches
-the exclude regex.
-
 Controlling Debug Information
 -
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=346659&r1=346658&r2=346659&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Nov 12 06:57:17 2018
@@ -768,12 +768,6 @@ def fno_profile_instr_use : Flag<["-"],
 HelpText<"Disable using instrumentation data for profile-guided 
optimization">;
 def fno_profile_use : Flag<["-"], "fno-profile-use">,
 Alias;
-def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
-Group, Flags<[CC1Option, CoreOption]>,
-HelpText<"Instrument only functions from files where names match any regex 
separated by a semi-colon">;
-def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
-Group, Flags<[CC1Option, CoreOption]>,
-HelpText<"Instrument only functions from files where names don't match all 
the regexes separated by a semi-colon">;
 
 def faddrsig : Flag<["-"],

[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

2018-11-12 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D41005



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


[PATCH] D54426: [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

2018-11-12 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 173670.
takuto.ikuta added a comment.

short diag


Repository:
  rL LLVM

https://reviews.llvm.org/D54426

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -495,7 +495,7 @@
 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck 
-check-prefix=DllExportInlines %s
 // DllExportInlines-NOT: "-fno-dllexport-inlines"
 // RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | 
FileCheck -check-prefix=DllExportInlinesFallback %s
-// DllExportInlinesFallback: warning: option '/Zc:dllexportInlines-' is 
ignored when /fallback happens [-Woption-ignored]
+// DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is 
ABI-changing and not compatible with '/fallback'
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -669,12 +669,6 @@
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
 
-  // Warning for ignored flag.
-  if (const Arg *dllexportInlines =
-  Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
-C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
-  << dllexportInlines->getAsString(Args);
-
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5525,8 +5525,13 @@
 
  if (Args.hasFlag(options::OPT__SLASH_Zc_dllexportInlines_,
   options::OPT__SLASH_Zc_dllexportInlines,
-  false))
+  false)) {
+   if (Args.hasArg(options::OPT__SLASH_fallback)) {
+ D.Diag(clang::diag::err_drv_dllexport_inlines_and_fallback);
+   } else {
 CmdArgs.push_back("-fno-dllexport-inlines");
+   }
+ }
 
   Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
   Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -161,9 +161,8 @@
   "support for '/Yc' with more than one source file not implemented yet; flag 
ignored">,
   InGroup;
 
-def warn_drv_non_fallback_argument_clang_cl : Warning<
-  "option '%0' is ignored when /fallback happens">,
-  InGroup;
+def err_drv_dllexport_inlines_and_fallback : Error<
+  "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with 
'/fallback'">;
 
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -495,7 +495,7 @@
 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
 // DllExportInlines-NOT: "-fno-dllexport-inlines"
 // RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlinesFallback %s
-// DllExportInlinesFallback: warning: option '/Zc:dllexportInlines-' is ignored when /fallback happens [-Woption-ignored]
+// DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -669,12 +669,6 @@
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
 
-  // Warning for ignored flag.
-  if (const Arg *dllexportInlines =
-  Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
-C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
-  << dllexportInlines->getAsString(Args);
-
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5525,8 +5525,13 @@
 
  if (Args.hasFlag(options::OPT__SLASH_Zc_dlle

[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-11-12 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM! Let's continue the conversation about coding standards somewhere else.

Can you please mark inlines as done?


https://reviews.llvm.org/D52984



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


[PATCH] D54426: [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

2018-11-12 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta marked 2 inline comments as done.
takuto.ikuta added a comment.

Thank you for review!




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5529
+  false)) {
+   Arg *dllexportInlines = 
Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_);
+   if (Args.hasArg(options::OPT__SLASH_fallback) && dllexportInlines) {

hans wrote:
> We know there must be a OPT__SLASH_Zc_dllexportInlines_ flag at this point 
> (because it's checked in the if above), so I think think you need "&& 
> dllexportInlines" below.
> 
> In the previous version, you output the getAsString() of the arg to the 
> diagnostic. Don't you want to do this still?
Ah, I don't need to call getAsString() anymore.


Repository:
  rL LLVM

https://reviews.llvm.org/D54426



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


[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

2018-11-12 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Thanks for taking a look! ^-^




Comment at: lib/StaticAnalyzer/Core/CheckerRegistry.cpp:51
 
-/// Collects the checkers for the supplied \p opt option into \p collected.
-static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers,
-const llvm::StringMap &packageSizes,
-CheckerOptInfo &opt, CheckerInfoSet &collected) {
-  // Use a binary search to find the possible start of the package.
-  CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
-  auto end = checkers.cend();
-  auto i = std::lower_bound(checkers.cbegin(), end, packageInfo, 
checkerNameLT);
-
-  // If we didn't even find a possible package, give up.
-  if (i == end)
-return;
-
-  // If what we found doesn't actually start the package, give up.
-  if (!isInPackage(*i, opt.getName()))
-return;
-
-  // There is at least one checker in the package; claim the option.
-  opt.claim();
-
-  // See how large the package is.
-  // If the package doesn't exist, assume the option refers to a single 
checker.
-  size_t size = 1;
-  llvm::StringMap::const_iterator packageSize =
-packageSizes.find(opt.getName());
-  if (packageSize != packageSizes.end())
-size = packageSize->getValue();
-
-  // Step through all the checkers in the package.
-  for (auto checkEnd = i+size; i != checkEnd; ++i)
-if (opt.isEnabled())
-  collected.insert(&*i);
-else
-  collected.remove(&*i);
+static CheckerInfoSet getEnabledCheckers(
+const CheckerRegistry::CheckerInfoList &checkers,

MTC wrote:
> I just curious about the reason why you move the `CheckerInfoSet` from the 
> parameter passing by reference to the return value, keep the number of 
> parameter at a lower value? Or make the code at the caller cite cleaner?
Both, actually. From what I've seen, out-params usually lead to much harder to 
comprehend code.


https://reviews.llvm.org/D54401



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


[PATCH] D54426: [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag

2018-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D54426



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


[PATCH] D54427: [clangd] Allow symbols from AnyScope in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.

We should allow symbols from any scope in dexp results, othewise
`find StringRef` doesn't return any results (llvm::StringRef).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54427

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -52,6 +52,7 @@
 std::vector getSymbolIDsFromIndex(StringRef QualifiedName,
 const SymbolIndex *Index) {
   FuzzyFindRequest Request;
+  Request.AnyScope = true;
   // Remove leading "::" qualifier as FuzzyFind doesn't need leading "::"
   // qualifier for global scope.
   bool IsGlobalScope = QualifiedName.consume_front("::");
@@ -134,6 +135,7 @@
 FuzzyFindRequest Request;
 Request.Limit = Limit;
 Request.Query = Query;
+Request.AnyScope = true;
 if (Scopes.getNumOccurrences() > 0) {
   SmallVector Scopes;
   StringRef(this->Scopes).split(Scopes, ',');


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -52,6 +52,7 @@
 std::vector getSymbolIDsFromIndex(StringRef QualifiedName,
 const SymbolIndex *Index) {
   FuzzyFindRequest Request;
+  Request.AnyScope = true;
   // Remove leading "::" qualifier as FuzzyFind doesn't need leading "::"
   // qualifier for global scope.
   bool IsGlobalScope = QualifiedName.consume_front("::");
@@ -134,6 +135,7 @@
 FuzzyFindRequest Request;
 Request.Limit = Limit;
 Request.Query = Query;
+Request.AnyScope = true;
 if (Scopes.getNumOccurrences() > 0) {
   SmallVector Scopes;
   StringRef(this->Scopes).split(Scopes, ',');
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54427: [clangd] Allow symbols from AnyScope in dexp.

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



Comment at: clangd/index/dex/dexp/Dexp.cpp:55
   FuzzyFindRequest Request;
+  Request.AnyScope = true;
   // Remove leading "::" qualifier as FuzzyFind doesn't need leading "::"

I don't think you would want AnyScope here. For example, if `QualifiedName` is 
std::string, you can also get `llvm::StringRef` in the results.



Comment at: clangd/index/dex/dexp/Dexp.cpp:138
 Request.Query = Query;
+Request.AnyScope = true;
 if (Scopes.getNumOccurrences() > 0) {

I think what you actually want is `Request.AnyScope = Scopes.empty()`? It 
doesn't seem useful to set AnyScope when scopes are provided.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54427



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


[PATCH] D54428: [clangd] XPC transport layer, framework, test-client

2018-11-12 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: arphaman, sammccall.
Herald added subscribers: cfe-commits, kadircet, dexonsmith, MaskRay, ioeric, 
ilya-biryukov, mgorny.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54428

Files:
  CMakeLists.txt
  Features.inc.in
  clangd/CMakeLists.txt
  clangd/xpc/CMakeLists.txt
  clangd/xpc/ConversionTests.cpp
  clangd/xpc/initialize.test
  lit.cfg
  lit.site.cfg.in
  tool/CMakeLists.txt
  tool/ClangdMain.cpp
  xpc/CMakeLists.txt
  xpc/Conversion.cpp
  xpc/Conversion.h
  xpc/README.txt
  xpc/XPCTransport.cpp
  xpc/XPCTransport.h
  xpc/cmake/Info.plist.in
  xpc/cmake/XPCServiceInfo.plist.in
  xpc/cmake/modules/CreateClangdXPCFramework.cmake
  xpc/framework/CMakeLists.txt
  xpc/framework/ClangdXPC.cpp
  xpc/test-client/CMakeLists.txt
  xpc/test-client/ClangdXPCTestClient.cpp

Index: clangd/xpc/ConversionTests.cpp
===
--- /dev/null
+++ clangd/xpc/ConversionTests.cpp
@@ -0,0 +1,36 @@
+//===-- ConversionTests.cpp  --*- C++ -*---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "xpc/Conversion.h"
+#include "gtest/gtest.h"
+
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using namespace llvm;
+
+TEST(JsonXpcConversionTest, JsonToXpcToJson) {
+
+  for (auto &testcase :
+   {json::Value(false), json::Value(3.14), json::Value(42),
+json::Value(-100), json::Value("foo"), json::Value(""),
+json::Value("123"), json::Value(" "),
+json::Value{true, "foo", nullptr, 42},
+json::Value(json::Object{
+{"a", true}, {"b", "foo"}, {"c", nullptr}, {"d", 42}})}) {
+EXPECT_TRUE(testcase == xpcToJson(jsonToXpc(testcase))) << testcase;
+  }
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clangd/xpc/CMakeLists.txt
===
--- /dev/null
+++ clangd/xpc/CMakeLists.txt
@@ -0,0 +1,21 @@
+set(LLVM_LINK_COMPONENTS
+  support
+  )
+
+get_filename_component(CLANGD_SOURCE_DIR
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
+include_directories(
+  ${CLANGD_SOURCE_DIR}
+  )
+
+add_extra_unittest(ClangdXpcTests
+  ConversionTests.cpp
+  )
+
+target_link_libraries(ClangdXpcTests
+  PRIVATE
+  clangdXpcJsonConversions
+  clangDaemon
+  LLVMSupport
+  LLVMTestingSupport
+  )
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -60,3 +60,7 @@
   LLVMSupport
   LLVMTestingSupport
   )
+
+if (CLANGD_BUILD_XPC)
+  add_subdirectory(xpc)
+endif ()
Index: lit.site.cfg.in
===
--- lit.site.cfg.in
+++ lit.site.cfg.in
@@ -11,6 +11,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clangd_xpc_support = @CLANGD_BUILD_XPC_SUPPORT@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -117,6 +117,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('ansi-escape-sequences')
 
+# XPC support for Clangd.
+if config.clangd_xpc_support:
+config.available_features.add('clangd-xpc-support')
+
 if config.clang_staticanalyzer:
 config.available_features.add('static-analyzer')
 
Index: clangd/xpc/initialize.test
===
--- /dev/null
+++ clangd/xpc/initialize.test
@@ -0,0 +1,10 @@
+# RUN: clangd-xpc-test-client < %s | FileCheck %s
+# REQUIRES: clangd-xpc-support
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"test:///workspace","capabilities":{},"trace":"off"}}
+# CHECK: {"id":0,"jsonrpc":"2.0","result":{"capabilities"
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"id":3,"jsonrpc":"2.0","result":null}
+
+{"jsonrpc":"2.0","method":"exit"}
Index: xpc/test-client/ClangdXPCTestClient.cpp
===
--- /dev/null
+++ xpc/test-client/ClangdXPCTestClient.cpp
@@ -0,0 +1,96 @@
+#include "xpc/Conversion.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
+
+typedef const char *(*clangd_xpc_get_bundle_identifier_t)(void);
+
+using namespace llvm;
+

[PATCH] D54407: Record the matcher type when storing a binding

2018-11-12 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added a comment.

In https://reviews.llvm.org/D54407#1294934, @aaron.ballman wrote:

> Adding @sbenza in case he has opinions on this approach. I think it's 
> reasonable, but I also know that changes to the the AST matcher internals 
> sometimes have unintended side effects with the various instantiations.


The problem used to come with the number of template instantiations, but afaik 
this was with an MSVC configuration that is no longer supported.
In any case, I don't see this change making new template instantiations.

I also don't see any actual use of this newly stored data so I don't see the 
goal. Is this for diagnostics on failures or something like that?


Repository:
  rC Clang

https://reviews.llvm.org/D54407



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


[PATCH] D54427: [clangd] Allow symbols from AnyScope in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 173676.
hokein marked 2 inline comments as done.
hokein added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54427

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -139,6 +139,7 @@
   StringRef(this->Scopes).split(Scopes, ',');
   Request.Scopes = {Scopes.begin(), Scopes.end()};
 }
+Request.AnyScope = Request.Scopes.empty();
 // FIXME(kbobyrev): Print symbol final scores to see the distribution.
 static const auto OutputFormat = "{0,-4} | {1,-40} | {2,-25}\n";
 outs() << formatv(OutputFormat, "Rank", "Symbol ID", "Symbol Name");


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -139,6 +139,7 @@
   StringRef(this->Scopes).split(Scopes, ',');
   Request.Scopes = {Scopes.begin(), Scopes.end()};
 }
+Request.AnyScope = Request.Scopes.empty();
 // FIXME(kbobyrev): Print symbol final scores to see the distribution.
 static const auto OutputFormat = "{0,-4} | {1,-40} | {2,-25}\n";
 outs() << formatv(OutputFormat, "Rank", "Symbol ID", "Symbol Name");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54427: [clangd] Allow symbols from AnyScope in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:55
   FuzzyFindRequest Request;
+  Request.AnyScope = true;
   // Remove leading "::" qualifier as FuzzyFind doesn't need leading "::"

ioeric wrote:
> I don't think you would want AnyScope here. For example, if `QualifiedName` 
> is std::string, you can also get `llvm::StringRef` in the results.
Yeah, the input is required qualified name, I misthought that we can use 
unqualified name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54427



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


[clang-tools-extra] r346665 - [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-12 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Nov 12 08:01:39 2018
New Revision: 346665

URL: http://llvm.org/viewvc/llvm-project?rev=346665&view=rev
Log:
[clang-tidy] new check: bugprone-too-small-loop-variable

The new checker searches for those for loops which has a loop variable with a 
"too small" type which means this type can't represent all values which are 
part of the iteration range.

For example:

```
int main() {
  long size = 30;
  for( short int i = 0; i < size; ++i) {}
}
```

The short type leads to infinite loop here because it can't store all values in 
the `[0..size]` interval. In a real use case, size means a container's size 
which depends on the user input. Which means for small amount of objects the 
algorithm works, but with a larger user input the software will freeze.

The idea of the checker comes from the LibreOffice project, where the same 
check was implemented as a clang compiler plugin, called `LoopVarTooSmall` 
(LLVM licensed).
The idea is the same behind this check, but the code is different because of 
the different framework.

Patch by ztamas.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth, xazax.hun, whisperity

Reviewed By: JonasToth, whisperity

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=346665&r1=346664&r2=346665&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Mon Nov 
12 08:01:39 2018
@@ -44,6 +44,7 @@
 #include "SwappedArgumentsCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
+#include "TooSmallLoopVariableCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnusedRaiiCheck.h"
@@ -96,6 +97,8 @@ public:
 "bugprone-move-forwarding-reference");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
+CheckFactories.registerCheck(
+"bugprone-too-small-loop-variable");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=346665&r1=346664&r2=346665&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Mon Nov 12 
08:01:39 2018
@@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModul
   SwappedArgumentsCheck.cpp
   TerminatingContinueCheck.cpp
   ThrowKeywordMissingCheck.cpp
+  TooSmallLoopVariableCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnusedRaiiCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp?rev=346665&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp 
Mon Nov 12 08:01:39 2018
@@ -0,0 +1,168 @@
+//===--- TooSmallLoopVariableCheck.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 "TooSmallLoopVariableCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+static constexpr llvm::StringLiteral LoopName =
+llvm::StringLiteral("forLoopName");
+static constexpr llvm::StringLiteral LoopVarName =
+llvm::StringLiteral("loopVar");
+static constexpr llvm::StringLite

[PATCH] D54407: Record the matcher type when storing a binding

2018-11-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In https://reviews.llvm.org/D54407#129, @sbenza wrote:

> In https://reviews.llvm.org/D54407#1294934, @aaron.ballman wrote:
>
> > Adding @sbenza in case he has opinions on this approach. I think it's 
> > reasonable, but I also know that changes to the the AST matcher internals 
> > sometimes have unintended side effects with the various instantiations.
>
>
> The problem used to come with the number of template instantiations, but 
> afaik this was with an MSVC configuration that is no longer supported.
>  In any case, I don't see this change making new template instantiations.
>
> I also don't see any actual use of this newly stored data so I don't see the 
> goal. Is this for diagnostics on failures or something like that?


This commit is part of a series. You can see the use of this in the next 
commit: https://reviews.llvm.org/D54408


Repository:
  rC Clang

https://reviews.llvm.org/D54407



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


[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-12 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346665: [clang-tidy] new check: 
bugprone-too-small-loop-variable (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53974

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp

Index: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -44,6 +44,7 @@
 #include "SwappedArgumentsCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
+#include "TooSmallLoopVariableCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnusedRaiiCheck.h"
@@ -96,6 +97,8 @@
 "bugprone-move-forwarding-reference");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
+CheckFactories.registerCheck(
+"bugprone-too-small-loop-variable");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.h
+++ clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.h
@@ -0,0 +1,43 @@
+//===--- TooSmallLoopVariableCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_TOOSMALLLOOPVARIABLECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_TOOSMALLLOOPVARIABLECHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// This check gives a warning if a loop variable has a too small type which
+/// might not be able to represent all values which are part of the whole range
+/// in which the loop iterates.
+/// If the loop variable's type is too small we might end up in an infinite
+/// loop. Example:
+/// \code
+///   long size = 294967296l;
+///   for (short i = 0; i < size; ++i) {} { ... }
+/// \endcode
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-too-small-loop-variable.html
+class TooSmallLoopVariableCheck : public ClangTidyCheck {
+public:
+  TooSmallLoopVariableCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_TOOSMALLLOOPVARIABLECHECK_H
Index: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
@@ -35,6 +35,7 @@
   SwappedArgumentsCheck.cpp
   TerminatingContinueCheck.cpp
   ThrowKeywordMissingCheck.cpp
+  TooSmallLoopVariableCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnusedRaiiCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
@@ -0,0 +1,168 @@
+//===--- TooSmallLoopVariableCheck.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 "TooSmallLoopVariableCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/AST

[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Committed r346665.

Thank you very much for the patch!


Repository:
  rL LLVM

https://reviews.llvm.org/D53974



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


[PATCH] D54429: Creating standard shpinx documentation for Clang Static Analyzer

2018-11-12 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp created this revision.
dkrupp added reviewers: Szelethus, NoQ, george.karpenkov.
dkrupp added a project: clang.
Herald added subscribers: cfe-commits, donat.nagy, jfb, arphaman, a.sidorin, 
rnkovacs, baloghadamsoftware, whisperity.

Standard Clang tools (ThreadSanitizer, MemorySanitizer, DataFlowSanitizer etc.)
all have documentation delivered with Clang and build using Sphinx tool.
Would be great to have the ClangSA docs there too in sphinx markup.

I wonder what you guys think about this approach?

  

In this patch the analyzer's documentation main and checker pages are
transformed into Sphinx rst to be part of the standard clang documentation 
tree: https://clang.llvm.org/docs/

The generated new documentation would look like this:
http://cc.elte.hu/clang-docs/docs/html/ClangStaticAnalyzer.html

 

Advantages:

  

- The documentation is easier to be maintained in Sphinx markup compared to raw 
HTML
- The documentation is easier found in the standard clang doc tree
- The generated documentation looks nicer ;)

In detail this patch contains the following contributions:

  

- Transformation of the main page https://clang-analyzer.llvm.org/ to 
http://cc.elte.hu/clang-docs/docs/html/ClangStaticAnalyzer.html
- Transformation of the https://clang-analyzer.llvm.org/available_checks.html 
and https://clang-analyzer.llvm.org/alpha_checks.html pages to 
http://cc.elte.hu/clang-docs/docs/html/analyzer/checkers.html
- Per checker page added for alpha.cplusplus.UninitializedObject checker. Would 
be great to create similar doc for all checkers in the long term. See 
http://cc.elte.hu/clang-docs/docs/html/analyzer/checkers/UninitializedObject.html
- Design discussion documents were renamed and formatted to rst and linked from 
the Development/Design Discussions section.

If you agree with the direction I can transform the rest of the 
https://clang-analyzer.llvm.org/ documentation into rst. But most importantly 
we would like to have a per checker one pager doc like the one in 
http://cc.elte.hu/clang-docs/docs/html/analyzer/checkers/UninitializedObject.html

RST seemed to be a better format than plain HTML. Then we could make mandatory 
for checker author to write such one pagers to their checkers similar to 
clang-tidy...


Repository:
  rC Clang

https://reviews.llvm.org/D54429

Files:
  docs/ClangStaticAnalyzer.rst
  docs/analyzer/DesignDiscussions/IPA.rst
  docs/analyzer/DesignDiscussions/InitializerLists.rst
  docs/analyzer/DesignDiscussions/RegionStore.rst
  docs/analyzer/DesignDiscussions/nullability.rst
  docs/analyzer/IPA.txt
  docs/analyzer/RegionStore.txt
  docs/analyzer/checkers.rst
  docs/analyzer/checkers/UninitializedObject.rst
  docs/analyzer/nullability.rst
  docs/conf.py
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -23,6 +23,7 @@
AttributeReference
DiagnosticsReference
CrossCompilation
+   ClangStaticAnalyzer
ThreadSafetyAnalysis
AddressSanitizer
ThreadSanitizer
Index: docs/conf.py
===
--- docs/conf.py
+++ docs/conf.py
@@ -65,7 +65,7 @@
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['_build', 'analyzer']
+exclude_patterns = ['_build']
 
 # The reST default role (used for this markup: `text`) to use for all documents.
 #default_role = None
Index: docs/analyzer/nullability.rst
===
--- docs/analyzer/nullability.rst
+++ /dev/null
@@ -1,92 +0,0 @@
-
-Nullability Checks
-
-
-This document is a high level description of the nullablility checks.
-These checks intended to use the annotations that is described in this
-RFC: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-March/041798.html.
-
-Let's consider the following 2 categories:
-
-1) nullable
-
-
-If a pointer 'p' has a nullable annotation and no explicit null check or assert, we should warn in the following cases:
-- 'p' gets implicitly converted into nonnull pointer, for example, we are passing it to a function that takes a nonnull parameter.
-- 'p' gets dereferenced
-
-Taking a branch on nullable pointers are the same like taking branch on null unspecified pointers.
-
-Explicit cast from nullable to nonnul::
-
-__nullable id foo;
-id bar = foo;
-takesNonNull((_nonnull) bar); <— should not warn here (backward compatibility hack)
-anotherTakesNonNull(bar); <— would be great to warn here, but not necessary(*)
-
-Because bar corresponds to the same symbol all the time it is not easy to implement the checker that way the cast only suppress the first call but not the second. For this reason in the first implementation after a contradictory cast happens, I will treat bar as nullable unspecified, this way all of the warnings w

[clang-tools-extra] r346666 - [clangd] Allow symbols from AnyScope in dexp.

2018-11-12 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Nov 12 08:03:59 2018
New Revision: 34

URL: http://llvm.org/viewvc/llvm-project?rev=34&view=rev
Log:
[clangd] Allow symbols from AnyScope in dexp.

Summary:
We should allow symbols from any scope in dexp results, othewise
`find StringRef` doesn't return any results (llvm::StringRef).

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=34&r1=346665&r2=34&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Mon Nov 12 08:03:59 
2018
@@ -139,6 +139,7 @@ class FuzzyFind : public Command {
   StringRef(this->Scopes).split(Scopes, ',');
   Request.Scopes = {Scopes.begin(), Scopes.end()};
 }
+Request.AnyScope = Request.Scopes.empty();
 // FIXME(kbobyrev): Print symbol final scores to see the distribution.
 static const auto OutputFormat = "{0,-4} | {1,-40} | {2,-25}\n";
 outs() << formatv(OutputFormat, "Rank", "Symbol ID", "Symbol Name");


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


[PATCH] D54427: [clangd] Allow symbols from AnyScope in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL34: [clangd] Allow symbols from AnyScope in dexp. 
(authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54427

Files:
  clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
@@ -139,6 +139,7 @@
   StringRef(this->Scopes).split(Scopes, ',');
   Request.Scopes = {Scopes.begin(), Scopes.end()};
 }
+Request.AnyScope = Request.Scopes.empty();
 // FIXME(kbobyrev): Print symbol final scores to see the distribution.
 static const auto OutputFormat = "{0,-4} | {1,-40} | {2,-25}\n";
 outs() << formatv(OutputFormat, "Rank", "Symbol ID", "Symbol Name");


Index: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
@@ -139,6 +139,7 @@
   StringRef(this->Scopes).split(Scopes, ',');
   Request.Scopes = {Scopes.begin(), Scopes.end()};
 }
+Request.AnyScope = Request.Scopes.empty();
 // FIXME(kbobyrev): Print symbol final scores to see the distribution.
 static const auto OutputFormat = "{0,-4} | {1,-40} | {2,-25}\n";
 outs() << formatv(OutputFormat, "Rank", "Symbol ID", "Symbol Name");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54429: Creating standard shpinx documentation for Clang Static Analyzer

2018-11-12 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a subscriber: xazax.hun.
Szelethus added a comment.

I'll read through this as soon as possible, but a HUGE thank you for this. This 
is what the Static Analyzer desperately needed for years. This will trivialize 
documenting, so conversations about the inner workings of the analyzer will not 
be buried in many year old closed revisions.

@xazax.hun maybe your patch should be implemented with Sphinx too?

Please reupload with full context (`-U9`).


Repository:
  rC Clang

https://reviews.llvm.org/D54429



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


[PATCH] D54429: [analyzer] Creating standard shpinx documentation

2018-11-12 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp updated this revision to Diff 173679.
dkrupp added a comment.

making the diff full context.


Repository:
  rC Clang

https://reviews.llvm.org/D54429

Files:
  docs/ClangStaticAnalyzer.rst
  docs/analyzer/DesignDiscussions/IPA.rst
  docs/analyzer/DesignDiscussions/InitializerLists.rst
  docs/analyzer/DesignDiscussions/RegionStore.rst
  docs/analyzer/DesignDiscussions/nullability.rst
  docs/analyzer/IPA.txt
  docs/analyzer/RegionStore.txt
  docs/analyzer/checkers.rst
  docs/analyzer/checkers/UninitializedObject.rst
  docs/analyzer/nullability.rst
  docs/conf.py
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -23,6 +23,7 @@
AttributeReference
DiagnosticsReference
CrossCompilation
+   ClangStaticAnalyzer
ThreadSafetyAnalysis
AddressSanitizer
ThreadSanitizer
Index: docs/conf.py
===
--- docs/conf.py
+++ docs/conf.py
@@ -65,7 +65,7 @@
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['_build', 'analyzer']
+exclude_patterns = ['_build']
 
 # The reST default role (used for this markup: `text`) to use for all documents.
 #default_role = None
Index: docs/analyzer/nullability.rst
===
--- docs/analyzer/nullability.rst
+++ /dev/null
@@ -1,92 +0,0 @@
-
-Nullability Checks
-
-
-This document is a high level description of the nullablility checks.
-These checks intended to use the annotations that is described in this
-RFC: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-March/041798.html.
-
-Let's consider the following 2 categories:
-
-1) nullable
-
-
-If a pointer 'p' has a nullable annotation and no explicit null check or assert, we should warn in the following cases:
-- 'p' gets implicitly converted into nonnull pointer, for example, we are passing it to a function that takes a nonnull parameter.
-- 'p' gets dereferenced
-
-Taking a branch on nullable pointers are the same like taking branch on null unspecified pointers.
-
-Explicit cast from nullable to nonnul::
-
-__nullable id foo;
-id bar = foo;
-takesNonNull((_nonnull) bar); <— should not warn here (backward compatibility hack)
-anotherTakesNonNull(bar); <— would be great to warn here, but not necessary(*)
-
-Because bar corresponds to the same symbol all the time it is not easy to implement the checker that way the cast only suppress the first call but not the second. For this reason in the first implementation after a contradictory cast happens, I will treat bar as nullable unspecified, this way all of the warnings will be suppressed. Treating the symbol as nullable unspecified also has an advantage that in case the takesNonNull function body is being inlined, the will be no warning, when the symbol is dereferenced. In case I have time after the initial version I might spend additional time to try to find a more sophisticated solution, in which we would produce the second warning (*).
- 
-2) nonnull
-
-
-- Dereferencing a nonnull, or sending message to it is ok.
-- Converting nonnull to nullable is Ok.
-- When there is an explicit cast from nonnull to nullable I will trust the cast (it is probable there for a reason, because this cast does not suppress any warnings or errors).
-- But what should we do about null checks?::
-
-__nonnull id takesNonnull(__nonnull id x) {
-if (x == nil) {
-// Defensive backward compatible code:
-
-return nil; <- Should the analyzer cover this piece of code? Should we require the cast (__nonnull)nil?
-}
-
-}
-
-There are these directions:
-- We can either take the branch; this way the branch is analyzed
-	- Should we not warn about any nullability issues in that branch? Probably not, it is ok to break the nullability postconditions when the nullability preconditions are violated.
-- We can assume that these pointers are not null and we lose coverage with the analyzer. (This can be implemented either in constraint solver or in the checker itself.)
-
-Other Issues to keep in mind/take care of:
-Messaging:
-- Sending a message to a nullable pointer
-	- Even though the method might return a nonnull pointer, when it was sent to a nullable pointer the return type will be nullable.
-	- The result is nullable unless the receiver is known to be non null.
-- Sending a message to a unspecified or nonnull pointer
-	- If the pointer is not assumed to be nil, we should be optimistic and use the nullability implied by the method.
-- This will not happen automatically, since the AST will have null unspecified in this case.
-
-Inlining
-
-
-A symbol may need to be treated differently inside an inlined body. For example, consider these 

[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Only a few nits from me.




Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:30
+  WarnOnFloatingPointNarrowingConversion(
+  Options.get("WarnOnFloatingPointNarrowingConversion", 0)) {}
+

I would make this on by default. It is a valid diagnostic and people using this 
check might be surprised they have to activate it.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:169
+// Integer to Bool type conversions are well defined and not considered as 
a
+// narrowing. The following clang tidy already flags invalid boolean
+// conversions.

s/clang tidy already/clang-tidy check already/ (not sure if clang-tidy-check is 
correcter from english point of view.)



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:206
+
+  assert(false && "Unhandled type conversion");
+}

i think `llvm_unreachable` would fit better.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:299
+  Rhs->isCXX11ConstantExpr(Context, &Constant)) {
+if (Constant.isFloat())
+  diagIfNarrowFloatingPointConstant(Context, SourceLoc, Lhs, Rhs, 
Constant);

Why is the return here `true` even without diagnostic?



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:344
+  Cast->getExprLoc(), Cast, Cast->getSubExpr());
+  assert(false && "must be binary operator or cast expression");
 }

`llvm_unreachable`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D54430: [clangd] Don't show all refs results if -name is ambiguous in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54430

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -218,6 +218,12 @@
   IDs.push_back(*SID);
 } else {
   IDs = getSymbolIDsFromIndex(Name, Index);
+  if (IDs.size() > 1) {
+outs() << formatv("The name {0} is ambiguous, found {1} different "
+  "symbols. Please use id flag to disambiguate.\n",
+  Name, IDs.size());
+return;
+  }
 }
 RefsRequest RefRequest;
 RefRequest.IDs.insert(IDs.begin(), IDs.end());


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -218,6 +218,12 @@
   IDs.push_back(*SID);
 } else {
   IDs = getSymbolIDsFromIndex(Name, Index);
+  if (IDs.size() > 1) {
+outs() << formatv("The name {0} is ambiguous, found {1} different "
+  "symbols. Please use id flag to disambiguate.\n",
+  Name, IDs.size());
+return;
+  }
 }
 RefsRequest RefRequest;
 RefRequest.IDs.insert(IDs.begin(), IDs.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

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

> Before this change, this was not a problem because OverriddenFiles were keyed 
> on Status.getUniqueID(). Starting with this change, the key is the file path.

I suggest keeping two maps for overridden files: one for existing files (key is 
UniqueID), another one for the ones that don't exist (key is the file path).

> Is there a nice way to map different file paths of the same file to the same 
> id without touching the real file system? Would it be sufficient to normalize 
> the file paths? If yes, is there a utility function for this (can't find it 
> right now).

I don't think there is one, the unique ids are closely tied to the filesystem. 
IIUC the unique ids are the same whenever two different paths are symlinks (or 
hardlinks?) pointing to the same physical file and there's no way to tell if 
they're the same without resolving the symlink.


Repository:
  rC Clang

https://reviews.llvm.org/D41005



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


[PATCH] D54429: [analyzer] Creating standard shpinx documentation

2018-11-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I do like the idea of moving the Clang Static Analyzer documentation to where 
the rest of the tools are documented. I believe the original reason the 
analyzer had a separate homepage is due to it was off by default in clang at 
the beginning and users downloaded it from the separate page.

I do see the value in having a consistent style across the tools and I do hope 
that we will end up editing rst files more often (as probably most of the 
analyzers devs do not really like HTML).


Repository:
  rC Clang

https://reviews.llvm.org/D54429



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


r346635 - Fix compatibility with z3-4.8.1

2018-11-12 Thread Jan Kratochvil via cfe-commits
Author: jankratochvil
Date: Sun Nov 11 22:48:02 2018
New Revision: 346635

URL: http://llvm.org/viewvc/llvm-project?rev=346635&view=rev
Log:
Fix compatibility with z3-4.8.1

With z3-4.8.1:
../tools/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:49:40: error:
'Z3_get_error_msg_ex' was not declared in this scope
../tools/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:49:40: note:
suggested alternative: 'Z3_get_error_msg'

Formerly used Z3_get_error_msg_ex() as one could find in z3-4.7.1 states:
"Retained function name for backwards compatibility within v4.1"
And it is implemented only as a forwarding call:
return Z3_get_error_msg(c, err);

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=346635&r1=346634&r2=346635&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Sun Nov 11 
22:48:02 2018
@@ -46,7 +46,7 @@ public:
 // Function used to report errors
 void Z3ErrorHandler(Z3_context Context, Z3_error_code Error) {
   llvm::report_fatal_error("Z3 error: " +
-   llvm::Twine(Z3_get_error_msg_ex(Context, Error)));
+   llvm::Twine(Z3_get_error_msg(Context, Error)));
 }
 
 /// Wrapper for Z3 context


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


[PATCH] D54430: [clangd] Don't show all refs results if -name is ambiguous in dexp.

2018-11-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346671: [clangd] Don't show all refs results if -name 
is ambiguous in dexp. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54430

Files:
  clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
@@ -218,6 +218,12 @@
   IDs.push_back(*SID);
 } else {
   IDs = getSymbolIDsFromIndex(Name, Index);
+  if (IDs.size() > 1) {
+outs() << formatv("The name {0} is ambiguous, found {1} different "
+  "symbols. Please use id flag to disambiguate.\n",
+  Name, IDs.size());
+return;
+  }
 }
 RefsRequest RefRequest;
 RefRequest.IDs.insert(IDs.begin(), IDs.end());


Index: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
@@ -218,6 +218,12 @@
   IDs.push_back(*SID);
 } else {
   IDs = getSymbolIDsFromIndex(Name, Index);
+  if (IDs.size() > 1) {
+outs() << formatv("The name {0} is ambiguous, found {1} different "
+  "symbols. Please use id flag to disambiguate.\n",
+  Name, IDs.size());
+return;
+  }
 }
 RefsRequest RefRequest;
 RefRequest.IDs.insert(IDs.begin(), IDs.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r346671 - [clangd] Don't show all refs results if -name is ambiguous in dexp.

2018-11-12 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Nov 12 08:41:15 2018
New Revision: 346671

URL: http://llvm.org/viewvc/llvm-project?rev=346671&view=rev
Log:
[clangd] Don't show all refs results if -name is ambiguous in dexp.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=346671&r1=346670&r2=346671&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Mon Nov 12 08:41:15 
2018
@@ -218,6 +218,12 @@ class Refs : public Command {
   IDs.push_back(*SID);
 } else {
   IDs = getSymbolIDsFromIndex(Name, Index);
+  if (IDs.size() > 1) {
+outs() << formatv("The name {0} is ambiguous, found {1} different "
+  "symbols. Please use id flag to disambiguate.\n",
+  Name, IDs.size());
+return;
+  }
 }
 RefsRequest RefRequest;
 RefRequest.IDs.insert(IDs.begin(), IDs.end());


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


[PATCH] D54309: [AST] Allow limiting the scope of common AST traversals (getParents, RAV).

2018-11-12 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a subscriber: thakis.
ioeric added a comment.

The new API and the refactoring look good to me. Just a nit and a question.




Comment at: lib/AST/ASTContext.cpp:10292
+  if (!Parents)
 // We always need to run over the whole translation unit, as
 // hasAncestor can escape any subtree.

is this comment outdated?



Comment at: lib/ASTMatchers/ASTMatchFinder.cpp:676
 const auto &Parents = ActiveASTContext->getParents(Node);
-assert(!Parents.empty() && "Found node that is not in the parent map.");
 if (Parents.size() == 1) {

A quick search for "Found node that is not in the parent map." in my fav. 
search engine found a few prior discussions about this. E.g. @klimek seemed to 
want to remove the assertion 
(http://clang-developers.42468.n3.nabble.com/Question-about-failed-assertion-ASTMatchFinder-cc-quot-Found-node-that-is-not-in-the-parent-map-quot-td4038612.html),
 while @thakis seemed to favor keeping the assertion 
(https://bugs.chromium.org/p/chromium/issues/detail?id=580749).

Maybe we could still assertion if the scope if TU?


Repository:
  rC Clang

https://reviews.llvm.org/D54309



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


r346675 - Revert "Make clang-based tools find libc++ on MacOS"

2018-11-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Nov 12 08:59:50 2018
New Revision: 346675

URL: http://llvm.org/viewvc/llvm-project?rev=346675&view=rev
Log:
Revert "Make clang-based tools find libc++ on MacOS"

This breaks the LLDB bots.

Removed:
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12 08:59:50 2018
@@ -108,13 +108,6 @@ public:
   /// etc.).
   std::string ResourceDir;
 
-  /// Compiler install dir as detected by the Driver.
-  /// This is typically the directory that contains the clang executable, i.e.
-  /// the 'bin/' subdir of a clang distribution.
-  /// Only used to add include dirs for libc++ on Darwin. Please avoid relying
-  /// on this field for other purposes.
-  std::string InstallDir;
-
   /// The directory used for the module cache.
   std::string ModuleCachePath;
 

Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov 12 
08:59:50 2018
@@ -11,18 +11,17 @@
 //
 
//===--===//
 
+#include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/Path.h"
 using namespace clang;
 using namespace llvm::opt;
 
@@ -103,8 +102,5 @@ std::unique_ptr clan
  CCArgs.size(),
  *Diags))
 return nullptr;
-  // Patch up the install dir, so we find the same standard library as the
-  // original compiler on MacOS.
-  CI->getHeaderSearchOpts().InstallDir = TheDriver.getInstalledDir();
   return CI;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Nov 12 08:59:50 2018
@@ -476,9 +476,14 @@ void InitHeaderSearch::AddDefaultInclude
   if (triple.isOSDarwin()) {
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-if (!HSOpts.InstallDir.empty()) {
-  // Get from foo/bin to foo.
-  SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir));
+if (!HSOpts.ResourceDir.empty()) {
+  // Remove version from foo/lib/clang/version
+  StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
+  // Remove clang from foo/lib/clang
+  StringRef Lib = llvm::sys::path::parent_path(NoVer);
+  // Remove lib from foo/lib
+  SmallString<128> P = llvm::sys::path::parent_path(Lib);
+
   // Get foo/include/c++/v1
   llvm::sys::path::append(P, "include", "c++", "v1");
   AddUnmappedPath(P, CXXSystem, false);

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Mon Nov 12 08:59:50 2018
@@ -327,9 +327,6 @@ bool ToolInvocation::run() {
 Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
   Input.release());
   }
-  // Patch up the install dir, so we find the same standard library as the
-  // original compiler on MacOS.
-  In

[clang-tools-extra] r346676 - [clang-tidy] fix ARM tests, because int and long have same width

2018-11-12 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Nov 12 09:02:05 2018
New Revision: 346676

URL: http://llvm.org/viewvc/llvm-project?rev=346676&view=rev
Log:
[clang-tidy] fix ARM tests, because int and long have same width

Modified:
clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp?rev=346676&r1=346675&r2=346676&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-too-small-loop-variable.cpp 
Mon Nov 12 09:02:05 2018
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-too-small-loop-variable %t
+// RUN: %check_clang_tidy %s bugprone-too-small-loop-variable %t -- -- 
--target=x86_64-linux
 
 long size() { return 294967296l; }
 


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


[PATCH] D54310: Make clang-based tools find libc++ on MacOS

2018-11-12 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

I reverted this because it broke the LLDB bots on GreenDragon: 
http://green.lab.llvm.org/green/view/LLDB/


Repository:
  rL LLVM

https://reviews.llvm.org/D54310



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


[PATCH] D54166: [AST] Store the string data in StringLiteral in a trailing array of chars

2018-11-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: include/clang/AST/Expr.h:1700-1701
   bool containsNonAscii() const {
-StringRef Str = getString();
-for (unsigned i = 0, e = Str.size(); i != e; ++i)
-  if (!isASCII(Str[i]))
+for (auto c : getString())
+  if (!isASCII(c))
 return true;

Seems like changes like this are unrelated refactoring? Or are they in some way 
needed for this change? 

(also the isXXX functions above - might be neat/tidy to pull those out 
separately (as an NFC change) so that then this change (that modifies the 
implementation of getKind) is just that, without having to refactor all the 
other bits too? But not a big deal either way there, really)


Repository:
  rC Clang

https://reviews.llvm.org/D54166



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


r346677 - Implement P1094R2 (nested inline namespaces)

2018-11-12 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 12 09:19:48 2018
New Revision: 346677

URL: http://llvm.org/viewvc/llvm-project?rev=346677&view=rev
Log:
Implement P1094R2 (nested inline namespaces)

As approved for the Working Paper in San Diego, support annotating
inline namespaces with 'inline'.

Change-Id: I51a654e11ffb475bf27cccb2458768151619e384

Added:
cfe/trunk/test/Parser/cxx2a-inline-nested-namespace-definition.cpp   (with 
props)
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=346677&r1=346676&r2=346677&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Nov 12 09:19:48 
2018
@@ -222,6 +222,11 @@ def ext_nested_namespace_definition : Ex
 def warn_cxx14_compat_nested_namespace_definition : Warning<
   "nested namespace definition is incompatible with C++ standards before 
C++17">,
   InGroup, DefaultIgnore;
+def ext_inline_nested_namespace_definition : ExtWarn<
+  "inline nested namespace definition is a C++2a extension">, InGroup;
+def warn_cxx17_compat_inline_nested_namespace_definition : Warning<
+  "inline nested namespace definition is incompatible with C++ standards 
before"
+  " C++2a">, InGroup, DefaultIgnore;
 def err_inline_nested_namespace_definition : Error<
   "nested namespace definition cannot be 'inline'">;
 def err_expected_semi_after_attribute_list : Error<

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=346677&r1=346676&r2=346677&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Nov 12 09:19:48 2018
@@ -2659,9 +2659,16 @@ private:
   DeclGroupPtrTy ParseNamespace(DeclaratorContext Context,
 SourceLocation &DeclEnd,
 SourceLocation InlineLoc = SourceLocation());
-  void ParseInnerNamespace(std::vector &IdentLoc,
-   std::vector &Ident,
-   std::vector &NamespaceLoc,
+
+  struct InnerNamespaceInfo {
+SourceLocation NamespaceLoc;
+SourceLocation InlineLoc;
+SourceLocation IdentLoc;
+IdentifierInfo *Ident;
+  };
+  using InnerNamespaceInfoList = llvm::SmallVector;
+
+  void ParseInnerNamespace(const InnerNamespaceInfoList &InnerNSs,
unsigned int index, SourceLocation &InlineLoc,
ParsedAttributes &attrs,
BalancedDelimiterTracker &Tracker);

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=346677&r1=346676&r2=346677&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Nov 12 09:19:48 2018
@@ -33,24 +33,23 @@ using namespace clang;
 /// may either be a top level namespace or a block-level namespace alias. If
 /// there was an inline keyword, it has already been parsed.
 ///
-///   namespace-definition: [C++ 7.3: basic.namespace]
+///   namespace-definition: [C++: namespace.def]
 /// named-namespace-definition
 /// unnamed-namespace-definition
+/// nested-namespace-definition
+///
+///   named-namespace-definition:
+/// 'inline'[opt] 'namespace' attributes[opt] identifier '{' 
namespace-body '}'
 ///
 ///   unnamed-namespace-definition:
 /// 'inline'[opt] 'namespace' attributes[opt] '{' namespace-body '}'
 ///
-///   named-namespace-definition:
-/// original-namespace-definition
-/// extension-namespace-definition
+///   nested-namespace-definition:
+/// 'namespace' enclosing-namespace-specifier '::' 'inline'[opt] 
identifier '{' namespace-body '}'
 ///
-///   original-namespace-definition:
-/// 'inline'[opt] 'namespace' identifier attributes[opt]
-/// '{' namespace-body '}'
-///
-///   extension-namespace-definition:
-/// 'inline'[opt] 'namespace' original-namespace-name
-/// '{' namespace-body '}'
+///   enclosing-namespace-specifier:
+/// identifier
+/// enclosing-namespace-specifier '::' 'inline'[opt] identifier
 ///
 ///   namespace-alias-definition:  [C++ 7.3.2: namespace.alias]
 /// 'namespace' identifier '=' qualified-namespace-specifier ';'
@@ -70,9 +69,8 @@ Parser::DeclGroupPtrTy Parser::ParseName
 
   SourceLocation Ide

[PATCH] D53764: [OpenCL] Enable address spaces for references in C++

2018-11-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 173693.
Anastasia marked an inline comment as done.
Anastasia added a comment.

- Extended assert
  - Handled AS of ToType


https://reviews.llvm.org/D53764

Files:
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/address-space-deduction.cl

Index: test/CodeGenOpenCLCXX/address-space-deduction.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/address-space-deduction.cl
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - | FileCheck %s -check-prefixes=COMMON,PTR
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - -DREF | FileCheck %s -check-prefixes=COMMON,REF
+
+#ifdef REF
+#define PTR &
+#define ADR(x) x
+#else
+#define PTR *
+#define ADR(x) &x
+#endif
+
+//COMMON: @glob = addrspace(1) global i32
+int glob;
+//PTR: @glob_p = addrspace(1) global i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @glob to i32 addrspace(4)*)
+//REF: @glob_p = addrspace(1) global i32 addrspace(4)* null
+int PTR glob_p = ADR(glob);
+
+//COMMON: @_ZZ3fooi{{P|R}}U3AS4iE6loc_st = internal addrspace(1) global i32
+//PTR: @_ZZ3fooiPU3AS4iE8loc_st_p = internal addrspace(1) global i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @_ZZ3fooiPU3AS4iE6loc_st to i32 addrspace(4)*)
+//REF: @_ZZ3fooiRU3AS4iE8loc_st_p = internal addrspace(1) global i32 addrspace(4)* null
+//COMMON: @loc_ext_p = external addrspace(1) {{global|constant}} i32 addrspace(4)*
+//COMMON: @loc_ext = external addrspace(1) global i32
+
+//REF: store i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @glob to i32 addrspace(4)*), i32 addrspace(4)* addrspace(1)* @glob_p
+
+//COMMON: define spir_func i32 @_Z3fooi{{P|R}}U3AS4i(i32 %par, i32 addrspace(4)*{{.*}} %par_p)
+int foo(int par, int PTR par_p){
+//COMMON: %loc = alloca i32
+  int loc;
+//COMMON: %loc_p = alloca i32 addrspace(4)*
+//COMMON: [[GAS:%[0-9]+]] = addrspacecast i32* %loc to i32 addrspace(4)*
+//COMMON: store i32 addrspace(4)* [[GAS]], i32 addrspace(4)** %loc_p
+  int PTR loc_p = ADR(loc);
+
+// CHECK directives for the following code are located above.
+  static int loc_st;
+  static int PTR loc_st_p = ADR(loc_st);
+  extern int loc_ext;
+  extern int PTR loc_ext_p;
+  (void)loc_ext_p;
+  return loc_ext;
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7177,7 +7177,8 @@
   bool IsPointee =
   ChunkIndex > 0 &&
   (D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Pointer ||
-   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer);
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer ||
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Reference);
   bool IsFuncReturnType =
   ChunkIndex > 0 &&
   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Function;
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7209,12 +7209,20 @@
   return CreateMaterializeTemporaryExpr(E->getType(), E, false);
 }
 
-ExprResult
-InitializationSequence::Perform(Sema &S,
-const InitializedEntity &Entity,
-const InitializationKind &Kind,
-MultiExprArg Args,
-QualType *ResultType) {
+ExprResult Sema::PerformQualificationConversion(Expr *E, QualType Ty,
+ExprValueKind VK,
+CheckedConversionKind CCK) {
+  CastKind CK = (Ty.getAddressSpace() != E->getType().getAddressSpace())
+? CK_AddressSpaceConversion
+: CK_NoOp;
+  return ImpCastExprToType(E, Ty, CK, VK, /*BasePath=*/nullptr, CCK);
+}
+
+ExprResult InitializationSequence::Perform(Sema &S,
+   const InitializedEntity &Entity,
+   const InitializationKind &Kind,
+   MultiExprArg Args,
+   QualType *ResultType) {
   if (Failed()) {
 Diagnose(S, Entity, Kind, Args);
 return ExprError();
@@ -7603,12 +7611,11 @@
 case SK_QualificationConversionRValue: {
   // Perform a qualification conversion; these can never go wrong.
   ExprValueKind VK =
-  Step->Kind == SK_QualificationConversionLValue ?
-  VK_LValue :
-  (Step->Kind == SK_QualificationConversionXValue ?
-   VK_XValue :
-   VK_RValue);
-  CurInit = S.ImpCastExprToType(CurInit.get(), Step-

[clang-tools-extra] r346678 - Revert "Add a test checking clang-tidy can find libc++ on Mac"

2018-11-12 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Nov 12 09:22:36 2018
New Revision: 346678

URL: http://llvm.org/viewvc/llvm-project?rev=346678&view=rev
Log:
Revert "Add a test checking clang-tidy can find libc++ on Mac"

This reverts commit r346653.

Removed:

clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp

Removed: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c%2B%2B/v1/mock_vector?rev=346677&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
 (removed)
@@ -1,2 +0,0 @@
-class vector {};
-typedef vector* vector_ptr;

Removed: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp?rev=346677&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-mac-libcxx.cpp (removed)
@@ -1,17 +0,0 @@
-// Clang on MacOS can find libc++ living beside the installed compiler.
-// This test makes sure clang-tidy emulates this properly.
-//
-// RUN: rm -rf %t
-// RUN: mkdir %t
-//
-// Install the mock libc++ (simulates the libc++ directory structure).
-// RUN: cp -r %S/Inputs/mock-libcxx %t/
-//
-// Pretend clang is installed beside the mock library that we provided.
-// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ 
-stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | 
sed -e 's/\\/\//g' > %t/compile_commands.json
-// RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-tidy -header-filter='.*' -system-headers 
-checks='-*,modernize-use-using'  "%t/test.cpp" | FileCheck %s
-// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 
'typedef'
-
-#include 
-typedef vector* vec_ptr;


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


[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-12 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

> Thank you very much for the patch!

Thank you for reviewing!


Repository:
  rL LLVM

https://reviews.llvm.org/D53974



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


r346680 - [analyzer] Drastically simplify the tblgen files used for checkers

2018-11-12 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Mon Nov 12 09:49:51 2018
New Revision: 346680

URL: http://llvm.org/viewvc/llvm-project?rev=346680&view=rev
Log:
[analyzer] Drastically simplify the tblgen files used for checkers

Interestingly, only about the quarter of the emitter file is used, the DescFile
entry hasn't ever been touched [1], and the entire concept of groups is a
mystery, so I removed them.

[1] http://lists.llvm.org/pipermail/cfe-dev/2018-October/059664.html

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=346680&r1=346679&r2=346680&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Nov 12 09:49:51 2018
@@ -106,11 +106,11 @@ def analyzer_checker : Separate<["-"], "
   ValuesCode<[{
 const char *Values =
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H)  FULLNAME ","
+#define CHECKER(FULLNAME, CLASS, HT)  FULLNAME ","
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_CHECKERS
 #define GET_PACKAGES
-#define PACKAGE(FULLNAME, G, D)  FULLNAME ","
+#define PACKAGE(FULLNAME)  FULLNAME ","
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_PACKAGES
 ;

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td?rev=346680&r1=346679&r2=346680&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td Mon Nov 12 
09:49:51 2018
@@ -11,29 +11,34 @@
 //
 
//===--===//
 
-class CheckerGroup {
-  string GroupName = name;
-}
-class InGroup { CheckerGroup Group = G; }
-
+/// Describes a package. Every checker is a part of a package, for example,
+/// 'NullDereference' is part of the 'core' package, hence it's full name is
+/// 'core.NullDereference'.
+/// Example:
+///   def Core : Package<"core">;
 class Package {
   string   PackageName = name;
-  bit  Hidden = 0;
   Package ParentPackage;
-  CheckerGroup Group;
 }
-class InPackage { Package ParentPackage = P; }
 
-// All checkers are an indirect subclass of this.
+/// Describes a 'super' package that holds another package inside it. This is
+/// used to nest packages in one another. One may, for example, create the
+/// 'builtin' package inside 'core', thus creating the package 'core.builtin'.
+/// Example:
+///   def CoreBuiltin : Package<"builtin">, ParentPackage;
+class ParentPackage { Package ParentPackage = P; }
+
+/// A description. May be displayed to the user when clang is invoked with
+/// a '-help'-like command line option.
+class HelpText { string HelpText = text; }
+
+/// Describes a checker. Every builtin checker has to be registered with the 
use
+/// of this class (out-of-trunk checkers loaded from plugins obviously don't).
+/// Note that a checker has a name (e.g.: 'NullDereference'), and a fullname,
+/// that is autogenerated with the help of the ParentPackage field, that also
+/// includes package names (e.g.: 'core.NullDereference').
 class Checker {
   string  CheckerName = name;
-  string  DescFile;
   string  HelpText;
-  bit Hidden = 0;
   Package ParentPackage;
-  CheckerGroup Group;
 }
-
-class DescFile { string DescFile = filename; }
-class HelpText { string HelpText = text; }
-class Hidden { bit Hidden = 1; }

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=346680&r1=346679&r2=346680&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Nov 12 
09:49:51 2018
@@ -21,9 +21,9 @@ include "CheckerBase.td"
 def Alpha : Package<"alpha">;
 
 def Core : Package<"core">;
-def CoreBuiltin : Package<"builtin">, InPackage;
-def CoreUninitialized  : Package<"uninitialized">, InPackage;
-def CoreAlp

[PATCH] D53995: [analyzer] Drastically simplify the tblgen files used for checkers

2018-11-12 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346680: [analyzer] Drastically simplify the tblgen files 
used for checkers (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53995?vs=172534&id=173704#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53995

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Index: cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -11,34 +11,19 @@
 //
 //===--===//
 
-#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
 #include 
+
 using namespace llvm;
 
 //===--===//
 // Static Analyzer Checkers Tables generation
 //===--===//
 
-/// True if it is specified hidden or a parent package is specified
-/// as hidden, otherwise false.
-static bool isHidden(const Record &R) {
-  if (R.getValueAsBit("Hidden"))
-return true;
-  // Not declared as hidden, check the parent package if it is hidden.
-  if (DefInit *DI = dyn_cast(R.getValueInit("ParentPackage")))
-return isHidden(*DI->getDef());
-
-  return false;
-}
-
-static bool isCheckerNamed(const Record *R) {
-  return !R->getValueAsString("CheckerName").empty();
-}
-
 static std::string getPackageFullName(const Record *R);
 
 static std::string getParentPackageFullName(const Record *R) {
@@ -50,17 +35,19 @@
 
 static std::string getPackageFullName(const Record *R) {
   std::string name = getParentPackageFullName(R);
-  if (!name.empty()) name += ".";
+  if (!name.empty())
+name += ".";
+  assert(!R->getValueAsString("PackageName").empty());
   name += R->getValueAsString("PackageName");
   return name;
 }
 
 static std::string getCheckerFullName(const Record *R) {
   std::string name = getParentPackageFullName(R);
-  if (isCheckerNamed(R)) {
-if (!name.empty()) name += ".";
-name += R->getValueAsString("CheckerName");
-  }
+  if (!name.empty())
+name += ".";
+  assert(!R->getValueAsString("CheckerName").empty());
+  name += R->getValueAsString("CheckerName");
   return name;
 }
 
@@ -70,129 +57,12 @@
   return std::string();
 }
 
-namespace {
-struct GroupInfo {
-  llvm::DenseSet Checkers;
-  llvm::DenseSet SubGroups;
-  bool Hidden;
-  unsigned Index;
-
-  GroupInfo() : Hidden(false) { }
-};
-}
-
-static void addPackageToCheckerGroup(const Record *package, const Record *group,
-  llvm::DenseMap &recordGroupMap) {
-  llvm::DenseSet &checkers = recordGroupMap[package]->Checkers;
-  for (llvm::DenseSet::iterator
- I = checkers.begin(), E = checkers.end(); I != E; ++I)
-recordGroupMap[group]->Checkers.insert(*I);
-
-  llvm::DenseSet &subGroups = recordGroupMap[package]->SubGroups;
-  for (llvm::DenseSet::iterator
- I = subGroups.begin(), E = subGroups.end(); I != E; ++I)
-addPackageToCheckerGroup(*I, group, recordGroupMap);
-}
-
 namespace clang {
 void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
   std::vector checkers = Records.getAllDerivedDefinitions("Checker");
-  llvm::DenseMap checkerRecIndexMap;
-  for (unsigned i = 0, e = checkers.size(); i != e; ++i)
-checkerRecIndexMap[checkers[i]] = i;
-
-  // Invert the mapping of checkers to package/group into a one to many
-  // mapping of packages/groups to checkers.
-  std::map groupInfoByName;
-  llvm::DenseMap recordGroupMap;
-
   std::vector packages = Records.getAllDerivedDefinitions("Package");
-  for (unsigned i = 0, e = packages.size(); i != e; ++i) {
-Record *R = packages[i];
-std::string fullName = getPackageFullName(R);
-if (!fullName.empty()) {
-  GroupInfo &info = groupInfoByName[fullName];
-  info.Hidden = isHidden(*R);
-  recordGroupMap[R] = &info;
-}
-  }
-
-  std::vector
-  checkerGroups = Records.getAllDerivedDefinitions("CheckerGroup");
-  for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i) {
-Record *R = checkerGroups[i];
-std::string name = R->getValueAsString("GroupName");
-if (!name.empty()) {
-  GroupInfo &info = groupInfoByName[name];
-  recordGroupMap[R] = &info

[PATCH] D54166: [AST] Store the string data in StringLiteral in a trailing array of chars

2018-11-12 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

@dblaikie Thanks for looking at this patch !

I have a set of patches shrinking the other statements/expressions.
Can I add you to review some of these too ? Most of them consists of just moving
some data. I added rsmith but I think that he is busy with the standard.




Comment at: include/clang/AST/Expr.h:1701
+for (auto c : getString())
+  if (!isASCII(c))
 return true;

They are not needed, I just could not resist.
I can factor these changes out of this patch and submit it as an NFC.


Repository:
  rC Clang

https://reviews.llvm.org/D54166



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


r346687 - [clang-format] Support breaking consecutive string literals for TableGen

2018-11-12 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Mon Nov 12 10:15:04 2018
New Revision: 346687

URL: http://llvm.org/viewvc/llvm-project?rev=346687&view=rev
Log:
[clang-format] Support breaking consecutive string literals for TableGen

Summary:
clang-format can get confused by string literals in TableGen: it knows that 
strings can be broken up, but doesn't seem to understand how that can be 
indented across line breaks, and arranges them in a weird triangular pattern. 
Take this output example from `clang-format tools/llvm-objcopy/ObjcopyOpts.td` 
(which has now been formatted in rL345896 with this patch applied):

```
defm keep_global_symbols
: Eq<
  "keep-global-symbols", "Reads a list of symbols from  and "
 "runs as if " "--keep-global-symbol= "
   "is set for each one. "
   " " "contains one "
 "symbol per line "
 "and may contain "
 "comments "
 "beginning " "with"
  " '#'"
  ". "
  "Lead"
  "ing "
```

Reviewers: alexshap, MaskRay, djasper

Reviewed By: MaskRay

Subscribers: krasimir, mgorny, cfe-commits

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

Added:
cfe/trunk/unittests/Format/FormatTestTableGen.cpp
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=346687&r1=346686&r2=346687&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Nov 12 10:15:04 2018
@@ -2875,6 +2875,7 @@ bool TokenAnnotator::mustBreakBefore(con
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
  Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TableGen ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;

Modified: cfe/trunk/unittests/Format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CMakeLists.txt?rev=346687&r1=346686&r2=346687&view=diff
==
--- cfe/trunk/unittests/Format/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Format/CMakeLists.txt Mon Nov 12 10:15:04 2018
@@ -12,6 +12,7 @@ add_clang_unittest(FormatTests
   FormatTestProto.cpp
   FormatTestRawStrings.cpp
   FormatTestSelective.cpp
+  FormatTestTableGen.cpp
   FormatTestTextProto.cpp
   NamespaceEndCommentsFixerTest.cpp
   SortImportsTestJS.cpp

Added: cfe/trunk/unittests/Format/FormatTestTableGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTableGen.cpp?rev=346687&view=auto
==
--- cfe/trunk/unittests/Format/FormatTestTableGen.cpp (added)
+++ cfe/trunk/unittests/Format/FormatTestTableGen.cpp Mon Nov 12 10:15:04 2018
@@ -0,0 +1,56 @@
+//===- unittest/Format/FormatTestTableGen.cpp 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestTableGen : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle &Style) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string format(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TableGen);
+Style.ColumnLimit = 60; // To make w

[PATCH] D53952: [clang-format] Support breaking consecutive string literals for TableGen

2018-11-12 Thread Jordan Rupprecht via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346687: [clang-format] Support breaking consecutive string 
literals for TableGen (authored by rupprecht, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53952?vs=172029&id=173711#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53952

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestTableGen.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2875,6 +2875,7 @@
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
  Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TableGen ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -12,6 +12,7 @@
   FormatTestProto.cpp
   FormatTestRawStrings.cpp
   FormatTestSelective.cpp
+  FormatTestTableGen.cpp
   FormatTestTextProto.cpp
   NamespaceEndCommentsFixerTest.cpp
   SortImportsTestJS.cpp
Index: unittests/Format/FormatTestTableGen.cpp
===
--- unittests/Format/FormatTestTableGen.cpp
+++ unittests/Format/FormatTestTableGen.cpp
@@ -0,0 +1,56 @@
+//===- unittest/Format/FormatTestTableGen.cpp 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestTableGen : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle &Style) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string format(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TableGen);
+Style.ColumnLimit = 60; // To make writing tests easier.
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static void verifyFormat(llvm::StringRef Code) {
+EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
+EXPECT_EQ(Code.str(), format(test::messUp(Code)));
+  }
+};
+
+TEST_F(FormatTestTableGen, FormatStringBreak) {
+  verifyFormat("include \"OptParser.td\"\n"
+   "def flag : Flag<\"--foo\">,\n"
+   "   HelpText<\n"
+   "   \"This is a very, very, very, very, \"\n"
+   "   \"very, very, very, very, very, very, \"\n"
+   "   \"very long help string\">;\n");
+}
+
+} // namespace format
+} // end namespace clang


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2875,6 +2875,7 @@
   } else if (Style.Language == FormatStyle::LK_Cpp ||
  Style.Language == FormatStyle::LK_ObjC ||
  Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TableGen ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Left.isStringLiteral() && Right.isStringLiteral())
   return true;
Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -12,6 +12,7 @@
   FormatTestProto.cpp
   FormatTestRawStrings.cpp
   FormatTestSelective.cpp
+  FormatTestTableGen.cpp
   FormatTestTextProto.cpp
   NamespaceEndCommentsFixerTest.cpp
   SortImportsTestJS.cpp
Index: unittests/Format/FormatTestTableGen.cpp
===
--- unittests/Format/FormatTestTableGen.cpp
+++ unittests/Format/FormatTestTableGen.cpp
@@ -0,0 +1,56 @@
+//===- unittest/Format/FormatTestTableGen.cpp -===//
+//
+// The LLVM Compile

[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-11-12 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

In https://reviews.llvm.org/D46403#1291697, @filcab wrote:

> Sorry to ressurect this review, but I have a few questions:
>
> - What kind of functions fail?
> - Are there bugzillas to track these?
> - How can a compiler expect to have blacklists for "all" its CFI clients? 
> (I'm ok with having a default for "most-used, well-known, problematic 
> functions", e.g: functions in libstdc++ or libc++)


The default blacklist should contain problematic functions in the stdlibs that 
we don't control (i.e. libstdc++ and the MSVC stdlib). In libc++, we blacklist 
functions directly in the source code using the `no_sanitize` attribute. In 
general the blacklist entries for the stdlib are necessary because the standard 
requires that functions have a particular signature which requires the 
implementation to make what is considered to be a bad cast by CFI, so there 
isn't a bug as such.

> - clang/compiler-rt don't seem to have a default blacklist, what should the 
> contents be?

There is a default blacklist, see 
http://llvm-cs.pcc.me.uk/projects/compiler-rt/lib/cfi/cfi_blacklist.txt
Its contents are as mentioned above.

It should be installed by default, is that not happening for you?

> This patch seems to be saying "There are some well-known functions that 
> should never be instrumented with CFI, I'll provide a list of names", which 
> doesn't really seem possible to do in general, for "most" CFI-toolchain 
> clients. As I see it, each client will need to have their own blacklist, and 
> provide it as an argument if needed.

Right, if the client needs a blacklist it should be passed on the command line. 
More importantly, it should be applied in addition to the standard one so that 
the user doesn't have to repeat the stdlib blacklist in their blacklist (which 
was the situation before we added support for multiple blacklists).

> Which brings us to:
> 
> - If I pass `-fsanitize-blacklist=my_blacklist.txt` I still get an error. 
> This is not ideal, as I might be working on the blacklist to include in my 
> toolchain/program.
> 
>   I don't think we should have an error that is default enabled for this 
> issue. At most a warning (+ `-Werror`) if there was no blacklist passed in 
> nor found in the toolchain resource directory.

Clang prints this error if the blacklist is missing from the resource 
directory, which means that Clang was not installed properly. This is 
intentional as it prevents us from silently not applying the standard blacklist 
in that case.

If you are working on the toolchain blacklist, that is a very special case and 
there are plenty of ways around this issue. For example you can edit 
`lib/cfi/cfi_blacklist.txt` in place and use `ninja` to install it.


Repository:
  rC Clang

https://reviews.llvm.org/D46403



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


[PATCH] D54169: [clang-tidy] Zircon ->

2018-11-12 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett abandoned this revision.
juliehockett added a comment.

After a lot of discussion, we'll do this migration internally. Thanks for your 
comments!


https://reviews.llvm.org/D54169



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


[PATCH] D54168: [clang-tidy] Zircon fbl::move -> std::move

2018-11-12 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett abandoned this revision.
juliehockett added a comment.

After a lot of discussion, we'll do this migration internally. Thanks for your 
comments!


https://reviews.llvm.org/D54168



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


  1   2   3   >