[PATCH] D62442: [Driver] Update handling of c++ and runtime directories

2019-05-25 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361709: [Driver] Update handling of c++ and runtime 
directories (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62442?vs=201432=201433#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62442

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/Inputs/basic_fuchsia_tree/bin/.keep
  test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/asan/libc++.so
  test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/libc++.so
  
test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/noexcept/libc++.so
  test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/asan/libc++.so
  test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/libc++.so
  
test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/noexcept/libc++.so
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/asan/.keep
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/.keep
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/asan/.keep
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/.keep
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp
  test/Driver/linux-per-target-runtime-dir.c

Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -389,6 +389,12 @@
   getCompilerRTArgString(const llvm::opt::ArgList , StringRef Component,
  FileType Type = ToolChain::FT_Static) const;
 
+  // Returns target specific runtime path if it exists.
+  virtual Optional getRuntimePath() const;
+
+  // Returns target specific C++ library path if it exists.
+  virtual Optional getCXXStdlibPath() const;
+
   // Returns /lib//.  This is used by runtimes (such
   // as OpenMP) to find arch-specific libraries.
   std::string getArchSpecificLibPath() const;
Index: test/Driver/fuchsia.cpp
===
--- test/Driver/fuchsia.cpp
+++ test/Driver/fuchsia.cpp
@@ -1,4 +1,5 @@
 // RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
@@ -44,29 +45,33 @@
 // CHECK-STATIC: "--pop-state"
 // CHECK-STATIC: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIBXX
 // CHECK-NOSTDLIBXX-NOT: "-lc++"
 // CHECK-NOSTDLIBXX-NOT: "-lm"
 // CHECK-NOSTDLIBXX: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-NOEXCEPT-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
 // CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-MULTILIB-ASAN-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}asan"
-// CHECK-MULTILIB-NOEXCEPT-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}noexcept"
-// CHECK-MULTILIB-X86: 

r361709 - [Driver] Update handling of c++ and runtime directories

2019-05-25 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sat May 25 20:39:07 2019
New Revision: 361709

URL: http://llvm.org/viewvc/llvm-project?rev=361709=rev
Log:
[Driver] Update handling of c++ and runtime directories

This is a follow up to r361432 and r361504 which addresses issues
introduced by those changes. Specifically, it avoids duplicating
file and runtime paths in case when the effective triple is the
same as the cannonical one. Furthermore, it fixes the broken multilib
setup in the Fuchsia driver and deduplicates some of the code.

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

Added:
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/bin/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/bin/.keep
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/asan/

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/asan/libc++.so

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/libc++.so

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/noexcept/

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/noexcept/libc++.so
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/
cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/asan/

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/asan/libc++.so

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/libc++.so

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/noexcept/

cfe/trunk/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/noexcept/libc++.so
Removed:

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/asan/

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/asan/

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp
cfe/trunk/test/Driver/linux-per-target-runtime-dir.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=361709=361708=361709=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Sat May 25 20:39:07 2019
@@ -389,6 +389,12 @@ public:
   getCompilerRTArgString(const llvm::opt::ArgList , StringRef Component,
  FileType Type = ToolChain::FT_Static) const;
 
+  // Returns target specific runtime path if it exists.
+  virtual Optional getRuntimePath() const;
+
+  // Returns target specific C++ library path if it exists.
+  virtual Optional getCXXStdlibPath() const;
+
   // Returns /lib//.  This is used by runtimes (such
   // as OpenMP) to find arch-specific libraries.
   std::string getArchSpecificLibPath() const;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=361709=361708=361709=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Sat May 25 20:39:07 2019
@@ -73,29 +73,13 @@ ToolChain::ToolChain(const Driver , co
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  SmallString<128> P;
-
   if (D.CCCIsCXX()) {
-P.assign(D.Dir);
-llvm::sys::path::append(P, "..", "lib", D.getTargetTriple(), "c++");
-if (getVFS().exists(P))
-  getLibraryPaths().push_back(P.str());
-
-P.assign(D.Dir);
-llvm::sys::path::append(P, "..", "lib", Triple.str(), "c++");
-if (getVFS().exists(P))
-  getLibraryPaths().push_back(P.str());
+if (auto CXXStdlibPath = getCXXStdlibPath())
+  getFilePaths().push_back(*CXXStdlibPath);
   }
 
-  P.assign(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P))
-getLibraryPaths().push_back(P.str());
-
-  P.assign(D.ResourceDir);
-  llvm::sys::path::append(P, Triple.str(), "lib");
-  if (getVFS().exists(P))
-getLibraryPaths().push_back(P.str());
+  if (auto RuntimePath = 

[PATCH] D62442: [Driver] Update handling of c++ and runtime directories

2019-05-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D62442#1517183 , @mcgrathr wrote:

> lgtm contingent on verifying intended behavior changes and adding comments.  
> The factoring suggestion for the triple,triple searching is preferred but at 
> your discretion, though I'd really like to see at least comments.


I have undone that factoring as I have realized I could simplify the logic 
further, but as that's going to require more cleanup I'll do it in a follow up 
change.




Comment at: clang/lib/Driver/ToolChain.cpp:389
 SmallString<128> P(LibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + 
Suffix);
+return P.str();

mcgrathr wrote:
> Can you explain the change to  use the first entry rather than the first 
> existing entry?
> If the first one in the list is presumed to exist, then why is there a list 
> instead of a single directory stored?
That was unintentional, I've reverted that change.



Comment at: clang/lib/Driver/ToolChain.cpp:424
+
+Optional ToolChain::getCXXStdlibPath() const {
+  SmallString<128> P;

mcgrathr wrote:
> Same here.  Can these use a common subroutine/template for trying something 
> based on these two, so the logic about what D.getTargetTriple() and 
> Triple.str() mean and both the code and justifying comments for their 
> ordering logic is de-duplicated?
I plan on cleaning up the runtime handling in a follow up change.



Comment at: clang/test/Driver/fuchsia.c:96
 // CHECK-ASAN-X86: "-dynamic-linker" "asan/ld.so.1"
-// CHECK-ASAN-X86: 
"-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}asan"
-// CHECK-ASAN-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib"

mcgrathr wrote:
> To clarify, these are dropped because their sole intent was always to serve 
> -lc++ and that's properly not enabled for this C-only link?
Correct.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62442



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


[PATCH] D62442: [Driver] Update handling of c++ and runtime directories

2019-05-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 201432.
phosek marked 8 inline comments as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D62442

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/Inputs/basic_fuchsia_tree/bin/.keep
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/asan/libc++.so
  clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-fuchsia/c++/noexcept/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/asan/libc++.so
  clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/libc++.so
  
clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-fuchsia/c++/noexcept/libc++.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/asan/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/asan/.keep
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/.keep
  clang/test/Driver/fuchsia.c
  clang/test/Driver/fuchsia.cpp
  clang/test/Driver/linux-per-target-runtime-dir.c

Index: clang/test/Driver/linux-per-target-runtime-dir.c
===
--- clang/test/Driver/linux-per-target-runtime-dir.c
+++ clang/test/Driver/linux-per-target-runtime-dir.c
@@ -13,7 +13,6 @@
 // CHECK-PER-TARGET-RUNTIME: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-PER-TARGET-RUNTIME: "--sysroot=[[SYSROOT]]"
 // CHECK-PER-TARGET-RUNTIME: "-L{{.*}}{{/|}}..{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}c++"
-// CHECK-PER-TARGET-RUNTIME: "-L[[RESDIR]]{{/|}}x86_64-linux-gnu{{/|}}lib"
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=x86_64-linux-gnu \
Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -1,4 +1,5 @@
 // RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
@@ -44,29 +45,33 @@
 // CHECK-STATIC: "--pop-state"
 // CHECK-STATIC: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -nostdlib++ -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIBXX
 // CHECK-NOSTDLIBXX-NOT: "-lc++"
 // CHECK-NOSTDLIBXX-NOT: "-lm"
 // CHECK-NOSTDLIBXX: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-NOEXCEPT-X86
-// RUN: %clang %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=address -fno-exceptions \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: -fuse-ld=lld 2>&1\
 // RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
 // CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-MULTILIB-ASAN-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}asan"
-// CHECK-MULTILIB-NOEXCEPT-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}noexcept"
-// CHECK-MULTILIB-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib"
+// CHECK-MULTILIB-ASAN-X86: 

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

2019-05-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This builds on D59407  to provide YAML and 
RIFF serialization support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62459

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

Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -149,8 +149,15 @@
 }
 std::vector YAMLFromRefs(const RefSlab ) {
   std::vector Result;
-  for (const auto  : Slab)
-Result.push_back(toYAML(Sym));
+  for (const auto  : Slab)
+Result.push_back(toYAML(Refs));
+  return Result;
+}
+
+std::vector YAMLFromRelations(const RelationSlab ) {
+  std::vector Result;
+  for (const auto  : Slab)
+Result.push_back(toYAML(Rel));
   return Result;
 }
 
@@ -215,6 +222,110 @@
   }
 }
 
