Re: r362316 - Add script to update OpenMP -ast-dump test expectations, and use it to

2019-06-02 Thread Roman Lebedev via cfe-commits
Thank you!

On Sun, Jun 2, 2019 at 6:57 AM Richard Smith via cfe-commits
 wrote:
>
> Author: rsmith
> Date: Sat Jun  1 21:00:38 2019
> New Revision: 362316
>
> URL: http://llvm.org/viewvc/llvm-project?rev=362316&view=rev
> Log:
> Add script to update OpenMP -ast-dump test expectations, and use it to
> regenerate the test expectations.
>
> (Only two tests change, as a result of no longer matching the 0x in a
> pointer; the other tests were already excluding that.)
>
> Added:
> cfe/trunk/utils/make-ast-dump-check.sh   (with props)
> Modified:
> cfe/trunk/test/AST/ast-dump-openmp-for.c
> cfe/trunk/test/AST/ast-dump-openmp-parallel.c
>
> Modified: cfe/trunk/test/AST/ast-dump-openmp-for.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-openmp-for.c?rev=362316&r1=362315&r2=362316&view=diff
> ==
> --- cfe/trunk/test/AST/ast-dump-openmp-for.c (original)
> +++ cfe/trunk/test/AST/ast-dump-openmp-for.c Sat Jun  1 21:00:38 2019
> @@ -35,208 +35,208 @@ void test_five(int x, int y, int z) {
>  ;
>  }
>
> -// CHECK: TranslationUnitDecl 0x{{.*}} <> 
> -// CHECK: |-FunctionDecl 0x{{.*}} <{{.*}}ast-dump-openmp-for.c:3:1, 
> line:7:1> line:3:6 test_one 'void (int)'
> -// CHECK-NEXT: | |-ParmVarDecl 0x{{.*}}  col:19 used x 'int'
> -// CHECK-NEXT: | `-CompoundStmt 0x{{.*}} 
> -// CHECK-NEXT: |   `-OMPForDirective 0x{{.*}} 
> -// CHECK-NEXT: | `-CapturedStmt 0x{{.*}} 
> -// CHECK-NEXT: |   |-CapturedDecl 0x{{.*}} <>  sloc>
> -// CHECK-NEXT: |   | |-ForStmt 0x{{.*}} 
> -// CHECK-NEXT: |   | | |-DeclStmt 0x{{.*}} 
> -// CHECK-NEXT: |   | | | `-VarDecl 0x{{.*}}  col:12 used 
> i 'int' cinit
> -// CHECK-NEXT: |   | | |   `-IntegerLiteral 0x{{.*}}  'int' 0
> +// CHECK: TranslationUnitDecl {{.*}} <> 
> +// CHECK: |-FunctionDecl {{.*}} <{{.*}}ast-dump-openmp-for.c:3:1, line:7:1> 
> line:3:6 test_one 'void (int)'
> +// CHECK-NEXT: | |-ParmVarDecl {{.*}}  col:19 used x 'int'
> +// CHECK-NEXT: | `-CompoundStmt {{.*}} 
> +// CHECK-NEXT: |   `-OMPForDirective {{.*}} 
> +// CHECK-NEXT: | `-CapturedStmt {{.*}} 
> +// CHECK-NEXT: |   |-CapturedDecl {{.*}} <> 
> +// CHECK-NEXT: |   | |-ForStmt {{.*}} 
> +// CHECK-NEXT: |   | | |-DeclStmt {{.*}} 
> +// CHECK-NEXT: |   | | | `-VarDecl {{.*}}  col:12 used i 
> 'int' cinit
> +// CHECK-NEXT: |   | | |   `-IntegerLiteral {{.*}}  'int' 0
>  // CHECK-NEXT: |   | | |-<<>>
> -// CHECK-NEXT: |   | | |-BinaryOperator 0x{{.*}}  'int' 
> '<'
> -// CHECK-NEXT: |   | | | |-ImplicitCastExpr 0x{{.*}}  'int' 
> 
> -// CHECK-NEXT: |   | | | | `-DeclRefExpr 0x{{.*}}  'int' lvalue 
> Var 0x{{.*}} 'i' 'int'
> -// CHECK-NEXT: |   | | | `-ImplicitCastExpr 0x{{.*}}  'int' 
> 
> -// CHECK-NEXT: |   | | |   `-DeclRefExpr 0x{{.*}}  'int' lvalue 
> ParmVar 0x{{.*}} 'x' 'int'
> -// CHECK-NEXT: |   | | |-UnaryOperator 0x{{.*}}  'int' 
> postfix '++'
> -// CHECK-NEXT: |   | | | `-DeclRefExpr 0x{{.*}}  'int' lvalue 
> Var 0x{{.*}} 'i' 'int'
> -// CHECK-NEXT: |   | | `-NullStmt 0x{{.*}}  
> openmp_structured_block
> -// CHECK-NEXT: |   | |-ImplicitParamDecl 0x{{.*}}  col:1 
> implicit __context 'struct (anonymous at {{.*}}ast-dump-openmp-for.c:4:1) 
> *const restrict'
> -// CHECK-NEXT: |   | `-VarDecl 0x{{.*}}  col:12 used i 
> 'int' cinit
> -// CHECK-NEXT: |   |   `-IntegerLiteral 0x{{.*}}  'int' 0
> -// CHECK-NEXT: |   `-DeclRefExpr 0x{{.*}}  'int' lvalue ParmVar 
> 0x{{.*}} 'x' 'int'
> -// CHECK-NEXT: |-FunctionDecl 0x{{.*}}  line:9:6 
> test_two 'void (int, int)'
> -// CHECK-NEXT: | |-ParmVarDecl 0x{{.*}}  col:19 used x 'int'
> -// CHECK-NEXT: | |-ParmVarDecl 0x{{.*}}  col:26 used y 'int'
> -// CHECK-NEXT: | `-CompoundStmt 0x{{.*}} 
> -// CHECK-NEXT: |   `-OMPForDirective 0x{{.*}} 
> -// CHECK-NEXT: | `-CapturedStmt 0x{{.*}} 
> -// CHECK-NEXT: |   |-CapturedDecl 0x{{.*}} <>  sloc>
> -// CHECK-NEXT: |   | |-ForStmt 0x{{.*}} 
> -// CHECK-NEXT: |   | | |-DeclStmt 0x{{.*}} 
> -// CHECK-NEXT: |   | | | `-VarDecl 0x{{.*}}  col:12 used 
> i 'int' cinit
> -// CHECK-NEXT: |   | | |   `-IntegerLiteral 0x{{.*}}  'int' 0
> +// CHECK-NEXT: |   | | |-BinaryOperator {{.*}}  'int' '<'
> +// CHECK-NEXT: |   | | | |-ImplicitCastExpr {{.*}}  'int' 
> 
> +// CHECK-NEXT: |   | | | | `-DeclRefExpr {{.*}}  'int' lvalue 
> Var {{.*}} 'i' 'int'
> +// CHECK-NEXT: |   | | | `-ImplicitCastExpr {{.*}}  'int' 
> 
> +// CHECK-NEXT: |   | | |   `-DeclRefExpr {{.*}}  'int' lvalue 
> ParmVar {{.*}} 'x' 'int'
> +// CHECK-NEXT: |   | | |-UnaryOperator {{.*}}  'int' 
> postfix '++'
> +// CHECK-NEXT: |   | | | `-DeclRefExpr {{.*}}  'int' lvalue Var 
> {{.*}} 'i' 'int'
> +// CHECK-NEXT: |   | | `-NullStmt {{.*}}  
> openmp_structured_block
> +// CHECK-NEXT: |   | |-ImplicitParamDecl {{.*}}  col:1 
> implicit __context 'struct (anonymous at {{.*}}ast-dump-openmp-for.c:4:1) 
> *const res

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

