[clang-tools-extra] r339781 - [clangd][tests] Fix typo in tests - invalid LSP exit message

2018-08-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Aug 15 08:50:45 2018
New Revision: 339781

URL: http://llvm.org/viewvc/llvm-project?rev=339781&view=rev
Log:
[clangd][tests] Fix typo in tests - invalid LSP exit message

Syntactically invalid JSON payload was causing clangd to terminate because of 
unexpected EOF rather than exit as a response to LSP exit message.

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

Modified:
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/formatting.test
clang-tools-extra/trunk/test/clangd/initialize-params.test
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
clang-tools-extra/trunk/test/clangd/unsupported-method.test

Modified: clang-tools-extra/trunk/test/clangd/extra-flags.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/extra-flags.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/extra-flags.test (original)
+++ clang-tools-extra/trunk/test/clangd/extra-flags.test Wed Aug 15 08:50:45 
2018
@@ -49,6 +49,6 @@
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}
 
 

Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Wed Aug 15 08:50:45 2018
@@ -184,4 +184,4 @@
 ---
 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/initialize-params.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/initialize-params.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/initialize-params.test (original)
+++ clang-tools-extra/trunk/test/clangd/initialize-params.test Wed Aug 15 
08:50:45 2018
@@ -46,4 +46,4 @@
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": null
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test Wed Aug 15 
08:50:45 2018
@@ -1,4 +1,4 @@
 # RUN: clangd -lit-test < %s
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test Wed Aug 15 
08:50:45 2018
@@ -1,2 +1,2 @@
 # RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}

Modified: clang-tools-extra/trunk/test/clangd/unsupported-method.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/unsupported-method.test?rev=339781&r1=339780&r2=339781&view=diff
==
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test (original)
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test Wed Aug 15 
08:50:45 2018
@@ -13,4 +13,4 @@
 ---
 {"jsonrpc":"2.0","id":2,"method":"shutdown"}
 ---
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0","method":"exit"}


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


[clang-tools-extra] r339782 - [clangd][tests] Rename tests of clangd instance termination

2018-08-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Aug 15 08:58:05 2018
New Revision: 339782

URL: http://llvm.org/viewvc/llvm-project?rev=339782&view=rev
Log:
[clangd][tests] Rename tests of clangd instance termination

Just making testnames better reflect their testing scenarios.

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

Added:
clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test
  - copied, changed from r339781, 
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test
  - copied, changed from r339781, 
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
Removed:
clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test

Copied: clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test (from 
r339781, clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test?p2=clang-tools-extra/trunk/test/clangd/exit-with-shutdown.test&p1=clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test&r1=339781&r2=339782&rev=339782&view=diff
==
(empty)

Copied: clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test (from 
r339781, clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test?p2=clang-tools-extra/trunk/test/clangd/exit-without-shutdown.test&p1=clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test&r1=339781&r2=339782&rev=339782&view=diff
==
(empty)

Removed: clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test?rev=339781&view=auto
==
--- clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-with-exit.test (removed)
@@ -1,4 +0,0 @@
-# RUN: clangd -lit-test < %s
-{"jsonrpc":"2.0","id":3,"method":"shutdown"}

-{"jsonrpc":"2.0","method":"exit"}

Removed: clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test?rev=339781&view=auto
==
--- clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (original)
+++ clang-tools-extra/trunk/test/clangd/shutdown-without-exit.test (removed)
@@ -1,2 +0,0 @@
-# RUN: not clangd -lit-test < %s
-{"jsonrpc":"2.0","method":"exit"}


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


r332598 - Use dotted format of version tuple for availability diagnostics

2018-05-17 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu May 17 04:51:49 2018
New Revision: 332598

URL: http://llvm.org/viewvc/llvm-project?rev=332598&view=rev
Log:
Use dotted format of version tuple for availability diagnostics

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

We are maintaining backward compatibility by parsing underscore-delimited 
version tuples but no longer keep track of the separator and using dot format 
for output.

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

rdar://problem/39845032

Added:
cfe/trunk/test/Sema/availability-guard-format.mm
Modified:
cfe/trunk/include/clang/Basic/VersionTuple.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Basic/VersionTuple.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m
cfe/trunk/test/SemaObjC/attr-availability-1.m

Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=332598&r1=332597&r2=332598&view=diff
==
--- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
+++ cfe/trunk/include/clang/Basic/VersionTuple.h Thu May 17 04:51:49 2018
@@ -24,9 +24,7 @@ namespace clang {
 
 /// Represents a version number in the form major[.minor[.subminor[.build]]].
 class VersionTuple {
-  unsigned Major : 31;
-
-  unsigned UsesUnderscores : 1;
+  unsigned Major : 32;
 
   unsigned Minor : 31;
   unsigned HasMinor : 1;
@@ -39,30 +37,25 @@ class VersionTuple {
 
 public:
   VersionTuple()
-  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
+  : Major(0), Minor(0), HasMinor(false), Subminor(0), HasSubminor(false),
+Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
-
-  explicit VersionTuple(unsigned Major, unsigned Minor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
-HasBuild(false) {}
+  : Major(Major), Minor(0), HasMinor(false), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
 
-  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
-HasBuild(false) {}
+  explicit VersionTuple(unsigned Major, unsigned Minor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
+
+  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
-HasBuild(true) {}
+unsigned Build)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(Build), HasBuild(true) {}
 
   /// Determine whether this version information is empty
   /// (e.g., all version components are zero).
@@ -93,14 +86,6 @@ public:
   return None;
 return Build;
   }
-
-  bool usesUnderscores() const {
-return UsesUnderscores;
-  }
-
-  void UseDotAsSeparator() {
-UsesUnderscores = false;
-  }
   
   /// Determine if two version numbers are equivalent. If not
   /// provided, minor and subminor version numbers are considered to be zero.

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=332598&r1=332597&r2=332598&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu May 17 04:51:49 2018
@@ -550,7 +550,6 @@ static AvailabilityResult CheckAvailabil
   Message->clear();
   llvm::raw_string_ostream Out(*Message);
   VersionTuple VTI(A->getIntroduced());
-  VTI.UseDotAsSeparator();
   Out << "introduced in " << PrettyPlatformName << ' ' 
   << VTI << HintMessage;
 }
@@ -564,7 +563,6 @@ static AvailabilityResult CheckAvailabil
   Message->clear();
   llvm::raw_string_ostream Out(*Message);
   VersionTuple VTO(A->getObsoleted());
-  VTO.UseDotAsSeparator();
   Out << "obsoleted in " << PrettyPlatformName << ' ' 
   << 

r315236 - PR13575: Fix USR mangling for fixed-size arrays

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 12:51:33 2017
New Revision: 315236

URL: http://llvm.org/viewvc/llvm-project?rev=315236&view=rev
Log:
PR13575: Fix USR mangling for fixed-size arrays

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

Added:
cfe/trunk/test/Index/USR/
cfe/trunk/test/Index/USR/array-type.cpp
Modified:
cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315236&r1=315235&r2=315236&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 12:51:33 2017
@@ -816,6 +816,25 @@ void USRGenerator::VisitType(QualType T)
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';

Added: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315236&view=auto
==
--- cfe/trunk/test/Index/USR/array-type.cpp (added)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 12:51:33 2017
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);


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


r315241 - PR13575: Fix test

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 13:17:28 2017
New Revision: 315241

URL: http://llvm.org/viewvc/llvm-project?rev=315241&view=rev
Log:
PR13575: Fix test

Ignore OS-specific mangled name.

Modified:
cfe/trunk/test/Index/USR/array-type.cpp

Modified: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315241&r1=315240&r2=315241&view=diff
==
--- cfe/trunk/test/Index/USR/array-type.cpp (original)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 13:17:28 2017
@@ -3,9 +3,9 @@
 // Function template specializations differing in array type parameter should 
have unique USRs.
 
 template void foo(buffer);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C#
 template<> void foo(char[16]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C#
 template<> void foo(char[32]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C#
 template<> void foo(char[64]);


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


r315252 - Fix typos in documentation

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 16:45:20 2017
New Revision: 315252

URL: http://llvm.org/viewvc/llvm-project?rev=315252&view=rev
Log:
Fix typos in documentation

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

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=315252&r1=315251&r2=315252&view=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Mon Oct  9 16:45:20 2017
@@ -1540,7 +1540,7 @@ Implementation Approach
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@ are similar.
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't


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


r315255 - R13575: Fix USR mangling for function pointer types

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 17:35:16 2017
New Revision: 315255

URL: http://llvm.org/viewvc/llvm-project?rev=315255&view=rev
Log:
R13575: Fix USR mangling for function pointer types

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

Added:
cfe/trunk/test/Index/USR/func-type.cpp
Modified:
cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315255&r1=315254&r2=315255&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 17:35:16 2017
@@ -754,8 +754,12 @@ void USRGenerator::VisitType(QualType T)
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto &I : FT->param_types())
+  Out << '(';
+  for (const auto &I : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;

Added: cfe/trunk/test/Index/USR/func-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/func-type.cpp?rev=315255&view=auto
==
--- cfe/trunk/test/Index/USR/func-type.cpp (added)
+++ cfe/trunk/test/Index/USR/func-type.cpp Mon Oct  9 17:35:16 2017
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |


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


r315367 - Fix indexer crash for default template template parameter value

2017-10-10 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct 10 14:09:49 2017
New Revision: 315367

URL: http://llvm.org/viewvc/llvm-project?rev=315367&view=rev
Log:
Fix indexer crash for default template template parameter value

rdar://33058798

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

Added:
cfe/trunk/test/Index/index-template-template-param.cpp
Modified:
cfe/trunk/lib/Index/IndexDecl.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=315367&r1=315366&r2=315367&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Oct 10 14:09:49 2017
@@ -666,7 +666,6 @@ public:
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@ public:
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }

Added: cfe/trunk/test/Index/index-template-template-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-template-template-param.cpp?rev=315367&view=auto
==
--- cfe/trunk/test/Index/index-template-template-param.cpp (added)
+++ cfe/trunk/test/Index/index-template-template-param.cpp Tue Oct 10 14:09:49 
2017
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |


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


r315652 - Typos in tutorial

2017-10-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Oct 12 17:31:07 2017
New Revision: 315652

URL: http://llvm.org/viewvc/llvm-project?rev=315652&view=rev
Log:
Typos in tutorial

Modified:
cfe/trunk/www/hacking.html

Modified: cfe/trunk/www/hacking.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/hacking.html?rev=315652&r1=315651&r2=315652&view=diff
==
--- cfe/trunk/www/hacking.html (original)
+++ cfe/trunk/www/hacking.html Thu Oct 12 17:31:07 2017
@@ -246,9 +246,9 @@
   For example:
 
   
-  python C:\Tool\llvm\utils\lit\lit.py -sv
+  python C:\Tools\llvm\utils\lit\lit.py -sv
   --param=build_mode=Win32 --param=build_config=Debug
-  --param=clang_site_config=c:\Tools\build\tools\clang\test\lit.site.cfg
+  --param=clang_site_config=C:\Tools\build\tools\clang\test\lit.site.cfg
   C:\Tools\llvm\tools\clang\test\Sema\wchar.c
 
 


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


r341074 - [Sema][NFC] Trivial cleanup in ActOnCallExpr

2018-08-30 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Aug 30 07:46:48 2018
New Revision: 341074

URL: http://llvm.org/viewvc/llvm-project?rev=341074&view=rev
Log:
[Sema][NFC] Trivial cleanup in ActOnCallExpr

Use logical or operator instead of a bool variable and if/else.

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=341074&r1=341073&r2=341074&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Aug 30 07:46:48 2018
@@ -5330,13 +5330,7 @@ ExprResult Sema::ActOnCallExpr(Scope *Sc
 
 // Determine whether this is a dependent call inside a C++ template,
 // in which case we won't do any semantic analysis now.
-bool Dependent = false;
-if (Fn->isTypeDependent())
-  Dependent = true;
-else if (Expr::hasAnyTypeDependentArguments(ArgExprs))
-  Dependent = true;
-
-if (Dependent) {
+if (Fn->isTypeDependent() || Expr::hasAnyTypeDependentArguments(ArgExprs)) 
{
   if (ExecConfig) {
 return new (Context) CUDAKernelCallExpr(
 Context, Fn, cast(ExecConfig), ArgExprs,


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


r324607 - [Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo

2018-02-08 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Feb  8 06:37:58 2018
New Revision: 324607

URL: http://llvm.org/viewvc/llvm-project?rev=324607&view=rev
Log:
[Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo

rdar://problem/10214588

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

Added:
cfe/trunk/test/FixIt/fixit-typedef-instead-of-typename-typo.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/CXX/temp/temp.param/p2.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=324607&r1=324606&r2=324607&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Feb  8 06:37:58 
2018
@@ -1162,6 +1162,9 @@ def err_objc_parameterized_implementatio
 
 def err_objc_type_args_after_protocols : Error<
   "protocol qualifiers must precede type arguments">;
+
+def note_meant_to_use_typename : Note<
+  "did you mean to use 'typename'?">;
 }
 
 let CategoryName = "Coroutines Issue" in {

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=324607&r1=324606&r2=324607&view=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Feb  8 06:37:58 2018
@@ -488,6 +488,20 @@ NamedDecl *Parser::ParseTemplateParamete
   if (Tok.is(tok::kw_template))
 return ParseTemplateTemplateParameter(Depth, Position);
 
+  // Is there just a typo in the input code? ('typedef' instead of 'typename')
+  if (Tok.is(tok::kw_typedef)) {
+Diag(Tok.getLocation(), diag::err_expected_template_parameter);
+
+Diag(Tok.getLocation(), diag::note_meant_to_use_typename)
+<< FixItHint::CreateReplacement(CharSourceRange::getCharRange(
+Tok.getLocation(), 
Tok.getEndLoc()),
+"typename");
+
+Tok.setKind(tok::kw_typename);
+
+return ParseTypeParameter(Depth, Position);
+  }
+
   // If it's none of the above, then it must be a parameter declaration.
   // NOTE: This will pick up errors in the closure of the template parameter
   // list (e.g., template < ; Check here to implement >> style closures.

Modified: cfe/trunk/test/CXX/temp/temp.param/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p2.cpp?rev=324607&r1=324606&r2=324607&view=diff
==
--- cfe/trunk/test/CXX/temp/temp.param/p2.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.param/p2.cpp Thu Feb  8 06:37:58 2018
@@ -15,29 +15,29 @@ template::type
 
 // A storage class shall not be specified in a template-parameter declaration.
 template struct Z; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error2{{invalid 
declaration specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0;  //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
+template struct Z0; //expected-error{{expected template 
parameter}} expected-error{{expected identifier}} expected-error{{extraneous 
'template<>' in declaration of struct 'Z0'}} expected-note{{did you mean to use 
'typename'?}}
+template struct Z1; //expected-error2{{invalid 
declaration specifier}}
+template struct Z2; //expected-error{{invalid declaration 
specifier}}
+template struct Z3; //expected-error{{invalid declaration 
specifier}}
+template struct Z4; //expected-error{{invalid declaration 
specifier}}
+template struct Z5; //expected-error{{invalid declaration 
specifier}}
+template struct Z6;  //expected-error{{invalid declaration 
specifier}}
+template struct Z7; //expected-error{{invalid declaration 
specifier}}
+template struct Z8; //expected-error{{invalid declaration 
specifier}}
 
-template struct Z0; // OK 
-template struct Z0; // OK
+template struct Z9; // OK
+template struct Z10; // OK
 
 
 
 #ifdef CPP11
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
-template struct Z0; //expected-error{{invalid declaration 
specifier}}
+template struct Z11; //expected-error{{invalid declaration 
specifier}}
+template struct Z12; //expected-error{{invalid declara

r327313 - [Driver] Add text description of --help-hidden so it is shown in help

2018-03-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 12 11:33:55 2018
New Revision: 327313

URL: http://llvm.org/viewvc/llvm-project?rev=327313&view=rev
Log:
[Driver] Add text description of --help-hidden so it is shown in help

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=327313&r1=327312&r2=327313&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Mar 12 11:33:55 2018
@@ -2401,7 +2401,8 @@ def _for_linker_EQ : Joined<["--"], "for
 def _for_linker : Separate<["--"], "for-linker">, Alias;
 def _force_link_EQ : Joined<["--"], "force-link=">, Alias;
 def _force_link : Separate<["--"], "force-link">, Alias;
-def _help_hidden : Flag<["--"], "help-hidden">;
+def _help_hidden : Flag<["--"], "help-hidden">,
+  HelpText<"Display help for hidden options">;
 def _imacros_EQ : Joined<["--"], "imacros=">, Alias;
 def _include_barrier : Flag<["--"], "include-barrier">, Alias;
 def _include_directory_after_EQ : Joined<["--"], "include-directory-after=">, 
Alias;


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


r327735 - [Parser] Remove hard-coded bracket depth limit

2018-03-16 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Mar 16 13:17:28 2018
New Revision: 327735

URL: http://llvm.org/viewvc/llvm-project?rev=327735&view=rev
Log:
[Parser] Remove hard-coded bracket depth limit

The diagnostics produced if assert fails are using proper limit from language 
definition already.

Modified:
cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h?rev=327735&r1=327734&r2=327735&view=diff
==
--- cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h (original)
+++ cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h Fri Mar 16 13:17:28 
2018
@@ -378,8 +378,6 @@ namespace clang {
   }
 }
 
-enum { MaxDepth = 256 };
-
 bool diagnoseOverflow();
 bool diagnoseMissingClose();
 

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=327735&r1=327734&r2=327735&view=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Fri Mar 16 13:17:28 2018
@@ -2250,7 +2250,7 @@ bool BalancedDelimiterTracker::expectAnd
 return true;
   }
 
-  if (getDepth() < MaxDepth)
+  if (getDepth() < P.getLangOpts().BracketDepth)
 return false;
 
   return diagnoseOverflow();


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


[clang-tools-extra] r327901 - [clangd][nfc] Give name to a magic constant

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:15 2018
New Revision: 327901

URL: http://llvm.org/viewvc/llvm-project?rev=327901&view=rev
Log:
[clangd][nfc] Give name to a magic constant

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

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327901&r1=327900&r2=327901&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:15 2018
@@ -56,16 +56,18 @@ public:
   }
 
 private:
+  static constexpr unsigned HashByteLength = 20;
+
   friend llvm::hash_code hash_value(const SymbolID &ID) {
 // We already have a good hash, just return the first bytes.
-static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
 return *reinterpret_cast(ID.HashValue.data());
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);
   friend void operator>>(llvm::StringRef Str, SymbolID &ID);
 
-  std::array HashValue;
+  std::array HashValue;
 };
 
 // Write SymbolID into the given stream. SymbolID is encoded as a 40-bytes


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


[clang-tools-extra] r327902 - [clangd] Fix undefined behavior due to misaligned type cast

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:18 2018
New Revision: 327902

URL: http://llvm.org/viewvc/llvm-project?rev=327902&view=rev
Log:
[clangd] Fix undefined behavior due to misaligned type cast

The current code was casting pointer to a misaligned type which is undefined 
behavior.
Found by compiling with Undefined Behavior Sanitizer and running tests 
(check-clang-tools).

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

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327902&r1=327901&r2=327902&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:18 2018
@@ -61,7 +61,9 @@ private:
   friend llvm::hash_code hash_value(const SymbolID &ID) {
 // We already have a good hash, just return the first bytes.
 static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
-return *reinterpret_cast(ID.HashValue.data());
+size_t Result;
+memcpy(&Result, ID.HashValue.data(), sizeof(size_t));
+return llvm::hash_code(Result);
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);


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


r334062 - [Sema] Fix parsing of anonymous union in language linkage specification

2018-06-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jun  5 22:16:34 2018
New Revision: 334062

URL: http://llvm.org/viewvc/llvm-project?rev=334062&view=rev
Log:
[Sema] Fix parsing of anonymous union in language linkage specification

C++17 [dcl.link]p4:
A linkage specification does not establish a scope.

C++17 [class.union.anon]p2:
Namespace level anonymous unions shall be declared static.

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

rdar://problem/37545925