+const char *RelationsYAML = R"(
+--- !Symbol
+ID:  6481EE7AF2841756
+Name:Base
+Scope:   ''
+SymInfo: 
+  Kind:Struct
+  Lang:C
+CanonicalDeclaration: 
+  FileURI: 'file:///path/foo.cc'
+  Start:   
+Line:0
+Column:  7
+  End: 
+Line:0
+Column:  11
+Definition:  
+  FileURI: 'file:///path/foo.cc'
+  Start:   
+Line:0
+Column:  7
+  End: 
+Line:0
+Column:  11
+References:  1
+Origin:  4
+Flags:   0
+Signature:   ''
+TemplateSpecializationArgs: ''
+CompletionSnippetSuffix: ''
+Documentation:   ''
+ReturnType:  ''
+Type:''
+...
+--- !Symbol
+ID:  6512AEC512EA3A2D
+Name:Derived
+Scope:   ''
+SymInfo:
+  Kind:Struct
+  Lang:Cpp
+CanonicalDeclaration:
+  FileURI: 'file:///path/foo.cc'
+  Start:
+Line:1
+Column:  7
+  End:
+Line:1
+Column:  14
+Definition:
+  FileURI: 'file:///path/foo.cc'
+  Start:
+Line:1
+Column:  7
+  End:
+Line:1
+Column:  14
+Origin:  4
+Flags:   0
+Signature:   ''
+TemplateSpecializationArgs: ''
+CompletionSnippetSuffix: ''
+Documentation:   ''
+ReturnType:  ''
+Type:''
+...
+--- !Relations
+Subject:
+  ID:  6481EE7AF2841756
+Predicate:   2
+Object:
+  ID:  6512AEC512EA3A2D
+...
+)";
+
+TEST(SerializationTest, Relations) {
+  auto In = readIndexFile(RelationsYAML);
+
+  EXPECT_TRUE(bool(In)) << In.takeError();
+
+  SymbolID Base = cantFail(SymbolID::fromStr("6481EE7AF2841756"));
+  SymbolID Derived = cantFail(SymbolID::fromStr("6512AEC512EA3A2D"));
+
+  EXPECT_TRUE(bool(In->Relations));
+  EXPECT_THAT(*In->Relations,
+  UnorderedElementsAre(
+  Relation{Base, index::SymbolRole::RelationBaseOf, Derived}));
+
+  // Write to binary format, and parse again.
+  IndexFileOut Out(*In);
+  Out.Format = IndexFileFormat::RIFF;
+  std::string Serialized = llvm::to_string(Out);
+
+  auto In2 = readIndexFile(Serialized);
+  ASSERT_TRUE(bool(In2)) << In.takeError();
+  ASSERT_TRUE(In2->Symbols);
+  ASSERT_TRUE(In2->Refs);
+  ASSERT_TRUE(In2->Relations);
+
+  // Assert the YAML serializations match, for nice comparisons and diffs.
+  EXPECT_THAT(YAMLFromRelations(*In2->Relations),
+  UnorderedElementsAreArray(YAMLFromRelations(*In->Relations)));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/YAMLSerialization.cpp
===
--- clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "Index.h"
+#include "Relation.h"
 #include "Serialization.h"
 #include "SymbolLocation.h"
 #include "SymbolOrigin.h"
@@ -35,10 +36,11 @@
 namespace {
 using RefBundle =
 std::pair>;
-// This is a pale imitation of std::variant
+// This is a pale imitation of std::variant
 struct VariantEntry {
   llvm::Optional Symbol;
   llvm::Optional Refs;
+  llvm::Optional Relation;
 };
 // A class helps YAML to serialize the 32-bit encoded position (Line),
 // as YAMLIO can't directly map bitfields.
@@ -53,6 +55,8 @@
 
 using clang::clangd::Ref;
 using clang::clangd::RefKind;
+using clang::clangd::Relation;
+using clang::clangd::RelationKind;
 using 

[PATCH] D62333: Fix unresolved symbols when linking tools/clang/unittests/Tooling/ToolingTests

2019-05-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: cfe/trunk/unittests/Tooling/CMakeLists.txt:4
   Support
   TestingSupport
   )

The library is already up here. Why do we need it twice?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62333



___
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-05-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/index/Relation.cpp:19
+llvm::iterator_range
+RelationSlab::lookup(const SymbolID ,
+ index::SymbolRole Predicate) const {

kadircet wrote:
> I would suggest adding another version which returns all the relations a 
> given `Subject` participates, but I suppose currently we don't have any use 
> cases.
> 
> Feel free to add or skip, that can be added when necessary.
I'd rather add this when a use case arises.



Comment at: clang-tools-extra/clangd/index/Relation.h:52
+
+class RelationSlab {
+public:

kadircet wrote:
> I believe `RelationSlab` should still be immutable, even after the `build` 
> operation below `RelationSlab` is mutable.
> Let's introduce the builder class and move mutating operations and build into 
> it. So that it would be more symmetric to other slabs we have.
> 
> Also are there any use-cases requiring RelationSlab to be mutable?
I'm not aware of any use-cases requiring it to be mutable. I'm making it 
immutable as suggested.



Comment at: clang-tools-extra/clangd/index/Relation.h:89
+private:
+  RelationSlab(std::vector Relations)
+  : Relations(std::move(Relations)) {}

kadircet wrote:
> Do we really need this?
I think so. The builder needs a way to construct the slab. Aggregate 
initialization doesn't work because the class already has declared default and 
copy constructors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59407



___
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-05-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 201427.
nridge marked 19 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59407

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

Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -76,6 +76,29 @@
 EXPECT_THAT(*S.find(SymbolID(Sym)), Named(Sym));
 }
 
+TEST(RelationSlab, Lookup) {
+  SymbolID A{"A"};
+  SymbolID B{"B"};
+  SymbolID C{"C"};
+  SymbolID D{"D"};
+
+  RelationSlab::Builder Builder;
+  Builder.insert(Relation{A, index::SymbolRole::RelationBaseOf, B});
+  Builder.insert(Relation{A, index::SymbolRole::RelationBaseOf, C});
+  Builder.insert(Relation{B, index::SymbolRole::RelationBaseOf, D});
+  Builder.insert(Relation{C, index::SymbolRole::RelationBaseOf, D});
+  Builder.insert(Relation{B, index::SymbolRole::RelationChildOf, A});
+  Builder.insert(Relation{C, index::SymbolRole::RelationChildOf, A});
+  Builder.insert(Relation{D, index::SymbolRole::RelationChildOf, B});
+  Builder.insert(Relation{D, index::SymbolRole::RelationChildOf, C});
+
+  RelationSlab Slab = std::move(Builder).build();
+  EXPECT_THAT(
+  Slab.lookup(A, index::SymbolRole::RelationBaseOf),
+  UnorderedElementsAre(Relation{A, index::SymbolRole::RelationBaseOf, B},
+   Relation{A, index::SymbolRole::RelationBaseOf, C}));
+}
+
 TEST(SwapIndexTest, OldIndexRecycled) {
   auto Token = std::make_shared();
   std::weak_ptr WeakToken = Token;
Index: clang-tools-extra/clangd/index/Relation.h
===
--- /dev/null
+++ clang-tools-extra/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 ) const {
+return std::tie(Subject, Predicate, Object) ==
+   std::tie(Other.Subject, Other.Predicate, Other.Object);
+  }
+  // SPO order
+  bool operator<(const Relation ) 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 &) = default;
+  RelationSlab =(RelationSlab &) = 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 ,
+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 ) { Relations.push_back(R); }
+
+/// Consumes the builder to finalize the slab.
+RelationSlab build() &&;
+
+  private:
+std::vector Relations;
+  };
+
+private:
+  RelationSlab(std::vector Relations)
+  : Relations(std::move(Relations)) {}
+
+  std::vector Relations;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RELATION_H
Index: clang-tools-extra/clangd/index/Relation.cpp
===
--- /dev/null
+++ 