sysv abi is not only for UNIX but most non-Windows ones (BSDs, HAIKU, ...).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59744/new/

https://reviews.llvm.org/D59744



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


[PATCH] D62133: test/CodeGen/builtin-stackaddress.c duplicates test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c

2019-06-02 Thread A. Skrobov via Phabricator via cfe-commits
t.yomitch added a comment.

Thanks Eric!
I don't have commit access; could someone please commit this for me?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62133/new/

https://reviews.llvm.org/D62133



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


r362328 - [test] Fix plugin tests

2019-06-02 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Sun Jun  2 08:53:43 2019
New Revision: 362328

URL: http://llvm.org/viewvc/llvm-project?rev=362328&view=rev
Log:
[test] Fix plugin tests

Recommit of r361790 that was temporarily reverted in r361793 due to bot 
breakage.

Summary:
The following changes were required to fix these tests:

1) Change LLVM_ENABLE_PLUGINS to an option and move it to
   llvm/CMakeLists.txt with an appropriate default -- which matches
   the original default behavior.

2) Move the plugins directory from clang/test/Analysis
   clang/lib/Analysis.  It's not enough to add an exclude to the
   lit.local.cfg file because add_lit_testsuites recurses the tree and
   automatically adds the appropriate `check-` targets, which don't
   make sense for the plugins because they aren't tests and don't
   have `RUN` statements.

   Here's a list of the `clang-check-anlysis*` targets with this
   change:

```
  $ ninja -t targets all| sed -n "s/.*\/\(check[^:]*\):.*/\1/p" | sort -u | 
grep clang-analysis
  check-clang-analysis
  check-clang-analysis-checkers
  check-clang-analysis-copypaste
  check-clang-analysis-diagnostics
  check-clang-analysis-engine
  check-clang-analysis-exploration_order
  check-clang-analysis-html_diagnostics
  check-clang-analysis-html_diagnostics-relevant_lines
  check-clang-analysis-inlining
  check-clang-analysis-objc
  check-clang-analysis-unified-sources
  check-clang-analysis-z3
```

3) Simplify the logic and only include the subdirectories under
   clang/lib/Analysis/plugins if LLVM_ENABLE_PLUGINS is set.

Reviewed By: NoQ

Tags: #clang, #llvm

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

Added:
cfe/trunk/lib/Analysis/plugins/
cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt

cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp

cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/
cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt

cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp

cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
Removed:
cfe/trunk/test/Analysis/plugins/
Modified:
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/lib/Analysis/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CMakeLists.txt?rev=362328&r1=362327&r2=362328&view=diff
==
--- cfe/trunk/lib/Analysis/CMakeLists.txt (original)
+++ cfe/trunk/lib/Analysis/CMakeLists.txt Sun Jun  2 08:53:43 2019
@@ -34,3 +34,5 @@ add_clang_library(clangAnalysis
   clangBasic
   clangLex
   )
+
+add_subdirectory(plugins)

Added: cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/CMakeLists.txt?rev=362328&view=auto
==
--- cfe/trunk/lib/Analysis/plugins/CMakeLists.txt (added)
+++ cfe/trunk/lib/Analysis/plugins/CMakeLists.txt Sun Jun  2 08:53:43 2019
@@ -0,0 +1,5 @@
+if(LLVM_ENABLE_PLUGINS)
+  add_subdirectory(SampleAnalyzer)
+  add_subdirectory(CheckerDependencyHandling)
+  add_subdirectory(CheckerOptionHandling)
+endif()

Added: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt?rev=362328&view=auto
==
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
(added)
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt Sun 
Jun  2 08:53:43 2019
@@ -0,0 +1,10 @@
+set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+
+target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
+  clangAnalysis
+  clangAST
+  clangStaticAnalyzerCore
+  clangStaticAnalyzerFrontend
+  LLVMSupport
+  )

Added: 
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp?rev=362328&vi

[PATCH] D62445: [test] Fix plugin tests

2019-06-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362328: [test] Fix plugin tests (authored by dhinton, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62445?vs=202573&id=202605#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62445/new/

https://reviews.llvm.org/D62445

Files:
  cfe/trunk/lib/Analysis/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
  
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
  cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  
cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports
  cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/lit.local.cfg
  cfe/trunk/test/Analysis/plugins/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
  
cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  
cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
  cfe/trunk/test/CMakeLists.txt
  llvm/trunk/CMakeLists.txt
  llvm/trunk/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
@@ -912,14 +912,6 @@
   message(FATAL_ERROR "LLVM_LINK_LLVM_DYLIB not compatible with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS")
 endif()
 
-# Plugin support
-# FIXME: Make this configurable.
-if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
-  set(LLVM_ENABLE_PLUGINS ON)
-else()
-  set(LLVM_ENABLE_PLUGINS OFF)
-endif()
-
 # By default we should enable LLVM_ENABLE_IDE only for multi-configuration
 # generators. This option disables optional build system features that make IDEs
 # less usable.
Index: llvm/trunk/CMakeLists.txt
===
--- llvm/trunk/CMakeLists.txt
+++ llvm/trunk/CMakeLists.txt
@@ -622,6 +622,17 @@
 message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
 message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(WIN32 OR CYGWIN)
+  if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
+set(LLVM_ENABLE_PLUGINS_default ON)
+  else()
+set(LLVM_ENABLE_PLUGINS_default OFF)
+  endif()
+else()
+  set(LLVM_ENABLE_PLUGINS_default ON)
+endif()
+option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default})
+
 include(HandleLLVMOptions)
 
 # Verify that we can find a Python 2 interpreter.  Python 3 is unsupported.
Index: cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CMakeLists.txt
@@ -0,0 +1,5 @@
+if(LLVM_ENABLE_PLUGINS)
+  add_subdirectory(SampleAnalyzer)
+  add_subdirectory(CheckerDependencyHandling)
+  add_subdirectory(CheckerOptionHandling)
+endif()
Index: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
===
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString
Index: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL cla

r362329 - Add test coverage for __pascal mangling

2019-06-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Sun Jun  2 09:47:07 2019
New Revision: 362329