Added:
cfe/trunk/test/SemaCXX/anonymous-union-export.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/anonymous-union.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=334062&r1=334061&r2=334062&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun  5 22:16:34 2018
@@ -4642,12 +4642,14 @@ Decl *Sema::BuildAnonymousStructOrUnion(
 unsigned DiagID;
 if (Record->isUnion()) {
   // C++ [class.union]p6:
+  // C++17 [class.union.anon]p2:
   //   Anonymous unions declared in a named namespace or in the
   //   global namespace shall be declared static.
+  DeclContext *OwnerScope = Owner->getRedeclContext();
   if (DS.getStorageClassSpec() != DeclSpec::SCS_static &&
-  (isa(Owner) ||
-   (isa(Owner) &&
-cast(Owner)->getDeclName( {
+  (OwnerScope->isTranslationUnit() ||
+   (OwnerScope->isNamespace() &&
+!cast(OwnerScope)->isAnonymousNamespace( {
 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
   << FixItHint::CreateInsertion(Record->getLocation(), "static ");
 

Added: cfe/trunk/test/SemaCXX/anonymous-union-export.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/anonymous-union-export.cpp?rev=334062&view=auto
==
--- cfe/trunk/test/SemaCXX/anonymous-union-export.cpp (added)
+++ cfe/trunk/test/SemaCXX/anonymous-union-export.cpp Tue Jun  5 22:16:34 2018
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++17 -fmodules-ts -emit-obj -verify %s
+
+export module M;
+export {
+union { bool a; }; // expected-error{{anonymous unions at namespace or 
global scope must be declared 'static'}}
+}

Modified: cfe/trunk/test/SemaCXX/anonymous-union.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/anonymous-union.cpp?rev=334062&r1=334061&r2=334062&view=diff
==
--- cfe/trunk/test/SemaCXX/anonymous-union.cpp (original)
+++ cfe/trunk/test/SemaCXX/anonymous-union.cpp Tue Jun  5 22:16:34 2018
@@ -80,6 +80,10 @@ union { // expected-error{{anonymous uni
   float float_val;
 };
 
+extern "C++" {
+union { }; // expected-error{{anonymous unions at namespace or global scope 
must be declared 'static'}}
+}
+
 static union {
   int int_val2; // expected-note{{previous definition is here}}
   float float_val2;


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


[clang-tools-extra] r351280 - [clangd] XPC transport layer

2019-01-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jan 15 16:24:22 2019
New Revision: 351280

URL: http://llvm.org/viewvc/llvm-project?rev=351280&view=rev
Log:
[clangd] XPC transport layer

- New transport layer for macOS.
- XPC Framework
- Test client

Framework and client were written by Alex Lorenz.

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

Added:
clang-tools-extra/trunk/clangd/Features.inc.in
clang-tools-extra/trunk/clangd/xpc/
clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt
clang-tools-extra/trunk/clangd/xpc/Conversion.cpp
clang-tools-extra/trunk/clangd/xpc/Conversion.h
clang-tools-extra/trunk/clangd/xpc/README.txt
clang-tools-extra/trunk/clangd/xpc/XPCTransport.cpp
clang-tools-extra/trunk/clangd/xpc/cmake/
clang-tools-extra/trunk/clangd/xpc/cmake/Info.plist.in
clang-tools-extra/trunk/clangd/xpc/cmake/XPCServiceInfo.plist.in
clang-tools-extra/trunk/clangd/xpc/cmake/modules/

clang-tools-extra/trunk/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
clang-tools-extra/trunk/clangd/xpc/framework/
clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt
clang-tools-extra/trunk/clangd/xpc/framework/ClangdXPC.cpp
clang-tools-extra/trunk/clangd/xpc/test-client/
clang-tools-extra/trunk/clangd/xpc/test-client/CMakeLists.txt
clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp
clang-tools-extra/trunk/test/clangd/xpc/
clang-tools-extra/trunk/test/clangd/xpc/initialize.test
clang-tools-extra/trunk/unittests/clangd/xpc/
clang-tools-extra/trunk/unittests/clangd/xpc/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/xpc/ConversionTests.cpp
Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Transport.h
clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/test/lit.cfg
clang-tools-extra/trunk/test/lit.site.cfg.in
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=351280&r1=351279&r2=351280&view=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Tue Jan 15 16:24:22 2019
@@ -1,3 +1,8 @@
+option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF)
+if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE)
+endif ()
+
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-reorder-fields)
 add_subdirectory(modularize)

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=351280&r1=351279&r2=351280&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Jan 15 16:24:22 2019
@@ -1,3 +1,11 @@
+# Configure the Features.inc file.
+llvm_canonicalize_cmake_booleans(
+  CLANGD_BUILD_XPC)
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Features.inc
+)
+
 set(LLVM_LINK_COMPONENTS
   Support
   )
@@ -109,3 +117,6 @@ add_subdirectory(index/dex/dexp)
 if (LLVM_INCLUDE_BENCHMARKS)
   add_subdirectory(benchmarks)
 endif()
+if ( CLANGD_BUILD_XPC )
+  add_subdirectory(xpc)
+endif ()

Added: clang-tools-extra/trunk/clangd/Features.inc.in
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Features.inc.in?rev=351280&view=auto
==
--- clang-tools-extra/trunk/clangd/Features.inc.in (added)
+++ clang-tools-extra/trunk/clangd/Features.inc.in Tue Jan 15 16:24:22 2019
@@ -0,0 +1 @@
+#define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@

Modified: clang-tools-extra/trunk/clangd/Transport.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Transport.h?rev=351280&r1=351279&r2=351280&view=diff
==
--- clang-tools-extra/trunk/clangd/Transport.h (original)
+++ clang-tools-extra/trunk/clangd/Transport.h Tue Jan 15 16:24:22 2019
@@ -86,6 +86,12 @@ newJSONTransport(std::FILE *In, llvm::ra
  llvm::raw_ostream *InMirror, bool Pretty,
  JSONStreamStyle = JSONStreamStyle::Standard);
 
+#ifdef CLANGD_BUILD_XPC
+// Returns a Transport for macOS based on XPC.
+// Clangd with this transport is meant to be run as bundled XPC service.
+std::unique_ptr newXPCTransport();
+#endif
+
 } // namespace clangd
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-pro

[clang-tools-extra] r347674 - [clangd][NFC] Move SymbolID to a separate file

2018-11-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Nov 27 08:40:34 2018
New Revision: 347674

URL: http://llvm.org/viewvc/llvm-project?rev=347674&view=rev
Log:
[clangd][NFC] Move SymbolID to a separate file

Prerequisity for textDocument/SymbolInfo

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

Added:
clang-tools-extra/trunk/clangd/index/SymbolID.cpp
clang-tools-extra/trunk/clangd/index/SymbolID.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=347674&r1=347673&r2=347674&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Nov 27 08:40:34 2018
@@ -46,6 +46,7 @@ add_clang_library(clangDaemon
   index/IndexAction.cpp
   index/MemIndex.cpp
   index/Merge.cpp
+  index/SymbolID.cpp
   index/Serialization.cpp
   index/SymbolCollector.cpp
   index/YAMLSerialization.cpp

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=347674&r1=347673&r2=347674&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Tue Nov 27 08:40:34 2018
@@ -25,6 +25,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
 
 #include "URI.h"
+#include "index/SymbolID.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/JSON.h"
 #include 

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=347674&r1=347673&r2=347674&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Tue Nov 27 08:40:34 2018
@@ -12,7 +12,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -43,34 +42,6 @@ raw_ostream &operator<<(raw_ostream &OS,
 << "-" << L.End.line() << ":" << L.End.column() << ")";
 }
 
-SymbolID::SymbolID(StringRef USR) {
-  auto Hash = SHA1::hash(arrayRefFromStringRef(USR));
-  static_assert(sizeof(Hash) >= RawSize, "RawSize larger than SHA1");
-  memcpy(HashValue.data(), Hash.data(), RawSize);
-}
-
-raw_ostream &operator<<(raw_ostream &OS, const SymbolID &ID) {
-  return OS << toHex(ID.raw());
-}
-
-SymbolID SymbolID::fromRaw(StringRef Raw) {
-  SymbolID ID;
-  assert(Raw.size() == RawSize);
-  memcpy(ID.HashValue.data(), Raw.data(), RawSize);
-  return ID;
-}
-
-std::string SymbolID::str() const { return toHex(raw()); }
-
-Expected SymbolID::fromStr(StringRef Str) {
-  if (Str.size() != RawSize * 2)
-return createStringError(inconvertibleErrorCode(), "Bad ID length");
-  for (char C : Str)
-if (!isHexDigit(C))
-  return createStringError(inconvertibleErrorCode(), "Bad hex ID");
-  return fromRaw(fromHex(Str));
-}
-
 raw_ostream &operator<<(raw_ostream &OS, SymbolOrigin O) {
   if (O == SymbolOrigin::Unknown)
 return OS << "unknown";

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=347674&r1=347673&r2=347674&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Tue Nov 27 08:40:34 2018
@@ -11,11 +11,11 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
 
 #include "ExpectedTypes.h"
+#include "SymbolID.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -95,53 +95,6 @@ inline bool operator<(const SymbolLocati
 }
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolLocation &);
 
-// The class identifies a particular C++ symbol (class, function, method, etc).
-//
-// As USRs (Unified Symbol Resolution) could be large, especially for functions
-// with long type arguments, SymbolID is using truncated SHA1(USR) values to
-// guarantee the uniqueness of symbols while using a relatively small amount of
-// memory (vs storing USRs directly).
-//
-// SymbolID can be used as key in the symbol indexes to lookup the symbol.
-class SymbolID {
-public:
-  SymbolID() = default;
-  explicit SymbolID(llvm::Stri

[clang-tools-extra] r347675 - [clangd] textDocument/SymbolInfo extension

2018-11-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Nov 27 08:40:46 2018
New Revision: 347675

URL: http://llvm.org/viewvc/llvm-project?rev=347675&view=rev
Log:
[clangd] textDocument/SymbolInfo extension

New method returning symbol info for given source position.

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

rdar://problem/46050281

Added:
clang-tools-extra/trunk/test/clangd/symbol-info.test
clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/XRefs.h
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=347675&r1=347674&r2=347675&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Nov 27 08:40:46 2018
@@ -698,6 +698,12 @@ void ClangdLSPServer::onReference(const
  std::move(Reply));
 }
 
+void ClangdLSPServer::onSymbolInfo(const TextDocumentPositionParams &Params,
+   Callback> Reply) 
{
+  Server->symbolInfo(Params.textDocument.uri.file(), Params.position,
+ std::move(Reply));
+}
+
 ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
  const clangd::CodeCompleteOptions &CCOpts,
  Optional CompileCommandsDir,
@@ -733,6 +739,7 @@ ClangdLSPServer::ClangdLSPServer(class T
   MsgHandler->bind("textDocument/didChange", 
&ClangdLSPServer::onDocumentDidChange);
   MsgHandler->bind("workspace/didChangeWatchedFiles", 
&ClangdLSPServer::onFileEvent);
   MsgHandler->bind("workspace/didChangeConfiguration", 
&ClangdLSPServer::onChangeConfiguration);
+  MsgHandler->bind("textDocument/symbolInfo", &ClangdLSPServer::onSymbolInfo);
   // clang-format on
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=347675&r1=347674&r2=347675&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Nov 27 08:40:46 2018
@@ -92,6 +92,8 @@ private:
   void onHover(const TextDocumentPositionParams &,
Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
+  void onSymbolInfo(const TextDocumentPositionParams &,
+Callback>);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic &D);
 

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=347675&r1=347674&r2=347675&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Nov 27 08:40:46 2018
@@ -503,6 +503,18 @@ void ClangdServer::findReferences(PathRe
   WorkScheduler.runWithAST("References", File, Bind(Action, std::move(CB)));
 }
 
+void ClangdServer::symbolInfo(PathRef File, Position Pos,
+  Callback> CB) {
+  auto Action = [Pos](Callback> CB,
+  Expected InpAST) {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::getSymbolInfo(InpAST->AST, Pos));
+  };
+
+  WorkScheduler.runWithAST("SymbolInfo", File, Bind(Action, std::move(CB)));
+}
+
 std::vector>
 ClangdServer::getUsedBytesPerFile() const {
   return WorkScheduler.getUsedBytesPerFile();

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=347675&r1=347674&r2=347675&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Tue Nov 27 08:40:46 2018
@@ -202,6 +202,11 @@ public:
   /// Called when an event occurs for a watched file in the workspace.
   void onFileEvent(const DidChangeWatchedFilesParams &Params);
 
+  /// Get symbol info for given position.
+  /// Clangd extension - not part of official LSP.
+  void symbolInfo(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
  

Re: [clang-tools-extra] r347675 - [clangd] textDocument/SymbolInfo extension

2018-11-28 Thread Jan Korous via cfe-commits
h:329:42: note: candidate template ignored:
>> disabled by 'enable_if' [with T = llvm::json::Object]
>>   typename = typename std::enable_if> bool>::value>::type,
>>  ^
>> ../include/llvm/Support/JSON.h:337:42: note: candidate template ignored:
>> disabled by 'enable_if' [with T = llvm::json::Object]
>>   typename = typename std::enable_if::value>::type,
>>  ^
>> ../include/llvm/Support/JSON.h:345:41: note: candidate template ignored:
>> disabled by 'enable_if' [with T = llvm::json::Object]
>> typename
>> std::enable_if::value>::type,
>> ^
>> ../include/llvm/Support/JSON.h:355:3: note: candidate template ignored:
>> substitution failure [with T = llvm::json::Object]: no matching function
>> for call to 'toJSON'
>>   Value(const T &V) : Value(toJSON(V)) {}
>>   ^
>> 1 error generated.
>> 
>> ---
>> 
>> It looks very similar to a problem that was fixed in r347539:
>> 
>> -  return Result;
>> +  // Older gcc cannot compile 'return Result', even though it is legal.
>> +  return json::Value(std::move(Result));
>> 
>> Regards,
>> Mikael
>> 
>> On 11/27/18 5:40 PM, Jan Korous via cfe-commits wrote:
>>> Author: jkorous
>>> Date: Tue Nov 27 08:40:46 2018
>>> New Revision: 347675
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=347675&view=rev
>>> Log:
>>> [clangd] textDocument/SymbolInfo extension
>>> 
>>> New method returning symbol info for given source position.
>>> 
>>> Differential Revision: https://reviews.llvm.org/D54799
>>> 
>>> rdar://problem/46050281
>>> 
>>> Added:
>>> clang-tools-extra/trunk/test/clangd/symbol-info.test
>>> clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
>>> Modified:
>>> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>>> clang-tools-extra/trunk/clangd/ClangdLSPServer.h
>>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> clang-tools-extra/trunk/clangd/ClangdServer.h
>>> clang-tools-extra/trunk/clangd/Protocol.cpp
>>> clang-tools-extra/trunk/clangd/Protocol.h
>>> clang-tools-extra/trunk/clangd/XRefs.cpp
>>> clang-tools-extra/trunk/clangd/XRefs.h
>>> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
>>> 
>>> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=347675&r1=347674&r2=347675&view=diff
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Nov 27 08:40:46 
>>> 2018
>>> @@ -698,6 +698,12 @@ void ClangdLSPServer::onReference(const
>>>   std::move(Reply));
>>>  }
>>> 
>>> +void ClangdLSPServer::onSymbolInfo(const TextDocumentPositionParams 
>>> &Params,
>>> +   Callback> 
>>> Reply) {
>>> +  Server->symbolInfo(Params.textDocument.uri.file(), Params.position,
>>> + std::move(Reply));
>>> +}
>>> +
>>>  ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
>>>   const clangd::CodeCompleteOptions &CCOpts,
>>>   Optional CompileCommandsDir,
>>> @@ -733,6 +739,7 @@ ClangdLSPServer::ClangdLSPServer(class T
>>>MsgHandler->bind("textDocument/didChange", 
>>> &ClangdLSPServer::onDocumentDidChange);
>>>MsgHandler->bind("workspace/didChangeWatchedFiles", 
>>> &ClangdLSPServer::onFileEvent);
>>>MsgHandler->bind("workspace/didChangeConfiguration", 
>>> &ClangdLSPServer::onChangeConfiguration);
>>> +  MsgHandler->bind("textDocument/symbolInfo", 
>>> &ClangdLSPServer::onSymbolInfo);
>>>// clang-format on
>>>  }
>>> 
>>> 
>>> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=347675&r1=347674&r2=347675&view=diff
>&g

[clang-tools-extra] r347738 - [clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo

2018-11-28 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Nov 28 02:24:07 2018
New Revision: 347738

URL: http://llvm.org/viewvc/llvm-project?rev=347738&view=rev
Log:
[clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo

Apparently clang 3.6 couldn't build the preceding patch.

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

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=347738&r1=347737&r2=347738&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Wed Nov 28 02:24:07 2018
@@ -453,7 +453,8 @@ llvm::json::Value toJSON(const SymbolDet
   if (P.ID.hasValue())
 result["id"] = P.ID.getValue().str();
 
-  return result;
+  // Older clang cannot compile 'return Result', even though it is legal.
+  return json::Value(std::move(result));
 }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {


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


Re: [clang-tools-extra] r347675 - [clangd] textDocument/SymbolInfo extension

2018-11-28 Thread Jan Korous via cfe-commits
 >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:299:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'json::Object &&' 
> > > >>> for
> > > >>> 1st argument
> > > >>>   Value(json::Object &&Properties) : Type(T_Object) {
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:305:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'std::string' (aka
> > > >>> 'basic_string') for 1st argument
> > > >>>   Value(std::string V) : Type(T_String) {
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:312:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'const
> > > >>> llvm::SmallVectorImpl &' for 1st argument
> > > >>>   Value(const llvm::SmallVectorImpl &V)
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:314:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'const
> > > >>> llvm::formatv_object_base &' for 1st argument
> > > >>>   Value(const llvm::formatv_object_base &V) : Value(V.str()){};
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:316:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'llvm::StringRef' 
> > > >>> for
> > > >>> 1st argument
> > > >>>   Value(StringRef V) : Type(T_StringRef) {
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:323:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'const char *' for
> > > >>> 1st argument
> > > >>>   Value(const char *V) : Value(StringRef(V)) {}
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:324:3: note: candidate constructor not
> > > >>> viable: no known conversion from 'json::Object' to 'std::nullptr_t' 
> > > >>> (aka
> > > >>> 'nullptr_t') for 1st argument
> > > >>>   Value(std::nullptr_t) : Type(T_Null) {}
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:298:3: note: candidate template 
> > > >>> ignored:
> > > >>> could not match 'vector > > >>> allocator >' against 'llvm::json::Object'
> > > >>>   Value(const std::vector &C) : Value(json::Array(C)) {}
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:303:3: note: candidate template 
> > > >>> ignored:
> > > >>> could not match 'map, type-parameter-0-0,
> > > >>> std::less >, allocator > > >>> std::basic_string, type-parameter-0-0> > >' against
> > > >>> 'llvm::json::Object'
> > > >>>   Value(const std::map &C) : Value(json::Object(C)) 
> > > >>> {}
> > > >>>   ^
> > > >>> ../include/llvm/Support/JSON.h:329:42: note: candidate template 
> > > >>> ignored:
> > > >>> disabled by 'enable_if' [with T = llvm::json::Object]
> > > >>>   typename = typename std::enable_if > > >>> bool>::value>::type,
> > > >>>  ^
> > > >>> ../include/llvm/Support/JSON.h:337:42: note: candidate template 
> > > >>> ignored:
> > > >>> disabled by 'enable_if' [with T = llvm::json::Object]
> > > >>>   typename = typename
> > > >>> std::enable_if::value>::type,
> > > >>>  ^
> > > >>> ../include/llvm/Support/JSON.h:345:41: note: candidate template 
> > > >>> ignored:
> > > >>> disabled by 'enable_if' [with T = llvm::json::Object]
> > > >>> typename
> > > >>> std::enable_if::value>::type,
> > > >>>  

r348379 - [NFC] Use clang-format on PrintingPolicy::PrintingPolicy() after fd5c386f743

2018-12-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Dec  5 08:19:49 2018
New Revision: 348379

URL: http://llvm.org/viewvc/llvm-project?rev=348379&view=rev
Log:
[NFC] Use clang-format on PrintingPolicy::PrintingPolicy() after fd5c386f743

The white-space change was causing conflicts downstream.

rdar://problem/46486841

Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=348379&r1=348378&r2=348379&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Wed Dec  5 08:19:49 2018
@@ -38,21 +38,19 @@ public:
 struct PrintingPolicy {
   /// Create a default printing policy for the specified language.
   PrintingPolicy(const LangOptions &LO)
-: Indentation(2), SuppressSpecifiers(false),
-  SuppressTagKeyword(LO.CPlusPlus),
-  IncludeTagDefinition(false), SuppressScope(false),
-  SuppressUnwrittenScope(false), SuppressInitializers(false),
-  ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
-  SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
-  SuppressTemplateArgsInCXXConstructors(false),
-  Bool(LO.Bool), Restrict(LO.C99),
-  Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
-  UseVoidForZeroParams(!LO.CPlusPlus),
-  TerseOutput(false), PolishForDeclaration(false),
-  Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
-  IncludeNewlines(true), MSVCFormatting(false),
-  ConstantsAsWritten(false), SuppressImplicitBase(false),
-  FullyQualifiedName(false) { }
+  : Indentation(2), SuppressSpecifiers(false),
+SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
+SuppressScope(false), SuppressUnwrittenScope(false),
+SuppressInitializers(false), ConstantArraySizeAsWritten(false),
+AnonymousTagLocations(true), SuppressStrongLifetime(false),
+SuppressLifetimeQualifiers(false),
+SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
+Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
+UseVoidForZeroParams(!LO.CPlusPlus), TerseOutput(false),
+PolishForDeclaration(false), Half(LO.Half),
+MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
+MSVCFormatting(false), ConstantsAsWritten(false),
+SuppressImplicitBase(false), FullyQualifiedName(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only


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


[clang-tools-extra] r354949 - [clangd] Library dependencies in XPC

2019-02-26 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Feb 26 18:37:44 2019
New Revision: 354949

URL: http://llvm.org/viewvc/llvm-project?rev=354949&view=rev
Log:
[clangd] Library dependencies in XPC

Patch by Nicholas Allegra

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

Modified:
clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt?rev=354949&r1=354948&r2=354949&view=diff
==
--- clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt Tue Feb 26 18:37:44 2019
@@ -20,10 +20,10 @@ set(LLVM_OPTIONAL_SOURCES Conversion.cpp
 
 add_clang_library(clangdXpcJsonConversions
   Conversion.cpp
+  LINK_LIBS clangDaemon
   )
 
 add_clang_library(clangdXpcTransport
   XPCTransport.cpp
-  DEPENDS clangdXpcJsonConversions
-  LINK_LIBS clangdXpcJsonConversions
+  LINK_LIBS clangDaemon clangdXpcJsonConversions
   )


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


r355035 - [clang][index-while-building] FileIndexRecord

2019-02-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Feb 27 13:47:40 2019
New Revision: 355035

URL: http://llvm.org/viewvc/llvm-project?rev=355035&view=rev
Log:
[clang][index-while-building] FileIndexRecord

Basic data structures for index

Tests are missing from this patch - will be covered properly by tests for the 
whole feature.
I'm just trying to split into smaller patches to make it easier for reviewers.

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

Added:
cfe/trunk/include/clang/Index/DeclOccurrence.h
cfe/trunk/lib/Index/FileIndexRecord.cpp
cfe/trunk/lib/Index/FileIndexRecord.h
Modified:
cfe/trunk/lib/Index/CMakeLists.txt

Added: cfe/trunk/include/clang/Index/DeclOccurrence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/DeclOccurrence.h?rev=355035&view=auto
==
--- cfe/trunk/include/clang/Index/DeclOccurrence.h (added)
+++ cfe/trunk/include/clang/Index/DeclOccurrence.h Wed Feb 27 13:47:40 2019
@@ -0,0 +1,42 @@
+//===--- DeclOccurrence.h - An occurrence of a decl within a file 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
+#define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+class Decl;
+
+namespace index {
+
+struct DeclOccurrence {
+  SymbolRoleSet Roles;
+  unsigned Offset;
+  const Decl *Dcl;
+  SmallVector Relations;
+
+  DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
+ ArrayRef Relations)
+  : Roles(R), Offset(Offset), Dcl(D),
+Relations(Relations.begin(), Relations.end()) {}
+
+  friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
+return LHS.Offset < RHS.Offset;
+  }
+};
+
+} // namespace index
+} // namespace clang
+
+#endif

Modified: cfe/trunk/lib/Index/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CMakeLists.txt?rev=355035&r1=355034&r2=355035&view=diff
==
--- cfe/trunk/lib/Index/CMakeLists.txt (original)
+++ cfe/trunk/lib/Index/CMakeLists.txt Wed Feb 27 13:47:40 2019
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangIndex
   CodegenNameGenerator.cpp
   CommentToXML.cpp
+  FileIndexRecord.cpp
   IndexBody.cpp
   IndexDecl.cpp
   IndexingAction.cpp

Added: cfe/trunk/lib/Index/FileIndexRecord.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/FileIndexRecord.cpp?rev=355035&view=auto
==
--- cfe/trunk/lib/Index/FileIndexRecord.cpp (added)
+++ cfe/trunk/lib/Index/FileIndexRecord.cpp Wed Feb 27 13:47:40 2019
@@ -0,0 +1,59 @@
+//===--- FileIndexRecord.cpp - Index data per file 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FileIndexRecord.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclTemplate.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang;
+using namespace clang::index;
+
+void FileIndexRecord::addDeclOccurence(SymbolRoleSet Roles, unsigned Offset,
+   const Decl *D,
+   ArrayRef Relations) {
+  assert(D->isCanonicalDecl() &&
+ "Occurrences should be associated with their canonical decl");
+
+  auto IsNextOccurence = [&]() -> bool {
+if (Decls.empty())
+  return true;
+auto &Last = Decls.back();
+return Last.Offset < Offset;
+  };
+
+  if (IsNextOccurence()) {
+Decls.emplace_back(Roles, Offset, D, Relations);
+return;
+  }
+
+  DeclOccurrence NewInfo(Roles, Offset, D, Relations);
+  auto It = std::upper_bound(Decls.begin(), Decls.end(), NewInfo);
+  Decls.insert(It, std::move(NewInfo));
+}
+
+void FileIndexRecord::print(llvm::raw_ostream &OS) const {
+  OS << "DECLS BEGIN ---\n";
+  for (auto &DclInfo : Decls) {
+auto D = DclInfo.Dcl;
+SourceManager &SM = D->getASTContext().getSourceManager();
+SourceLocation Loc = SM.getFileLoc(D->getLocation());
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+OS << llvm::sys::path::filename(PLoc.getFilename()) << ':' << 
PLoc.getLine()
+   << ':' << PLoc.getColumn();
+
+if (auto ND = dyn_cast(D)) {
+  OS << ' ' << ND->getNameAsString();
+}
+
+OS << '\n';
+  }
+  OS << "DECLS END ---\n";
+}

Add

r355036 - [clang][index-while-building][NFC] FileIndexRecord - Comments, replace auto with type

2019-02-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Feb 27 13:48:02 2019
New Revision: 355036

URL: http://llvm.org/viewvc/llvm-project?rev=355036&view=rev
Log:
[clang][index-while-building][NFC] FileIndexRecord - Comments, replace auto 
with type

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

Modified:
cfe/trunk/include/clang/Index/DeclOccurrence.h
cfe/trunk/lib/Index/FileIndexRecord.cpp
cfe/trunk/lib/Index/FileIndexRecord.h

Modified: cfe/trunk/include/clang/Index/DeclOccurrence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/DeclOccurrence.h?rev=355036&r1=355035&r2=355036&view=diff
==
--- cfe/trunk/include/clang/Index/DeclOccurrence.h (original)
+++ cfe/trunk/include/clang/Index/DeclOccurrence.h Wed Feb 27 13:48:02 2019
@@ -1,9 +1,8 @@
-//===--- DeclOccurrence.h - An occurrence of a decl within a file 
-===//
+//===- DeclOccurrence.h - An occurrence of a decl within a file -*- C++ 
-*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
 
@@ -39,4 +38,4 @@ struct DeclOccurrence {
 } // namespace index
 } // namespace clang
 
-#endif
+#endif // LLVM_CLANG_INDEX_DECLOCCURRENCE_H

Modified: cfe/trunk/lib/Index/FileIndexRecord.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/FileIndexRecord.cpp?rev=355036&r1=355035&r2=355036&view=diff
==
--- cfe/trunk/lib/Index/FileIndexRecord.cpp (original)
+++ cfe/trunk/lib/Index/FileIndexRecord.cpp Wed Feb 27 13:48:02 2019
@@ -1,4 +1,4 @@
-//===--- FileIndexRecord.cpp - Index data per file 
===//
+//===--- FileIndexRecord.cpp - Index data per file --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -42,7 +42,7 @@ void FileIndexRecord::addDeclOccurence(S
 void FileIndexRecord::print(llvm::raw_ostream &OS) const {
   OS << "DECLS BEGIN ---\n";
   for (auto &DclInfo : Decls) {
-auto D = DclInfo.Dcl;
+const Decl *D = DclInfo.Dcl;
 SourceManager &SM = D->getASTContext().getSourceManager();
 SourceLocation Loc = SM.getFileLoc(D->getLocation());
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);

Modified: cfe/trunk/lib/Index/FileIndexRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/FileIndexRecord.h?rev=355036&r1=355035&r2=355036&view=diff
==
--- cfe/trunk/lib/Index/FileIndexRecord.h (original)
+++ cfe/trunk/lib/Index/FileIndexRecord.h Wed Feb 27 13:48:02 2019
@@ -1,9 +1,8 @@
-//===--- FileIndexRecord.h - Index data per file 
--===//
+//===--- FileIndexRecord.h - Index data per file *- C++ 
-*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
 
@@ -55,4 +54,4 @@ public:
 } // end namespace index
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H


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


r355061 - [clang][index-while-building][NFC] Comment about implementation detail in FileIndexRecord

2019-02-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Feb 27 17:12:27 2019
New Revision: 355061

URL: http://llvm.org/viewvc/llvm-project?rev=355061&view=rev
Log:
[clang][index-while-building][NFC] Comment about implementation detail in 
FileIndexRecord

Modified:
cfe/trunk/lib/Index/FileIndexRecord.cpp

Modified: cfe/trunk/lib/Index/FileIndexRecord.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/FileIndexRecord.cpp?rev=355061&r1=355060&r2=355061&view=diff
==
--- cfe/trunk/lib/Index/FileIndexRecord.cpp (original)
+++ cfe/trunk/lib/Index/FileIndexRecord.cpp Wed Feb 27 17:12:27 2019
@@ -35,6 +35,7 @@ void FileIndexRecord::addDeclOccurence(S
   }
 
   DeclOccurrence NewInfo(Roles, Offset, D, Relations);
+  // We keep Decls in order as we need to access them in this order in all 
cases.
   auto It = std::upper_bound(Decls.begin(), Decls.end(), NewInfo);
   Decls.insert(It, std::move(NewInfo));
 }


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


r355365 - [clang-format][docs][NFC] Fix example for Allman brace breaking style

2019-03-04 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar  4 17:45:31 2019
New Revision: 355365

URL: http://llvm.org/viewvc/llvm-project?rev=355365&view=rev
Log:
[clang-format][docs][NFC] Fix example for Allman brace breaking style

I assume the example is wrong as it's clearly missing line-breaks before
braces.

I just ran the example through clang-format with .clang-format like
this:
BreakBeforeBraces: Allman

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=355365&r1=355364&r2=355365&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Mar  4 17:45:31 2019
@@ -925,19 +925,28 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-  try {
+  try
+  {
 foo();
   }
-  catch () {
+  catch ()
+  {
   }
   void foo() { bar(); }
-  class foo {
+  class foo
+  {
   };
-  if (foo()) {
+  if (foo())
+  {
   }
-  else {
+  else
+  {
   }
-  enum X : int { A, B };
+  enum X : int
+  {
+A,
+B
+  };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to


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


r355434 - [clang-format] Fix lambdas returning template specialization that contains operator in parameter

2019-03-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Mar  5 11:27:24 2019
New Revision: 355434

URL: http://llvm.org/viewvc/llvm-project?rev=355434&view=rev
Log:
[clang-format] Fix lambdas returning template specialization that contains 
operator in parameter

A template specialization of a template foo can contain integer 
constants and a whole bunch of operators - e. g.  foo< 1 ? !0 : (3+1)%4 >

Inspired by https://reviews.llvm.org/D58922

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

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=355434&r1=355433&r2=355434&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Mar  5 11:27:24 2019
@@ -1423,6 +1423,25 @@ bool UnwrappedLineParser::tryToParseLamb
 case tok::coloncolon:
 case tok::kw_mutable:
 case tok::kw_noexcept:
+// Specialization of a template with an integer parameter can contain
+// arithmetic, logical, comparison and ternary operators.
+case tok::plus:
+case tok::minus:
+case tok::exclaim:
+case tok::tilde:
+case tok::slash:
+case tok::percent:
+case tok::lessless:
+case tok::pipe:
+case tok::pipepipe:
+case tok::ampamp:
+case tok::caret:
+case tok::equalequal:
+case tok::exclaimequal:
+case tok::greaterequal:
+case tok::lessequal:
+case tok::question:
+case tok::colon:
   nextToken();
   break;
 case tok::arrow:

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=355434&r1=355433&r2=355434&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar  5 11:27:24 2019
@@ -11846,6 +11846,96 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> const D* {};");
   verifyFormat("[a, a]() -> a<1> {};");
+  verifyFormat("[]() -> foo<5 + 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 - 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 / 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 * 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 % 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 << 2> { return {}; };");
+  verifyFormat("[]() -> foo { return {}; };");
+  verifyFormat("[]() -> foo<~5> { return {}; };");
+  verifyFormat("[]() -> foo<5 | 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 || 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 & 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 && 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 == 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 != 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 >= 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 <= 2> { return {}; };");
+  verifyFormat("[]() -> foo<5 < 2> { return {}; };");
+  verifyFormat("[]() -> foo<2 ? 1 : 0> { return {}; };");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 + 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 - 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 / 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 * 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 % 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 << 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<~5> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 | 2> { return {}; }};\n"
+  "} // namespace bar");
+  verifyFormat("namespace bar {\n"
+  "// broken:\n"
+  "auto foo{[]() -> foo<5 || 2> { return {}; }};\n"
+  "} // namespace bar")

[clang-tools-extra] r356974 - [clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC

2019-03-25 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 25 20:48:25 2019
New Revision: 356974

URL: http://llvm.org/viewvc/llvm-project?rev=356974&view=rev
Log:
[clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC

We shouldn't prevent user from disabling XPC framework build on Darwin.
However, by keeping it on by default our CI systems also test
it by default on macOS.

Based on user request:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html

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

Modified:
clang-tools-extra/trunk/CMakeLists.txt

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=356974&r1=356973&r2=356974&view=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Mon Mar 25 20:48:25 2019
@@ -1,6 +1,13 @@
-option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF)
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-  set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE)
+if (NOT DEFINED CLANGD_BUILD_XPC)
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+set(CLANGD_BUILD_XPC_DEFAULT ON)
+  else ()
+set(CLANGD_BUILD_XPC_DEFAULT OFF)
+  endif ()
+
+  set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC 
Support For Clangd." FORCE)
+
+  unset(CLANGD_BUILD_XPC_DEFAULT)
 endif ()
 
 add_subdirectory(clang-apply-replacements)


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


r358133 - [clang][ASTContext] Try to exit early before loading serialized comments from AST files

2019-04-10 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Apr 10 13:23:33 2019
New Revision: 358133

URL: http://llvm.org/viewvc/llvm-project?rev=358133&view=rev
Log:
[clang][ASTContext] Try to exit early before loading serialized comments from 
AST files

Loading external comments is expensive. This change probably doesn't apply to 
common cases but is almost for free and would save some work in case none of 
the declaration needs external comments to be loaded.

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=358133&r1=358132&r2=358133&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Apr 10 13:23:33 2019
@@ -99,20 +99,13 @@ enum FloatingRank {
 };
 
 RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
-  if (!CommentsLoaded && ExternalSource) {
-ExternalSource->ReadComments();
-
-#ifndef NDEBUG
-ArrayRef RawComments = Comments.getComments();
-assert(std::is_sorted(RawComments.begin(), RawComments.end(),
-  BeforeThanCompare(SourceMgr)));
-#endif
-
-CommentsLoaded = true;
-  }
-
   assert(D);
 
+  // If we already tried to load comments but there are none,
+  // we won't find anything.
+  if (CommentsLoaded && Comments.getComments().empty())
+return nullptr;
+
   // User can not attach documentation to implicit declarations.
   if (D->isImplicit())
 return nullptr;
@@ -162,12 +155,6 @@ RawComment *ASTContext::getRawCommentFor
   isa(D))
 return nullptr;
 
-  ArrayRef RawComments = Comments.getComments();
-
-  // If there are no comments anywhere, we won't find anything.
-  if (RawComments.empty())
-return nullptr;
-
   // Find declaration location.
   // For Objective-C declarations we generally don't expect to have multiple
   // declarators, thus use declaration starting location as the "declaration
@@ -206,6 +193,23 @@ RawComment *ASTContext::getRawCommentFor
   if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
 return nullptr;
 
+  if (!CommentsLoaded && ExternalSource) {
+ExternalSource->ReadComments();
+
+#ifndef NDEBUG
+ArrayRef RawComments = Comments.getComments();
+assert(std::is_sorted(RawComments.begin(), RawComments.end(),
+  BeforeThanCompare(SourceMgr)));
+#endif
+
+CommentsLoaded = true;
+  }
+
+  ArrayRef RawComments = Comments.getComments();
+  // If there are no comments anywhere, we won't find anything.
+  if (RawComments.empty())
+return nullptr;
+
   // Find the comment that occurs just after this declaration.
   ArrayRef::iterator Comment;
   {


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


[clang-tools-extra] r359489 - [clangd][xpc] Fix XPC unittests

2019-04-29 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Apr 29 12:41:30 2019
New Revision: 359489

URL: http://llvm.org/viewvc/llvm-project?rev=359489&view=rev
Log:
[clangd][xpc] Fix XPC unittests

Fix build after recent changes in clangd tests & add xpc unittests to
check-clangd target.

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

Modified:
clang-tools-extra/trunk/clangd/test/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/xpc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/test/CMakeLists.txt?rev=359489&r1=359488&r2=359489&view=diff
==
--- clang-tools-extra/trunk/clangd/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/test/CMakeLists.txt Mon Apr 29 12:41:30 2019
@@ -8,6 +8,7 @@ set(CLANGD_TEST_DEPS
 
 if(CLANGD_BUILD_XPC)
   list(APPEND CLANGD_TEST_DEPS clangd-xpc-test-client)
+  list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
 foreach(dep FileCheck count not)

Modified: clang-tools-extra/trunk/clangd/unittests/xpc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/xpc/CMakeLists.txt?rev=359489&r1=359488&r2=359489&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/xpc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/unittests/xpc/CMakeLists.txt Mon Apr 29 
12:41:30 2019
@@ -8,7 +8,8 @@ include_directories(
   ${CLANGD_SOURCE_DIR}
   )
 
-add_extra_unittest(ClangdXpcTests
+add_custom_target(ClangdXpcUnitTests)
+add_unittest(ClangdXpcUnitTests ClangdXpcTests
   ConversionTests.cpp
   )
 


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


[clang-tools-extra] r359824 - [clangd][xpc] Cannonicalize value of CLANGD_BUILD_XPC before caching

2019-05-02 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu May  2 13:32:56 2019
New Revision: 359824

URL: http://llvm.org/viewvc/llvm-project?rev=359824&view=rev
Log:
[clangd][xpc] Cannonicalize value of CLANGD_BUILD_XPC before caching

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=359824&r1=359823&r2=359824&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Thu May  2 13:32:56 2019
@@ -6,6 +6,8 @@ if (NOT DEFINED CLANGD_BUILD_XPC)
 set(CLANGD_BUILD_XPC_DEFAULT OFF)
   endif ()
 
+  llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC_DEFAULT)
+
   set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC 
Support For Clangd." FORCE)
   unset(CLANGD_BUILD_XPC_DEFAULT)
 endif ()


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


r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-14 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Feb 14 15:02:35 2019
New Revision: 354075

URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
Log:
[clang][FileManager] fillRealPathName even if we aren't opening the file

The pathname wasn't previously filled when the getFile() method was called with 
openFile = false.
We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused the 
problem.

This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All

rdar://47536127

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

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
@@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
   if (UFE.File) {
 if (auto PathName = UFE.File->getName())
   fillRealPathName(&UFE, *PathName);
+  } else if (!openFile) {
+// We should still fill the path even if we aren't opening the file.
+fillRealPathName(&UFE, InterndFileName);
   }
   return &UFE;
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
@@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
   EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
+TEST_F(FileManagerTest, getFileDontOpenRealPath) {
+  auto statCache = llvm::make_unique();
+  statCache->InjectDirectory("/tmp/abc", 42);
+  SmallString<64> Path("/tmp/abc/foo.cpp");
+  statCache->InjectFile(Path.str().str().c_str(), 43);
+  manager.setStatCache(std::move(statCache));
+
+  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+
+  ASSERT_TRUE(file != nullptr);
+
+  ASSERT_EQ(file->tryGetRealPathName(), Path);
+}
+
 } // anonymous namespace


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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-18 Thread Jan Korous via cfe-commits
Hi all,

Sorry, my bad, I was out on Friday.

Will re-land patch with fixed test shortly.

Jan

> On Feb 15, 2019, at 12:47 PM, Reid Kleckner  wrote:
> 
> Reverted:
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4351 
> <http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4351>
> On Fri, Feb 15, 2019 at 11:07 AM Galina Kistanova via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hello Jan,
> 
> It looks like this commit broke tests on couple of win builders:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
>  
> <http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win 
> <http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win>
> . . .
> Failing Tests (1):
> Clang-Unit :: 
> Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath
> 
> Please have a look ASAP?
> 
> Thanks
> 
> Galina
> 
> On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=354075&view=rev>
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
> 
> The pathname wasn't previously filled when the getFile() method was called 
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused 
> the problem.
> 
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
> 
> rdar://47536127
> 
> Differential Revision: https://reviews.llvm.org/D58213 
> <https://reviews.llvm.org/D58213>
> 
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
> 
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff>
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(&UFE, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(&UFE, InterndFileName);
>}
>return &UFE;
>  }
> 
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff>
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
> 
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>

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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-18 Thread Jan Korous via cfe-commits
Hi Nico,

I didn't think it necessary as the change doesn't introduce any interaction 
with filesystem - it's just copying a string.

Do you mean it causes a performance regression?

Thanks.

Jan

> On Feb 15, 2019, at 6:15 AM, Nico Weber  wrote:
> 
> Did you do any performance testing to check if this slows down clang?
> 
> On Thu, Feb 14, 2019 at 6:02 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=354075&view=rev>
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
> 
> The pathname wasn't previously filled when the getFile() method was called 
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused 
> the problem.
> 
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
> 
> rdar://47536127
> 
> Differential Revision: https://reviews.llvm.org/D58213 
> <https://reviews.llvm.org/D58213>
> 
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
> 
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff>
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(&UFE, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(&UFE, InterndFileName);
>}
>return &UFE;
>  }
> 
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff>
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
> 
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>

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


r354291 - Reland "[clang][FileManager] fillRealPathName even if we aren't opening the file"

2019-02-18 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Feb 18 14:33:40 2019
New Revision: 354291

URL: http://llvm.org/viewvc/llvm-project?rev=354291&view=rev
Log:
Reland "[clang][FileManager] fillRealPathName even if we aren't opening the 
file"

This reverts commit e2bb3121fd4ab5b01f9ec1d2e3e9877db9c6a54c.
+ fixed test for Windows

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354291&r1=354290&r2=354291&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Feb 18 14:33:40 2019
@@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
   if (UFE.File) {
 if (auto PathName = UFE.File->getName())
   fillRealPathName(&UFE, *PathName);
+  } else if (!openFile) {
+// We should still fill the path even if we aren't opening the file.
+fillRealPathName(&UFE, InterndFileName);
   }
   return &UFE;
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354291&r1=354290&r2=354291&view=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Mon Feb 18 14:33:40 2019
@@ -346,4 +346,33 @@ TEST_F(FileManagerTest, getVirtualFileFi
   EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
+TEST_F(FileManagerTest, getFileDontOpenRealPath) {
+  SmallString<64> CustomWorkingDir;
+#ifdef _WIN32
+  CustomWorkingDir = "C:/";
+#else
+  CustomWorkingDir = "/";
+#endif
+
+  auto FS = IntrusiveRefCntPtr(
+  new llvm::vfs::InMemoryFileSystem);
+  // setCurrentworkingdirectory must finish without error.
+  ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
+
+  FileSystemOptions Opts;
+  FileManager Manager(Opts, FS);
+
+  auto statCache = llvm::make_unique();
+  statCache->InjectDirectory("/tmp/abc", 42);
+  SmallString<64> Path("/tmp/abc/foo.cpp");
+  statCache->InjectFile(Path.str().str().c_str(), 43);
+  manager.setStatCache(std::move(statCache));
+
+  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+
+  ASSERT_TRUE(file != nullptr);
+
+  ASSERT_EQ(file->tryGetRealPathName(), Path);
+}
+
 } // anonymous namespace


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


r354296 - [clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

2019-02-18 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Feb 18 15:12:29 2019
New Revision: 354296

URL: http://llvm.org/viewvc/llvm-project?rev=354296&view=rev
Log:
[clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

Modified:
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354296&r1=354295&r2=354296&view=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Mon Feb 18 15:12:29 2019
@@ -362,17 +362,21 @@ TEST_F(FileManagerTest, getFileDontOpenR
   FileSystemOptions Opts;
   FileManager Manager(Opts, FS);
 
+  // Inject fake files into the file system.
   auto statCache = llvm::make_unique();
-  statCache->InjectDirectory("/tmp/abc", 42);
-  SmallString<64> Path("/tmp/abc/foo.cpp");
-  statCache->InjectFile(Path.str().str().c_str(), 43);
-  manager.setStatCache(std::move(statCache));
+  statCache->InjectDirectory("/tmp", 42);
+  statCache->InjectFile("/tmp/test", 43);
 
-  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+  Manager.setStatCache(std::move(statCache));
 
+  // Check for real path.
+  const FileEntry *file = Manager.getFile("/tmp/test", /*OpenFile=*/false);
   ASSERT_TRUE(file != nullptr);
+  ASSERT_TRUE(file->isValid());
+  SmallString<64> ExpectedResult = CustomWorkingDir;
 
-  ASSERT_EQ(file->tryGetRealPathName(), Path);
+  llvm::sys::path::append(ExpectedResult, "tmp", "test");
+  EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
 } // anonymous namespace


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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-19 Thread Jan Korous via cfe-commits
I see. You're right the name sounds slow indeed. Thank you for the explanation!

> On Feb 19, 2019, at 6:43 AM, Nico Weber  wrote:
> 
> I didn't realize it just copied a string. I just saw a call to 
> "fillRealPathName" and the "RealPath" bit sounded slow. From clicking around 
> in http://llvm-cs.pcc.me.uk/tools/clang/lib/Basic/FileManager.cpp#361 
> <http://llvm-cs.pcc.me.uk/tools/clang/lib/Basic/FileManager.cpp#361> it looks 
> like it's not really computing a realpath (for symlinks). It still does quite 
> a bit of string processing if InterndFileName isn't absolute, but that's 
> probably fine. It's still the kind of thing I'd carefully measure since 
> getFile(openFile=false) was performance-sensitive in a certain case iirc (I 
> think when using pch files?)
> 
> On Mon, Feb 18, 2019 at 5:26 PM Jan Korous  <mailto:jkor...@apple.com>> wrote:
> Hi Nico,
> 
> I didn't think it necessary as the change doesn't introduce any interaction 
> with filesystem - it's just copying a string.
> 
> Do you mean it causes a performance regression?
> 
> Thanks.
> 
> Jan
> 
>> On Feb 15, 2019, at 6:15 AM, Nico Weber > <mailto:tha...@chromium.org>> wrote:
>> 
>> Did you do any performance testing to check if this slows down clang?
>> 
>> On Thu, Feb 14, 2019 at 6:02 PM Jan Korous via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: jkorous
>> Date: Thu Feb 14 15:02:35 2019
>> New Revision: 354075
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev 
>> <http://llvm.org/viewvc/llvm-project?rev=354075&view=rev>
>> Log:
>> [clang][FileManager] fillRealPathName even if we aren't opening the file
>> 
>> The pathname wasn't previously filled when the getFile() method was called 
>> with openFile = false.
>> We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused 
>> the problem.
>> 
>> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
>> 
>> rdar://47536127 <>
>> 
>> Differential Revision: https://reviews.llvm.org/D58213 
>> <https://reviews.llvm.org/D58213>
>> 
>> Modified:
>> cfe/trunk/lib/Basic/FileManager.cpp
>> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>> 
>> Modified: cfe/trunk/lib/Basic/FileManager.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>  
>> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff>
>> ==
>> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
>> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
>> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>>if (UFE.File) {
>>  if (auto PathName = UFE.File->getName())
>>fillRealPathName(&UFE, *PathName);
>> +  } else if (!openFile) {
>> +// We should still fill the path even if we aren't opening the file.
>> +fillRealPathName(&UFE, InterndFileName);
>>}
>>return &UFE;
>>  }
>> 
>> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>  
>> <http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff>
>> ==
>> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
>> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
>> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>>  }
>> 
>> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
>> +  auto statCache = llvm::make_unique();
>> +  statCache->InjectDirectory("/tmp/abc", 42);
>> +  SmallString<64> Path("/tmp/abc/foo.cpp");
>> +  statCache->InjectFile(Path.str().str().c_str(), 43);
>> +  manager.setStatCache(std::move(statCache));
>> +
>> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
>> +
>> +  ASSERT_TRUE(file != nullptr);
>> +
>> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
>> +}
>> +
>>  } // anonymous namespace
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
>> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>
> 

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


r362646 - [clang-format][NFC] Fix BS_Allman style example in the header docs are generated from

2019-06-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Jun  5 13:59:48 2019
New Revision: 362646

URL: http://llvm.org/viewvc/llvm-project?rev=362646&view=rev
Log:
[clang-format][NFC] Fix BS_Allman style example in the header docs are 
generated from

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=362646&r1=362645&r2=362646&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Jun  5 13:59:48 2019
@@ -1059,19 +1059,28 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-  try {
+  try
+  {
 foo();
   }
-  catch () {
+  catch ()
+  {
   }
   void foo() { bar(); }
-  class foo {
+  class foo
+  {
   };
-  if (foo()) {
+  if (foo())
+  {
   }
-  else {
+  else
+  {
   }
-  enum X : int { A, B };
+  enum X : int
+  {
+A,
+B
+  };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=362646&r1=362645&r2=362646&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Jun  5 13:59:48 2019
@@ -642,19 +642,28 @@ struct FormatStyle {
 BS_Stroustrup,
 /// Always break before braces.
 /// \code
-///   try {
+///   try
+///   {
 /// foo();
 ///   }
-///   catch () {
+///   catch ()
+///   {
 ///   }
 ///   void foo() { bar(); }
-///   class foo {
+///   class foo
+///   {
 ///   };
-///   if (foo()) {
+///   if (foo())
+///   {
 ///   }
-///   else {
+///   else
+///   {
 ///   }
-///   enum X : int { A, B };
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
 /// \endcode
 BS_Allman,
 /// Always break before braces and add an extra level of indentation to


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


[clang-tools-extra] r365804 - [clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded test

2019-07-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Jul 11 11:21:21 2019
New Revision: 365804

URL: http://llvm.org/viewvc/llvm-project?rev=365804&view=rev
Log:
[clangd][NFC] Decrease template depth limit in RecursiveHierarchyUnbounded test

...to minimize the chance of stack overflow before reaching the limit.

Modified:
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp?rev=365804&r1=365803&r2=365804&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp Thu Jul 11 
11:21:21 2019
@@ -390,6 +390,7 @@ TEST(TypeHierarchy, RecursiveHierarchyUn
   )cpp");
 
   TestTU TU = TestTU::withCode(Source.code());
+  TU.ExtraArgs.push_back("-ftemplate-depth=10");
   auto AST = TU.build();
 
   // The compiler should produce a diagnostic for hitting the


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


r365947 - Reland [clang] DirectoryWatcher

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 12:47:55 2019
New Revision: 365947

URL: http://llvm.org/viewvc/llvm-project?rev=365947&view=rev
Log:
Reland [clang] DirectoryWatcher

This reverts commit abce8c457dd3de6b156756e547cc0eefb7653c79.

+ Fix the build for platforms that don't have DW implementated.

Added:
cfe/trunk/include/clang/DirectoryWatcher/
cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
cfe/trunk/lib/DirectoryWatcher/
cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.cpp
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.h
cfe/trunk/lib/DirectoryWatcher/default/
cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
cfe/trunk/lib/DirectoryWatcher/linux/
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/lib/DirectoryWatcher/mac/
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
cfe/trunk/unittests/DirectoryWatcher/
cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
Modified:
cfe/trunk/lib/CMakeLists.txt
cfe/trunk/unittests/CMakeLists.txt

Added: cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h?rev=365947&view=auto
==
--- cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h (added)
+++ cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h Fri Jul 12 
12:47:55 2019
@@ -0,0 +1,123 @@
+//===- DirectoryWatcher.h - Listens for directory file changes --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+#define LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+/// Provides notifications for file changes in a directory.
+///
+/// Invokes client-provided function on every filesystem event in the watched
+/// directory. Initially the the watched directory is scanned and for every 
file
+/// found, an event is synthesized as if the file was added.
+///
+/// This is not a general purpose directory monitoring tool - list of
+/// limitations follows.
+///
+/// Only flat directories with no subdirectories are supported. In case
+/// subdirectories are present the behavior is unspecified - events *might* be
+/// passed to Receiver on macOS (due to FSEvents being used) while they
+/// *probably* won't be passed on Linux (due to inotify being used).
+///
+/// Known potential inconsistencies
+/// - For files that are deleted befor the initial scan processed them, clients
+/// might receive Removed notification without any prior Added notification.
+/// - Multiple notifications might be produced when a file is added to the
+/// watched directory during the initial scan. We are choosing the lesser evil
+/// here as the only known alternative strategy would be to invalidate the
+/// watcher instance and force user to create a new one whenever filesystem
+/// event occurs during the initial scan but that would introduce continuous
+/// restarting failure mode (watched directory is not always "owned" by the 
same
+/// process that is consuming it). Since existing clients can handle duplicate
+/// events well, we decided for simplicity.
+///
+/// Notifications are provided only for changes done through local user-space
+/// filesystem interface. Specifically, it's unspecified if notification would
+/// be provided in case of a:
+/// - a file mmap-ed and changed
+/// - a file changed via remote (NFS) or virtual (/proc) FS access to monitored
+/// directory
+/// - another filesystem mounted to the watched directory
+///
+/// No support for LLVM VFS.
+///
+/// It is unspecified whether notifications for files being deleted are sent in
+/// case the whole watched directory is sent.
+///
+/// Directories containing "too many" files and/or receiving events "too
+/// frequently" are not supported - if the initial scan can't be finished 
before
+/// the watcher instance gets invalidated (see WatcherGotInvalidated) there's 
no
+/// good error handling strategy - the only option for client is to destroy the
+/// watcher, restart watching with new instance and hope it won't repeat.
+class DirectoryWatcher {
+public:
+  struct Event {
+enum class EventKind {
+  Removed,
+  /// Content of a file was modified.
+  Modified,
+  /// The watched directory got deleted.
+  WatchedDirRemoved,
+  /// The DirectoryWatcher that originated this event is no longer 

r365948 - Revert "Reland [clang] DirectoryWatcher"

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 12:54:36 2019
New Revision: 365948

URL: http://llvm.org/viewvc/llvm-project?rev=365948&view=rev
Log:
Revert "Reland [clang] DirectoryWatcher"

This reverts commit fdcb7f47e783933e0af8a5fae91132269a208268.

Removed:
cfe/trunk/include/clang/DirectoryWatcher/
cfe/trunk/lib/DirectoryWatcher/
cfe/trunk/unittests/DirectoryWatcher/
Modified:
cfe/trunk/lib/CMakeLists.txt
cfe/trunk/unittests/CMakeLists.txt

Modified: cfe/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CMakeLists.txt?rev=365948&r1=365947&r2=365948&view=diff
==
--- cfe/trunk/lib/CMakeLists.txt (original)
+++ cfe/trunk/lib/CMakeLists.txt Fri Jul 12 12:54:36 2019
@@ -18,7 +18,6 @@ add_subdirectory(Serialization)
 add_subdirectory(Frontend)
 add_subdirectory(FrontendTool)
 add_subdirectory(Tooling)
-add_subdirectory(DirectoryWatcher)
 add_subdirectory(Index)
 if(CLANG_ENABLE_STATIC_ANALYZER)
   add_subdirectory(StaticAnalyzer)

Modified: cfe/trunk/unittests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CMakeLists.txt?rev=365948&r1=365947&r2=365948&view=diff
==
--- cfe/trunk/unittests/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CMakeLists.txt Fri Jul 12 12:54:36 2019
@@ -30,7 +30,6 @@ add_subdirectory(CodeGen)
 if(NOT WIN32 AND CLANG_TOOL_LIBCLANG_BUILD) 
   add_subdirectory(libclang)
 endif()
-add_subdirectory(DirectoryWatcher)
 add_subdirectory(Rename)
 add_subdirectory(Index)
 add_subdirectory(Serialization)


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


r365954 - Reland [clang] DirectoryWatcher

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 13:34:10 2019
New Revision: 365954

URL: http://llvm.org/viewvc/llvm-project?rev=365954&view=rev
Log:
Reland [clang] DirectoryWatcher

This reverts commit f561227d133224d2d6a5a016abe4be051fa75501.

- DirectoryWatcher
- Fix the build for platforms that don't have DW implementated.
- Fix the threading dependencies (thanks to compnerd).

Added:
cfe/trunk/include/clang/DirectoryWatcher/
cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
cfe/trunk/lib/DirectoryWatcher/
cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.cpp
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.h
cfe/trunk/lib/DirectoryWatcher/default/
cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
cfe/trunk/lib/DirectoryWatcher/linux/
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/lib/DirectoryWatcher/mac/
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
cfe/trunk/unittests/DirectoryWatcher/
cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
Modified:
cfe/trunk/lib/CMakeLists.txt
cfe/trunk/unittests/CMakeLists.txt

Added: cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h?rev=365954&view=auto
==
--- cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h (added)
+++ cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h Fri Jul 12 
13:34:10 2019
@@ -0,0 +1,123 @@
+//===- DirectoryWatcher.h - Listens for directory file changes --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+#define LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+/// Provides notifications for file changes in a directory.
+///
+/// Invokes client-provided function on every filesystem event in the watched
+/// directory. Initially the the watched directory is scanned and for every 
file
+/// found, an event is synthesized as if the file was added.
+///
+/// This is not a general purpose directory monitoring tool - list of
+/// limitations follows.
+///
+/// Only flat directories with no subdirectories are supported. In case
+/// subdirectories are present the behavior is unspecified - events *might* be
+/// passed to Receiver on macOS (due to FSEvents being used) while they
+/// *probably* won't be passed on Linux (due to inotify being used).
+///
+/// Known potential inconsistencies
+/// - For files that are deleted befor the initial scan processed them, clients
+/// might receive Removed notification without any prior Added notification.
+/// - Multiple notifications might be produced when a file is added to the
+/// watched directory during the initial scan. We are choosing the lesser evil
+/// here as the only known alternative strategy would be to invalidate the
+/// watcher instance and force user to create a new one whenever filesystem
+/// event occurs during the initial scan but that would introduce continuous
+/// restarting failure mode (watched directory is not always "owned" by the 
same
+/// process that is consuming it). Since existing clients can handle duplicate
+/// events well, we decided for simplicity.
+///
+/// Notifications are provided only for changes done through local user-space
+/// filesystem interface. Specifically, it's unspecified if notification would
+/// be provided in case of a:
+/// - a file mmap-ed and changed
+/// - a file changed via remote (NFS) or virtual (/proc) FS access to monitored
+/// directory
+/// - another filesystem mounted to the watched directory
+///
+/// No support for LLVM VFS.
+///
+/// It is unspecified whether notifications for files being deleted are sent in
+/// case the whole watched directory is sent.
+///
+/// Directories containing "too many" files and/or receiving events "too
+/// frequently" are not supported - if the initial scan can't be finished 
before
+/// the watcher instance gets invalidated (see WatcherGotInvalidated) there's 
no
+/// good error handling strategy - the only option for client is to destroy the
+/// watcher, restart watching with new instance and hope it won't repeat.
+class DirectoryWatcher {
+public:
+  struct Event {
+enum class EventKind {
+  Removed,
+  /// Content of a file was modified.
+  Modified,
+  /// The watched directory got deleted.
+  WatchedDirRemoved

r365966 - [DirectoryWatcher][linux] Fix use of uninitialized value

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 15:11:43 2019
New Revision: 365966

URL: http://llvm.org/viewvc/llvm-project?rev=365966&view=rev
Log:
[DirectoryWatcher][linux] Fix use of uninitialized value

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=365966&r1=365965&r2=365966&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Fri Jul 12 
15:11:43 2019
@@ -220,8 +220,8 @@ void DirectoryWatcherLinux::InotifyPolli
 
 // Multiple epoll_events can be received for a single file descriptor per
 // epoll_wait call.
-for (const auto &EpollEvent : EpollEventBuffer) {
-  if (EpollEvent.data.fd == InotifyPollingStopSignal.FDRead) {
+for (int i = 0; i < EpollWaitResult; ++i) {
+  if (EpollEventBuffer[i].data.fd == InotifyPollingStopSignal.FDRead) {
 StopWork();
 return;
   }


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


r365968 - [DirectoryWatcher][NFC] Silence warnings in release build

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 15:25:17 2019
New Revision: 365968

URL: http://llvm.org/viewvc/llvm-project?rev=365968&view=rev
Log:
[DirectoryWatcher][NFC] Silence warnings in release build

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=365968&r1=365967&r2=365968&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Fri Jul 12 
15:25:17 2019
@@ -55,7 +55,10 @@ struct SemaphorePipe {
   };
 
   void signal() {
-ssize_t Result = llvm::sys::RetryAfterSignal(-1, write, FDWrite, "A", 1);
+#ifndef NDEBUG
+ssize_t Result =
+#endif
+llvm::sys::RetryAfterSignal(-1, write, FDWrite, "A", 1);
 assert(Result != -1);
   }
   ~SemaphorePipe() {

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=365968&r1=365967&r2=365968&view=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Fri Jul 12 
15:25:17 2019
@@ -38,12 +38,18 @@ struct DirectoryWatcherTestFixture {
 
   DirectoryWatcherTestFixture() {
 SmallString<128> pathBuf;
-std::error_code UniqDirRes = createUniqueDirectory("dirwatcher", pathBuf);
+#ifndef NDEBUG
+std::error_code UniqDirRes =
+#endif
+createUniqueDirectory("dirwatcher", pathBuf);
 assert(!UniqDirRes);
 TestRootDir = pathBuf.str();
 path::append(pathBuf, "watch");
 TestWatchedDir = pathBuf.str();
-std::error_code CreateDirRes = create_directory(TestWatchedDir, false);
+#ifndef NDEBUG
+std::error_code CreateDirRes =
+#endif
+create_directory(TestWatchedDir, false);
 assert(!CreateDirRes);
   }
 
@@ -415,8 +421,9 @@ TEST(DirectoryWatcherTest, ChangeMetadat
 const int FD = HopefullyTheFD.get();
 const TimePoint<> NewTimePt =
 std::chrono::system_clock::now() - std::chrono::minutes(1);
-
+#ifndef NDEBUG
 std::error_code setTimeRes =
+#endif
 llvm::sys::fs::setLastAccessAndModificationTime(FD, NewTimePt,
 NewTimePt);
 assert(!setTimeRes);


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


r365976 - [DirectoryWatcher][test][NFC] Add information to test failure reports

2019-07-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jul 12 17:09:04 2019
New Revision: 365976

URL: http://llvm.org/viewvc/llvm-project?rev=365976&view=rev
Log:
[DirectoryWatcher][test][NFC] Add information to test failure reports

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=365976&r1=365975&r2=365976&view=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Fri Jul 12 
17:09:04 2019
@@ -97,7 +97,9 @@ std::string eventKindToString(const Dire
 
 struct VerifyingConsumer {
   std::vector ExpectedInitial;
+  const std::vector ExpectedInitialCopy;
   std::vector ExpectedNonInitial;
+  const std::vector ExpectedNonInitialCopy;
   std::vector OptionalNonInitial;
   std::vector UnexpectedInitial;
   std::vector UnexpectedNonInitial;
@@ -108,8 +110,8 @@ struct VerifyingConsumer {
   const std::vector &ExpectedInitial,
   const std::vector &ExpectedNonInitial,
   const std::vector &OptionalNonInitial = {})
-  : ExpectedInitial(ExpectedInitial),
-ExpectedNonInitial(ExpectedNonInitial),
+  : ExpectedInitial(ExpectedInitial), ExpectedInitialCopy(ExpectedInitial),
+ExpectedNonInitial(ExpectedNonInitial), 
ExpectedNonInitialCopy(ExpectedNonInitial),
 OptionalNonInitial(OptionalNonInitial) {}
 
   // This method is used by DirectoryWatcher.
@@ -181,6 +183,26 @@ struct VerifyingConsumer {
   }
 
   void printUnmetExpectations(llvm::raw_ostream &OS) {
+// If there was any issue, print the expected state
+if (
+  !ExpectedInitial.empty()
+  ||
+  !ExpectedNonInitial.empty()
+  ||
+  !UnexpectedInitial.empty()
+  ||
+  !UnexpectedNonInitial.empty()
+) {
+  OS << "Expected initial events: \n";
+  for (const auto &E : ExpectedInitialCopy) {
+OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+  }
+  OS << "Expected non-initial events: \n";
+  for (const auto &E : ExpectedNonInitialCopy) {
+OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+  }
+}
+
 if (!ExpectedInitial.empty()) {
   OS << "Expected but not seen initial events: \n";
   for (const auto &E : ExpectedInitial) {
@@ -218,6 +240,7 @@ void checkEventualResultWithTimeout(Veri
   EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
+  std::unique_lock L(TestConsumer.Mtx);
   EXPECT_TRUE(TestConsumer.result().hasValue());
   if (TestConsumer.result().hasValue()) {
 EXPECT_TRUE(*TestConsumer.result());


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


r366137 - [DirectoryWatcher][NFC][test] Add typedef for enum

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 15:11:28 2019
New Revision: 366137

URL: http://llvm.org/viewvc/llvm-project?rev=366137&view=rev
Log:
[DirectoryWatcher][NFC][test] Add typedef for enum

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=366137&r1=366136&r2=366137&view=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Mon Jul 15 
15:11:28 2019
@@ -32,6 +32,8 @@ static bool operator==(const DirectoryWa
 
 namespace {
 
+typedef DirectoryWatcher::Event::EventKind EventKind;
+
 struct DirectoryWatcherTestFixture {
   std::string TestRootDir;
   std::string TestWatchedDir;
@@ -81,15 +83,15 @@ struct DirectoryWatcherTestFixture {
   }
 };
 
-std::string eventKindToString(const DirectoryWatcher::Event::EventKind K) {
+std::string eventKindToString(const EventKind K) {
   switch (K) {
-  case DirectoryWatcher::Event::EventKind::Removed:
+  case EventKind::Removed:
 return "Removed";
-  case DirectoryWatcher::Event::EventKind::Modified:
+  case EventKind::Modified:
 return "Modified";
-  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+  case EventKind::WatchedDirRemoved:
 return "WatchedDirRemoved";
-  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+  case EventKind::WatcherGotInvalidated:
 return "WatcherGotInvalidated";
   }
   llvm_unreachable("unknown event kind");
@@ -249,7 +251,6 @@ void checkEventualResultWithTimeout(Veri
   !TestConsumer.result().hasValue())
 TestConsumer.printUnmetExpectations(llvm::outs());
 }
-
 } // namespace
 
 TEST(DirectoryWatcherTest, InitialScanSync) {
@@ -260,9 +261,9 @@ TEST(DirectoryWatcherTest, InitialScanSy
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}},
   {}};
 
   auto DW = DirectoryWatcher::create(
@@ -284,9 +285,9 @@ TEST(DirectoryWatcherTest, InitialScanAs
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}},
   {}};
 
   auto DW = DirectoryWatcher::create(
@@ -305,9 +306,9 @@ TEST(DirectoryWatcherTest, AddFiles) {
 
   VerifyingConsumer TestConsumer{
   {},
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}}};
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -330,8 +331,8 @@ TEST(DirectoryWatcherTest, ModifyFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
+  {{EventKind::Modified, "a"}},
+  {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -359,8 +360,8 @@ TEST(DirectoryWatcherTest, DeleteFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  {{DirectoryWatcher::Event::EventKind::Removed, "a"}}};
+  {{EventKind::Modified, "a"}},
+  {{EventKind::Removed, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -380,8 +381,8 @@ TEST(DirectoryWatcherTest, DeleteWatched
 
   VerifyingConsumer TestConsumer{
   {},
-  {{DirectoryWatcher::Event::EventKind::WatchedDirRemoved, ""},
-   {DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+  {{EventKind::WatchedDirRemoved, ""},
+   {EventKind::WatcherGotInvalidated, ""}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -400,7 +401,7 @@ TEST(DirectoryWatcherTest, InvalidatedWa
   DirectoryWatcherTestFixture fixture;
 
   VerifyingConsumer TestConsumer{
-  {}, {{DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+  {}, {{EventKind::WatcherGotInvalidated, ""}}};
 
   {
 auto DW = DirectoryWatcher::create(


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.

r366138 - [DirectoryWatcher][test] Relax test assumptions

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 15:11:51 2019
New Revision: 366138

URL: http://llvm.org/viewvc/llvm-project?rev=366138&view=rev
Log:
[DirectoryWatcher][test] Relax test assumptions

Workaround for FSEvents sometimes sending notifications for events that happened
before DirectoryWatcher was created.

This caused tests to be flaky on green dragon.

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=366138&r1=366137&r2=366138&view=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Mon Jul 15 
15:11:51 2019
@@ -264,7 +264,14 @@ TEST(DirectoryWatcherTest, InitialScanSy
   {{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
-  {}};
+  {},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}
+  };
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -288,7 +295,14 @@ TEST(DirectoryWatcherTest, InitialScanAs
   {{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
-  {}};
+  {},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}
+   };
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -332,6 +346,7 @@ TEST(DirectoryWatcherTest, ModifyFile) {
 
   VerifyingConsumer TestConsumer{
   {{EventKind::Modified, "a"}},
+  {{EventKind::Modified, "a"}},
   {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
@@ -361,7 +376,8 @@ TEST(DirectoryWatcherTest, DeleteFile) {
 
   VerifyingConsumer TestConsumer{
   {{EventKind::Modified, "a"}},
-  {{EventKind::Removed, "a"}}};
+  {{EventKind::Removed, "a"}},
+  {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -414,44 +430,4 @@ TEST(DirectoryWatcherTest, InvalidatedWa
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
-}
-
-TEST(DirectoryWatcherTest, ChangeMetadata) {
-  DirectoryWatcherTestFixture fixture;
-  fixture.addFile("a");
-
-  VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  // We don't expect any notification for file having access file changed.
-  {},
-  // Given the timing we are ok with receiving the duplicate event.
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
-
-  auto DW = DirectoryWatcher::create(
-  fixture.TestWatchedDir,
-  [&TestConsumer](llvm::ArrayRef Events,
-  bool IsInitial) {
-TestConsumer.consume(Events, IsInitial);
-  },
-  /*waitForInitialSync=*/true);
-
-  { // Change access and modification time of file a.
-Expected HopefullyTheFD = llvm::sys::fs::openNativeFileForWrite(
-fixture.getPathInWatched("a"), CD_OpenExisting, OF_None);
-if (!HopefullyTheFD) {
-  llvm::outs() << HopefullyTheFD.takeError();
-}
-
-const int FD = HopefullyTheFD.get();
-const TimePoint<> NewTimePt =
-std::chrono::system_clock::now() - std::chrono::minutes(1);
-#ifndef NDEBUG
-std::error_code setTimeRes =
-#endif
-llvm::sys::fs::setLastAccessAndModificationTime(FD, NewTimePt,
-NewTimePt);
-assert(!setTimeRes);
-  }
-
-  checkEventualResultWithTimeout(TestConsumer);
-}
+}
\ No newline at end of file


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


r366152 - [DirectoryWatcher][linux] Fix for older kernels

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 16:14:00 2019
New Revision: 366152

URL: http://llvm.org/viewvc/llvm-project?rev=366152&view=rev
Log:
[DirectoryWatcher][linux] Fix for older kernels

IN_EXCL_UNLINK exists since Linux 2.6.36

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

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=366152&r1=366151&r2=366152&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Mon Jul 15 
16:14:00 2019
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -332,8 +333,12 @@ std::unique_ptr clang:
 
   const int InotifyWD = inotify_add_watch(
   InotifyFD, Path.str().c_str(),
-  IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_EXCL_UNLINK | IN_MODIFY |
-  IN_MOVED_FROM | IN_MOVE_SELF | IN_MOVED_TO | IN_ONLYDIR | 
IN_IGNORED);
+  IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY |
+  IN_MOVED_FROM | IN_MOVE_SELF | IN_MOVED_TO | IN_ONLYDIR | IN_IGNORED
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+  | IN_EXCL_UNLINK
+#endif
+  );
   if (InotifyWD == -1)
 return nullptr;
 


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


r366823 - [clang][NFCI] Fix random typos

2019-07-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jul 23 09:54:11 2019
New Revision: 366823

URL: http://llvm.org/viewvc/llvm-project?rev=366823&view=rev
Log:
[clang][NFCI] Fix random typos

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue Jul 23 
09:54:11 2019
@@ -1315,7 +1315,7 @@ class ForEachMatcher : public WrapperMat
 ///
 /// Input matchers can have any type (including other polymorphic matcher
 /// types), and the actual Matcher is generated on demand with an implicit
-/// coversion operator.
+/// conversion operator.
 template  class VariadicOperatorMatcher {
 public:
   VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, Ps &&... 
Params)

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Tue Jul 23 09:54:11 2019
@@ -513,7 +513,7 @@ StringRef index::getSymbolKindString(Sym
   case SymbolKind::StaticProperty: return "static-property";
   case SymbolKind::Constructor: return "constructor";
   case SymbolKind::Destructor: return "destructor";
-  case SymbolKind::ConversionFunction: return "coversion-func";
+  case SymbolKind::ConversionFunction: return "conversion-func";
   case SymbolKind::Parameter: return "param";
   case SymbolKind::Using: return "using";
   }

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul 23 09:54:11 2019
@@ -7173,7 +7173,7 @@ ExprResult Sema::BuildCXXMemberCallExpr(
 
   if (Method->getParent()->isLambda() &&
   Method->getConversionType()->isBlockPointerType()) {
-// This is a lambda coversion to block pointer; check if the argument
+// This is a lambda conversion to block pointer; check if the argument
 // was a LambdaExpr.
 Expr *SubE = E;
 CastExpr *CE = dyn_cast(SubE);


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


[clang-tools-extra] r367354 - [clangd][NFC] Typo in comment

2019-07-30 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jul 30 13:39:39 2019
New Revision: 367354

URL: http://llvm.org/viewvc/llvm-project?rev=367354&view=rev
Log:
[clangd][NFC] Typo in comment

Modified:
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=367354&r1=367353&r2=367354&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Tue Jul 30 13:39:39 2019
@@ -125,7 +125,7 @@ public:
 private:
   // Identifying files in a way that persists from preamble build to subsequent
   // builds is surprisingly hard. FileID is unavailable in 
InclusionDirective(),
-  // and RealPathName and UniqueID are not preseved in the preamble.
+  // and RealPathName and UniqueID are not preserved in the preamble.
   // We use the FileEntry::Name, which is stable, interned into a "file index".
   // The paths we want to expose are the RealPathName, so store those too.
   std::vector RealPathNames; // In file index order.


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


[clang-tools-extra] r367361 - [clangd][NFC] Fix typo in comment

2019-07-30 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jul 30 15:18:04 2019
New Revision: 367361

URL: http://llvm.org/viewvc/llvm-project?rev=367361&view=rev
Log:
[clangd][NFC] Fix typo in comment

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=367361&r1=367360&r2=367361&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Jul 30 15:18:04 2019
@@ -374,7 +374,7 @@ ParsedAST::build(std::unique_ptr FixIncludes;
   auto BuildDir = VFS->getCurrentWorkingDirectory();


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


r367632 - [DirectoryWatcher] Relax assumption to prevent test flakiness

2019-08-01 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Aug  1 16:24:30 2019
New Revision: 367632

URL: http://llvm.org/viewvc/llvm-project?rev=367632&view=rev
Log:
[DirectoryWatcher] Relax assumption to prevent test flakiness

Modified:
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp?rev=367632&r1=367631&r2=367632&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp Thu Aug  1 
16:24:30 2019
@@ -25,6 +25,24 @@ static void stopFSEventStream(FSEventStr
 
 namespace {
 
+/// This implementation is based on FSEvents API which implementation is
+/// aggressively coallescing events. This can manifest as duplicate events.
+///
+/// For example this scenario has been observed:
+///
+/// create foo/bar
+/// sleep 5 s
+/// create DirectoryWatcherMac for dir foo
+/// receive notification: bar EventKind::Modified
+/// sleep 5 s
+/// modify foo/bar
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Modified
+/// sleep 5 s
+/// delete foo/bar
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Removed
 class DirectoryWatcherMac : public clang::DirectoryWatcher {
 public:
   DirectoryWatcherMac(

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=367632&r1=367631&r2=367632&view=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Thu Aug  1 
16:24:30 2019
@@ -377,7 +377,7 @@ TEST(DirectoryWatcherTest, DeleteFile) {
   VerifyingConsumer TestConsumer{
   {{EventKind::Modified, "a"}},
   {{EventKind::Removed, "a"}},
-  {{EventKind::Modified, "a"}}};
+  {{EventKind::Modified, "a"}, {EventKind::Removed, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,


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


Re: [PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-08-01 Thread Jan Korous via cfe-commits
Oh! Interesting! Thanks for investigating this.

I'm happy to review the patch.

> On Aug 1, 2019, at 5:17 PM, Puyan Lotfi  wrote:
> 
> Hi Jan, Thanks for the follow up!
> 
> Me and Compnerd narrowed down the issue to the inotify file count limit being 
> exceeded as the cause. DirectoryWatcherLinux::create() in 
> DirectoryWatcher-linux.cpp also doesn't properly perror, I'll post a patch 
> for this shortly to print perror info if the file count is exceeded.
> 
> The cause of the inotify limit being exceeded was... drumroll... _Dropbox_ 
> 
> PL
> 
> 
> 
> On Thu, Aug 1, 2019 at 11:24 AM Jan Korous via Phabricator via llvm-commits 
> mailto:llvm-comm...@lists.llvm.org>> wrote:
> jkorous added a comment.
> 
> Hi Puyan,
> 
> I failed to reproduce with llvm.org/master  
> (5faa533e47b0e54b04166b0257c5ebb48e6ffcaa 
>  >) on 
> Ubuntu 18.04.1 LTS both in debug and release build.
> 
> Since it sounds like you can reproduce "reliably" - can you please share more 
> info how to reproduce?
> 
> 
> Repository:
>   rL LLVM
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D58418/new/ 
> 
> https://reviews.llvm.org/D58418 
> 
> 
> 
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org 
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits 
> 

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


r367906 - [DirectoryWatcher][linux] Fix build for older kernels

2019-08-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Aug  5 11:44:07 2019
New Revision: 367906

URL: http://llvm.org/viewvc/llvm-project?rev=367906&view=rev
Log:
[DirectoryWatcher][linux] Fix build for older kernels

Apparently kernel support for IN_EXCL_UNLINK in inotify_add_watch() doesn't 
imply it's defined in sys/inotify.h.

https://bugs.llvm.org/show_bug.cgi?id=42824

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=367906&r1=367905&r2=367906&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Mon Aug  5 
11:44:07 2019
@@ -24,7 +24,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -336,7 +335,7 @@ std::unique_ptr clang:
   InotifyFD, Path.str().c_str(),
   IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY |
   IN_MOVED_FROM | IN_MOVE_SELF | IN_MOVED_TO | IN_ONLYDIR | IN_IGNORED
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+#ifdef IN_EXCL_UNLINK
   | IN_EXCL_UNLINK
 #endif
   );


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


r368732 - [clang] Refactor doc comments to Decls attribution

2019-08-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Aug 13 11:11:44 2019
New Revision: 368732

URL: http://llvm.org/viewvc/llvm-project?rev=368732&view=rev
Log:
[clang] Refactor doc comments to Decls attribution

- Create ASTContext::attachCommentsToJustParsedDecls so we don't have to load 
external comments in Sema when trying to attach existing comments to just 
parsed Decls.
- Keep comments ordered and cache their decomposed location - faster 
SourceLoc-based searching.
- Optimize work with redeclarations.
- Keep one comment per redeclaration chain (represented by canonical Decl) 
instead of comment per redeclaration.
- For redeclaration chains with no comment attached keep just the last 
declaration in chain that had no comment instead of every comment-less 
redeclaration.

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

Added:
cfe/trunk/test/Index/comment-redeclarations.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=368732&r1=368731&r2=368732&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Aug 13 11:11:44 2019
@@ -729,71 +729,49 @@ public:
   /// True if comments are already loaded from ExternalASTSource.
   mutable bool CommentsLoaded = false;
 
-  class RawCommentAndCacheFlags {
-  public:
-enum Kind {
-  /// We searched for a comment attached to the particular declaration, but
-  /// didn't find any.
-  ///
-  /// getRaw() == 0.
-  NoCommentInDecl = 0,
-
-  /// We have found a comment attached to this particular declaration.
-  ///
-  /// getRaw() != 0.
-  FromDecl,
-
-  /// This declaration does not have an attached comment, and we have
-  /// searched the redeclaration chain.
-  ///
-  /// If getRaw() == 0, the whole redeclaration chain does not have any
-  /// comments.
-  ///
-  /// If getRaw() != 0, it is a comment propagated from other
-  /// redeclaration.
-  FromRedecl
-};
-
-Kind getKind() const LLVM_READONLY {
-  return Data.getInt();
-}
-
-void setKind(Kind K) {
-  Data.setInt(K);
-}
-
-const RawComment *getRaw() const LLVM_READONLY {
-  return Data.getPointer();
-}
-
-void setRaw(const RawComment *RC) {
-  Data.setPointer(RC);
-}
-
-const Decl *getOriginalDecl() const LLVM_READONLY {
-  return OriginalDecl;
-}
-
-void setOriginalDecl(const Decl *Orig) {
-  OriginalDecl = Orig;
-}
-
-  private:
-llvm::PointerIntPair Data;
-const Decl *OriginalDecl;
-  };
+  /// Mapping from declaration to directly attached comment.
+  ///
+  /// Raw comments are owned by Comments list.  This mapping is populated
+  /// lazily.
+  mutable llvm::DenseMap DeclRawComments;
 
-  /// Mapping from declarations to comments attached to any
-  /// redeclaration.
+  /// Mapping from canonical declaration to the first redeclaration in chain
+  /// that has a comment attached.
   ///
   /// Raw comments are owned by Comments list.  This mapping is populated
   /// lazily.
-  mutable llvm::DenseMap RedeclComments;
+  mutable llvm::DenseMap RedeclChainComments;
+
+  /// Keeps track of redeclaration chains that don't have any comment attached.
+  /// Mapping from canonical declaration to redeclaration chain that has no
+  /// comments attached to any redeclaration. Specifically it's mapping to
+  /// the last redeclaration we've checked.
+  ///
+  /// Shall not contain declarations that have comments attached to any
+  /// redeclaration in their chain.
+  mutable llvm::DenseMap CommentlessRedeclChains;
 
   /// Mapping from declarations to parsed comments attached to any
   /// redeclaration.
   mutable llvm::DenseMap ParsedComments;
 
+  /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
+  /// and removes the redeclaration chain from the set of commentless chains.
+  ///
+  /// Don't do anything if a comment has already been attached to \p OriginalD
+  /// or its redeclaration chain.
+  void cacheRawCommentForDecl(const Decl &OriginalD,
+  const RawComment &Comment) const;
+
+  /// \returns searches \p CommentsInFile for doc comment for \p D.
+  ///
+  /// \p RepresentativeLocForDecl is used as a location for searching doc
+  /// comments. \p CommentsInFile is a mapping offset -> comment of files in 
the
+  /// same file where \p RepresentativeLocForDecl is.
+  RawComment *getRawCommentForDeclNoCacheImpl(
+  const Decl *D, const SourceLocation RepresentativeLocForDecl,
+  const 

r368761 - [clang] DirectoryWatcher for Windows stubs (to fix build break).

2019-08-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Aug 13 15:39:26 2019
New Revision: 368761

URL: http://llvm.org/viewvc/llvm-project?rev=368761&view=rev
Log:
[clang] DirectoryWatcher for Windows stubs (to fix build break).

This is just a code skeleton for DirectoryWatcher-windows.cpp so the
build on Windows stops breaking.

(upstreamed from github.com/apple/swift-clang)

Added:
cfe/trunk/lib/DirectoryWatcher/windows/
cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
Modified:
cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt

Modified: cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt?rev=368761&r1=368760&r2=368761&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt (original)
+++ cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt Tue Aug 13 15:39:26 2019
@@ -17,6 +17,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux"
 list(APPEND DIRECTORY_WATCHER_SOURCES linux/DirectoryWatcher-linux.cpp)
 find_package(Threads REQUIRED)
   endif()
+elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  list(APPEND DIRECTORY_WATCHER_SOURCES windows/DirectoryWatcher-windows.cpp)
 else()
   list(APPEND DIRECTORY_WATCHER_SOURCES 
default/DirectoryWatcher-not-implemented.cpp)
 endif()

Added: cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp?rev=368761&view=auto
==
--- cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp (added)
+++ cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp Tue Aug 
13 15:39:26 2019
@@ -0,0 +1,48 @@
+//===- DirectoryWatcher-windows.cpp - Windows-platform directory watching 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// TODO: This is not yet an implementation, but it will make it so Windows
+//   builds don't fail.
+
+#include "DirectoryScanner.h"
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/AlignOf.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace {
+
+using namespace llvm;
+using namespace clang;
+
+class DirectoryWatcherWindows : public clang::DirectoryWatcher {
+public:
+  ~DirectoryWatcherWindows() override { }
+  void InitialScan() { }
+  void EventReceivingLoop() { }
+  void StopWork() { }
+};
+} // namespace
+
+std::unique_ptr clang::DirectoryWatcher::create(
+StringRef Path,
+std::function, bool)> 
Receiver,
+bool WaitForInitialSync) {
+return nullptr;
+}


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


r368762 - [clang][DirectoryWatcher] Fix Windows stub after LLVM change

2019-08-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Aug 13 15:39:50 2019
New Revision: 368762

URL: http://llvm.org/viewvc/llvm-project?rev=368762&view=rev
Log:
[clang][DirectoryWatcher] Fix Windows stub after LLVM change

r367979 changed DirectoryWatcher::Create to return an llvm::Expected.
Adjust the Windows stub accordingly.

(upstreamed from github.com/apple/swift-clang)

Modified:
cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp?rev=368762&r1=368761&r2=368762&view=diff
==
--- cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp 
(original)
+++ cfe/trunk/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp Tue Aug 
13 15:39:50 2019
@@ -40,9 +40,11 @@ public:
 };
 } // namespace
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected>
+clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> 
Receiver,
 bool WaitForInitialSync) {
-return nullptr;
+  return llvm::Expected>(
+  llvm::errorCodeToError(std::make_error_code(std::errc::not_supported)));
 }


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


r364690 - [clang][test][NFC] Explicitly specify clang ABI in AST Dumper test

2019-06-28 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Jun 28 15:37:31 2019
New Revision: 364690

URL: http://llvm.org/viewvc/llvm-project?rev=364690&view=rev
Log:
[clang][test][NFC] Explicitly specify clang ABI in AST Dumper test

Clang <= 4 used the pre-C++11 rule about which structures can be passed in 
registers.

Modified:
cfe/trunk/test/AST/ast-dump-record-definition-data-json.cpp

Modified: cfe/trunk/test/AST/ast-dump-record-definition-data-json.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-record-definition-data-json.cpp?rev=364690&r1=364689&r2=364690&view=diff
==
--- cfe/trunk/test/AST/ast-dump-record-definition-data-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-record-definition-data-json.cpp Fri Jun 28 
15:37:31 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump=json %s 
| FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=7.0 
-std=c++17 -ast-dump=json %s | FileCheck %s
 
 void f() {
   auto IsNotGenericLambda = [](){};


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


r365574 - [clang] DirectoryWatcher

2019-07-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jul  9 15:44:48 2019
New Revision: 365574

URL: http://llvm.org/viewvc/llvm-project?rev=365574&view=rev
Log:
[clang] DirectoryWatcher

Asynchronously monitors specified directory for changes and passes 
notifications to provided callback.

Dependency for index-while-building.

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

Added:
cfe/trunk/include/clang/DirectoryWatcher/
cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
cfe/trunk/lib/DirectoryWatcher/
cfe/trunk/lib/DirectoryWatcher/CMakeLists.txt
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.cpp
cfe/trunk/lib/DirectoryWatcher/DirectoryScanner.h
cfe/trunk/lib/DirectoryWatcher/linux/
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/lib/DirectoryWatcher/mac/
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
cfe/trunk/unittests/DirectoryWatcher/
cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
Modified:
cfe/trunk/lib/CMakeLists.txt
cfe/trunk/unittests/CMakeLists.txt

Added: cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h?rev=365574&view=auto
==
--- cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h (added)
+++ cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h Tue Jul  9 
15:44:48 2019
@@ -0,0 +1,123 @@
+//===- DirectoryWatcher.h - Listens for directory file changes --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+#define LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+/// Provides notifications for file changes in a directory.
+///
+/// Invokes client-provided function on every filesystem event in the watched
+/// directory. Initially the the watched directory is scanned and for every 
file
+/// found, an event is synthesized as if the file was added.
+///
+/// This is not a general purpose directory monitoring tool - list of
+/// limitations follows.
+///
+/// Only flat directories with no subdirectories are supported. In case
+/// subdirectories are present the behavior is unspecified - events *might* be
+/// passed to Receiver on macOS (due to FSEvents being used) while they
+/// *probably* won't be passed on Linux (due to inotify being used).
+///
+/// Known potential inconsistencies
+/// - For files that are deleted befor the initial scan processed them, clients
+/// might receive Removed notification without any prior Added notification.
+/// - Multiple notifications might be produced when a file is added to the
+/// watched directory during the initial scan. We are choosing the lesser evil
+/// here as the only known alternative strategy would be to invalidate the
+/// watcher instance and force user to create a new one whenever filesystem
+/// event occurs during the initial scan but that would introduce continuous
+/// restarting failure mode (watched directory is not always "owned" by the 
same
+/// process that is consuming it). Since existing clients can handle duplicate
+/// events well, we decided for simplicity.
+///
+/// Notifications are provided only for changes done through local user-space
+/// filesystem interface. Specifically, it's unspecified if notification would
+/// be provided in case of a:
+/// - a file mmap-ed and changed
+/// - a file changed via remote (NFS) or virtual (/proc) FS access to monitored
+/// directory
+/// - another filesystem mounted to the watched directory
+///
+/// No support for LLVM VFS.
+///
+/// It is unspecified whether notifications for files being deleted are sent in
+/// case the whole watched directory is sent.
+///
+/// Directories containing "too many" files and/or receiving events "too
+/// frequently" are not supported - if the initial scan can't be finished 
before
+/// the watcher instance gets invalidated (see WatcherGotInvalidated) there's 
no
+/// good error handling strategy - the only option for client is to destroy the
+/// watcher, restart watching with new instance and hope it won't repeat.
+class DirectoryWatcher {
+public:
+  struct Event {
+enum class EventKind {
+  Removed,
+  /// Content of a file was modified.
+  Modified,
+  /// The watched directory got deleted.
+  WatchedDirRemoved,
+  /// The DirectoryWatcher that originated this event is no longer valid 
and
+  /// its behavior is unspecified.
+  //

r360607 - [clang][ASTContext] Call setAttached for comments attached to a declaration

2019-05-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon May 13 10:52:09 2019
New Revision: 360607

URL: http://llvm.org/viewvc/llvm-project?rev=360607&view=rev
Log:
[clang][ASTContext] Call setAttached for comments attached to a declaration

This is a bug affecting performance when compiling with -Wdocumentation.

In Sema::ActOnDocumentable we're checking whether there are any comments 
unattached to declaration at the end of comment list whenever we encounter new 
documentable declaration.
Since this property of RawComment was never set we were trying to find comments 
every time and that involves at least a couple expensive SourceLocation 
decompositions.

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=360607&r1=360606&r2=360607&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon May 13 10:52:09 2019
@@ -255,6 +255,7 @@ RawComment *ASTContext::getRawCommentFor
 SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second)
   == SourceMgr.getLineNumber(CommentBeginDecomp.first,
  CommentBeginDecomp.second)) {
+  (**Comment).setAttached();
   return *Comment;
 }
   }
@@ -296,6 +297,7 @@ RawComment *ASTContext::getRawCommentFor
   if (Text.find_first_of(";{}#@") != StringRef::npos)
 return nullptr;
 
+  (**Comment).setAttached();
   return *Comment;
 }
 


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


r371578 - [clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path

2019-09-10 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Sep 10 17:30:26 2019
New Revision: 371578

URL: http://llvm.org/viewvc/llvm-project?rev=371578&view=rev
Log:
[clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path

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

Modified:
cfe/trunk/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/no-werror.json
cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
cfe/trunk/test/ClangScanDeps/error.cpp
cfe/trunk/test/ClangScanDeps/header_stat_before_open.m
cfe/trunk/test/ClangScanDeps/no-werror.cpp
cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m
cfe/trunk/test/ClangScanDeps/symlink.cpp
cfe/trunk/test/ClangScanDeps/vfsoverlay.cpp

Modified: cfe/trunk/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json?rev=371578&r1=371577&r2=371578&view=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json 
(original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json Tue 
Sep 10 17:30:26 2019
@@ -1,7 +1,7 @@
 [
 {
   "directory": "DIR",
-  "command": "clang -E DIR/header_stat_before_open.m -iframework 
Inputs/frameworks",
-  "file": "DIR/header_stat_before_open.m"
+  "command": "clang -E DIR/header_stat_before_open_input.m -iframework 
Inputs/frameworks",
+  "file": "DIR/header_stat_before_open_input.m"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/no-werror.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/no-werror.json?rev=371578&r1=371577&r2=371578&view=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/no-werror.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/no-werror.json Tue Sep 10 17:30:26 2019
@@ -1,7 +1,7 @@
 [
 {
   "directory": "DIR",
-  "command": "clang -E DIR/no-werror.cpp -IInputs -std=c++17 -Weverything 
-Werror",
+  "command": "clang -E DIR/no-werror_input.cpp -IInputs -std=c++17 
-Weverything -Werror",
   "file": "DIR/no-werror.cpp"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json?rev=371578&r1=371577&r2=371578&view=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json Tue Sep 10 17:30:26 
2019
@@ -1,12 +1,12 @@
 [
 {
   "directory": "DIR",
-  "command": "clang -E -fsyntax-only DIR/regular_cdb2.cpp -IInputs -D 
INCLUDE_HEADER2 -MD -MF DIR/regular_cdb2.d",
-  "file": "DIR/regular_cdb2.cpp"
+  "command": "clang -E -fsyntax-only DIR/regular_cdb_input2.cpp -IInputs -D 
INCLUDE_HEADER2 -MD -MF DIR/regular_cdb2.d",
+  "file": "DIR/regular_cdb_input2.cpp"
 },
 {
   "directory": "DIR",
-  "command": "clang -E DIR/regular_cdb.cpp -IInputs",
-  "file": "DIR/regular_cdb.cpp"
+  "command": "clang -E DIR/regular_cdb_input.cpp -IInputs",
+  "file": "DIR/regular_cdb_input.cpp"
 }
 ]

Modified: 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json?rev=371578&r1=371577&r2=371578&view=diff
==
--- 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
(original)
+++ 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
Tue Sep 10 17:30:26 2019
@@ -1,12 +1,12 @@
 [
 {
   "directory": "DIR",
-  "command": "clang -E DIR/subframework_header_dir_symlink.m -D EMPTY 
-iframework Inputs/frameworks",
+  "command": "clang -E DIR/subframework_header_dir_symlink_input.m -D EMPTY 
-iframework Inputs/frameworks",
   "file": "DIR/subframework_header_dir_symlink.m"
 },
 {
   "directory": "DIR",
-  "command": "clang -E DIR/subframework_header_dir_symlink2.m 
-FInputs/frameworks -iframework Inputs/frameworks_symlink",
+  "command": "clang -E DIR/subframework_header_dir_symlink_input2.m 
-FInputs/frameworks -iframework Inputs/frameworks_symlink",
   "file": "DIR/subframework_header_dir_symlink2.m"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json?rev=371578&r1=371577&r2=371578&view=diff
==
---

r371697 - [clang-scan-deps] Add dependency targets

2019-09-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Sep 11 17:48:45 2019
New Revision: 371697

URL: http://llvm.org/viewvc/llvm-project?rev=371697&view=rev
Log:
[clang-scan-deps] Add dependency targets

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

Modified:
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
cfe/trunk/test/ClangScanDeps/header_stat_before_open.m
cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m
cfe/trunk/test/ClangScanDeps/vfsoverlay.cpp
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp

Modified: 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json?rev=371697&r1=371696&r2=371697&view=diff
==
--- 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
(original)
+++ 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
Wed Sep 11 17:48:45 2019
@@ -2,11 +2,11 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/subframework_header_dir_symlink_input.m -D EMPTY 
-iframework Inputs/frameworks",
-  "file": "DIR/subframework_header_dir_symlink.m"
+  "file": "DIR/subframework_header_dir_symlink_input.m"
 },
 {
   "directory": "DIR",
   "command": "clang -E DIR/subframework_header_dir_symlink_input2.m 
-FInputs/frameworks -iframework Inputs/frameworks_symlink",
-  "file": "DIR/subframework_header_dir_symlink2.m"
+  "file": "DIR/subframework_header_dir_symlink_input2.m"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json?rev=371697&r1=371696&r2=371697&view=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/symlink_cdb.json Wed Sep 11 17:48:45 
2019
@@ -2,11 +2,11 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/symlink_input.cpp -IInputs",
-  "file": "DIR/symlink.cpp"
+  "file": "DIR/symlink_input.cpp"
 },
 {
   "directory": "DIR",
   "command": "clang -E DIR/symlink_input2.cpp -IInputs",
-  "file": "DIR/symlink2.cpp"
+  "file": "DIR/symlink_input2.cpp"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json?rev=371697&r1=371696&r2=371697&view=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json Wed Sep 11 17:48:45 
2019
@@ -2,6 +2,6 @@
 {
   "directory": "DIR",
   "command": "clang -E DIR/vfsoverlay_input.cpp -IInputs -ivfsoverlay 
DIR/vfsoverlay.yaml",
-  "file": "DIR/vfsoverlay.cpp"
+  "file": "DIR/vfsoverlay_input.cpp"
 }
 ]

Modified: cfe/trunk/test/ClangScanDeps/header_stat_before_open.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/header_stat_before_open.m?rev=371697&r1=371696&r2=371697&view=diff
==
--- cfe/trunk/test/ClangScanDeps/header_stat_before_open.m (original)
+++ cfe/trunk/test/ClangScanDeps/header_stat_before_open.m Wed Sep 11 17:48:45 
2019
@@ -12,7 +12,7 @@
 #include "Framework/Framework.h"
 #include "Framework/PrivateHeader.h"
 
-// CHECK: clang-scan-deps dependency
+// CHECK: header_stat_before_open_input.o
 // CHECK-NEXT: header_stat_before_open_input.m
 // CHECK-NEXT: 
Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}Headers{{/|\\}}Framework.h
 // CHECK-NEXT: 
Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}PrivateHeaders{{/|\\}}PrivateHeader.h

Modified: cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/regular_cdb.cpp?rev=371697&r1=371696&r2=371697&view=diff
==
--- cfe/trunk/test/ClangScanDeps/regular_cdb.cpp (original)
+++ cfe/trunk/test/ClangScanDeps/regular_cdb.cpp Wed Sep 11 17:48:45 2019
@@ -36,6 +36,7 @@
 #include "header.h"
 
 // CHECK1: regular_cdb_input2.cpp
+// CHECK1-NEXT: regular_cdb_input2.cpp
 // CHECK1-NEXT: Inputs{{/|\\}}header.h
 // CHECK1-NEXT: Inputs{{/|\\}}header2.h
 

Modified: cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/subframework_header_dir_symlink.m?rev=371697&r1=371696&r2=371697&view=diff
==
--- cfe/trunk/test/ClangScanDeps/

r371787 - [libclang] Expose abort()-ing LLVM fatal error handler

2019-09-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep 12 15:55:55 2019
New Revision: 371787

URL: http://llvm.org/viewvc/llvm-project?rev=371787&view=rev
Log:
[libclang] Expose abort()-ing LLVM fatal error handler

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

Added:
cfe/trunk/include/clang-c/FatalErrorHandler.h
cfe/trunk/tools/libclang/FatalErrorHandler.cpp
cfe/trunk/unittests/libclang/CrashTests/
cfe/trunk/unittests/libclang/CrashTests/CMakeLists.txt
cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CMakeLists.txt
cfe/trunk/tools/libclang/libclang.exports
cfe/trunk/unittests/libclang/CMakeLists.txt

Added: cfe/trunk/include/clang-c/FatalErrorHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/FatalErrorHandler.h?rev=371787&view=auto
==
--- cfe/trunk/include/clang-c/FatalErrorHandler.h (added)
+++ cfe/trunk/include/clang-c/FatalErrorHandler.h Thu Sep 12 15:55:55 2019
@@ -0,0 +1,33 @@
+/*===-- clang-c/FatalErrorHandler.h - Fatal Error Handling *- C 
-*-===*\
+|*
*|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM  
*|
+|* Exceptions.
*|
+|* See https://llvm.org/LICENSE.txt for license information.  
*|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*|
+|*
*|
+\*===--===*/
+
+#ifndef LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
+#define LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Installs error handler that prints error message to stderr and calls 
abort().
+ * Replaces currently installed error handler (if any).
+ */
+void clang_install_aborting_llvm_fatal_error_handler();
+
+/**
+ * Removes currently installed error handler (if any).
+ * If no error handler is intalled, the default strategy is to print error
+ * message to stderr and call exit(1).
+ */
+void clang_uninstall_llvm_fatal_error_handler();
+
+#ifdef __cplusplus
+}
+#endif
+#endif

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=371787&r1=371786&r2=371787&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Sep 12 15:55:55 2019
@@ -20,6 +20,7 @@
 #include "CXTranslationUnit.h"
 #include "CXType.h"
 #include "CursorVisitor.h"
+#include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/StmtVisitor.h"
@@ -3243,18 +3244,10 @@ RefNamePieces buildPieces(unsigned NameF
 // Misc. API hooks.
 
//===--===//
   
 
-static void fatal_error_handler(void *user_data, const std::string& reason,
-bool gen_crash_diag) {
-  // Write the result out to stderr avoiding errs() because raw_ostreams can
-  // call report_fatal_error.
-  fprintf(stderr, "LIBCLANG FATAL ERROR: %s\n", reason.c_str());
-  ::abort();
-}
-
 namespace {
 struct RegisterFatalErrorHandler {
   RegisterFatalErrorHandler() {
-llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
+clang_install_aborting_llvm_fatal_error_handler();
   }
 };
 }

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=371787&r1=371786&r2=371787&view=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Thu Sep 12 15:55:55 2019
@@ -19,6 +19,7 @@ set(SOURCES
   CXString.cpp
   CXType.cpp
   Indexing.cpp
+  FatalErrorHandler.cpp
 
   ADDITIONAL_HEADERS
   CIndexDiagnostic.h
@@ -43,6 +44,7 @@ set(LIBS
   clangSema
   clangSerialization
   clangTooling
+  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)

Added: cfe/trunk/tools/libclang/FatalErrorHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/FatalErrorHandler.cpp?rev=371787&view=auto
==
--- cfe/trunk/tools/libclang/FatalErrorHandler.cpp (added)
+++ cfe/trunk/tools/libclang/FatalErrorHandler.cpp Thu Sep 12 15:55:55 2019
@@ -0,0 +1,28 @@
+/*===-- clang-c/FatalErrorHandler.cpp - Fatal Error Handling --*- C 
-*-===*\
+|*
*|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 

r371794 - [libclang] Fix UninstallAbortingLLVMFatalErrorHandler test

2019-09-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep 12 16:51:48 2019
New Revision: 371794

URL: http://llvm.org/viewvc/llvm-project?rev=371794&view=rev
Log:
[libclang] Fix UninstallAbortingLLVMFatalErrorHandler test

Modified:
cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp

Modified: cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp?rev=371794&r1=371793&r2=371794&view=diff
==
--- cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp (original)
+++ cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp Thu Sep 12 
16:51:48 2019
@@ -31,6 +31,7 @@ TEST_F(LibclangParseTest, UninstallAbort
   std::string Main = "main.h";
   WriteFile(Main, "#pragma clang __debug llvm_fatal_error");
 
-  EXPECT_NO_FATAL_FAILURE(clang_parseTranslationUnit(
-  Index, Main.c_str(), nullptr, 0, nullptr, 0, TUFlags));
+  EXPECT_EXIT(clang_parseTranslationUnit(
+  Index, Main.c_str(), nullptr, 0, nullptr, 0, TUFlags),
+  ::testing::ExitedWithCode(1), "ERROR");
 }


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


r371890 - [Support] Add overload writeFileAtomically(std::function Writer)

2019-09-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Sep 13 13:08:27 2019
New Revision: 371890

URL: http://llvm.org/viewvc/llvm-project?rev=371890&view=rev
Log:
[Support] Add overload writeFileAtomically(std::function Writer)

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=371890&r1=371889&r2=371890&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Sep 13 13:08:27 2019
@@ -84,6 +84,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -2301,26 +2302,19 @@ bool ASTUnit::Save(StringRef File) {
   SmallString<128> TempPath;
   TempPath = File;
   TempPath += "-";
-  int fd;
-  if (llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath))
-return true;
-
   // FIXME: Can we somehow regenerate the stat cache here, or do we need to
   // unconditionally create a stat cache when we parse the file?
-  llvm::raw_fd_ostream Out(fd, /*shouldClose=*/true);
-
-  serialize(Out);
-  Out.close();
-  if (Out.has_error()) {
-Out.clear_error();
-return true;
-  }
 
-  if (llvm::sys::fs::rename(TempPath, File)) {
-llvm::sys::fs::remove(TempPath);
+  if (llvm::Error Err = llvm::writeFileAtomically(
+  TempPath, File, [this](llvm::raw_ostream &Out) {
+return serialize(Out) ? llvm::make_error(
+"ASTUnit serialization failed",
+llvm::inconvertibleErrorCode())
+  : llvm::Error::success();
+  })) {
+consumeError(std::move(Err));
 return true;
   }
-
   return false;
 }
 

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=371890&r1=371889&r2=371890&view=diff
==
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Fri Sep 13 13:08:27 2019
@@ -10,7 +10,6 @@
 //
 
//===--===//
 
-
 #include "ASTReaderInternals.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -21,10 +20,12 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/Support/DJB.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/LockFileManager.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/OnDiskHashTable.h"
@@ -912,37 +913,9 @@ GlobalModuleIndex::writeIndex(FileManage
  "failed writing index");
   }
 
-  // Write the global index file to a temporary file.
-  llvm::SmallString<128> IndexTmpPath;
-  int TmpFD;
-  if (llvm::sys::fs::createUniqueFile(IndexPath + "-", TmpFD,
-  IndexTmpPath))
-return llvm::createStringError(std::errc::io_error,
-   "failed creating unique file");
-
-  // Open the temporary global index file for output.
-  llvm::raw_fd_ostream Out(TmpFD, true);
-  if (Out.has_error())
-return llvm::createStringError(Out.error(), "failed outputting to stream");
-
-  // Write the index.
-  Out.write(OutputBuffer.data(), OutputBuffer.size());
-  Out.close();
-  if (Out.has_error())
-return llvm::createStringError(Out.error(), "failed writing to stream");
-
-  // Remove the old index file. It isn't relevant any more.
-  llvm::sys::fs::remove(IndexPath);
-
-  // Rename the newly-written index file to the proper name.
-  if (std::error_code Err = llvm::sys::fs::rename(IndexTmpPath, IndexPath)) {
-// Remove the file on failure, don't check whether removal succeeded.
-llvm::sys::fs::remove(IndexTmpPath);
-return llvm::createStringError(Err, "failed renaming file \"%s\" to 
\"%s\"",
-   IndexTmpPath.c_str(), IndexPath.c_str());
-  }
-
-  return llvm::Error::success();
+  return llvm::writeFileAtomically(
+  (IndexPath + "-").str(), IndexPath,
+  llvm::StringRef(OutputBuffer.data(), OutputBuffer.size()));
 }
 
 namespace {


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

[clang-tools-extra] r371890 - [Support] Add overload writeFileAtomically(std::function Writer)

2019-09-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Sep 13 13:08:27 2019
New Revision: 371890

URL: http://llvm.org/viewvc/llvm-project?rev=371890&view=rev
Log:
[Support] Add overload writeFileAtomically(std::function Writer)

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

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

Modified: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp?rev=371890&r1=371889&r2=371890&view=diff
==
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp Fri Sep 13 
13:08:27 2019
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -35,34 +36,6 @@ std::string getShardPathFromFilePath(llv
   return ShardRootSS.str();
 }
 
-llvm::Error
-writeAtomically(llvm::StringRef OutPath,
-llvm::function_ref Writer) {
-  // Write to a temporary file first.
-  llvm::SmallString<128> TempPath;
-  int FD;
-  auto EC =
-  llvm::sys::fs::createUniqueFile(OutPath + ".tmp.", FD, TempPath);
-  if (EC)
-return llvm::errorCodeToError(EC);
-  // Make sure temp file is destroyed on failure.
-  auto RemoveOnFail =
-  llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
-  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
-  Writer(OS);
-  OS.close();
-  if (OS.has_error())
-return llvm::errorCodeToError(OS.error());
-  // Then move to real location.
-  EC = llvm::sys::fs::rename(TempPath, OutPath);
-  if (EC)
-return llvm::errorCodeToError(EC);
-  // If everything went well, we already moved the file to another name. So
-  // don't delete the file, as the name might be taken by another file.
-  RemoveOnFail.release();
-  return llvm::ErrorSuccess();
-}
-
 // Uses disk as a storage for index shards. Creates a directory called
 // ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
@@ -100,9 +73,12 @@ public:
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-return writeAtomically(
-getShardPathFromFilePath(DiskShardRoot, ShardIdentifier),
-[&Shard](llvm::raw_ostream &OS) { OS << Shard; });
+auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+return llvm::writeFileAtomically(ShardPath + ".tmp.", ShardPath,
+ [&Shard](llvm::raw_ostream &OS) {
+   OS << Shard;
+   return llvm::Error::success();
+ });
   }
 };
 


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


r372174 - [clang-scan-deps] Add verbose mode

2019-09-17 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Sep 17 12:45:24 2019
New Revision: 372174

URL: http://llvm.org/viewvc/llvm-project?rev=372174&view=rev
Log:
[clang-scan-deps] Add verbose mode

When running in the default mode we don't print anything other than actual 
output to stdout to make automated processing easier.

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

Modified:
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp

Modified: cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp?rev=372174&r1=372173&r2=372174&view=diff
==
--- cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp (original)
+++ cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp Tue Sep 17 12:45:24 2019
@@ -177,6 +177,11 @@ llvm::cl::opt SkipExcludedPPRanges
 "until reaching the end directive."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt Verbose("v", llvm::cl::Optional,
+llvm::cl::desc("Use verbose output."),
+llvm::cl::init(false),
+llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -284,8 +289,10 @@ int main(int argc, const char **argv) {
   std::mutex Lock;
   size_t Index = 0;
 
-  llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
-   << " files using " << NumWorkers << " workers\n";
+  if (Verbose) {
+llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
+ << " files using " << NumWorkers << " workers\n";
+  }
   for (unsigned I = 0; I < NumWorkers; ++I) {
 auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &WorkerTools]() {
   while (true) {


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


r372679 - [static analyzer] Define __clang_analyzer__ macro in driver

2019-09-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Sep 23 17:33:47 2019
New Revision: 372679

URL: http://llvm.org/viewvc/llvm-project?rev=372679&view=rev
Log:
[static analyzer] Define __clang_analyzer__ macro in driver

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

Added:
cfe/trunk/test/Analysis/misc-driver.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=372679&r1=372678&r2=372679&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Sep 23 17:33:47 2019
@@ -3896,8 +3896,10 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasArg(options::OPT_municode))
 CmdArgs.push_back("-DUNICODE");
 
-  if (isa(JA))
+  if (isa(JA)) {
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
+CmdArgs.push_back("-D__clang_analyzer__");
+  }
 
   // Enable compatilibily mode to avoid analyzer-config related errors.
   // Since we can't access frontend flags through hasArg, let's manually 
iterate

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=372679&r1=372678&r2=372679&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Sep 23 17:33:47 2019
@@ -990,10 +990,6 @@ static void InitializePredefinedMacros(c
   else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
 Builder.defineMacro("__SSP_ALL__", "3");
 
-  // Define a macro that exists only when using the static analyzer.
-  if (FEOpts.ProgramAction == frontend::RunAnalysis)
-Builder.defineMacro("__clang_analyzer__");
-
   if (LangOpts.FastRelaxedMath)
 Builder.defineMacro("__FAST_RELAXED_MATH__");
 

Added: cfe/trunk/test/Analysis/misc-driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372679&view=auto
==
--- cfe/trunk/test/Analysis/misc-driver.c (added)
+++ cfe/trunk/test/Analysis/misc-driver.c Mon Sep 23 17:33:47 2019
@@ -0,0 +1,5 @@
+// RUN: %clang --analyze %s
+
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=372679&r1=372678&r2=372679&view=diff
==
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Sep 23 17:33:47 2019
@@ -2,10 +2,6 @@
 // RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 
-#ifndef __clang_analyzer__
-#error __clang_analyzer__ not defined
-#endif
-
 typedef struct objc_ivar *Ivar;
 typedef struct objc_selector *SEL;
 typedef signed char BOOL;


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


r372680 - [static analyzer] Remove --analyze-auto

2019-09-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Sep 23 17:37:25 2019
New Revision: 372680

URL: http://llvm.org/viewvc/llvm-project?rev=372680&view=rev
Log:
[static analyzer] Remove --analyze-auto

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

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Types.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=372680&r1=372679&r2=372680&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Mon Sep 23 17:37:25 2019
@@ -86,8 +86,6 @@ Pass  to the target offloading tool
 
 Run the static analyzer
 
-.. option:: --analyze-auto
-
 .. option:: --analyzer-no-default-checks
 
 .. option:: --analyzer-output

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=372680&r1=372679&r2=372680&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Sep 23 17:37:25 2019
@@ -2762,7 +2762,6 @@ def _mhwdiv : Separate<["--"], "mhwdiv">
 def _CLASSPATH_EQ : Joined<["--"], "CLASSPATH=">, Alias;
 def _CLASSPATH : Separate<["--"], "CLASSPATH">, Alias;
 def _all_warnings : Flag<["--"], "all-warnings">, Alias;
-def _analyze_auto : Flag<["--"], "analyze-auto">, Flags<[DriverOption]>;
 def _analyzer_no_default_checks : Flag<["--"], "analyzer-no-default-checks">, 
Flags<[DriverOption]>;
 def _analyzer_output : JoinedOrSeparate<["--"], "analyzer-output">, 
Flags<[DriverOption]>,
   HelpText<"Static analyzer report output format 
(html|plist|plist-multi-file|plist-html|text).">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=372680&r1=372679&r2=372680&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Sep 23 17:37:25 2019
@@ -287,8 +287,7 @@ phases::ID Driver::getFinalPhase(const D
  (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
  (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) ||
- (PhaseArg = DAL.getLastArg(options::OPT__analyze,
-options::OPT__analyze_auto)) ||
+ (PhaseArg = DAL.getLastArg(options::OPT__analyze)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
 FinalPhase = phases::Compile;
 
@@ -3501,7 +3500,7 @@ Action *Driver::ConstructPhaseAction(
 if (Args.hasArg(options::OPT_rewrite_legacy_objc))
   return C.MakeAction(Input,
 types::TY_RewrittenLegacyObjC);
-if (Args.hasArg(options::OPT__analyze, options::OPT__analyze_auto))
+if (Args.hasArg(options::OPT__analyze))
   return C.MakeAction(Input, types::TY_Plist);
 if (Args.hasArg(options::OPT__migrate))
   return C.MakeAction(Input, types::TY_Remap);

Modified: cfe/trunk/lib/Driver/Types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=372680&r1=372679&r2=372680&view=diff
==
--- cfe/trunk/lib/Driver/Types.cpp (original)
+++ cfe/trunk/lib/Driver/Types.cpp Mon Sep 23 17:37:25 2019
@@ -328,7 +328,7 @@ void types::getCompilationPhases(const c
DAL.getLastArg(options::OPT_rewrite_legacy_objc) ||
DAL.getLastArg(options::OPT__migrate) ||
DAL.getLastArg(options::OPT_emit_iterface_stubs) ||
-   DAL.getLastArg(options::OPT__analyze, options::OPT__analyze_auto) ||
+   DAL.getLastArg(options::OPT__analyze) ||
DAL.getLastArg(options::OPT_emit_ast))
 llvm::copy_if(PhaseList, std::back_inserter(P),
   [](phases::ID Phase) { return Phase <= phases::Compile; });


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


r372683 - [static analyzer][test] Test directly that driver sets D__clang_analyzer__

2019-09-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Sep 23 19:06:59 2019
New Revision: 372683

URL: http://llvm.org/viewvc/llvm-project?rev=372683&view=rev
Log:
[static analyzer][test] Test directly that driver sets D__clang_analyzer__

Follow-up to fbd13570b0d

Modified:
cfe/trunk/test/Analysis/misc-driver.c

Modified: cfe/trunk/test/Analysis/misc-driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372683&r1=372682&r2=372683&view=diff
==
--- cfe/trunk/test/Analysis/misc-driver.c (original)
+++ cfe/trunk/test/Analysis/misc-driver.c Mon Sep 23 19:06:59 2019
@@ -1,5 +1,2 @@
-// RUN: %clang --analyze %s
-
-#ifndef __clang_analyzer__
-#error __clang_analyzer__ not defined
-#endif
+// RUN: %clang -### --analyze %s 2>&1 | FileCheck %s
+// CHECK: -D__clang_analyzer__


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


Re: r372679 - [static analyzer] Define __clang_analyzer__ macro in driver

2019-09-23 Thread Jan Korous via cfe-commits
Well, those were not fixups in the sense that I was aware of anything broken...

Anyway, I don't see a quick fix for clang-tidy so I'm going to revert.

> On Sep 23, 2019, at 8:00 PM, Nico Weber  wrote:
> 
> Even after all the fixup attempts, there's still a failing clang-tools-extra 
> test:
> 
> ninja: Entering directory `out/gn'
> [0/2] ACTION 
> //clang-tools-extra/test:check-clang-tools(//llvm/utils/gn/build/toolchain:unix)
> -- Testing: 787 tests, 64 threads --
> Testing: 0 .. 10
> FAIL: Clang Tools :: clang-tidy/clang-tidy-__clang_analyzer__macro.cpp (112 
> of 787)
>  TEST 'Clang Tools :: 
> clang-tidy/clang-tidy-__clang_analyzer__macro.cpp' FAILED 
> Script:
> --
> : 'RUN: at line 1';   clang-tidy 
> /usr/local/google/home/thakis/src/llvm-project/clang-tools-extra/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
>  -checks=-*,modernize-use-nullptr -- | count 0
> --
> Exit Code: 1
> 
> Command Output (stderr):
> --
> 1 error generated.
> Error while processing 
> /usr/local/google/home/thakis/src/llvm-project/clang-tools-extra/test/clang-tidy/clang-tidy-__clang_analyzer__macro.cpp.
> Found compiler error(s).
> Expected 0 lines, got 3.
> 
> --
> 
> 
> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
> Testing Time: 4.11s
> ************
> Failing Tests (1):
> Clang Tools :: clang-tidy/clang-tidy-__clang_analyzer__macro.cpp
> 
> 
> On Mon, Sep 23, 2019 at 8:31 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Mon Sep 23 17:33:47 2019
> New Revision: 372679
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=372679&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=372679&view=rev>
> Log:
> [static analyzer] Define __clang_analyzer__ macro in driver
> 
> Differential Revision: https://reviews.llvm.org/D67938 
> <https://reviews.llvm.org/D67938>
> 
> Added:
> cfe/trunk/test/Analysis/misc-driver.c
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Analysis/misc-ps.m
> 
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=372679&r1=372678&r2=372679&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=372679&r1=372678&r2=372679&view=diff>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Sep 23 17:33:47 2019
> @@ -3896,8 +3896,10 @@ void Clang::ConstructJob(Compilation &C,
>if (Args.hasArg(options::OPT_municode))
>  CmdArgs.push_back("-DUNICODE");
> 
> -  if (isa(JA))
> +  if (isa(JA)) {
>  RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
> +CmdArgs.push_back("-D__clang_analyzer__");
> +  }
> 
>// Enable compatilibily mode to avoid analyzer-config related errors.
>// Since we can't access frontend flags through hasArg, let's manually 
> iterate
> 
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=372679&r1=372678&r2=372679&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=372679&r1=372678&r2=372679&view=diff>
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Sep 23 17:33:47 2019
> @@ -990,10 +990,6 @@ static void InitializePredefinedMacros(c
>else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
>  Builder.defineMacro("__SSP_ALL__", "3");
> 
> -  // Define a macro that exists only when using the static analyzer.
> -  if (FEOpts.ProgramAction == frontend::RunAnalysis)
> -Builder.defineMacro("__clang_analyzer__");
> -
>if (LangOpts.FastRelaxedMath)
>  Builder.defineMacro("__FAST_RELAXED_MATH__");
> 
> 
> Added: cfe/trunk/test/Analysis/misc-driver.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372679&view=auto
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372679&view=auto>
> ==
&

r372685 - Revert "[static analyzer][test] Test directly that driver sets D__clang_analyzer__"

2019-09-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Sep 23 20:19:20 2019
New Revision: 372685

URL: http://llvm.org/viewvc/llvm-project?rev=372685&view=rev
Log:
Revert "[static analyzer][test] Test directly that driver sets 
D__clang_analyzer__"

This reverts commit c7541903d72765a38808e9973572a8d50c9d94fb.

Modified:
cfe/trunk/test/Analysis/misc-driver.c

Modified: cfe/trunk/test/Analysis/misc-driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372685&r1=372684&r2=372685&view=diff
==
--- cfe/trunk/test/Analysis/misc-driver.c (original)
+++ cfe/trunk/test/Analysis/misc-driver.c Mon Sep 23 20:19:20 2019
@@ -1,2 +1,5 @@
-// RUN: %clang -### --analyze %s 2>&1 | FileCheck %s
-// CHECK: -D__clang_analyzer__
+// RUN: %clang --analyze %s
+
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif


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


r372687 - Revert "[static analyzer] Define __clang_analyzer__ macro in driver"

2019-09-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Sep 23 20:21:22 2019
New Revision: 372687

URL: http://llvm.org/viewvc/llvm-project?rev=372687&view=rev
Log:
Revert "[static analyzer] Define __clang_analyzer__ macro in driver"

This reverts commit fbd13570b0d5f92ef2cf6bcfe7cc2f6178500187.

Removed:
cfe/trunk/test/Analysis/misc-driver.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=372687&r1=372686&r2=372687&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Sep 23 20:21:22 2019
@@ -3896,10 +3896,8 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasArg(options::OPT_municode))
 CmdArgs.push_back("-DUNICODE");
 
-  if (isa(JA)) {
+  if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
-CmdArgs.push_back("-D__clang_analyzer__");
-  }
 
   // Enable compatilibily mode to avoid analyzer-config related errors.
   // Since we can't access frontend flags through hasArg, let's manually 
iterate

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=372687&r1=372686&r2=372687&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Sep 23 20:21:22 2019
@@ -990,6 +990,10 @@ static void InitializePredefinedMacros(c
   else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
 Builder.defineMacro("__SSP_ALL__", "3");
 
+  // Define a macro that exists only when using the static analyzer.
+  if (FEOpts.ProgramAction == frontend::RunAnalysis)
+Builder.defineMacro("__clang_analyzer__");
+
   if (LangOpts.FastRelaxedMath)
 Builder.defineMacro("__FAST_RELAXED_MATH__");
 

Removed: cfe/trunk/test/Analysis/misc-driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-driver.c?rev=372686&view=auto
==
--- cfe/trunk/test/Analysis/misc-driver.c (original)
+++ cfe/trunk/test/Analysis/misc-driver.c (removed)
@@ -1,5 +0,0 @@
-// RUN: %clang --analyze %s
-
-#ifndef __clang_analyzer__
-#error __clang_analyzer__ not defined
-#endif

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=372687&r1=372686&r2=372687&view=diff
==
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Sep 23 20:21:22 2019
@@ -2,6 +2,10 @@
 // RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif
+
 typedef struct objc_ivar *Ivar;
 typedef struct objc_selector *SEL;
 typedef signed char BOOL;


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


Re: r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-12 Thread Jan Korous via cfe-commits
Hi Richard,

Here you are:
https://reviews.llvm.org/D45569 <https://reviews.llvm.org/D45569>

I am now thinking if it makes sense to output this warning for pre-17 standards:

warning: incrementing expression of type bool is deprecated and incompatible 
with C++17

Produced in:

SemaExpr.cpp

static QualType CheckIncrementDecrementOperand

// Increment of bool sets it to true, but is deprecated.
S.Diag(OpLoc, S.getLangOpts().CPlusPlus17 ? diag::ext_increment_bool
  : diag::warn_increment_bool)

What do you think?

Jan

> On 11 Apr 2018, at 15:19, Richard Smith  wrote:
> 
> While you're here... ++ should not be available for bool in C++17 onwards. :)
> 
> On Wed, 11 Apr 2018, 14:39 Jan Korous via cfe-commits, 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Wed Apr 11 06:36:29 2018
> New Revision: 329804
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329804&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=329804&view=rev>
> Log:
> [Sema] Fix built-in decrement operator overload resolution
> 
> C++ [over.built] p4:
> 
> "For every pair (T, VQ), where T is an arithmetic type other than bool, and 
> VQ is either volatile or empty, there exist candidate operator functions of 
> the form
> 
>   VQ T&  operator--(VQ T&);
>   T  operator--(VQ T&, int);
> "
> The bool type is in position LastPromotedIntegralType in 
> BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but 
> addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.
> 
> Differential Revision: https://reviews.llvm.org/D44988 
> <https://reviews.llvm.org/D44988>
> 
> rdar://problem/34255516
> 
> Modified:
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804&r1=329803&r2=329804&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804&r1=329803&r2=329804&view=diff>
> ==
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
> @@ -7796,10 +7796,12 @@ public:
>  if (!HasArithmeticOrEnumeralCandidateType)
>return;
> 
> -for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
> - Arith < NumArithmeticTypes; ++Arith) {
> +for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
> +  const auto TypeOfT = ArithmeticTypes[Arith];
> +  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
> +continue;
>addPlusPlusMinusMinusStyleOverloads(
> -ArithmeticTypes[Arith],
> +TypeOfT,
>  VisibleTypeConversionsQuals.hasVolatile(),
>  VisibleTypeConversionsQuals.hasRestrict());
>  }
> 
> Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804&r1=329803&r2=329804&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804&r1=329803&r2=329804&view=diff>
> ==
> --- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
> +++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11 
> 06:36:29 2018
> @@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
>// FIXME: should pass (void)static_cast(islong(e1 % e2));
>  }
> 
> +struct BoolRef {
> +  operator bool&();
> +};
> +
>  struct ShortRef { // expected-note{{candidate function (the implicit copy 
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment 
> operator) not viable}}
> @@ -73,6 +77,10 @@ struct LongRef {
>operator volatile long&();
>  };
> 
> +struct FloatRef {
> +  operator float&();
> +};
> +
>  struct XpmfRef { // expected-note{{candidate function (the implicit copy 
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment 
> operator) not viable}}
> @@ -84,13 +92,19 @@ struct E2Ref {
>operator E2&();
>  };
> 
> -void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef p

[clang-tools-extra] r329958 - [clangd][nfc] Simplify readDelimitedMessage()

2018-04-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Apr 12 14:33:24 2018
New Revision: 329958

URL: http://llvm.org/viewvc/llvm-project?rev=329958&view=rev
Log:
[clangd][nfc] Simplify readDelimitedMessage()

istream::eof() is always false after successful getline()

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

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=329958&r1=329957&r2=329958&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Thu Apr 12 14:33:24 
2018
@@ -271,8 +271,8 @@ static llvm::Optional readD
   std::string JSON;
   std::string Line;
   while (std::getline(In, Line)) {
-if (!In.eof()) // getline() consumed the newline.
-  Line.push_back('\n');
+Line.push_back('\n'); // getline() consumed the newline.
+
 auto LineRef = llvm::StringRef(Line).trim();
 if (LineRef.startswith("#")) // comment
   continue;
@@ -280,7 +280,7 @@ static llvm::Optional readD
 bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
 if (!IsDelim) // Line is part of a JSON message.
   JSON += Line;
-if (IsDelim || In.eof()) {
+if (IsDelim) {
   Out.mirrorInput(
   llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
   return std::move(JSON);


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


r330254 - [Sema] Disable built-in increment operator for bool in overload resolution in C++17

2018-04-18 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Apr 18 06:38:39 2018
New Revision: 330254

URL: http://llvm.org/viewvc/llvm-project?rev=330254&view=rev
Log:
[Sema] Disable built-in increment operator for bool in overload resolution in 
C++17

Following: https://llvm.org/svn/llvm-project/cfe/trunk@329804

For C++17 the wording of [over.built] p4 excluded bool:

For every pair (T , vq), where T is an arithmetic type other than bool, there 
exist
candidate operator functions of the form
  vq T & operator++(vq T &);
  T operator++(vq T &, int);

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

Added:
cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=330254&r1=330253&r2=330254&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 18 06:38:39 2018
@@ -7782,11 +7782,13 @@ public:
 InitArithmeticTypes();
   }
 
+  // Increment is deprecated for bool since C++17.
+  //
   // C++ [over.built]p3:
   //
-  //   For every pair (T, VQ), where T is an arithmetic type, and VQ
-  //   is either volatile or empty, there exist candidate operator
-  //   functions of the form
+  //   For every pair (T, VQ), where T is an arithmetic type other
+  //   than bool, and VQ is either volatile or empty, there exist
+  //   candidate operator functions of the form
   //
   //   VQ T&  operator++(VQ T&);
   //   T  operator++(VQ T&, int);
@@ -7805,8 +7807,12 @@ public:
 
 for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
   const auto TypeOfT = ArithmeticTypes[Arith];
-  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
-continue;
+  if (TypeOfT == S.Context.BoolTy) {
+if (Op == OO_MinusMinus)
+  continue;
+if (Op == OO_PlusPlus && S.getLangOpts().CPlusPlus17)
+  continue;
+  }
   addPlusPlusMinusMinusStyleOverloads(
 TypeOfT,
 VisibleTypeConversionsQuals.hasVolatile(),

Added: cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp?rev=330254&view=auto
==
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp (added)
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp Wed Apr 18 
06:38:39 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple 
x86_64-linux-gnu -std=c++17 %s
+
+struct BoolRef {
+  operator bool&();
+};
+
+void foo(BoolRef br) {
+  // C++ [over.built]p3: Increment for bool was removed in C++17.
+  bool b = br++; // expected-error{{cannot increment value of type 'BoolRef'}}
+}
\ No newline at end of file


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


[clang-tools-extra] r330608 - [clangd][tests] Fix handling of EOF in delimited input

2018-04-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Apr 23 08:55:07 2018
New Revision: 330608

URL: http://llvm.org/viewvc/llvm-project?rev=330608&view=rev
Log:
[clangd][tests] Fix handling of EOF in delimited input

Request in delimited input ended by EOF shouldn't be an error state.
Comments at the end of test file shouldn't be logged as an error state.
Input mirroring should work for the last request in delimited test file.

Added:
clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=330608&r1=330607&r2=330608&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Apr 23 08:55:07 
2018
@@ -277,21 +277,19 @@ static llvm::Optional readD
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }

Added: 
clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test?rev=330608&view=auto
==
--- clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test 
(added)
+++ clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test 
Mon Apr 23 08:55:07 2018
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t 
< %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end


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


[clang-tools-extra] r330609 - [clangd][tests] Fix delimiter handling

2018-04-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Apr 23 08:58:42 2018
New Revision: 330609

URL: http://llvm.org/viewvc/llvm-project?rev=330609&view=rev
Log:
[clangd][tests] Fix delimiter handling

Empty line shouldn't be considered a delimiter

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

Added:
clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=330609&r1=330608&r2=330609&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Apr 23 08:58:42 
2018
@@ -278,7 +278,7 @@ static llvm::Optional readD
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;

Added: clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test?rev=330609&view=auto
==
--- clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test (added)
+++ clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test Mon Apr 
23 08:58:42 2018
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck 
%s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error


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


r373977 - Add VFS support for sanitizers' blacklist

2019-10-07 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  7 15:36:19 2019
New Revision: 373977

URL: http://llvm.org/viewvc/llvm-project?rev=373977&view=rev
Log:
Add VFS support for sanitizers' blacklist

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

Added:
cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/ubsan-blacklist.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=373977&r1=373976&r2=373977&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct  7 15:36:19 2019
@@ -72,6 +72,7 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -81,6 +82,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -826,6 +828,18 @@ static bool isAddrSpaceMapManglingEnable
   llvm_unreachable("getAddressSpaceMapMangling() doesn't cover anything.");
 }
 
+static std::vector
+getRealPaths(llvm::vfs::FileSystem &VFS, llvm::ArrayRef Paths) {
+  std::vector Result;
+  llvm::SmallString<128> Buffer;
+  for (const auto &File : Paths) {
+if (std::error_code EC = VFS.getRealPath(File, Buffer))
+  llvm::report_fatal_error("can't open file '" + File + "': " + 
EC.message());
+Result.push_back(Buffer.str());
+  }
+  return Result;
+}
+
 ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins)
@@ -833,7 +847,10 @@ ASTContext::ASTContext(LangOptions &LOpt
   TemplateSpecializationTypes(this_()),
   DependentTemplateSpecializationTypes(this_()),
   SubstTemplateTemplateParmPacks(this_()), SourceMgr(SM), LangOpts(LOpts),
-  SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, 
SM)),
+  SanitizerBL(new SanitizerBlacklist(
+  getRealPaths(SM.getFileManager().getVirtualFileSystem(),
+   LangOpts.SanitizerBlacklistFiles),
+  SM)),
   XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles,
 LangOpts.XRayNeverInstrumentFiles,
 LangOpts.XRayAttrListFiles, SM)),

Added: cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml?rev=373977&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml (added)
+++ cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml Mon Oct  
7 15:36:19 2019
@@ -0,0 +1,15 @@
+{
+  'version': 0,
+  'roots': [
+{ 'name': '@DIR@', 'type': 'directory',
+  'contents': [
+{ 'name': 'only-virtual-file.blacklist', 'type': 'file',
+  'external-contents': '@REAL_FILE@'
+},
+{ 'name': 'invalid-virtual-file.blacklist', 'type': 'file',
+  'external-contents': '@NONEXISTENT_FILE@'
+}
+  ]
+}
+  ]
+}

Modified: cfe/trunk/test/CodeGen/ubsan-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist.c?rev=373977&r1=373976&r2=373977&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist.c Mon Oct  7 15:36:19 2019
@@ -5,6 +5,17 @@
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FUNC
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FILE
 
+// RUN: rm -f %t-vfsoverlay.yaml
+// RUN: rm -f %t-nonexistent.blacklist
+// RUN: sed -e "s|@DIR@|%T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
+
+// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
+// INVALID-MAPPED-FILE: inval

r373999 - Revert "Add VFS support for sanitizers' blacklist"

2019-10-07 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  7 17:36:19 2019
New Revision: 373999

URL: http://llvm.org/viewvc/llvm-project?rev=373999&view=rev
Log:
Revert "Add VFS support for sanitizers' blacklist"

Fix tests on Windows for now.

This reverts commit 96ac97a4213287003f08636d0c372b3f71e9cfca.

Removed:
cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/ubsan-blacklist.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=373999&r1=373998&r2=373999&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct  7 17:36:19 2019
@@ -72,7 +72,6 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -82,7 +81,6 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -828,18 +826,6 @@ static bool isAddrSpaceMapManglingEnable
   llvm_unreachable("getAddressSpaceMapMangling() doesn't cover anything.");
 }
 
-static std::vector
-getRealPaths(llvm::vfs::FileSystem &VFS, llvm::ArrayRef Paths) {
-  std::vector Result;
-  llvm::SmallString<128> Buffer;
-  for (const auto &File : Paths) {
-if (std::error_code EC = VFS.getRealPath(File, Buffer))
-  llvm::report_fatal_error("can't open file '" + File + "': " + 
EC.message());
-Result.push_back(Buffer.str());
-  }
-  return Result;
-}
-
 ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins)
@@ -847,10 +833,7 @@ ASTContext::ASTContext(LangOptions &LOpt
   TemplateSpecializationTypes(this_()),
   DependentTemplateSpecializationTypes(this_()),
   SubstTemplateTemplateParmPacks(this_()), SourceMgr(SM), LangOpts(LOpts),
-  SanitizerBL(new SanitizerBlacklist(
-  getRealPaths(SM.getFileManager().getVirtualFileSystem(),
-   LangOpts.SanitizerBlacklistFiles),
-  SM)),
+  SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, 
SM)),
   XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles,
 LangOpts.XRayNeverInstrumentFiles,
 LangOpts.XRayAttrListFiles, SM)),

Removed: cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml?rev=373998&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml (original)
+++ cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml (removed)
@@ -1,15 +0,0 @@
-{
-  'version': 0,
-  'roots': [
-{ 'name': '@DIR@', 'type': 'directory',
-  'contents': [
-{ 'name': 'only-virtual-file.blacklist', 'type': 'file',
-  'external-contents': '@REAL_FILE@'
-},
-{ 'name': 'invalid-virtual-file.blacklist', 'type': 'file',
-  'external-contents': '@NONEXISTENT_FILE@'
-}
-  ]
-}
-  ]
-}

Modified: cfe/trunk/test/CodeGen/ubsan-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist.c?rev=373999&r1=373998&r2=373999&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist.c Mon Oct  7 17:36:19 2019
@@ -5,17 +5,6 @@
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FUNC
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FILE
 
-// RUN: rm -f %t-vfsoverlay.yaml
-// RUN: rm -f %t-nonexistent.blacklist
-// RUN: sed -e "s|@DIR@|%T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
-// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
-
-// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPP

r374006 - Reland 'Add VFS support for sanitizers' blacklist'

2019-10-07 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  7 18:13:17 2019
New Revision: 374006

URL: http://llvm.org/viewvc/llvm-project?rev=374006&view=rev
Log:
Reland 'Add VFS support for sanitizers' blacklist'

The original patch broke the test for Windows.
Trying to fix as per Reid's suggestions outlined here:
https://reviews.llvm.org/rC371663

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

Added:
cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/ubsan-blacklist.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=374006&r1=374005&r2=374006&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct  7 18:13:17 2019
@@ -72,6 +72,7 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -81,6 +82,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -826,6 +828,18 @@ static bool isAddrSpaceMapManglingEnable
   llvm_unreachable("getAddressSpaceMapMangling() doesn't cover anything.");
 }
 
+static std::vector
+getRealPaths(llvm::vfs::FileSystem &VFS, llvm::ArrayRef Paths) {
+  std::vector Result;
+  llvm::SmallString<128> Buffer;
+  for (const auto &File : Paths) {
+if (std::error_code EC = VFS.getRealPath(File, Buffer))
+  llvm::report_fatal_error("can't open file '" + File + "': " + 
EC.message());
+Result.push_back(Buffer.str());
+  }
+  return Result;
+}
+
 ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins)
@@ -833,7 +847,10 @@ ASTContext::ASTContext(LangOptions &LOpt
   TemplateSpecializationTypes(this_()),
   DependentTemplateSpecializationTypes(this_()),
   SubstTemplateTemplateParmPacks(this_()), SourceMgr(SM), LangOpts(LOpts),
-  SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, 
SM)),
+  SanitizerBL(new SanitizerBlacklist(
+  getRealPaths(SM.getFileManager().getVirtualFileSystem(),
+   LangOpts.SanitizerBlacklistFiles),
+  SM)),
   XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles,
 LangOpts.XRayNeverInstrumentFiles,
 LangOpts.XRayAttrListFiles, SM)),

Added: cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml?rev=374006&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml (added)
+++ cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml Mon Oct  
7 18:13:17 2019
@@ -0,0 +1,15 @@
+{
+  'version': 0,
+  'roots': [
+{ 'name': '@DIR@', 'type': 'directory',
+  'contents': [
+{ 'name': 'only-virtual-file.blacklist', 'type': 'file',
+  'external-contents': '@REAL_FILE@'
+},
+{ 'name': 'invalid-virtual-file.blacklist', 'type': 'file',
+  'external-contents': '@NONEXISTENT_FILE@'
+}
+  ]
+}
+  ]
+}

Modified: cfe/trunk/test/CodeGen/ubsan-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist.c?rev=374006&r1=374005&r2=374006&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist.c Mon Oct  7 18:13:17 2019
@@ -5,6 +5,17 @@
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FUNC
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FILE
 
+// RUN: rm -f %t-vfsoverlay.yaml
+// RUN: rm -f %t-nonexistent.blacklist
+// RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
+
+// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-

r374011 - [NFC] Fix ubsan-blacklist test

2019-10-07 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  7 19:26:17 2019
New Revision: 374011

URL: http://llvm.org/viewvc/llvm-project?rev=374011&view=rev
Log:
[NFC] Fix ubsan-blacklist test

Restored original test and marked tests for VFS as unsupported on Windows.

Added:
cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c
Modified:
cfe/trunk/test/CodeGen/ubsan-blacklist.c

Added: cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c?rev=374011&view=auto
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c Mon Oct  7 19:26:17 2019
@@ -0,0 +1,38 @@
+// UNSUPPORTED: system-windows
+
+// Verify ubsan doesn't emit checks for blacklisted functions and files
+// RUN: echo "fun:hash" > %t-func.blacklist
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.blacklist
+
+// RUN: rm -f %t-vfsoverlay.yaml
+// RUN: rm -f %t-nonexistent.blacklist
+// RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
+
+// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
+// INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': No such file or 
directory
+
+// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm %s 
-o - 2>&1 | FileCheck %s --check-prefix=INVALID
+// INVALID: nonexistent.blacklist': No such file or directory
+
+unsigned i;
+
+// DEFAULT: @hash
+// FUNC: @hash
+// FILE: @hash
+unsigned hash() {
+// DEFAULT: call {{.*}}void @__ubsan
+// FUNC-NOT: call {{.*}}void @__ubsan
+// FILE-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// DEFAULT: @add
+// FUNC: @add
+// FILE: @add
+unsigned add() {
+// DEFAULT: call {{.*}}void @__ubsan
+// FUNC: call {{.*}}void @__ubsan
+// FILE-NOT: call {{.*}}void @__ubsan
+  return i + 1;
+}

Modified: cfe/trunk/test/CodeGen/ubsan-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist.c?rev=374011&r1=374010&r2=374011&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist.c Mon Oct  7 19:26:17 2019
@@ -5,17 +5,6 @@
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FUNC
 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow 
-fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s 
--check-prefix=FILE
 
-// RUN: rm -f %t-vfsoverlay.yaml
-// RUN: rm -f %t-nonexistent.blacklist
-// RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
-// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
-
-// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
-// INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': No such file or 
directory
-
-// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm %s 
-o - 2>&1 | FileCheck %s --check-prefix=INVALID
-// INVALID: nonexistent.blacklist': No such file or directory
-
 unsigned i;
 
 // DEFAULT: @hash


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


r374098 - [NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows

2019-10-08 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct  8 11:13:04 2019
New Revision: 374098

URL: http://llvm.org/viewvc/llvm-project?rev=374098&view=rev
Log:
[NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows

Previously disabled in d0c2d5daa3e

Modified:
cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c

Modified: cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c?rev=374098&r1=374097&r2=374098&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c Tue Oct  8 11:13:04 2019
@@ -1,5 +1,3 @@
-// UNSUPPORTED: system-windows
-
 // Verify ubsan doesn't emit checks for blacklisted functions and files
 // RUN: echo "fun:hash" > %t-func.blacklist
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.blacklist
@@ -7,9 +5,9 @@
 // RUN: rm -f %t-vfsoverlay.yaml
 // RUN: rm -f %t-nonexistent.blacklist
 // RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | 
sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e 
"s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
-// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%/T/only-virtual-file.blacklist 
-emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
 
-// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
+// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%/T/invalid-virtual-file.blacklist 
-emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
 // INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': No such file or 
directory
 
 // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
%t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm %s 
-o - 2>&1 | FileCheck %s --check-prefix=INVALID


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


Re: r374098 - [NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows

2019-10-08 Thread Jan Korous via cfe-commits
Thanks for the fix!

> On Oct 8, 2019, at 12:06 PM, Nico Weber  wrote:
> 
> Almost: http://45.33.8.238/win/78/step_6.txt 
> <http://45.33.8.238/win/78/step_6.txt>
> 
> C:\src\llvm-project\clang\test\CodeGen\ubsan-blacklist-vfs.c:11:25: error: 
> INVALID-MAPPED-FILE: expected string not found in input
> // INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': No such file or 
> directory
> ^
> :1:1: note: scanning from here
> fatal error: error in backend: can't open file 
> 'C:/src/llvm-project/out/gn/obj/clang/test/CodeGen/Output/invalid-virtual-file.blacklist':
>  no such file or directory
> 
> 
> Looks like it expects a "No such file" with a capital "No" but gets a "no 
> such file" with a lower-case n. {{[Nn]}}o probably fixes this.
> 
> On Tue, Oct 8, 2019 at 2:10 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Tue Oct  8 11:13:04 2019
> New Revision: 374098
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=374098&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=374098&view=rev>
> Log:
> [NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows
> 
> Previously disabled in d0c2d5daa3e
> 
> Modified:
> cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c
> 
> Modified: cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c?rev=374098&r1=374097&r2=374098&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c?rev=374098&r1=374097&r2=374098&view=diff>
> ==
> --- cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c (original)
> +++ cfe/trunk/test/CodeGen/ubsan-blacklist-vfs.c Tue Oct  8 11:13:04 2019
> @@ -1,5 +1,3 @@
> -// UNSUPPORTED: system-windows
> -
>  // Verify ubsan doesn't emit checks for blacklisted functions and files
>  // RUN: echo "fun:hash" > %t-func.blacklist
>  // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.blacklist
> @@ -7,9 +5,9 @@
>  // RUN: rm -f %t-vfsoverlay.yaml
>  // RUN: rm -f %t-nonexistent.blacklist
>  // RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml 
> | sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e 
> "s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
> -// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
> %t-vfsoverlay.yaml -fsanitize-blacklist=%T/only-virtual-file.blacklist 
> -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
> +// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
> %t-vfsoverlay.yaml -fsanitize-blacklist=%/T/only-virtual-file.blacklist 
> -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
> 
> -// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
> %t-vfsoverlay.yaml -fsanitize-blacklist=%T/invalid-virtual-file.blacklist 
> -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
> +// RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
> %t-vfsoverlay.yaml -fsanitize-blacklist=%/T/invalid-virtual-file.blacklist 
> -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
>  // INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': No such file or 
> directory
> 
>  // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay 
> %t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm 
> %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>

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


Re: r374006 - Reland 'Add VFS support for sanitizers' blacklist'

2019-10-09 Thread Jan Korous via cfe-commits
Ok, no worries. I understand the reason for the revert and will rewrite the 
patch.


> On Oct 9, 2019, at 7:19 AM, Ilya Biryukov  wrote:
> 
> Fair enough, sorry about that.
> 
> Nevertheless, I wanted to re-raise concerns about the approach taken in the 
> patch. It seems to assume invariants about VFS that don't necessarily hold 
> for filesystems outside those tested in upstream LLVM.
> PTAL at the original patch - calling `getRealPath` on the FS and later using 
> real-file-system with the results assumes the passed VFS is an overlay over 
> the physical filesystem.
> A simple unit-test with InMemoryFS would break right away, so the failing 
> case is pretty obvious.
> 
> There's an obvious alternative: just pass VFS to SanitizerBlacklist (in fact, 
> it already gets a source manager, which has a link to the VFS) and use it for 
> file accesses.
> I would suggest doing another round of review on this, happy to take part too.
> 
> On Wed, Oct 9, 2019 at 3:55 PM Nico Weber  <mailto:tha...@chromium.org>> wrote:
> FWIW reverting a patch for it breaking some internal system seems like poor 
> form to me. It's really hard to reland in that case. Please make a reduced 
> repro next time.
> 
> On Wed, Oct 9, 2019 at 5:38 AM Ilya Biryukov via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Reverted in r374151.
> 
> On Wed, Oct 9, 2019 at 11:03 AM Ilya Biryukov  <mailto:ibiryu...@google.com>> wrote:
> Hi Jan,
> 
> This patch seems to assume VFS will only re-map some paths, but still point 
> into the physical filesystem.
> This may not be the case, e.g. in unit tests.
> 
> This also manages to break some of our internal clang-tidy integrations for 
> obscure reasons.
> 
> Can we instead just pass VFS instance to the SanitizerBlacklist and use 
> relative paths?
> 
> We might also need to revert the patch to unbreak our release, sorry about 
> the inconvenience.
> 
> On Tue, Oct 8, 2019 at 3:11 AM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Mon Oct  7 18:13:17 2019
> New Revision: 374006
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=374006&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=374006&view=rev>
> Log:
> Reland 'Add VFS support for sanitizers' blacklist'
> 
> The original patch broke the test for Windows.
> Trying to fix as per Reid's suggestions outlined here:
> https://reviews.llvm.org/rC371663 <https://reviews.llvm.org/rC371663>
> 
> Differential Revision: https://reviews.llvm.org/D67742 
> <https://reviews.llvm.org/D67742>
> 
> Added:
> cfe/trunk/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml
> Modified:
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/test/CodeGen/ubsan-blacklist.c
> 
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=374006&r1=374005&r2=374006&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=374006&r1=374005&r2=374006&view=diff>
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct  7 18:13:17 2019
> @@ -72,6 +72,7 @@
>  #include "llvm/ADT/PointerUnion.h"
>  #include "llvm/ADT/STLExtras.h"
>  #include "llvm/ADT/SmallPtrSet.h"
> +#include "llvm/ADT/SmallString.h"
>  #include "llvm/ADT/SmallVector.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/StringRef.h"
> @@ -81,6 +82,7 @@
>  #include "llvm/Support/Compiler.h"
>  #include "llvm/Support/ErrorHandling.h"
>  #include "llvm/Support/MathExtras.h"
> +#include "llvm/Support/VirtualFileSystem.h"
>  #include "llvm/Support/raw_ostream.h"
>  #include 
>  #include 
> @@ -826,6 +828,18 @@ static bool isAddrSpaceMapManglingEnable
>llvm_unreachable("getAddressSpaceMapMangling() doesn't cover anything.");
>  }
> 
> +static std::vector
> +getRealPaths(llvm::vfs::FileSystem &VFS, llvm::ArrayRef Paths) {
> +  std::vector Result;
> +  llvm::SmallString<128> Buffer;
> +  for (const auto &File : Paths) {
> +if (std::error_code EC = VFS.getRealPath(File, Buffer))
> +  llvm::report_fatal_error("can't open file '" + File + "': " + 
> EC.message());
> +Result.push_back(Buffer.str());
> +  }
> +  return Result;
> +}
> +
>  ASTCon

[clang-tools-extra] r374815 - [clang-scan-deps] Support for clang --analyze in clang-scan-deps

2019-10-14 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct 14 13:15:01 2019
New Revision: 374815

URL: http://llvm.org/viewvc/llvm-project?rev=374815&view=rev
Log:
[clang-scan-deps] Support for clang --analyze in clang-scan-deps

The goal is to have 100% fidelity in clang-scan-deps behavior when
--analyze is present in compilation command.

At the same time I don't want to break clang-tidy which expects
__static_analyzer__ macro defined as built-in.

I introduce new cc1 options (-setup-static-analyzer) that controls
the macro definition and is conditionally set in driver.

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=374815&r1=374814&r2=374815&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Oct 14 13:15:01 2019
@@ -33,6 +33,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Rewrite/Frontend/FixItRewriter.h"
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/Tooling/Core/Diagnostic.h"
@@ -539,10 +540,8 @@ runClangTidy(clang::tidy::ClangTidyConte
FileManager *Files,
std::shared_ptr PCHContainerOps,
DiagnosticConsumer *DiagConsumer) override {
-  // Explicitly set ProgramAction to RunAnalysis to make the preprocessor
-  // define __clang_analyzer__ macro. The frontend analyzer action will not
-  // be called here.
-  Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
+  // Explicitly ask to define __clang_analyzer__ macro.
+  Invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
   return FrontendActionFactory::runInvocation(
   Invocation, Files, PCHContainerOps, DiagConsumer);
 }


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


r374815 - [clang-scan-deps] Support for clang --analyze in clang-scan-deps

2019-10-14 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct 14 13:15:01 2019
New Revision: 374815

URL: http://llvm.org/viewvc/llvm-project?rev=374815&view=rev
Log:
[clang-scan-deps] Support for clang --analyze in clang-scan-deps

The goal is to have 100% fidelity in clang-scan-deps behavior when
--analyze is present in compilation command.

At the same time I don't want to break clang-tidy which expects
__static_analyzer__ macro defined as built-in.

I introduce new cc1 options (-setup-static-analyzer) that controls
the macro definition and is conditionally set in driver.

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

Added:
cfe/trunk/test/Analysis/preprocessor-setup.c
cfe/trunk/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
cfe/trunk/test/ClangScanDeps/static-analyzer.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=374815&r1=374814&r2=374815&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Oct 14 13:15:01 2019
@@ -846,6 +846,8 @@ def preamble_bytes_EQ : Joined<["-"], "p
"covering the first N bytes of the main file">;
 def detailed_preprocessing_record : Flag<["-"], 
"detailed-preprocessing-record">,
   HelpText<"include a detailed record of preprocessing actions">;
+def setup_static_analyzer : Flag<["-"], "setup-static-analyzer">,
+  HelpText<"Set up preprocessor for static analyzer (done automatically when 
static analyzer is run).">;
 
 
//===--===//
 // OpenCL Options

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=374815&r1=374814&r2=374815&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Mon Oct 14 13:15:01 2019
@@ -181,6 +181,9 @@ public:
   ExcludedPreprocessorDirectiveSkipMapping
   *ExcludedConditionalDirectiveSkipMappings = nullptr;
 
+  /// Set up preprocessor for RunAnalysis action.
+  bool SetUpStaticAnalyzer = false;
+
 public:
   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=374815&r1=374814&r2=374815&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Oct 14 13:15:01 2019
@@ -3803,6 +3803,10 @@ void Clang::ConstructJob(Compilation &C,
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 
+  if (isa(JA) ||
+  (isa(JA) && Args.hasArg(options::OPT__analyze)))
+CmdArgs.push_back("-setup-static-analyzer");
+
   // Enable compatilibily mode to avoid analyzer-config related errors.
   // Since we can't access frontend flags through hasArg, let's manually 
iterate
   // through them.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=374815&r1=374814&r2=374815&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Oct 14 13:15:01 2019
@@ -3349,6 +3349,8 @@ static void ParsePreprocessorArgs(Prepro
   // "editor placeholder in source file" error in PP only mode.
   if (isStrictlyPreprocessorAction(Action))
 Opts.LexEditorPlaceholders = false;
+
+  Opts.SetUpStaticAnalyzer = Args.hasArg(OPT_setup_static_analyzer);
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=374815&r1=374814&r2=374815&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Oct 14 13:15:01 2019
@@ -560,6 +560,7 @@ static void InitializeCPlusPlusFeatureTe
 static void InitializePredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
const FrontendOptions &FEOpts,
+   const Prep

r374821 - [NFC] Fix ClangScanDeps/static-analyzer.c test on Windows

2019-10-14 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct 14 14:06:11 2019
New Revision: 374821

URL: http://llvm.org/viewvc/llvm-project?rev=374821&view=rev
Log:
[NFC] Fix ClangScanDeps/static-analyzer.c test on Windows

Follow-up to c5d14b5c6fa

Modified:
cfe/trunk/test/ClangScanDeps/static-analyzer.c

Modified: cfe/trunk/test/ClangScanDeps/static-analyzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/static-analyzer.c?rev=374821&r1=374820&r2=374821&view=diff
==
--- cfe/trunk/test/ClangScanDeps/static-analyzer.c (original)
+++ cfe/trunk/test/ClangScanDeps/static-analyzer.c Mon Oct 14 14:06:11 2019
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t.dir
-// RUN: rm -rf %t.dir/cdb.json
+// RUN: rm -rf %t-cdb.json
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/static-analyzer.c
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/analyze_header_input.h
-// RUN: sed -e "s|DIR|%t.dir|g" %S/Inputs/static-analyzer-cdb.json > 
%t.dir/cdb.json
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/static-analyzer-cdb.json > 
%t-cdb.json
 //
-// RUN: clang-scan-deps -compilation-database %t.dir/cdb.json -j 1 | FileCheck 
%s
+// RUN: clang-scan-deps -compilation-database %t-cdb.json -j 1 | FileCheck %s
 
 #ifdef __clang_analyzer__
 #include "Inputs/analyze_header_input.h"


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


r374926 - Reland [Driver] Fix -working-directory issues

2019-10-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct 15 10:51:59 2019
New Revision: 374926

URL: http://llvm.org/viewvc/llvm-project?rev=374926&view=rev
Log:
Reland [Driver] Fix -working-directory issues

Don't change the default VFS in Driver, update tests & reland.

This reverts commit 999f8a7416f8edc54ef92e715fd23c532bcc74d4.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/gen-cdb-fragment.c
cfe/trunk/test/Driver/working-directory.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=374926&r1=374925&r2=374926&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Oct 15 10:51:59 
2019
@@ -91,6 +91,8 @@ def err_no_external_assembler : Error<
   "there is no external assembler that can be used on this platform">;
 def err_drv_unable_to_remove_file : Error<
   "unable to remove file: %0">;
+def err_drv_unable_to_set_working_directory : Error <
+  "unable to set working directory: %0">;
 def err_drv_command_failure : Error<
   "unable to execute command: %0">;
 def err_drv_invalid_darwin_version : Error<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=374926&r1=374925&r2=374926&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Oct 15 10:51:59 2019
@@ -1012,6 +1012,11 @@ Compilation *Driver::BuildCompilation(Ar
 }
   }
 
+  // Check for working directory option before accessing any files
+  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
+if (VFS->setCurrentWorkingDirectory(WD->getValue()))
+  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 
@@ -1993,20 +1998,11 @@ bool Driver::DiagnoseInputExistence(cons
   if (Value == "-")
 return true;
 
-  SmallString<64> Path(Value);
-  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
-if (!llvm::sys::path::is_absolute(Path)) {
-  SmallString<64> Directory(WorkDir->getValue());
-  llvm::sys::path::append(Directory, Value);
-  Path.assign(Directory);
-}
-  }
-
-  if (getVFS().exists(Path))
+  if (getVFS().exists(Value))
 return true;
 
   if (IsCLMode()) {
-if (!llvm::sys::path::is_absolute(Twine(Path)) &&
+if (!llvm::sys::path::is_absolute(Twine(Value)) &&
 llvm::sys::Process::FindInEnvPath("LIB", Value))
   return true;
 
@@ -2032,12 +2028,12 @@ bool Driver::DiagnoseInputExistence(cons
 if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
   ExcludedFlagsBitmask) <= 1) {
   Diag(clang::diag::err_drv_no_such_file_with_suggestion)
-  << Path << Nearest;
+  << Value << Nearest;
   return false;
 }
   }
 
-  Diag(clang::diag::err_drv_no_such_file) << Path;
+  Diag(clang::diag::err_drv_no_such_file) << Value;
   return false;
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=374926&r1=374925&r2=374926&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Oct 15 10:51:59 2019
@@ -519,16 +519,15 @@ getFramePointerKind(const ArgList &Args,
 }
 
 /// Add a CC1 option to specify the debug compilation directory.
-static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
+static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs,
+   const llvm::vfs::FileSystem &VFS) {
   if (Arg *A = Args.getLastArg(options::OPT_fdebug_compilation_dir)) {
 CmdArgs.push_back("-fdebug-compilation-dir");
 CmdArgs.push_back(A->getValue());
-  } else {
-SmallString<128> cwd;
-if (!llvm::sys::fs::current_path(cwd)) {
-  CmdArgs.push_back("-fdebug-compilation-dir");
-  CmdArgs.push_back(Args.MakeArgString(cwd));
-}
+  } else if (llvm::ErrorOr CWD =
+ VFS.getCurrentWorkingDirectory()) {
+CmdArgs.push_back("-fdebug-compilation-dir");
+CmdArgs.push_back(Args.MakeArgString(*CWD));
   }
 }
 
@@ -808,13 +807,8 @@ static void addPGOAndCoverageFlags(const
 else
   OutputFilename = llvm::sys::path::filename(Output.getBaseInput());
 SmallString<128> CoverageFilename = OutputFilename;
-if (llvm::sys::path::is_relative(CoverageFilename)) {
-  SmallString<128> Pwd;
-  if (!llv

r374929 - Fix Driver/working-directory.c test

2019-10-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct 15 11:04:18 2019
New Revision: 374929

URL: http://llvm.org/viewvc/llvm-project?rev=374929&view=rev
Log:
Fix Driver/working-directory.c test

Accidentally committed debug print.

Modified:
cfe/trunk/test/Driver/working-directory.c

Modified: cfe/trunk/test/Driver/working-directory.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/working-directory.c?rev=374929&r1=374928&r2=374929&view=diff
==
--- cfe/trunk/test/Driver/working-directory.c (original)
+++ cfe/trunk/test/Driver/working-directory.c Tue Oct 15 11:04:18 2019
@@ -1,7 +1,6 @@
 // RUN: %clang -### -coverage -working-directory /no/such/dir/ input 2>&1 | 
FileCheck %s
 // RUN: %clang -### -coverage -working-directory %p/Inputs no_such_file.cpp -c 
2>&1 | FileCheck %s --check-prefix=CHECK_NO_FILE
 // RUN: %clang -### -coverage -working-directory %p/Inputs pchfile.cpp -c 2>&1 
| FileCheck %s --check-prefix=CHECK_WORKS
-// RUN: fail please
 
 // CHECK: unable to set working directory: /no/such/dir/
 


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


[clang] - b26e9e2 - Revert "[static analyzer] Define __clang_analyzer__ macro in driver"

2019-10-16 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2019-09-24T03:21:22Z
New Revision: b26e9e2a8f1865711c4e9b9aa7be712589169b3d

URL: 
https://github.com/llvm/llvm-project/commit/b26e9e2a8f1865711c4e9b9aa7be712589169b3d
DIFF: 
https://github.com/llvm/llvm-project/commit/b26e9e2a8f1865711c4e9b9aa7be712589169b3d.diff

LOG: Revert "[static analyzer] Define __clang_analyzer__ macro in driver"

This reverts commit fbd13570b0d5f92ef2cf6bcfe7cc2f6178500187.

llvm-svn: 372687

Added: 
   

Modified: 
   clang/lib/Driver/ToolChains/Clang.cpp
   clang/lib/Frontend/InitPreprocessor.cpp
   clang/test/Analysis/misc-ps.m

Removed: 
   clang/test/Analysis/misc-driver.c




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6453af73b0a5..aa17efbee32b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3896,10 +3896,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (Args.hasArg(options::OPT_municode))
 CmdArgs.push_back("-DUNICODE");
 
-  if (isa(JA)) {
+  if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
-CmdArgs.push_back("-D__clang_analyzer__");
-  }
 
   // Enable compatilibily mode to avoid analyzer-config related errors.
   // Since we can't access frontend flags through hasArg, let's manually 
iterate

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 9da37e0a446d..95d9f62c6087 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -990,6 +990,10 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
 Builder.defineMacro("__SSP_ALL__", "3");
 
+  // Define a macro that exists only when using the static analyzer.
+  if (FEOpts.ProgramAction == frontend::RunAnalysis)
+Builder.defineMacro("__clang_analyzer__");
+
   if (LangOpts.FastRelaxedMath)
 Builder.defineMacro("__FAST_RELAXED_MATH__");
 

diff  --git a/clang/test/Analysis/misc-driver.c 
b/clang/test/Analysis/misc-driver.c
deleted file mode 100644
index f9e7fe373d3c..
--- a/clang/test/Analysis/misc-driver.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang --analyze %s
-
-#ifndef __clang_analyzer__
-#error __clang_analyzer__ not defined
-#endif

diff  --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index 1cfd2eb1caf2..9a75cfd87b62 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -2,6 +2,10 @@
 // RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 
-analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region 
-verify -fblocks -Wno-unreachable-code -Wno-null-dereference 
-Wno-objc-root-class %s
 
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif
+
 typedef struct objc_ivar *Ivar;
 typedef struct objc_selector *SEL;
 typedef signed char BOOL;



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


[clang] f7c7e8a - [Analyzer][WebKit] RefCntblBaseVirtualDtorChecker

2020-05-21 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-05-21T11:54:49-07:00
New Revision: f7c7e8a523f56b0ed1b14c0756ba4e5d1ccb48d2

URL: 
https://github.com/llvm/llvm-project/commit/f7c7e8a523f56b0ed1b14c0756ba4e5d1ccb48d2
DIFF: 
https://github.com/llvm/llvm-project/commit/f7c7e8a523f56b0ed1b14c0756ba4e5d1ccb48d2.diff

LOG: [Analyzer][WebKit] RefCntblBaseVirtualDtorChecker

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

Added: 
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
clang/test/Analysis/Checkers/WebKit/mock-types.h

clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor-templates.cpp
clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 0bfb6456dc82..79ba8fb18ba8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1374,6 +1374,33 @@ double freed, or use after freed. This check attempts to 
find such problems.
zx_handle_close(sb);
  }
 
+WebKit
+^^
+
+WebKit is an open-source web browser engine available for macOS, iOS and Linux.
+This section describes checkers that can find issues in WebKit codebase.
+
+Most of the checkers focus on memory management for which WebKit uses custom 
implementation of reference counted smartpointers.
+Checker are formulated in terms related to ref-counting:
+* *Ref-counted type* is either ``Ref`` or ``RefPtr``.
+* *Ref-countable type* is any type that implements ``ref()`` and ``deref()`` 
methods as ``RefPtr<>`` is a template (i. e. relies on duck typing).
+* *Uncounted type* is ref-countable but not ref-counted type.
+
+.. _webkit-WebKitRefCntblBaseVirtualDtor:
+
+webkit.WebKitRefCntblBaseVirtualDtor
+
+All uncounted types used as base classes must have a virtual destructor.
+
+Ref-counted types hold their ref-countable data by a raw pointer and allow 
implicit upcasting from ref-counted pointer to derived type to ref-counted 
pointer to base type. This might lead to an object of (dynamic) derived type 
being deleted via pointer to the base class type which C++ standard defines as 
UB in case the base class doesn't have virtual destructor ``[expr.delete]``.
+
+.. code-block:: cpp
+ struct RefCntblBase {
+   void ref() {}
+   void deref() {}
+ };
+
+ struct Derived : RefCntblBase { }; // warn
 
 .. _alpha-checkers:
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 93c4d964d772..ec65afb30dd0 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -116,6 +116,9 @@ def NonDeterminismAlpha : Package<"nondeterminism">, 
ParentPackage;
 def Fuchsia : Package<"fuchsia">;
 def FuchsiaAlpha : Package<"fuchsia">, ParentPackage;
 
+def WebKit : Package<"webkit">;
+def WebKitAlpha : Package<"webkit">, ParentPackage;
+
 
//===--===//
 // Core Checkers.
 
//===--===//
@@ -1620,3 +1623,13 @@ def FuchsiaLockChecker : Checker<"Lock">,
 
 } // end fuchsia
 
+//===--===//
+// WebKit checkers.
+//===--===//
+
+let ParentPackage = WebKit in {
+
+def WebKitRefCntblBaseVirtualDtorChecker : 
Checker<"WebKitRefCntblBaseVirtualDtor">,
+  HelpText<"Check for any ref-countable base class having virtual 
destructor.">,
+  Documentation;
+} // end webkit

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index bcf2dfdb8326..4f885fadf415 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -121,6 +121,8 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
+  WebKit/PtrTypesSemantics.cpp
+  WebKit/RefCntblBaseVirtualDtorChecker.cpp
 
   LINK_LIBS
   clangAST

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
new file mode 100644
index ..26d79cfcd9b5
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
@@ -0,0 +1,70 @@
+//===- ASTUtis.h -

[clang] 54e91a3 - Reland "[Analyzer][WebKit] RefCntblBaseVirtualDtorChecker"

2020-05-21 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-05-21T16:41:00-07:00
New Revision: 54e91a3c701040d9d2e467bd483c197073b2c5e4

URL: 
https://github.com/llvm/llvm-project/commit/54e91a3c701040d9d2e467bd483c197073b2c5e4
DIFF: 
https://github.com/llvm/llvm-project/commit/54e91a3c701040d9d2e467bd483c197073b2c5e4.diff

LOG: Reland "[Analyzer][WebKit] RefCntblBaseVirtualDtorChecker"

This reverts commit 1108f5c737dbdab0277874a7e5b237491839c43a.

Added: 
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
clang/test/Analysis/Checkers/WebKit/mock-types.h

clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor-templates.cpp
clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 0bfb6456dc82..ea3f0e838b6a 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1374,6 +1374,33 @@ double freed, or use after freed. This check attempts to 
find such problems.
zx_handle_close(sb);
  }
 
+WebKit
+^^
+
+WebKit is an open-source web browser engine available for macOS, iOS and Linux.
+This section describes checkers that can find issues in WebKit codebase.
+
+Most of the checkers focus on memory management for which WebKit uses custom 
implementation of reference counted smartpointers.
+Checker are formulated in terms related to ref-counting:
+* *Ref-counted type* is either ``Ref`` or ``RefPtr``.
+* *Ref-countable type* is any type that implements ``ref()`` and ``deref()`` 
methods as ``RefPtr<>`` is a template (i. e. relies on duck typing).
+* *Uncounted type* is ref-countable but not ref-counted type.
+
+.. _webkit-RefCntblBaseVirtualDtor:
+
+webkit.RefCntblBaseVirtualDtor
+
+All uncounted types used as base classes must have a virtual destructor.
+
+Ref-counted types hold their ref-countable data by a raw pointer and allow 
implicit upcasting from ref-counted pointer to derived type to ref-counted 
pointer to base type. This might lead to an object of (dynamic) derived type 
being deleted via pointer to the base class type which C++ standard defines as 
UB in case the base class doesn't have virtual destructor ``[expr.delete]``.
+
+.. code-block:: cpp
+ struct RefCntblBase {
+   void ref() {}
+   void deref() {}
+ };
+
+ struct Derived : RefCntblBase { }; // warn
 
 .. _alpha-checkers:
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 93c4d964d772..f0ad8326929e 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -116,6 +116,9 @@ def NonDeterminismAlpha : Package<"nondeterminism">, 
ParentPackage;
 def Fuchsia : Package<"fuchsia">;
 def FuchsiaAlpha : Package<"fuchsia">, ParentPackage;
 
+def WebKit : Package<"webkit">;
+def WebKitAlpha : Package<"webkit">, ParentPackage;
+
 
//===--===//
 // Core Checkers.
 
//===--===//
@@ -1620,3 +1623,13 @@ def FuchsiaLockChecker : Checker<"Lock">,
 
 } // end fuchsia
 
+//===--===//
+// WebKit checkers.
+//===--===//
+
+let ParentPackage = WebKit in {
+
+def RefCntblBaseVirtualDtorChecker : Checker<"RefCntblBaseVirtualDtor">,
+  HelpText<"Check for any ref-countable base class having virtual 
destructor.">,
+  Documentation;
+} // end webkit

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index bcf2dfdb8326..4f885fadf415 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -121,6 +121,8 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
+  WebKit/PtrTypesSemantics.cpp
+  WebKit/RefCntblBaseVirtualDtorChecker.cpp
 
   LINK_LIBS
   clangAST

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
new file mode 100644
index ..26d79cfcd9b5
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
@@ -0,0 +1,70 @@
+//===- ASTUtis.h --

[clang] 660cda5 - [Analyzer][WebKit] NoUncountedMembersChecker

2020-05-27 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-05-27T19:46:32-07:00
New Revision: 660cda572d6e05e55a9d959e61aba51790c0abbd

URL: 
https://github.com/llvm/llvm-project/commit/660cda572d6e05e55a9d959e61aba51790c0abbd
DIFF: 
https://github.com/llvm/llvm-project/commit/660cda572d6e05e55a9d959e61aba51790c0abbd.diff

LOG: [Analyzer][WebKit] NoUncountedMembersChecker

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

Added: 
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-members.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index dcf1f28994de..c977dde8c52f 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1403,6 +1403,24 @@ Ref-counted types hold their ref-countable data by a raw 
pointer and allow impli
 
  struct Derived : RefCntblBase { }; // warn
 
+.. _webkit-WebKitNoUncountedMemberChecker:
+
+webkit.WebKitNoUncountedMemberChecker
+
+Raw pointers and references to uncounted types can't be used as class members. 
Only ref-counted types are allowed.
+
+.. code-block:: cpp
+ struct RefCntbl {
+   void ref() {}
+   void deref() {}
+ };
+
+ struct Foo {
+   RefCntbl * ptr; // warn
+   RefCntbl & ptr; // warn
+   // ...
+ };
+
 .. _alpha-checkers:
 
 Experimental Checkers

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 2ba3881c6135..2d69d8f34420 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1623,4 +1623,8 @@ let ParentPackage = WebKit in {
 def RefCntblBaseVirtualDtorChecker : Checker<"RefCntblBaseVirtualDtor">,
   HelpText<"Check for any ref-countable base class having virtual 
destructor.">,
   Documentation;
+
+def WebKitNoUncountedMemberChecker : Checker<"WebKitNoUncountedMemberChecker">,
+  HelpText<"Check for no uncounted member variables.">,
+  Documentation;
 } // end webkit

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 4f885fadf415..b3dc7a9f6321 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -121,6 +121,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
+  WebKit/NoUncountedMembersChecker.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
index 4979b8ffc2b2..781a8d746001 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
@@ -23,6 +23,14 @@ void printQuotedQualifiedName(llvm::raw_ostream &Os,
   Os << "'";
 }
 
+template 
+void printQuotedName(llvm::raw_ostream &Os, const NamedDeclDerivedT &D) {
+  Os << "'";
+  D->getNameForDiagnostic(Os, D->getASTContext().getPrintingPolicy(),
+  /*Qualified=*/false);
+  Os << "'";
+}
+
 } // namespace clang
 
 #endif

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
new file mode 100644
index ..89caf602a17e
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
@@ -0,0 +1,150 @@
+//===- NoUncountedMembersChecker.cpp -*- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ASTUtils.h"
+#include "DiagOutputUtils.h"
+#include "PtrTypesSemantics.h"
+#include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Casting.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NoUncountedMemberChecker
+: public Checker> {
+private:
+  BugType Bug;
+  mutable BugReporter *BR;
+

[clang] 1a5c97f - [ASTMatchers] Matchers related to C++ inheritance

2020-05-29 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-05-29T12:38:01-07:00
New Revision: 1a5c97f3a4b88438b19ff34a285e559e57b1e9d4

URL: 
https://github.com/llvm/llvm-project/commit/1a5c97f3a4b88438b19ff34a285e559e57b1e9d4
DIFF: 
https://github.com/llvm/llvm-project/commit/1a5c97f3a4b88438b19ff34a285e559e57b1e9d4.diff

LOG: [ASTMatchers] Matchers related to C++ inheritance

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
clang/docs/LibASTMatchersReference.html
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
index 12fb7d8a7ae8..5b6988509742 100644
--- 
a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
@@ -59,8 +59,9 @@ void 
NonPrivateMemberVariablesInClassesCheck::registerMatchers(
   // If we are ok with public fields, then we only want to complain about
   // protected fields, else we want to complain about all non-private fields.
   // We can ignore public member variables in structs/classes, in unions.
-  auto InterestingField = fieldDecl(
-  IgnorePublicMemberVariables ? isProtected() : unless(isPrivate()));
+  auto InterestingField = IgnorePublicMemberVariables
+  ? fieldDecl(isProtected())
+  : fieldDecl(unless(isPrivate()));
 
   // We only want the records that not only contain the mutable data 
(non-static
   // member variables), but also have some logic (non-static, non-implicit

diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 9db6795eb5fa..bb5e4984fcdf 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2175,6 +2175,75 @@ Narrowing Matchers
 
 
 
+MatcherCXXBaseSpecifier>isPrivate
+Matches private C++ 
declarations and C++ base specifers that specify private
+inheritance.
+
+Examples:
+  class C {
+  public:int a;
+  protected: int b;
+  private:   int c; // fieldDecl(isPrivate()) matches 'c'
+  };
+
+  struct Base {};
+  struct Derived1 : private Base {}; // matches 'Base'
+  class Derived2 : Base {}; // matches 'Base'
+
+
+
+MatcherCXXBaseSpecifier>isProtected
+Matches protected C++ 
declarations and C++ base specifers that specify
+protected inheritance.
+
+Examples:
+  class C {
+  public:int a;
+  protected: int b; // fieldDecl(isProtected()) matches 'b'
+  private:   int c;
+  };
+
+  class Base {};
+  class Derived : protected Base {}; // matches 'Base'
+
+
+
+MatcherCXXBaseSpecifier>isPublic
+Matches public C++ 
declarations and C++ base specifers that specify public
+inheritance.
+
+Examples:
+  class C {
+  public:int a; // fieldDecl(isPublic()) matches 'a'
+  protected: int b;
+  private:   int c;
+  };
+
+  class Base {};
+  class Derived1 : public Base {}; // matches 'Base'
+  struct Derived2 : Base {}; // matches 'Base'
+
+
+
+MatcherCXXBaseSpecifier>isVirtual
+Matches declarations of 
virtual methods and C++ base specifers that specify
+virtual inheritance.
+
+Example:
+  class A {
+   public:
+virtual void x(); // matches x
+  };
+
+Example:
+  class Base {};
+  class DirectlyDerived : virtual Base {}; // matches Base
+  class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
+
+Usable as: MatcherCXXMethodDecl>,
 MatcherCXXBaseSpecifier>
+
+
+
 MatcherCXXBoolLiteralExpr>equalsbool Value
 
 
@@ -2562,14 +2631,21 @@ Narrowing Matchers
 
 
 MatcherCXXMethodDecl>isVirtual
-Matches if the given 
method declaration is virtual.
+Matches declarations of 
virtual methods and C++ base specifers that specify
+virtual inheritance.
 
-Given
+Example:
   class A {
public:
-virtual void x();
+virtual void x(); // matches x
   };
-  matches A::x
+
+Example:
+  class Base {};
+  c

[clang] d61ad66 - [Analyzer][WebKit] Check record definition is available in NoUncountedMembers checker

2020-06-02 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-06-02T13:10:36-07:00
New Revision: d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc

URL: 
https://github.com/llvm/llvm-project/commit/d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc
DIFF: 
https://github.com/llvm/llvm-project/commit/d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc.diff

LOG: [Analyzer][WebKit] Check record definition is available in 
NoUncountedMembers checker

isRefCountable asserts that the record passed as an argument has a definition 
available.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=46142

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

Added: 
clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp

Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
index 89caf602a17e..db53db1587d5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
@@ -75,7 +75,8 @@ class NoUncountedMemberChecker
 continue;
 
   if (auto *MemberCXXRD = MemberType->getPointeeCXXRecordDecl()) {
-if (isRefCountable(MemberCXXRD))
+// If we don't see the definition we just don't know.
+if (MemberCXXRD->hasDefinition() && isRefCountable(MemberCXXRD))
   reportBug(Member, MemberType, MemberCXXRD, RD);
   }
 }

diff  --git 
a/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp
new file mode 100644
index ..20e58e7926d8
--- /dev/null
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-members-regression-46142.cpp
@@ -0,0 +1,9 @@
+// regression test for https://bugs.llvm.org/show_bug.cgi?id=46142
+
+// RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.WebKitNoUncountedMemberChecker -verify %s
+// expected-no-diagnostics
+
+class ClassWithoutADefinition;
+class Foo {
+const ClassWithoutADefinition *foo;
+};



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


[clang] 39fa431 - [Analyzer][NFC] Fix markup in WebKit checkers documentation

2020-06-02 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-06-02T16:04:23-07:00
New Revision: 39fa431c8ccad45de9ec67e8681da923d0cd28c7

URL: 
https://github.com/llvm/llvm-project/commit/39fa431c8ccad45de9ec67e8681da923d0cd28c7
DIFF: 
https://github.com/llvm/llvm-project/commit/39fa431c8ccad45de9ec67e8681da923d0cd28c7.diff

LOG: [Analyzer][NFC] Fix markup in WebKit checkers documentation

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index c977dde8c52f..34018047d57f 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1381,10 +1381,11 @@ WebKit is an open-source web browser engine available 
for macOS, iOS and Linux.
 This section describes checkers that can find issues in WebKit codebase.
 
 Most of the checkers focus on memory management for which WebKit uses custom 
implementation of reference counted smartpointers.
-Checker are formulated in terms related to ref-counting:
-* *Ref-counted type* is either ``Ref`` or ``RefPtr``.
-* *Ref-countable type* is any type that implements ``ref()`` and ``deref()`` 
methods as ``RefPtr<>`` is a template (i. e. relies on duck typing).
-* *Uncounted type* is ref-countable but not ref-counted type.
+
+Checkers are formulated in terms related to ref-counting:
+ - *Ref-counted type* is either ``Ref`` or ``RefPtr``.
+ - *Ref-countable type* is any type that implements ``ref()`` and ``deref()`` 
methods as ``RefPtr<>`` is a template (i. e. relies on duck typing).
+ - *Uncounted type* is ref-countable but not ref-counted type.
 
 .. _webkit-RefCntblBaseVirtualDtor:
 
@@ -1410,6 +1411,7 @@ webkit.WebKitNoUncountedMemberChecker
 Raw pointers and references to uncounted types can't be used as class members. 
Only ref-counted types are allowed.
 
 .. code-block:: cpp
+
  struct RefCntbl {
void ref() {}
void deref() {}



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


[clang] 5e8b4be - [AST][NFC] Simplify a regression test

2020-07-16 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-07-16T12:07:18-07:00
New Revision: 5e8b4be9f8546884889b1f178a6a2c2a5c1c9d1f

URL: 
https://github.com/llvm/llvm-project/commit/5e8b4be9f8546884889b1f178a6a2c2a5c1c9d1f
DIFF: 
https://github.com/llvm/llvm-project/commit/5e8b4be9f8546884889b1f178a6a2c2a5c1c9d1f.diff

LOG: [AST][NFC] Simplify a regression test

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

Added: 


Modified: 
clang/test/AST/regression-new-expr-crash.cpp
clang/unittests/AST/CMakeLists.txt

Removed: 
clang/unittests/AST/HasSideEffectsTest.cpp



diff  --git a/clang/test/AST/regression-new-expr-crash.cpp 
b/clang/test/AST/regression-new-expr-crash.cpp
index 81dd193b93e8..e1d93f92a125 100644
--- a/clang/test/AST/regression-new-expr-crash.cpp
+++ b/clang/test/AST/regression-new-expr-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
 
 struct Bar {int a;};
 const Bar arr[2] = {{1}};
@@ -11,3 +11,8 @@ void foo(int a) {
   Foo *foo_array;
   foo_array = new Foo[arr[0].a];
 }
+
+void Test(int N) {
+  int arr[N];
+  decltype([&arr]{}) *p; // expected-error {{lambda expression in an 
unevaluated operand}}
+}

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 185995d5b5a2..2e750ac9ea92 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -26,7 +26,6 @@ add_clang_unittest(ASTTests
   DeclTest.cpp
   EvaluateAsRValueTest.cpp
   ExternalASTSourceTest.cpp
-  HasSideEffectsTest.cpp
   NamedDeclPrinterTest.cpp
   RecursiveASTVisitorTest.cpp
   SizelessTypesTest.cpp

diff  --git a/clang/unittests/AST/HasSideEffectsTest.cpp 
b/clang/unittests/AST/HasSideEffectsTest.cpp
deleted file mode 100644
index 842afd8d7a9c..
--- a/clang/unittests/AST/HasSideEffectsTest.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-//===- unittest/AST/HasSideEffectsTest.cpp 
===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Attr.h"
-#include "clang/Frontend/FrontendAction.h"
-#include "clang/Tooling/Tooling.h"
-#include "llvm/ADT/FunctionExtras.h"
-#include "llvm/ADT/STLExtras.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-#include 
-
-using namespace clang;
-
-namespace {
-class ProcessASTAction : public clang::ASTFrontendAction {
-public:
-  ProcessASTAction(llvm::unique_function Process)
-  : Process(std::move(Process)) {
-assert(this->Process);
-  }
-
-  std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
-class Consumer : public ASTConsumer {
-public:
-  Consumer(llvm::function_ref Process)
-  : Process(Process) {}
-
-  void HandleTranslationUnit(ASTContext &Ctx) override { Process(Ctx); }
-
-private:
-  llvm::function_ref Process;
-};
-
-return std::make_unique(Process);
-  }
-
-private:
-  llvm::unique_function Process;
-};
-
-class RunHasSideEffects
-: public RecursiveASTVisitor {
-public:
-  RunHasSideEffects(ASTContext& Ctx)
-  : Ctx(Ctx) {}
-
-  bool VisitLambdaExpr(LambdaExpr *LE) {
-LE->HasSideEffects(Ctx);
-return true;
-  }
-
-  ASTContext& Ctx;
-};
-} // namespace
-
-TEST(HasSideEffectsTest, All) {
-  llvm::StringRef Code = R"cpp(
-void Test() {
-  int msize = 4;
-  float arr[msize];
-  [&arr] {};
-}
-  )cpp";
-
-  ASSERT_NO_FATAL_FAILURE(
-clang::tooling::runToolOnCode(
-  std::make_unique(
-  [&](clang::ASTContext &Ctx) {
-  RunHasSideEffects Visitor(Ctx);
-  Visitor.TraverseAST(Ctx);
-  }
-  ),
-  Code)
-  );
-
-}



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


  1   2   >