[PATCH] D62457: Frontend: Create basic CompilerInstanceBuilder

2019-05-25 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: rsmith.
dexonsmith added a child revision: D62458: Frontend: Add CompilerInvocation and 
DiagnosticsEngine to the builder.

This sketches out the beginning of a `CompilerInstanceBuilder`.  For now
it just handles PCHContainerOps and InMemoryModuleCache, which are
already handled by the `CompilerInstance` constructor.

Subsequent commits will incrementally replace `CompilerInstance::set*`
and `CompilerInstance::create*` mutators with builder methods,
simplifying construction and possibly clarifying some lifetimes.


https://reviews.llvm.org/D62457

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Frontend/CompilerInstanceBuilder.h
  clang/lib/Frontend/CompilerInstance.cpp

Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -56,14 +56,31 @@
 
 using namespace clang;
 
+IntrusiveRefCntPtr
+CompilerInstanceBuilder::getModuleCache() {
+  return SharedModuleCache ? SharedModuleCache : new InMemoryModuleCache();
+}
+
+std::shared_ptr
+CompilerInstanceBuilder::getPCHContainerOps() {
+  return PCHContainerOps ? PCHContainerOps
+ : std::make_shared();
+}
+
+bool CompilerInstanceBuilder::isBuildingModule() { return SharedModuleCache; }
+
+CompilerInstance::CompilerInstance(CompilerInstanceBuilder Builder)
+: ModuleLoader(Builder.isBuildingModule()),
+  Invocation(new CompilerInvocation()),
+  ModuleCache(Builder.getModuleCache()),
+  ThePCHContainerOperations(Builder.getPCHContainerOps()) {}
+
 CompilerInstance::CompilerInstance(
 std::shared_ptr PCHContainerOps,
 InMemoryModuleCache *SharedModuleCache)