URL: http://llvm.org/viewvc/llvm-project?rev=362329&view=rev
Log:
Add test coverage for __pascal mangling

Modified:
cfe/trunk/test/CodeGenCXX/mangle-windows.cpp

Modified: cfe/trunk/test/CodeGenCXX/mangle-windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-windows.cpp?rev=362329&r1=362328&r2=362329&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-windows.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-windows.cpp Sun Jun  2 09:47:07 2019
@@ -20,6 +20,10 @@ extern "C" void __fastcall f4(void) {}
 // WIN: define dso_local x86_fastcallcc void @"\01@f4@0"
 // ITANIUM: define dso_local x86_fastcallcc void @"\01@f4@0"
 
+void __pascal f5(void) {}
+// WIN: define dso_local void @"?f5@@YCXXZ"
+// ITANIUM: define dso_local void @_Z2f5v
+
 struct Foo {
   void __stdcall foo();
   static void __stdcall bar();


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


r362331 - Add mangling test coverage for non-volatile const member pointers

2019-06-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Sun Jun  2 10:23:53 2019
New Revision: 362331

URL: http://llvm.org/viewvc/llvm-project?rev=362331&view=rev
Log:
Add mangling test coverage for non-volatile const member pointers

Modified:
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=362331&r1=362330&r2=362331&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Sun Jun  2 10:23:53 2019
@@ -120,6 +120,10 @@ FunT FunArr[10][20];
 int (__stdcall *j)(signed char, unsigned char);
 // CHECK-DAG: @"?j@@3P6GHCE@ZA"
 
+const char foo2::*m;
+// CHECK-DAG: @"?m@@3PRfoo@@DR1@"
+// X64-DAG:   @"?m@@3PERfoo@@DER1@"
+
 const volatile char foo2::*k;
 // CHECK-DAG: @"?k@@3PTfoo@@DT1@"
 // X64-DAG:   @"?k@@3PETfoo@@DET1@"


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


r362334 - Fix bug in r362328 -- append to dependency list instead of overwrite it.

2019-06-02 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Sun Jun  2 10:56:26 2019
New Revision: 362334

URL: http://llvm.org/viewvc/llvm-project?rev=362334&view=rev
Log:
Fix bug in r362328 -- append to dependency list instead of overwrite it.

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=362334&r1=362333&r2=362334&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Sun Jun  2 10:56:26 2019
@@ -121,7 +121,7 @@ endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
   if (LLVM_ENABLE_PLUGINS)
-set(CLANG_TEST_DEPS
+list(APPEND CLANG_TEST_DEPS
   SampleAnalyzerPlugin
   CheckerDependencyHandlingAnalyzerPlugin
   CheckerOptionHandlingAnalyzerPlugin


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


r362336 - Transform lambda expression captures when transforming an expression to

2019-06-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jun  2 11:53:44 2019
New Revision: 362336

URL: http://llvm.org/viewvc/llvm-project?rev=362336&view=rev
Log:
Transform lambda expression captures when transforming an expression to
potentially-evaluated.

This ensures that every potentially-evaluated expression is built in a
potentially-evaluated context. No functionality change intended.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=362336&r1=362335&r2=362336&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Jun  2 11:53:44 2019
@@ -5710,12 +5710,12 @@ public:
  LambdaCaptureDefault CaptureDefault);
 
   /// Start the definition of a lambda expression.
-  CXXMethodDecl *startLambdaDefinition(CXXRecordDecl *Class,
-   SourceRange IntroducerRange,
-   TypeSourceInfo *MethodType,
-   SourceLocation EndLoc,
-   ArrayRef Params,
-   bool IsConstexprSpecified);
+  CXXMethodDecl *
+  startLambdaDefinition(CXXRecordDecl *Class, SourceRange IntroducerRange,
+TypeSourceInfo *MethodType, SourceLocation EndLoc,
+ArrayRef Params,
+bool IsConstexprSpecified,
+Optional> Mangling = None);
 
   /// Endow the lambda scope info with the relevant properties.
   void buildLambdaScope(sema::LambdaScopeInfo *LSI,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=362336&r1=362335&r2=362336&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jun  2 11:53:44 2019
@@ -14579,6 +14579,7 @@ namespace {
 
 // Make sure we redo semantic analysis
 bool AlwaysRebuild() { return true; }
+bool ReplacingOriginal() { return true; }
 
 // We need to special-case DeclRefExprs referring to FieldDecls which
 // are not part of a member pointer formation; normal TreeTransforming
@@ -14605,10 +14606,11 @@ namespace {
   return BaseTransform::TransformUnaryOperator(E);
 }
 
-ExprResult TransformLambdaExpr(LambdaExpr *E) {
-  // Lambdas never need to be transformed.
-  return E;
-}
+// The body of a lambda-expression is in a separate expression evaluation
+// context so never needs to be transformed.
+// FIXME: Ideally we wouldn't transform the closure type either, and would
+// just recreate the capture expressions and lambda expression.
+StmtResult TransformLambdaBody(Stmt *Body) { return Body; }
   };
 }
 
@@ -14715,13 +14717,6 @@ void Sema::PopExpressionEvaluationContex
 
   for (const auto *L : Rec.Lambdas)
 Diag(L->getBeginLoc(), D);
-} else {
-  // Mark the capture expressions odr-used. This was deferred
-  // during lambda expression creation.
-  for (auto *Lambda : Rec.Lambdas) {
-for (auto *C : Lambda->capture_inits())
-  MarkDeclarationsReferencedInExpr(C);
-  }
 }
   }
 

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=362336&r1=362335&r2=362336&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Sun Jun  2 11:53:44 2019
@@ -367,12 +367,11 @@ Sema::ExpressionEvaluationContextRecord:
   return *MangleNumbering;
 }
 
-CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class,
-   SourceRange IntroducerRange,
-   TypeSourceInfo *MethodTypeInfo,
-   SourceLocation EndLoc,
-   ArrayRef Params,
-   const bool IsConstexprSpecified) {
+CXXMethodDecl *Sema::startLambdaDefinition(
+CXXRecordDecl *Class, SourceRange IntroducerRange,
+TypeSourceInfo *MethodTypeInfo, SourceLocation EndLoc,
+ArrayRef Params, const bool IsConstexprSpecified,
+Optional> Mangling) {
   QualType MethodType = MethodTypeInfo->getType();
   TemplateParameterList *TemplateParams =
 getGenericLambdaTemplateParameterList(getCurLambda(), *this);
@@ -438,12 +437,16 @@ CXXMethodDecl *Sema::startLambdaDefiniti
   P->setOwningFunction(Method);
   }
 
-  Decl *ManglingContextDecl;
-  if (Mang

r362340 - [analyzer] exploded-graph-rewriter: Initial commit.

2019-06-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Sun Jun  2 14:40:53 2019
New Revision: 362340

URL: http://llvm.org/viewvc/llvm-project?rev=362340&view=rev
Log:
[analyzer] exploded-graph-rewriter: Initial commit.

This is a utility to improve readability and generally manipulate
GraphViz dumps of the analysis graph. Such dumps are often huge and
not only hard to read, but also often hang the viewer apps with their
mere size. Such script should significantly improve debugging experience.

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

Added:
cfe/trunk/test/Analysis/exploded-graph-rewriter/
cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py   (with props)

Added: cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot?rev=362340&view=auto
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot (added)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot Sun Jun  2 
14:40:53 2019
@@ -0,0 +1,12 @@
+// RUN: %exploded_graph_rewriter %s | FileCheck %s
+
+Node0x1 [shape=record,label=
+ "{{ "node_id": 1, "pointer": "0x1",
+ "program_state": null, "program_points": []}\l}"];
+
+// CHECK: Node0x1 -> Node0x2;
+Node0x1 -> Node0x2;
+
+Node0x2 [shape=record,label=
+ "{{ "node_id": 2, "pointer": "0x2",
+ "program_state": null, "program_points": []}\l}"];