-: ModuleLoader(/* BuildingModule = */ SharedModuleCache),
-  Invocation(new CompilerInvocation()),
-  ModuleCache(SharedModuleCache ? SharedModuleCache
-: new InMemoryModuleCache),
-  ThePCHContainerOperations(std::move(PCHContainerOps)) {}
+: CompilerInstance(CompilerInstanceBuilder()
+   .sharedModuleCache(SharedModuleCache)
+   .pchContainerOps(PCHContainerOps)) {}
 
 CompilerInstance::~CompilerInstance() {
   assert(OutputFiles.empty() && "Still output files in flight?");
Index: clang/include/clang/Frontend/CompilerInstanceBuilder.h
===
--- /dev/null
+++ clang/include/clang/Frontend/CompilerInstanceBuilder.h
@@ -0,0 +1,55 @@
+//===- CompilerInstanceBuilder.h - CompilerInstance Builder -*- 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_FRONTEND_COMPILERINSTANCEBUILDER_H_
+#define LLVM_CLANG_FRONTEND_COMPILERINSTANCEBUILDER_H_
+
+namespace clang {
+
+class InMemoryModuleCache;
+class PCHContainerOperations;
+
+class CompilerInstanceBuilder {
+  InMemoryModuleCache *SharedModuleCache = nullptr;
+  std::shared_ptr PCHContainerOps;
+
+public:
+  CompilerInstanceBuilder() = default;
+  CompilerInstanceBuilder(CompilerInstanceBuilder &&) = default;
+  CompilerInstanceBuilder(const CompilerInstanceBuilder &) = delete;
+
+  CompilerInstanceBuilder &&
+  pchContainerOps(std::shared_ptr PCHContainerOps) && {
+this->PCHContainerOps = std::move(PCHContainerOps);
+return std::move(*this);
+  }
+
+  CompilerInstanceBuilder &&
+  moduleCache(InMemoryModuleCache ) && {
+this->SharedModuleCache = 
+return std::move(*this);
+  }
+
+private:
+  friend class CompilerInstance;
+
+  // Deprecated, for CompilerInstance's current constructor.
+  CompilerInstanceBuilder &&
+  sharedModuleCache(InMemoryModuleCache *SharedModuleCache) && {
+this->SharedModuleCache = SharedModuleCache;
+return std::move(*this);
+  }
+
+  IntrusiveRefCntPtr getModuleCache();
+  std::shared_ptr getPCHContainerOps();
+  bool isBuildingModule();
+};
+
+} // end namespace clang
+
+#endif
Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Frontend/CompilerInstanceBuilder.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
@@ -186,6 +187,7 @@
   CompilerInstance(const CompilerInstance &) = delete;
   void operator=(const CompilerInstance &) = delete;
 public:
+  explicit 

[PATCH] D62458: Frontend: Add CompilerInvocation and DiagnosticsEngine to the builder

2019-05-25 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: rsmith.
Herald added subscribers: kadircet, arphaman, jkorous.
dexonsmith added a parent revision: D62457: Frontend: Create basic 
CompilerInstanceBuilder.

Add CompilerInvocation and DiagnosticsEngine to the new builder,
replacing a number of no-longer-needed `CompilerInstance` mutators.
These are in the same commit because the construction of a
`CompilerInvocation` and a `DiagnosticsEngine` is interestingly
entangled, since they each can depend on the other.  When the dependency
is truly cyclic, a temporary `DiagnosticsEngine` is used to construct
the `CompilerInvocation`, then the latter to construct the "real"
`DiagnosticsEngine` and the former's diagnostics are replayed.


https://reviews.llvm.org/D62458

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang/examples/clang-interpreter/main.cpp
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Frontend/CompilerInstanceBuilder.h
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/driver/cc1_main.cpp
  clang/unittests/AST/ExternalASTSourceTest.cpp
  clang/unittests/CodeGen/BufferSourceTest.cpp
  clang/unittests/CodeGen/CodeGenExternalTest.cpp
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp
  clang/unittests/Frontend/CodeGenActionTest.cpp
  clang/unittests/Frontend/CompilerInstanceTest.cpp
  clang/unittests/Frontend/FrontendActionTest.cpp
  clang/unittests/Frontend/OutputStreamTest.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -663,8 +663,11 @@
   invocation->getPreprocessorOpts().addRemappedFile(ModuleImportBufferName,
 source_buffer.release());
 
-  std::unique_ptr instance(
-  new clang::CompilerInstance);
+  std::unique_ptr instance =
+  llvm::make_unique(
+  clang::CompilerInstanceBuilder()
+  .invocation(invocation)
+  .diags(*diagnostics_engine));
 
   // When capturing a reproducer, hook up the file collector with clang to
   // collector modules and headers.
@@ -680,8 +683,6 @@
 
   // Make sure clang uses the same VFS as LLDB.
   instance->createFileManager(FileSystem::Instance().GetVirtualFileSystem());
-  instance->setDiagnostics(diagnostics_engine.get());
-  instance->setInvocation(invocation);
 
   std::unique_ptr action(new clang::SyntaxOnlyAction);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -403,7 +403,6 @@
 }
 
   // 4. Create and install the target on the compiler.
-  m_compiler->createDiagnostics();
   auto target_info = TargetInfo::CreateTargetInfo(
   m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts);
   if (log) {
Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -113,14 +113,12 @@
   Diags->setClient(new IgnoringDiagConsumer);
 std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
   FileName};
-auto CI = createInvocationFromCommandLine(Args, Diags, FS);
-assert(CI);
-CI->getFrontendOpts().DisableFree = false;
-CI->getPreprocessorOpts().addRemappedFile(
+CompilerInstance Compiler(
+CompilerInstanceBuilder().diags(*Diags).invocationFromDriver(Args, FS));
+CompilerInvocation  = Compiler.getInvocation();
+CI.getFrontendOpts().DisableFree = false;
+CI.getPreprocessorOpts().addRemappedFile(
 FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
-CompilerInstance Compiler;
-Compiler.setInvocation(std::move(CI));
-Compiler.setDiagnostics(Diags.get());
 Compiler.setFileManager(FileMgr.get());
 Compiler.setSourceManager(SourceMgr.get());
 

r361708 - Add missing newline at end of file

2019-05-25 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat May 25 15:38:02 2019
New Revision: 361708

URL: http://llvm.org/viewvc/llvm-project?rev=361708=rev
Log:
Add missing newline at end of file

Modified:
cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp

Modified: cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp?rev=361708=361707=361708=diff
==
--- cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp Sat May 25 15:38:02 2019
@@ -651,4 +651,4 @@ TEST_F(TokenBufferTest, TokensToFileRang
   // We don't test assertion failures because death tests are slow.
 }
 
-} // namespace
\ No newline at end of file
+} // namespace


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


Re: r361340 - [Analysis] Link library dependencies to Analysis plugins

2019-05-25 Thread Don Hinton via cfe-commits
I've submitted a patch to fix this, https://reviews.llvm.org/D62445.

Without it, non of the bots can build/test any plugins.

On Fri, May 24, 2019 at 5:47 PM Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> I reverted the patch in r361685 to make the bot green again.
>
> > On May 23, 2019, at 5:22 PM, Akira Hatanaka  wrote:
> >
> > Hi Petr,
> >
> > This seems to have caused Analysis/checker-plugins.c to fail. Can you
> investigate it or revert your commit?
> >
> >
> http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan/6381/consoleFull#-5275661368254eaf0-7326-4999-85b0-388101f2d404
> >
> >> On May 21, 2019, at 5:47 PM, Petr Hosek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: phosek
> >> Date: Tue May 21 17:47:37 2019
> >> New Revision: 361340
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=361340=rev
> >> Log:
> >> [Analysis] Link library dependencies to Analysis plugins
> >>
> >> These are needed to avoid undefined symbols which aren't satisfied
> >> by Clang itself.
> >>
> >> Differential Revision: https://reviews.llvm.org/D62174
> >>
> >> Modified:
> >>
>  cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
> >>   cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
> >>   cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
> >>
> >> Modified:
> cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt?rev=361340=361339=361340=diff
> >>
> ==
> >> ---
> cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
> (original)
> >> +++
> cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
> Tue May 21 17:47:37 2019
> >> @@ -1,11 +1,12 @@
> >> set(LLVM_EXPORTED_SYMBOL_FILE
> ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
> >> add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE
> CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
> >>
> >> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
> >> +if(LLVM_ENABLE_PLUGINS)
> >>  target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
> >>clangAnalysis
> >>clangAST
> >>clangStaticAnalyzerCore
> >> +clangStaticAnalyzerFrontend
> >>LLVMSupport
> >>)
> >> endif()
> >>
> >> Modified:
> cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt?rev=361340=361339=361340=diff
> >>
> ==
> >> ---
> cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
> (original)
> >> +++
> cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt Tue
> May 21 17:47:37 2019
> >> @@ -1,11 +1,12 @@
> >> set(LLVM_EXPORTED_SYMBOL_FILE
> ${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
> >> add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE
> CheckerOptionHandling.cpp PLUGIN_TOOL clang)
> >>
> >> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
> >> +if(LLVM_ENABLE_PLUGINS)
> >>  target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
> >>clangAnalysis
> >>clangAST
> >>clangStaticAnalyzerCore
> >> +clangStaticAnalyzerFrontend
> >>LLVMSupport
> >>)
> >> endif()
> >>
> >> Modified: cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt?rev=361340=361339=361340=diff
> >>
> ==
> >> --- cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
> (original)
> >> +++ cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt Tue
> May 21 17:47:37 2019
> >> @@ -1,11 +1,12 @@
> >> set(LLVM_EXPORTED_SYMBOL_FILE
> ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
> >> add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp
> PLUGIN_TOOL clang)
> >>
> >> -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
> >> +if(LLVM_ENABLE_PLUGINS)
> >>  target_link_libraries(SampleAnalyzerPlugin PRIVATE
> >>clangAnalysis
> >>clangAST
> >>clangStaticAnalyzerCore
> >> +clangStaticAnalyzerFrontend
> >>LLVMSupport
> >>)
> >> endif()
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> 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
>
___
cfe-commits mailing list

[PATCH] D62215: Fixes to distribution example for X86_64 Arch Linux

2019-05-25 Thread Wink Saville via Phabricator via cfe-commits
winksaville abandoned this revision.
winksaville added a comment.

Rather than creating LLVMgold.so as this change does, @beanz suggested we use a 
known LTO capable linker, `lld`.  See D62279 ..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62215



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


[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

2019-05-25 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 201404.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Reread @rsmith's comments and surrounding code and found what I believe is the 
correct answer to these comments :)


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

https://reviews.llvm.org/D62435

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/ExceptionSpecificationType.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -742,6 +742,8 @@
 return CXCursor_ExceptionSpecificationKind_MSAny;
   case EST_BasicNoexcept:
 return CXCursor_ExceptionSpecificationKind_BasicNoexcept;
+  case EST_NoThrow:
+return CXCursor_ExceptionSpecificationKind_NoThrow;
   case EST_NoexceptFalse:
   case EST_NoexceptTrue:
   case EST_DependentNoexcept:
Index: clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/nothrow-vs-exception-specs.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++17 -DCPP17
+
+__attribute__((nothrow)) void f1();
+static_assert(noexcept(f1()), "");
+void f1() noexcept;
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+void f1() noexcept(false);
+
+__attribute__((nothrow)) void f2();
+static_assert(noexcept(f2()), "");
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-3 {{previous declaration is here}}
+void f2() noexcept(false);
+
+void f3() __attribute__((nothrow));
+static_assert(noexcept(f3()), "");
+void f3() noexcept;
+// expected-error@+2 {{exception specification in declaration does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+void f3() noexcept(false);
+
+// Still noexcept due to throw()
+__attribute__((nothrow)) void f4() throw();
+static_assert(noexcept(f4()), "");
+
+// Still noexcept due to noexcept
+__attribute__((nothrow)) void f5() noexcept;
+static_assert(noexcept(f5()), "");
+
+// Still noexcept due to noexcept(true)
+__attribute__((nothrow)) void f6() noexcept(true);
+static_assert(noexcept(f6()), "");
+
+#ifndef CPP17
+// Doesn't override C++ implementation.
+__attribute__((nothrow)) void f7() throw(int);
+static_assert(!noexcept(f7()), "");
+#endif
+
+// Doesn't override C++ implementation.
+__attribute__((nothrow)) void f8() noexcept(false);
+static_assert(!noexcept(f8()), "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -130,6 +130,7 @@
   case ParsedAttr::AT_Regparm: \
   case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:\
   case ParsedAttr::AT_AnyX86NoCfCheck: \
+  case ParsedAttr::AT_NoThrow: \
 CALLING_CONV_ATTRS_CASELIST
 
 // Microsoft-specific type qualifiers.
@@ -4516,7 +4517,7 @@
   // If the function declarator has a prototype (i.e. it is not () and
   // does not have a K identifier list), then the arguments are part
   // of the type, otherwise the argument list is ().
-  const DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
+  DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
   IsQualifiedFunction =
   FTI.hasMethodTypeQualifiers() || FTI.hasRefQualifier();
 
@@ -6945,6 +6946,38 @@
 return true;
   }
 