Added: cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot?rev=362340&view=auto
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot (added)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot Sun Jun  2 
14:40:53 2019
@@ -0,0 +1,9 @@
+// RUN: %exploded_graph_rewriter %s | FileCheck %s
+
+digraph "Exploded Graph" {
+  label="Exploded Graph";
+}
+
+// CHECK:  digraph "ExplodedGraph" {
+// CHECK-NEXT:   label="";
+// CHECK-NEXT: }

Added: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=362340&view=auto
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (added)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Sun Jun  2 
14:40:53 2019
@@ -0,0 +1,50 @@
+// RUN: %exploded_graph_rewriter %s | FileCheck %s
+
+// CHECK: Environment: 
+// CHECK-SAME: 
+// CHECK-SAME:   
+// CHECK-SAME: 
+// CHECK-SAME:   #0 Call
+// CHECK-SAME: 
+// CHECK-SAME: 
+// CHECK-SAME:   foo (line 4)
+// CHECK-SAME: 
+// CHECK-SAME:   
+// CHECK-SAME:   
+// CHECK-SAME: 
+// CHECK-SAME:   S5
+// CHECK-SAME: 
+// CHECK-SAME: 
+// CHECK-SAME:   bar()
+// CHECK-SAME: 
+// CHECK-SAME: 
+// CHECK-SAME:   Unknown
+// CHECK-SAME: 
+// CHECK-SAME:   
+// CHECK-SAME: 
+Node0x1 [shape=record,label=
+ "{
+{ "node_id": 1,
+  "pointer": "0x1",
+  "state_id": 2,
+  "program_points": [],
+  "program_state": {
+"store": null,
+"environment": [
+  {
+"location_context": "#0 Call",
+"lctx_id": 3,
+"calling": "foo",
+"call_line": 4,
+"items": [
+  {
+"stmt_id": 5,
+"pretty": "bar()",
+"value": "Unknown"
+  }
+]
+  }
+]
+  }
+}
+\l}"];

Added: cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg?rev=362340&view=auto
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg (added)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg Sun Jun  2 
14:40:53 2019
@@ -0,0 +1,13 @@
+import lit.util
+import lit.formats
+import os
+
+use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
+config.test_format = lit.formats.ShTest(use_lit_shell == "0")
+
+config.substitutions.append(('%exploded_graph_rewriter',
+ lit.util.which('exploded-graph-rewriter.py',
+os.path.join(config.clang_src_dir,
+ 'utils', 
'analyzer'

[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-06-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362340: [analyzer] exploded-graph-rewriter: Initial commit. 
(authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62638?vs=202511&id=202623#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62638/new/

https://reviews.llvm.org/D62638

Files:
  cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
  cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
  cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
  cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
  cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot
  cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Index: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
===
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,398 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import collections
+import json
+import logging
+import re
+
+
+# A deserialized source location.
+class SourceLocation(object):
+def __init__(self, json_loc):
+super(SourceLocation, self).__init__()
+self.line = json_loc['line']
+self.col = json_loc['column']
+self.filename = json_loc['filename'] \
+if 'filename' in json_loc else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json_pp):
+super(ProgramPoint, self).__init__()
+self.kind = json_pp['kind']
+self.tag = json_pp['tag']
+if self.kind == 'Edge':
+self.src_id = json_pp['src_id']
+self.dst_id = json_pp['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json_pp['stmt_kind']
+self.pointer = json_pp['pointer']
+self.pretty = json_pp['pretty']
+self.loc = SourceLocation(json_pp['location']) \
+if json_pp['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json_pp['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json_eb):
+super(EnvironmentBinding, self).__init__()
+self.stmt_id = json_eb['stmt_id']
+self.pretty = json_eb['pretty']
+self.value = json_eb['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, json_frame):
+super(LocationContext, self).__init__()
+self.lctx_id = json_frame['lctx_id']
+self.caption = json_frame['location_context']
+self.decl = json_frame['calling']
+self.line = json_frame['call_line']
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json_frame):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json_frame)
+self.bindings = [EnvironmentBinding(b) for b in json_frame['items']] \
+if json_frame['items'] is not None else []
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json_e):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json_e]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json_sb):
+super(StoreBinding, self).__init__()
+self.kind = json_sb['kind']
+self.offset = json_sb['offset']
+self.value = json_sb['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json_sc):
+super(StoreCluster, self).__init__()
+self.base_region = json_sc['cluster']
+self.bindings = [StoreBinding(b) for b in json_sc['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json_s):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json_s]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json_ps):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json_ps['store']) \
+if json_ps['store'] is not None else None
+self.environment = Environment(json_ps['environment']) \
+if json_ps['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constra

[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-06-02 Thread Jian Cai via Phabricator via cfe-commits
jcai19 marked 6 inline comments as done.
jcai19 added inline comments.



Comment at: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp:31
+  Result,
+  "prefer pipe2() to pipe() because pipe2() allows O_CLOEXEC",
+  ReplacementText);

gribozavr wrote:
> hokein wrote:
> > the message doesn't seem to explain the reason, especially to the people 
> > who are not familiar with the `pipe` API, maybe `prefer pipe2() to pipe() 
> > to avoid file descriptor leakage` is clearer?
> > 
> > Ah, it looks like you are following the existing `CloexecCreatCheck` check, 
> > no need to do it in this patch. 
> "prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child 
> processes"
> 
> No need to change in this patch if you're following an existing pattern, but 
> please do update the message in all checks in a separate patch to explain 
> things better.
Thanks for the comments. I have updated the text. 



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp:17
+  pipe(pipefd);
+  // CHECK-MESSAGES-NOT: warning:
+}

srhines wrote:
> hokein wrote:
> > nit: no need to do it explicitly, if a warning is shown unexpectedly, the 
> > test will fail.
> I somehow never realized this (and there seem to be several places that also 
> don't realize it). Thanks for letting us know.
Thanks for the clarification.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61967/new/

https://reviews.llvm.org/D61967



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


[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-06-02 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 202625.
jcai19 marked an inline comment as done.
jcai19 added a comment.

Remove CHECK-MESSAGES-NOT and update description based on comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61967/new/

https://reviews.llvm.org/D61967

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe %t
+
+extern "C" int pipe(int pipefd[2]);
+
+void f() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}
+
+namespace i {
+int pipe(int pipefd[2]);
+void g() {
+  int pipefd[2];
+  pipe(pipefd);
+}
+} // namespace i
+
+class C {
+public:
+  int pipe(int pipefd[2]);
+  void h() {
+int pipefd[2];
+pipe(pipefd);
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - android-cloexec-pipe
+
+android-cloexec-pipe
+
+
+This check detects usage of ``pipe()``. Using ``pipe()`` is not recommended, ``pipe2()`` is the
+suggested replacement. The check also adds the O_CLOEXEC flag that marks the file descriptor to
+be closed in child processes. Without this flag a sensitive file descriptor can be leaked to a
+child process, potentially into a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe(pipefd);
+
+Suggested replacement:
+
+.. code-block:: c++
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  This check detects usage of ``pipe()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy-*- 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_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Suggests to replace calls to pipe() with calls to pipe2().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
===
--- /dev/null
+++ clang-t

r362343 - [analyzer] exploded-graph-rewriter: An attempt to fix Windows buildbots.

2019-06-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Sun Jun  2 16:17:56 2019
New Revision: 362343

URL: http://llvm.org/viewvc/llvm-project?rev=362343&view=rev
Log:
[analyzer] exploded-graph-rewriter: An attempt to fix Windows buildbots.

Breakage caused by r362340.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg?rev=362343&r1=362342&r2=362343&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg Sun Jun  2 
16:17:56 2019
@@ -7,7 +7,7 @@ config.test_format = lit.formats.ShTest(
 
 config.substitutions.append(('%exploded_graph_rewriter',
  lit.util.which('exploded-graph-rewriter.py',
-os.path.join(config.clang_src_dir,
- 'utils', 
'analyzer'
+config.clang_src_dir +
+'/utils/analyzer')))
 
 config.suffixes = ['.dot']


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


r362347 - Revert "[analyzer] exploded-graph-rewriter: An attempt to fix Windows buildbots."

2019-06-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Sun Jun  2 17:21:00 2019
New Revision: 362347

URL: http://llvm.org/viewvc/llvm-project?rev=362347&view=rev
Log:
Revert "[analyzer] exploded-graph-rewriter: An attempt to fix Windows 
buildbots."

This reverts commit r362343.

Instead, disable tests on Windows for now.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot Sun Jun  2 
17:21:00 2019
@@ -1,5 +1,8 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
 Node0x1 [shape=record,label=
  "{{ "node_id": 1, "pointer": "0x1",
  "program_state": null, "program_points": []}\l}"];

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot Sun Jun  2 
17:21:00 2019
@@ -1,5 +1,8 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
 digraph "Exploded Graph" {
   label="Exploded Graph";
 }

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Sun Jun  2 
17:21:00 2019
@@ -1,5 +1,8 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
 // CHECK: Environment: 
 // CHECK-SAME: 
 // CHECK-SAME:   

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/lit.local.cfg Sun Jun  2 
17:21:00 2019
@@ -7,7 +7,7 @@ config.test_format = lit.formats.ShTest(
 
 config.substitutions.append(('%exploded_graph_rewriter',
  lit.util.which('exploded-graph-rewriter.py',
-config.clang_src_dir +
-'/utils/analyzer')))
+os.path.join(config.clang_src_dir,
+ 'utils', 
'analyzer'
 
 config.suffixes = ['.dot']

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot 
(original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot Sun Jun  
2 17:21:00 2019
@@ -1,5 +1,8 @@
 // RUN: %exploded_graph_rewriter %s | FileCheck %s
 
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
 // CHECK: Program point:
 // CHECK-SAME: 
 // CHECK-SAME:   

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot?rev=362347&r1=362346&r2=362347&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot Sun Jun  2 
17:21:00 2019
@@ -1,5 +1,8 @@
 // RUN: %exploded_graph_rewriter %s | FileChe

r362348 - [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda

2019-06-02 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Sun Jun  2 17:47:32 2019
New Revision: 362348

URL: http://llvm.org/viewvc/llvm-project?rev=362348&view=rev
Log:
[coroutines][PR41909] Don't build dependent coroutine statements for generic 
lambda

Summary:
https://bugs.llvm.org/show_bug.cgi?id=41909 describes an issue in which
a generic lambda that takes a dependent argument `auto set` causes the
template instantiation machinery for coroutine body statements to crash
with an ICE. The issue is two-fold:

1. The paths taken by the template instantiator contain several asserts
   that the coroutine promise must not have a dependent type.
2. The template instantiator unconditionally builds corotuine statements
   that depend on the promise type, which cannot be dependent.

To work around the issue, prevent the template instantiator from building
dependent coroutine statements if the coroutine promise type is dependent.
Since we only expect this to occur in the case of a generic lambda, limit
the workaround behavior to just that case.

Reviewers: GorNishanov, EricWF, lewissbaker, tks2103

Reviewed By: GorNishanov

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=362348&r1=362347&r2=362348&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Sun Jun  2 17:47:32 2019
@@ -7163,13 +7163,22 @@ TreeTransform::TransformCorouti
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-assert(!Promise->getType()->isDependentType() &&
-   "the promise type must no longer be dependent");
-assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
-   !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
-   "these nodes should not have been built yet");
-if (!Builder.buildDependentStatements())
-  return StmtError();
+// PR41909: We may find a generic coroutine lambda definition within a
+// template function that is being instantiated. In this case, the lambda
+// will have a dependent promise type, until it is used in an expression
+// that creates an instantiation with a non-dependent promise type. We
+// should not assert or build coroutine dependent statements for such a
+// generic lambda.
+auto *MD = dyn_cast_or_null(FD);
+if (!MD || !MD->getParent()->isGenericLambda()) {
+  assert(!Promise->getType()->isDependentType() &&
+ "the promise type must no longer be dependent");
+  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
+ !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
+ "these nodes should not have been built yet");
+  if (!Builder.buildDependentStatements())
+return StmtError();
+}
   } else {
 if (auto *OnFallthrough = S->getFallthroughHandler()) {
   StmtResult Res = getDerived().TransformStmt(OnFallthrough);

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=362348&r1=362347&r2=362348&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Sun Jun  2 17:47:32 2019
@@ -720,6 +720,16 @@ coro ok_static_coawait()
   co_await 42;
 }
 
+template void ok_generic_lambda_coawait_PR41909() {
+  [](auto& arg) -> coro { // expected-warning {{expression 
result unused}}
+co_await 12;
+  };
+  [](auto &arg) -> coro {
+co_await 24;
+  }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in 
instantiation of function template specialization 
'ok_generic_lambda_coawait_PR41909' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 


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


[PATCH] D62550: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda

2019-06-02 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362348: [coroutines][PR41909] Don't build dependent 
coroutine statements for generic… (authored by modocache, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62550/new/

https://reviews.llvm.org/D62550

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/SemaCXX/coroutines.cpp


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -720,6 +720,16 @@
   co_await 42;
 }
 
+template void ok_generic_lambda_coawait_PR41909() {
+  [](auto& arg) -> coro { // expected-warning {{expression 
result unused}}
+co_await 12;
+  };
+  [](auto &arg) -> coro {
+co_await 24;
+  }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in 
instantiation of function template specialization 
'ok_generic_lambda_coawait_PR41909' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -7163,13 +7163,22 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-assert(!Promise->getType()->isDependentType() &&
-   "the promise type must no longer be dependent");
-assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
-   !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
-   "these nodes should not have been built yet");
-if (!Builder.buildDependentStatements())
-  return StmtError();
+// PR41909: We may find a generic coroutine lambda definition within a
+// template function that is being instantiated. In this case, the lambda
+// will have a dependent promise type, until it is used in an expression
+// that creates an instantiation with a non-dependent promise type. We
+// should not assert or build coroutine dependent statements for such a
+// generic lambda.
+auto *MD = dyn_cast_or_null(FD);
+if (!MD || !MD->getParent()->isGenericLambda()) {
+  assert(!Promise->getType()->isDependentType() &&
+ "the promise type must no longer be dependent");
+  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
+ !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
+ "these nodes should not have been built yet");
+  if (!Builder.buildDependentStatements())
+return StmtError();
+}
   } else {
 if (auto *OnFallthrough = S->getFallthroughHandler()) {
   StmtResult Res = getDerived().TransformStmt(OnFallthrough);


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -720,6 +720,16 @@
   co_await 42;
 }
 
+template void ok_generic_lambda_coawait_PR41909() {
+  [](auto& arg) -> coro { // expected-warning {{expression result unused}}
+co_await 12;
+  };
+  [](auto &arg) -> coro {
+co_await 24;
+  }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -7163,13 +7163,22 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-assert(!Promise->getType()->isDependentType() &&
-   "the promise type must no longer be dependent");
-assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
-   !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
-   "these nodes should not have been built yet");
-if (!Builder.buildDependentStatements())
-  return StmtError();
+// PR41909: We may find a generic coroutine lambda definition within a
+// template function that is being instantiated. In this case, the lambda
+// will have a dependent promise type, until it is used in an expression
+// that creates an instantiation with a non-dependent promise type. We
+// should not assert or build coroutine dependent statements for such a
+// generic lambda.
+auto *MD = dyn_cast_or_null(FD);
+if (!MD || !MD->getParent()->isGenericLambda()) {
+  assert(!Promise->getType()->isDependentType() &&
+ "the promise type must no longer be dependent"

[PATCH] D62550: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda

2019-06-02 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Great, thanks for the review!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62550/new/

https://reviews.llvm.org/D62550



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


[PATCH] D59407: [clangd] Add RelationSlab

2019-06-02 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362352: [clangd] Add RelationSlab (authored by nridge, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59407?vs=202369&id=202643#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59407/new/

https://reviews.llvm.org/D59407

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/Relation.cpp
  clang-tools-extra/trunk/clangd/index/Relation.h
  clang-tools-extra/trunk/clangd/unittests/IndexTests.cpp

Index: clang-tools-extra/trunk/clangd/index/Relation.cpp
===
--- clang-tools-extra/trunk/clangd/index/Relation.cpp
+++ clang-tools-extra/trunk/clangd/index/Relation.cpp
@@ -0,0 +1,40 @@
+//===--- Relation.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 "Relation.h"
+
+#include 
+
+namespace clang {
+namespace clangd {
+
+llvm::iterator_range
+RelationSlab::lookup(const SymbolID &Subject,
+ index::SymbolRole Predicate) const {
+  auto IterPair = std::equal_range(Relations.begin(), Relations.end(),
+   Relation{Subject, Predicate, SymbolID{}},
+   [](const Relation &A, const Relation &B) {
+ return std::tie(A.Subject, A.Predicate) <
+std::tie(B.Subject, B.Predicate);
+   });
+  return {IterPair.first, IterPair.second};
+}
+
+RelationSlab RelationSlab::Builder::build() && {
+  // Sort in SPO order.
+  std::sort(Relations.begin(), Relations.end());
+
+  // Remove duplicates.
+  Relations.erase(std::unique(Relations.begin(), Relations.end()),
+  Relations.end());
+
+  return RelationSlab{std::move(Relations)};
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/trunk/clangd/index/Relation.h
===
--- clang-tools-extra/trunk/clangd/index/Relation.h
+++ clang-tools-extra/trunk/clangd/index/Relation.h
@@ -0,0 +1,88 @@
+//===--- Relation.h --*- 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_TOOLS_EXTRA_CLANGD_INDEX_RELATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RELATION_H
+
+#include "SymbolID.h"
+#include "SymbolLocation.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/iterator_range.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Represents a relation between two symbols.
+/// For an example "A is a base class of B" may be represented
+/// as { Subject = A, Predicate = RelationBaseOf, Object = B }.
+struct Relation {
+  SymbolID Subject;
+  index::SymbolRole Predicate;
+  SymbolID Object;
+
+  bool operator==(const Relation &Other) const {
+return std::tie(Subject, Predicate, Object) ==
+   std::tie(Other.Subject, Other.Predicate, Other.Object);
+  }
+  // SPO order
+  bool operator<(const Relation &Other) const {
+return std::tie(Subject, Predicate, Object) <
+   std::tie(Other.Subject, Other.Predicate, Other.Object);
+  }
+};
+
+class RelationSlab {
+public:
+  using value_type = Relation;
+  using const_iterator = std::vector::const_iterator;
+  using iterator = const_iterator;
+
+  RelationSlab() = default;
+  RelationSlab(RelationSlab &&Slab) = default;
+  RelationSlab &operator=(RelationSlab &&RHS) = default;
+
+  const_iterator begin() const { return Relations.begin(); }
+  const_iterator end() const { return Relations.end(); }
+  size_t size() const { return Relations.size(); }
+  bool empty() const { return Relations.empty(); }
+
+  size_t bytes() const {
+return sizeof(*this) + sizeof(value_type) * Relations.capacity();
+  }
+
+  /// Lookup all relations matching the given subject and predicate.
+  llvm::iterator_range lookup(const SymbolID &Subject,
+index::SymbolRole Predicate) const;
+
+  /// RelationSlab::Builder is a mutable container that can 'freeze' to
+  /// RelationSlab.
+  class Builder {
+  public:
+/// Adds a relation to the slab.
+void insert(const Relation &R) { Relations.push_back(R); }
+

[PATCH] D62459: [clangd] Serialization support for RelationSlab

2019-06-02 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
nridge marked 4 inline comments as done.
Closed by commit rL362353: [clangd] Serialization support for RelationSlab 
(authored by nridge, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62459?vs=202370&id=202645#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62459/new/

https://reviews.llvm.org/D62459

Files:
  clang-tools-extra/trunk/clangd/index/Serialization.cpp
  clang-tools-extra/trunk/clangd/index/Serialization.h
  clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/trunk/clangd/unittests/SerializationTests.cpp

Index: clang-tools-extra/trunk/clangd/index/Serialization.cpp
===
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp
@@ -24,6 +24,29 @@
   return llvm::make_error(Msg,
  llvm::inconvertibleErrorCode());
 }
+} // namespace
+
+RelationKind symbolRoleToRelationKind(index::SymbolRole Role) {
+  // SymbolRole is used to record relations in the index.
+  // Only handle the relations we actually store currently.
+  // If we start storing more relations, this list can be expanded.
+  switch (Role) {
+  case index::SymbolRole::RelationBaseOf:
+return RelationKind::BaseOf;
+  default:
+llvm_unreachable("Unsupported symbol role");
+  }
+}
+
+index::SymbolRole relationKindToSymbolRole(RelationKind Kind) {
+  switch (Kind) {
+  case RelationKind::BaseOf:
+return index::SymbolRole::RelationBaseOf;
+  }
+  llvm_unreachable("Invalid relation kind");
+}
+
+namespace {
 
 // IO PRIMITIVES
 // We use little-endian 32 bit ints, sometimes with variable-length encoding.
@@ -358,6 +381,28 @@
   return Result;
 }
 
+// RELATIONS ENCODING
+// A relations section is a flat list of relations. Each relation has:
+//  - SymbolID (subject): 8 bytes
+//  - relation kind (predicate): 1 byte
+//  - SymbolID (object): 8 bytes
+// In the future, we might prefer a packed representation if the need arises.
+
+void writeRelation(const Relation &R, llvm::raw_ostream &OS) {
+  OS << R.Subject.raw();
+  RelationKind Kind = symbolRoleToRelationKind(R.Predicate);
+  OS.write(static_cast(Kind));
+  OS << R.Object.raw();
+}
+
+Relation readRelation(Reader &Data) {
+  SymbolID Subject = Data.consumeID();
+  index::SymbolRole Predicate =
+  relationKindToSymbolRole(static_cast(Data.consume8()));
+  SymbolID Object = Data.consumeID();
+  return {Subject, Predicate, Object};
+}
+
 // FILE ENCODING
 // A file is a RIFF chunk with type 'CdIx'.
 // It contains the sections:
@@ -434,6 +479,17 @@
   return makeError("malformed or truncated refs");
 Result.Refs = std::move(Refs).build();
   }
+  if (Chunks.count("rela")) {
+Reader RelationsReader(Chunks.lookup("rela"));
+RelationSlab::Builder Relations;
+while (!RelationsReader.eof()) {
+  auto Relation = readRelation(RelationsReader);
+  Relations.insert(Relation);
+}
+if (RelationsReader.err())
+  return makeError("malformed or truncated relations");
+Result.Relations = std::move(Relations).build();
+  }
   return std::move(Result);
 }
 
@@ -483,6 +539,14 @@
 }
   }
 
+  std::vector Relations;
+  if (Data.Relations) {
+for (const auto &Relation : *Data.Relations) {
+  Relations.emplace_back(Relation);
+  // No strings to be interned in relations.
+}
+  }
+
   std::string StringSection;
   {
 llvm::raw_string_ostream StringOS(StringSection);
@@ -508,6 +572,16 @@
 RIFF.Chunks.push_back({riff::fourCC("refs"), RefsSection});
   }
 
+  std::string RelationSection;
+  if (Data.Relations) {
+{
+  llvm::raw_string_ostream RelationOS{RelationSection};
+  for (const auto &Relation : Relations)
+writeRelation(Relation, RelationOS);
+}
+RIFF.Chunks.push_back({riff::fourCC("rela"), RelationSection});
+  }
+
   std::string SrcsSection;
   {
 {
@@ -561,6 +635,7 @@
 
   SymbolSlab Symbols;
   RefSlab Refs;
+  RelationSlab Relations;
   {
 trace::Span Tracer("ParseIndex");
 if (auto I = readIndexFile(Buffer->get()->getBuffer())) {
@@ -568,6 +643,8 @@
 Symbols = std::move(*I->Symbols);
   if (I->Refs)
 Refs = std::move(*I->Refs);
+  if (I->Relations)
+Relations = std::move(*I->Relations);
 } else {
   llvm::errs() << "Bad Index: " << llvm::toString(I.takeError()) << "\n";
   return nullptr;
@@ -576,15 +653,17 @@
 
   size_t NumSym = Symbols.size();
   size_t NumRefs = Refs.numRefs();
+  size_t NumRelations = Relations.size();
 
   trace::Span Tracer("BuildIndex");
   auto Index = UseDex ? dex::Dex::build(std::move(Symbols), std::move(Refs))
   : MemIndex::build(std::move(Symbols), std::move(Refs));
   vlog("Loaded {0} from {1} 

[PATCH] D62471: [clangd] SymbolCollector support for relations

2019-06-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 202646.
nridge marked 5 inline comments as done.
nridge added a comment.

Address remaining review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62471/new/

https://reviews.llvm.org/D62471

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -123,8 +123,9 @@
 assert(AST.hasValue());
 const NamedDecl &ND =
 Qualified ? findDecl(*AST, Name) : findUnqualifiedDecl(*AST, Name);
-const SourceManager& SM = AST->getSourceManager();
-bool MainFile = SM.isWrittenInMainFile(SM.getExpansionLoc(ND.getBeginLoc()));
+const SourceManager &SM = AST->getSourceManager();
+bool MainFile =
+SM.isWrittenInMainFile(SM.getExpansionLoc(ND.getBeginLoc()));
 return SymbolCollector::shouldCollectSymbol(
 ND, AST->getASTContext(), SymbolCollector::Options(), MainFile);
   }
@@ -272,13 +273,14 @@
 Args, Factory->create(), Files.get(),
 std::make_shared());
 
-InMemoryFileSystem->addFile(
-TestHeaderName, 0, llvm::MemoryBuffer::getMemBuffer(HeaderCode));
+InMemoryFileSystem->addFile(TestHeaderName, 0,
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 InMemoryFileSystem->addFile(TestFileName, 0,
 llvm::MemoryBuffer::getMemBuffer(MainCode));
 Invocation.run();
 Symbols = Factory->Collector->takeSymbols();
 Refs = Factory->Collector->takeRefs();
+Relations = Factory->Collector->takeRelations();
 return true;
   }
 
@@ -290,6 +292,7 @@
   std::string TestFileURI;
   SymbolSlab Symbols;
   RefSlab Refs;
+  RelationSlab Relations;
   SymbolCollector::Options CollectorOpts;
   std::unique_ptr PragmaHandler;
 };
@@ -634,6 +637,19 @@
   HaveRanges(Header.ranges();
 }
 
+TEST_F(SymbolCollectorTest, Relations) {
+  std::string Header = R"(
+  class Base {};
+  class Derived : public Base {};
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &Base = findSymbol(Symbols, "Base");
+  const Symbol &Derived = findSymbol(Symbols, "Derived");
+  EXPECT_THAT(Relations,
+  Contains(Relation{Base.ID, index::SymbolRole::RelationBaseOf,
+Derived.ID}));
+}
+
 TEST_F(SymbolCollectorTest, References) {
   const std::string Header = R"(
 class W;
@@ -783,10 +799,9 @@
 void f1() {}
   )";
   runSymbolCollector(/*Header=*/"", Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo"), QName("f1"), QName("f2"),
-   QName("ff"), QName("foo"), QName("foo::Bar"),
-   QName("main_f")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   QName("Foo"), QName("f1"), QName("f2"), QName("ff"),
+   QName("foo"), QName("foo::Bar"), QName("main_f")));
 }
 
 TEST_F(SymbolCollectorTest, Documentation) {
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -110,6 +110,7 @@
 
   SymbolSlab takeSymbols() { return std::move(Symbols).build(); }
   RefSlab takeRefs() { return std::move(Refs).build(); }
+  RelationSlab takeRelations() { return std::move(Relations).build(); }
 
   void finish() override;
 
@@ -117,6 +118,8 @@
   const Symbol *addDeclaration(const NamedDecl &, SymbolID,
bool IsMainFileSymbol);
   void addDefinition(const NamedDecl &, const Symbol &DeclSymbol);
+  void processRelations(const NamedDecl &ND, const SymbolID &ID,
+ArrayRef Relations);
 
   llvm::Optional getIncludeHeader(llvm::StringRef QName, FileID);
   bool isSelfContainedHeader(FileID);
@@ -135,6 +138,8 @@
   // Only symbols declared in preamble (from #include) and referenced from the
   // main file will be included.
   RefSlab::Builder Refs;
+  // All relations collected from the AST.
+  RelationSlab::Builder Relations;
   ASTContext *ASTCtx;
   std::shared_ptr PP;
   std::shared_ptr CompletionAllocator;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -193,6 +193,11 @@
   return static_cast(static_cast(RefKind::All) & Roles);
 }
 
+bool shouldIndexRelation(const index::SymbolRelation &R) {
+  // We currently only

r362358 - PR42104: Support instantiations of lambdas that implicitly capture

2019-06-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jun  2 23:02:10 2019
New Revision: 362358

URL: http://llvm.org/viewvc/llvm-project?rev=362358&view=rev
Log:
PR42104: Support instantiations of lambdas that implicitly capture
packs.

Two changes:
 * Track odr-use via FunctionParmPackExprs to properly handle dependent
   odr-uses of packs in generic lambdas.
 * Do not instantiate implicit captures; instead, regenerate them by
   instantiating the body of the lambda. This is necessary to
   distinguish between cases where only one element of a pack is
   captured and cases where the entire pack is captured.

Added:
cfe/trunk/test/SemaTemplate/lambda-capture-pack.cpp
Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=362358&r1=362357&r2=362358&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Sun Jun  2 23:02:10 2019
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_SEMA_SCOPEINFO_H
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/LLVM.h"
@@ -913,7 +914,8 @@ public:
   ///   };
   /// }
   void addPotentialCapture(Expr *VarExpr) {
-assert(isa(VarExpr) || isa(VarExpr));
+assert(isa(VarExpr) || isa(VarExpr) ||
+   isa(VarExpr));
 PotentiallyCapturingExprs.push_back(VarExpr);
   }
 
@@ -965,13 +967,15 @@ public:
   ///  building such a node. So we need a rule that anyone can implement and 
get
   ///  exactly the same result".
   void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr) {
-assert(isa(CapturingVarExpr)
-|| isa(CapturingVarExpr));
+assert(isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr));
 NonODRUsedCapturingExprs.insert(CapturingVarExpr);
   }
   bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const {
-assert(isa(CapturingVarExpr)
-  || isa(CapturingVarExpr));
+assert(isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr) ||
+   isa(CapturingVarExpr));
 return NonODRUsedCapturingExprs.count(CapturingVarExpr);
   }
   void removePotentialCapture(Expr *E) {
@@ -993,9 +997,8 @@ public:
   PotentialThisCaptureLocation.isValid();
   }
 
-  // When passed the index, returns the VarDecl and Expr associated
-  // with the index.
-  void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const;
+  void visitPotentialCaptures(
+  llvm::function_ref Callback) const;
 };
 
 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy()

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=362358&r1=362357&r2=362358&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Jun  2 23:02:10 2019
@@ -4179,6 +4179,7 @@ public:
   void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
   void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
   void MarkMemberReferenced(MemberExpr *E);
+  void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E);
   void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc,
  unsigned CapturingScopeIndex);
 

Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=362358&r1=362357&r2=362358&view=diff
==
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Sun Jun  2 23:02:10 2019
@@ -229,20 +229,20 @@ bool CapturingScopeInfo::isVLATypeCaptur
   return false;
 }
 
-void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *&VD,
-  Expr *&E) const {
-  assert(Idx < getNumPotentialVariableCaptures() &&
- "Index of potential capture must be within 0 to less than the "
- "number of captures!");
-  E = PotentiallyCapturingExprs[Idx];
-  if (DeclRefExpr *DRE = dyn_cast(E))
-VD = dyn_cast(DRE->getFoundDecl());
-  else if (MemberExpr *ME = dyn_cast(E))
-VD = dyn_cast(ME->getMemberDecl());
-  else
-llvm_unreachable("Only DeclRefExprs or MemberExprs should be added for "
-"potential captures");
-  assert(VD);
+void LambdaSco

[PATCH] D62550: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda

2019-06-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: cfe/trunk/lib/Sema/TreeTransform.h:7173
+auto *MD = dyn_cast_or_null(FD);
+if (!MD || !MD->getParent()->isGenericLambda()) {
+  assert(!Promise->getType()->isDependentType() &&

This assert doesn't seem correct to me; there's no reason to assume we have a 
generic lambda here. (A non-generic lambda inside a generic lambda, whose 
parameter types are dependent on the generic lambda's parameters, would hit 
exactly the same issue, for instance.)

Generally we should write the template instantiation code so it could be used 
to substitute into the definition of a function template to produce another 
function template, even if we happen to never call it that way right now 
(though deduction guide processing gets pretty close). The right thing to do 
here is to either substitute into the representation we already formed 
(building a dependent representation if it's still dependent and a 
non-dependent representation otherwise) or to rebuild the coroutine body from 
scratch (again, creating a dependent representation if the result is still 
dependent).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62550/new/

https://reviews.llvm.org/D62550



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