+  if (attr.getKind() == ParsedAttr::AT_NoThrow) {
+if (S.CheckAttrNoArgs(attr))
+  return true;
+
+// Delay if this is not a function type.
+if (!unwrapped.isFunctionType())
+  return false;
+
+// Otherwise we can process right away.
+auto *Proto = unwrapped.get()->getAs();
+
+// In the case where this is a FunctionNoProtoType instead of a
+// FunctionProtoType, let the existing NoThrowAttr implementation do its
+// thing.
+if (!Proto)
+  return false;
+
+attr.setUsedAsTypeAttr();
+
+// MSVC Ignores nothrow for exception specification if it is in conflict.
+if (Proto->hasExceptionSpec())
+  return true;
+
+type = 

[PATCH] D62404: [clang-tidy] Fix null pointer dereference in readability-identifier-naming

2019-05-25 Thread Mark Stegeman via Phabricator via cfe-commits
markstegeman updated this revision to Diff 201401.
markstegeman added a comment.

Added a test.


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

https://reviews.llvm.org/D62404

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp


Index: 
clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
@@ -0,0 +1,5 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s 
readability-identifier-naming %t
+
+// This used to cause a null pointer dereference.
+auto [left] = right;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'right'
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -800,10 +800,11 @@

 // Fix type aliases in value declarations
 if (const auto *Value = Result.Nodes.getNodeAs("decl")) {
-  if (const auto *Typedef =
-  Value->getType().getTypePtr()->getAs()) {
-addUsage(NamingCheckFailures, Typedef->getDecl(),
- Value->getSourceRange());
+  if (const auto *TypePtr = Value->getType().getTypePtrOrNull()) {
+if (const auto *Typedef = TypePtr->getAs()) {
+  addUsage(NamingCheckFailures, Typedef->getDecl(),
+   Value->getSourceRange());
+}
   }
 }



Index: clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
@@ -0,0 +1,5 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s readability-identifier-naming %t
+
+// This used to cause a null pointer dereference.
+auto [left] = right;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'right'
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -800,10 +800,11 @@

 // Fix type aliases in value declarations
 if (const auto *Value = Result.Nodes.getNodeAs("decl")) {
-  if (const auto *Typedef =
-  Value->getType().getTypePtr()->getAs()) {
-addUsage(NamingCheckFailures, Typedef->getDecl(),
- Value->getSourceRange());
+  if (const auto *TypePtr = Value->getType().getTypePtrOrNull()) {
+if (const auto *Typedef = TypePtr->getAs()) {
+  addUsage(NamingCheckFailures, Typedef->getDecl(),
+   Value->getSourceRange());
+}
   }
 }

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


[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

2019-05-25 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added inline comments.



Comment at: clang/include/clang-c/Index.h:202-204
+   * The cursor has a declspec(nothrow) exception specification.
+   */
+  CXCursor_ExceptionSpecificationKind_NoThrow,

rsmith wrote:
> This would renumber the later enumerators, resulting in an ABI break for our 
> stable C ABI.
Is it alright to just add it to the end then? Or do I need to translate it into 
one of the others?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:6067-6068
   if (EST2 == EST_NoexceptTrue) return ESI1;
+  if (EST1 == EST_NoThrow) return ESI2;
+  if (EST2 == EST_NoThrow) return ESI1;
 

rsmith wrote:
> I think this should be checked earlier, in the spirit of allowing "real" 
> syntax to be preferred to attributes. (Eg, given a declaration that's 
> `__declspec(nothrow)` and one that's `noexcept`, we should keep the 
> `noexcept` in the merged type.)
Ah, right, good point.

Looking above, I'm torn between above or below MSAny. Do you have a thought?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62435



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


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-25 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

In D61634#1517228 , @xbolva00 wrote:

> I have a question about qsort.. If we provide own implementation of qsort and 
> replace calls to libc's qsort to our qsort, we could fully inline cmp 
> function then. Ideas?


`qsort` would seem out of scope here since this is mostly about `string.h` 
style functions, more specifically `memcpy`/`memmove`. Things like `memset` 
would also fall under this category if covered in subsequent diffs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-25 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

I have a question about qsort.. If we provide own implementation of qsort and 
replace calls to libc's qsort to our qsort, we could fully inline cmp function 
then. Ideas?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D57184: [clang-format] Allow configuring list of function-like macros that resolve to a type

2019-05-25 Thread Marcin Radomski via Phabricator via cfe-commits
dextero updated this revision to Diff 201395.
dextero added a comment.

- [clang-format] Change "types" -> "type declarations" in Format.h


Repository:
  rC Clang

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

https://reviews.llvm.org/D57184

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -13545,6 +13545,35 @@
   guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
+TEST_F(FormatTest, TypenameMacros) {
+  std::vector TypenameMacros = {"STACK_OF", "LIST", "TAILQ_ENTRY"};
+
+  // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=30353
+  FormatStyle Google = getGoogleStyleWithColumns(0);
+  Google.TypenameMacros = TypenameMacros;
+  verifyFormat("struct foo {\n"
+   "  int bar;\n"
+   "  TAILQ_ENTRY(a) bleh;\n"
+   "};", Google);
+
+  FormatStyle Macros = getLLVMStyle();
+  Macros.TypenameMacros = TypenameMacros;
+
+  verifyFormat("STACK_OF(int) a;", Macros);
+  verifyFormat("STACK_OF(int) *a;", Macros);
+  verifyFormat("STACK_OF(int const *) *a;", Macros);
+  verifyFormat("STACK_OF(int *const) *a;", Macros);
+  verifyFormat("STACK_OF(int, string) a;", Macros);
+  verifyFormat("STACK_OF(LIST(int)) a;", Macros);
+  verifyFormat("STACK_OF(LIST(int)) a, b;", Macros);
+  verifyFormat("for (LIST(int) *a = NULL; a;) {\n}", Macros);
+  verifyFormat("STACK_OF(int) f(LIST(int) *arg);", Macros);
+
+  Macros.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("STACK_OF(int)* a;", Macros);
+  verifyFormat("STACK_OF(int*)* a;", Macros);
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1194,11 +1194,12 @@
 
 // Reset token type in case we have already looked at it and then
 // recovered from an error (e.g. failure to find the matching >).
-if (!CurrentToken->isOneOf(
-TT_LambdaLSquare, TT_LambdaLBrace, TT_ForEachMacro,
-TT_FunctionLBrace, TT_ImplicitStringLiteral, TT_InlineASMBrace,
-TT_JsFatArrow, TT_LambdaArrow, TT_OverloadedOperator,
-TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral))
+if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_LambdaLBrace,
+   TT_ForEachMacro, TT_TypenameMacro,
+   TT_FunctionLBrace, TT_ImplicitStringLiteral,
+   TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
+   TT_OverloadedOperator, TT_RegexLiteral,
+   TT_TemplateString, TT_ObjCStringLiteral))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -1416,6 +1417,7 @@
   if (AfterParen->Tok.isNot(tok::caret)) {
 if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
   if (BeforeParen->is(tok::identifier) &&
+  !BeforeParen->is(TT_TypenameMacro) &&
   BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
   (!BeforeParen->Previous ||
BeforeParen->Previous->ClosesTemplateDeclaration))
@@ -1667,7 +1669,8 @@
   FormatToken *TokenBeforeMatchingParen =
   PrevToken->MatchingParen->getPreviousNonComment();
   if (TokenBeforeMatchingParen &&
-  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
+TT_TypenameMacro))
 return TT_PointerOrReference;
 }
 
@@ -2527,7 +2530,8 @@
   FormatToken *TokenBeforeMatchingParen =
   Left.MatchingParen->getPreviousNonComment();
   if (!TokenBeforeMatchingParen ||
-  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
+ TT_TypenameMacro))
 return true;
 }
 return (Left.Tok.isLiteral() ||
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -39,6 +39,8 @@
 Macros.insert({(ForEachMacro), TT_ForEachMacro});
   for (const std::string  : Style.StatementMacros)
 Macros.insert({(StatementMacro), TT_StatementMacro});
+  for (const std::string  : Style.TypenameMacros)
+

[PATCH] D57184: [clang-format] Allow configuring list of function-like macros that resolve to a type

2019-05-25 Thread Marcin Radomski via Phabricator via cfe-commits
dextero updated this revision to Diff 201393.
dextero marked an inline comment as done.
dextero added a comment.

- [clang-format] Make documentation a bit clearer
- Rebased onto recent master

@Typz: thank you for the review! I don't have push access to the repository 
though. Could you commit this diff, or point me to someone I should ask instead?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57184

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -13545,6 +13545,35 @@
   guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
+TEST_F(FormatTest, TypenameMacros) {
+  std::vector TypenameMacros = {"STACK_OF", "LIST", "TAILQ_ENTRY"};
+
+  // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=30353
+  FormatStyle Google = getGoogleStyleWithColumns(0);
+  Google.TypenameMacros = TypenameMacros;
+  verifyFormat("struct foo {\n"
+   "  int bar;\n"
+   "  TAILQ_ENTRY(a) bleh;\n"
+   "};", Google);
+
+  FormatStyle Macros = getLLVMStyle();
+  Macros.TypenameMacros = TypenameMacros;
+
+  verifyFormat("STACK_OF(int) a;", Macros);
+  verifyFormat("STACK_OF(int) *a;", Macros);
+  verifyFormat("STACK_OF(int const *) *a;", Macros);
+  verifyFormat("STACK_OF(int *const) *a;", Macros);
+  verifyFormat("STACK_OF(int, string) a;", Macros);
+  verifyFormat("STACK_OF(LIST(int)) a;", Macros);
+  verifyFormat("STACK_OF(LIST(int)) a, b;", Macros);
+  verifyFormat("for (LIST(int) *a = NULL; a;) {\n}", Macros);
+  verifyFormat("STACK_OF(int) f(LIST(int) *arg);", Macros);
+
+  Macros.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("STACK_OF(int)* a;", Macros);
+  verifyFormat("STACK_OF(int*)* a;", Macros);
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1194,11 +1194,12 @@
 
 // Reset token type in case we have already looked at it and then
 // recovered from an error (e.g. failure to find the matching >).
-if (!CurrentToken->isOneOf(
-TT_LambdaLSquare, TT_LambdaLBrace, TT_ForEachMacro,
-TT_FunctionLBrace, TT_ImplicitStringLiteral, TT_InlineASMBrace,
-TT_JsFatArrow, TT_LambdaArrow, TT_OverloadedOperator,
-TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral))
+if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_LambdaLBrace,
+   TT_ForEachMacro, TT_TypenameMacro,
+   TT_FunctionLBrace, TT_ImplicitStringLiteral,
+   TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
+   TT_OverloadedOperator, TT_RegexLiteral,
+   TT_TemplateString, TT_ObjCStringLiteral))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -1416,6 +1417,7 @@
   if (AfterParen->Tok.isNot(tok::caret)) {
 if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
   if (BeforeParen->is(tok::identifier) &&
+  !BeforeParen->is(TT_TypenameMacro) &&
   BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
   (!BeforeParen->Previous ||
BeforeParen->Previous->ClosesTemplateDeclaration))
@@ -1667,7 +1669,8 @@
   FormatToken *TokenBeforeMatchingParen =
   PrevToken->MatchingParen->getPreviousNonComment();
   if (TokenBeforeMatchingParen &&
-  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
+TT_TypenameMacro))
 return TT_PointerOrReference;
 }
 
@@ -2527,7 +2530,8 @@
   FormatToken *TokenBeforeMatchingParen =
   Left.MatchingParen->getPreviousNonComment();
   if (!TokenBeforeMatchingParen ||
-  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
+ TT_TypenameMacro))
 return true;
 }
 return (Left.Tok.isLiteral() ||
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -39,6 +39,8 @@
 

[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361691: [X86FixupLEAs] Turn optIncDec into a generic two 
address LEA optimizer. Support… (authored by ctopper, committed by ).
Herald added a subscriber: qcolombet.

Changed prior to commit:
  https://reviews.llvm.org/D61472?vs=198303=201392#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61472

Files:
  llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp
  llvm/trunk/test/CodeGen/X86/GlobalISel/add-ext.ll
  llvm/trunk/test/CodeGen/X86/GlobalISel/callingconv.ll
  llvm/trunk/test/CodeGen/X86/GlobalISel/gep.ll
  llvm/trunk/test/CodeGen/X86/GlobalISel/memop-scalar.ll
  llvm/trunk/test/CodeGen/X86/MergeConsecutiveStores.ll
  llvm/trunk/test/CodeGen/X86/atomic-unordered.ll
  llvm/trunk/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
  llvm/trunk/test/CodeGen/X86/bitreverse.ll
  llvm/trunk/test/CodeGen/X86/bswap_tree2.ll
  llvm/trunk/test/CodeGen/X86/bypass-slow-division-32.ll
  llvm/trunk/test/CodeGen/X86/combine-srem.ll
  llvm/trunk/test/CodeGen/X86/dagcombine-shifts.ll
  llvm/trunk/test/CodeGen/X86/fixup-bw-copy.ll
  llvm/trunk/test/CodeGen/X86/fixup-lea.ll
  llvm/trunk/test/CodeGen/X86/imul.ll
  llvm/trunk/test/CodeGen/X86/leaFixup32.mir
  llvm/trunk/test/CodeGen/X86/leaFixup64.mir
  llvm/trunk/test/CodeGen/X86/mul-constant-i16.ll
  llvm/trunk/test/CodeGen/X86/mul-constant-i32.ll
  llvm/trunk/test/CodeGen/X86/mul-constant-i64.ll
  llvm/trunk/test/CodeGen/X86/mul-constant-i8.ll
  llvm/trunk/test/CodeGen/X86/popcnt.ll
  llvm/trunk/test/CodeGen/X86/ragreedy-hoist-spill.ll
  llvm/trunk/test/CodeGen/X86/reverse_branches.ll
  llvm/trunk/test/CodeGen/X86/rotate-extract.ll
  llvm/trunk/test/CodeGen/X86/sat-add.ll
  llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll
  llvm/trunk/test/CodeGen/X86/vector-bitreverse.ll
  llvm/trunk/test/CodeGen/X86/win_coreclr_chkstk.ll
  llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll

Index: llvm/trunk/test/CodeGen/X86/win_coreclr_chkstk.ll
===
--- llvm/trunk/test/CodeGen/X86/win_coreclr_chkstk.ll
+++ llvm/trunk/test/CodeGen/X86/win_coreclr_chkstk.ll
@@ -21,7 +21,7 @@
 ; WIN_X64:# %bb.1:
 ; WIN_X64:	andq	$-4096, %rdx
 ; WIN_X64:.LBB0_2:
-; WIN_X64:	leaq	-4096(%rcx), %rcx
+; WIN_X64:	addq	$-4096, %rcx
 ; WIN_X64:	movb	$0, (%rcx)
 ; WIN_X64:	cmpq	%rcx, %rdx
 ; WIN_X64:	jne	.LBB0_2
Index: llvm/trunk/test/CodeGen/X86/bswap_tree2.ll
===
--- llvm/trunk/test/CodeGen/X86/bswap_tree2.ll
+++ llvm/trunk/test/CodeGen/X86/bswap_tree2.ll
@@ -81,7 +81,7 @@
 ; CHECK64-NEXT:andl $-16777216, %edi # imm = 0xFF00
 ; CHECK64-NEXT:andl $16711680, %eax # imm = 0xFF
 ; CHECK64-NEXT:orl %edi, %eax
-; CHECK64-NEXT:leal (%rax,%rcx), %eax
+; CHECK64-NEXT:addl %ecx, %eax
 ; CHECK64-NEXT:retq
   %byte1 = lshr i32 %x, 8
   %byte0 = shl  i32 %x, 8
Index: llvm/trunk/test/CodeGen/X86/sat-add.ll
===
--- llvm/trunk/test/CodeGen/X86/sat-add.ll
+++ llvm/trunk/test/CodeGen/X86/sat-add.ll
@@ -236,7 +236,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpw %ax, %di
 ; ANY-NEXT:cmovbl %edi, %eax
-; ANY-NEXT:leal (%rax,%rsi), %eax
+; ANY-NEXT:addl %esi, %eax
 ; ANY-NEXT:# kill: def $ax killed $ax killed $eax
 ; ANY-NEXT:retq
   %noty = xor i16 %y, -1
@@ -287,7 +287,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpl %eax, %edi
 ; ANY-NEXT:cmovbl %edi, %eax
-; ANY-NEXT:leal (%rax,%rsi), %eax
+; ANY-NEXT:addl %esi, %eax
 ; ANY-NEXT:retq
   %noty = xor i32 %y, -1
   %c = icmp ult i32 %x, %noty
@@ -334,7 +334,7 @@
 ; ANY-NEXT:notq %rax
 ; ANY-NEXT:cmpq %rax, %rdi
 ; ANY-NEXT:cmovbq %rdi, %rax
-; ANY-NEXT:leaq (%rax,%rsi), %rax
+; ANY-NEXT:addq %rsi, %rax
 ; ANY-NEXT:retq
   %noty = xor i64 %y, -1
   %c = icmp ult i64 %x, %noty
Index: llvm/trunk/test/CodeGen/X86/bypass-slow-division-32.ll
===
--- llvm/trunk/test/CodeGen/X86/bypass-slow-division-32.ll
+++ llvm/trunk/test/CodeGen/X86/bypass-slow-division-32.ll
@@ -143,7 +143,7 @@
 ; CHECK-NEXT:movl %edx, %eax
 ; CHECK-NEXT:shrl $31, %eax
 ; CHECK-NEXT:sarl $3, %edx
-; CHECK-NEXT:leal (%edx,%eax), %eax
+; CHECK-NEXT:addl %edx, %eax
 ; CHECK-NEXT:retl
   %resultdiv = sdiv i32 %a, 33
   ret i32 %resultdiv
Index: llvm/trunk/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
===
--- llvm/trunk/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
+++ llvm/trunk/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
@@ -9268,7 +9268,7 @@
 ; X64-NEXT:kandw %k1, %k0, %k1 # encoding: [0xc5,0xfc,0x41,0xc9]
 ; X64-NEXT:kmovw %k1, %eax # encoding: [0xc5,0xf8,0x93,0xc1]
 ; X64-NEXT:kmovw %k0, %ecx # encoding: 

[PATCH] D62445: [test] Fix plugin tests

2019-05-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: beanz, phosek, george.karpenkov, NoQ, ahatanak, 
rjmccall.
Herald added subscribers: llvm-commits, dexonsmith, mgorny.
Herald added projects: clang, LLVM.
hintonda edited the summary of this revision.

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 no `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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62445

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

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/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/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -669,6 +669,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: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -126,27 +126,13 @@
 endif()
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(Analysis/plugins)
-  list(APPEND CLANG_TEST_DEPS 

[PATCH] D62442: [Driver] Update handling of c++ and runtime directories

2019-05-25 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm contingent on verifying intended behavior changes and adding comments.  
The factoring suggestion for the triple,triple searching is preferred but at 
your discretion, though I'd really like to see at least comments.




Comment at: clang/lib/Driver/Driver.cpp:4428
 
-  if (auto P = SearchPaths(TC.getFilePaths()))
+  if (auto P = SearchPaths(TC.getRuntimePaths()))
 return *P;

I see the renaming Library->Runtime throughout (not clear why, but OK by me).  
This also swaps the order of getFilePaths vs getRuntimePaths, which seems 
significant.  There's a woeful lack of comments in this function about its 
essential logic, which is the order in which it consults all the available 
sources of paths.
So changing the ordering a bit without any comments is concerning.

I'd like to see more comments overall, but as this is a preexisting problem in 
this code, it's enough for this change that you affirm this ordering change was 
intentional and add some commentary somewhere about the material change in 
behavior (here or in the log message).



Comment at: clang/lib/Driver/ToolChain.cpp:389
 SmallString<128> P(LibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + 
Suffix);
+return P.str();

Can you explain the change to  use the first entry rather than the first 
existing entry?
If the first one in the list is presumed to exist, then why is there a list 
instead of a single directory stored?



Comment at: clang/lib/Driver/ToolChain.cpp:410
+  SmallString<128> P;
+
+  P.assign(D.ResourceDir);

Comment about the distinction between D.getTargetTriple() and Triple.str() and 
why this order between them.



Comment at: clang/lib/Driver/ToolChain.cpp:424
+
+Optional ToolChain::getCXXStdlibPath() const {
+  SmallString<128> P;

Same here.  Can these use a common subroutine/template for trying something 
based on these two, so the logic about what D.getTargetTriple() and 
Triple.str() mean and both the code and justifying comments for their ordering 
logic is de-duplicated?



Comment at: clang/test/Driver/fuchsia.c:96
 // CHECK-ASAN-X86: "-dynamic-linker" "asan/ld.so.1"
-// CHECK-ASAN-X86: 
"-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}asan"
-// CHECK-ASAN-X86: "-L[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib"

To clarify, these are dropped because their sole intent was always to serve 
-lc++ and that's properly not enabled for this C-only link?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62442



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