[clang] 667598d - Revert "[Clang] Fix nomerge attribute not working with __builtin_trap(), __debugbreak(), __builtin_verbose_trap() (#101549)"

2024-08-01 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2024-08-01T14:46:36-07:00
New Revision: 667598d84b16d1789ce90b231565e9e7bfdbe77d

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

LOG: Revert "[Clang] Fix nomerge attribute not working with __builtin_trap(), 
__debugbreak(), __builtin_verbose_trap() (#101549)"

This reverts commit 5e84646982d1ec9bc94e48dde4b47f03c044a156, which
broke 'nomerge.ll' test on llvm bots.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGen/attr-nomerge.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/X86/nomerge.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index a1dce741c78a1..bb671c5ab5813 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3882,8 +3882,6 @@ llvm::CallInst 
*CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
 TrapCall->addFnAttr(A);
   }
 
-  if (InNoMergeAttributedStmt)
-TrapCall->addFnAttr(llvm::Attribute::NoMerge);
   return TrapCall;
 }
 

diff  --git a/clang/test/CodeGen/attr-nomerge.cpp 
b/clang/test/CodeGen/attr-nomerge.cpp
index b643920adde49..7305fb73cf1dc 100644
--- a/clang/test/CodeGen/attr-nomerge.cpp
+++ b/clang/test/CodeGen/attr-nomerge.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -fms-extensions -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
 
 class A {
 public:
@@ -42,9 +42,6 @@ void foo(int i, A *ap, B *bp) {
 
   A *newA = new B();
   delete newA;
-  [[clang::nomerge]] __builtin_trap();
-  [[clang::nomerge]] __debugbreak();
-  [[clang::nomerge]] __builtin_verbose_trap("check null", "Argument must not 
be null.");
 }
 
 int g(int i);
@@ -100,9 +97,6 @@ void something_else_again() {
 // CHECK: load ptr, ptr
 // CHECK: %[[AG:.*]] = load ptr, ptr
 // CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR1]]
-// CHECK: call void @llvm.trap() #[[ATTR0]]
-// CHECK: call void @llvm.debugtrap() #[[ATTR0]]
-// CHECK: call void @llvm.trap() #[[ATTR0]]
 // CHECK: call void  @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]
 
 // CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index a035fee6aafca..9f5e6466309e9 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7448,8 +7448,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const 
CallInst &I,
 break;
   default: llvm_unreachable("unknown trap intrinsic");
   }
-  DAG.addNoMergeSiteInfo(DAG.getRoot().getNode(),
- I.hasFnAttr(Attribute::NoMerge));
   return;
 }
 TargetLowering::ArgListTy Args;
@@ -7466,7 +7464,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const 
CallInst &I,
 DAG.getExternalSymbol(TrapFuncName.data(),
   TLI.getPointerTy(DAG.getDataLayout())),
 std::move(Args));
-CLI.NoMerge = I.hasFnAttr(Attribute::NoMerge);
+
 std::pair Result = TLI.LowerCallTo(CLI);
 DAG.setRoot(Result.second);
 return;

diff  --git a/llvm/test/CodeGen/X86/nomerge.ll 
b/llvm/test/CodeGen/X86/nomerge.ll
index d3e6feae87108..efbadf5b6911f 100644
--- a/llvm/test/CodeGen/X86/nomerge.ll
+++ b/llvm/test/CodeGen/X86/nomerge.ll
@@ -62,96 +62,4 @@ if.end:
 
 declare dso_local void @bar()
 
-define void @nomerge_trap(i32 %i) {
-; CHECK-LABEL: nomerge_trap:
-; CHECK:  # %bb.0: # %entry
-; CHECK:  # %bb.1: # %entry
-; CHECK:  # %bb.2: # %if.then
-; CHECK-NEXT: ud2
-; CHECK-NEXT: LBB1_3: # %if.then2
-; CHECK-NEXT: ud2
-; CHECK-NEXT: .LBB1_4: # %if.end3
-; CHECK-NEXT: ud2
-entry:
-  switch i32 %i, label %if.end3 [
-i32 5, label %if.then
-i32 7, label %if.then2
-  ]
-
-if.then:
-  tail call void @llvm.trap() #0
-  unreachable
-
-if.then2:
-  tail call void @llvm.trap() #0
-  unreachable
-
-if.end3:
-  tail call void @llvm.trap() #0
-  unreachable
-}
-
-declare dso_local void @llvm.trap()
-
-define void @nomerge_debugtrap(i32 %i) {
-; CHECK-LABEL: nomerge_debugtrap:
-; CHECK:  # %bb.0: # %entry
-; CHECK:  # %bb.1: # %entry
-; CHECK:  # %bb.2: # %if.then
-; CHECK-NEXT: int3
-; CHECK-NEXT: LBB2_3: # %if.then2
-; CHECK-NEXT: int3
-; CHECK-NEXT: .LBB2_4: # %if.end3
-; CHECK-NEXT: int3
-entry:
-  switch i32 %i, label %if.end3 [
-i32 5, label %if.then
-i32 7, label %if.then2
-  ]
-
-if.then:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-
-if.then2:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-
-if.end3:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-}
-
-define void @nomerge_named_debugtrap(i32 %i) {
-; CHECK-LABEL: nomerge_named_debugtrap:
-; CHE

[clang] f86ce86 - Revert "[C++20] [Modules] Always emit the inline builtins"

2024-07-30 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2024-07-30T12:27:58-07:00
New Revision: f86ce8675f74a6b8937f99e3562fbcae51fd1f2f

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

LOG: Revert "[C++20] [Modules] Always emit the inline builtins"

This reverts commit ca8a4111f796fe8533e0af95557875b15becff06.
This patch broke clang test on Windows x64 msvc

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
clang/test/Modules/inline-builtins.cppm



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 5a575c535b505..344a0e538f22a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4022,11 +4022,6 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
 return true;
 
   const auto *F = cast(GD.getDecl());
-  // Inline builtins declaration must be emitted. They often are fortified
-  // functions.
-  if (F->isInlineBuiltinDeclaration())
-return true;
-
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())
 return false;
 
@@ -4072,6 +4067,11 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
 }
   }
 
+  // Inline builtins declaration must be emitted. They often are fortified
+  // functions.
+  if (F->isInlineBuiltinDeclaration())
+return true;
+
   // PR9614. Avoid cases where the source code is lying to us. An available
   // externally function should have an equivalent function somewhere else,
   // but a function that calls itself through asm label/`__builtin_` trickery 
is

diff  --git a/clang/test/Modules/inline-builtins.cppm 
b/clang/test/Modules/inline-builtins.cppm
deleted file mode 100644
index 8f41ae2659513..0
--- a/clang/test/Modules/inline-builtins.cppm
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: cd %t
-//
-// RUN: %clang_cc1 -std=c++20 -O3 %t/a.cppm -emit-module-interface -o %t/a.pcm
-// RUN: %clang_cc1 -std=c++20 -O3 %t/test.cc -fmodule-file=a=%t/a.pcm \
-// RUN:   -emit-llvm -o - | FileCheck %t/test.cc
-
-//--- memmove.h
-typedef long unsigned int size_t;
-extern "C" void *memmove (void *__dest, const void *__src, size_t __n)
- throw () __attribute__ ((__nonnull__ (1, 2)));
-extern "C" __inline __attribute__ ((__always_inline__)) __attribute__ 
((__gnu_inline__)) void *
- memmove (void *__dest, const void *__src, size_t __len) throw ()
-{
-  return __builtin_memmove(__dest, __src, __len);
-}
-
-//--- a.cppm
-module;
-#include "memmove.h"
-export module a;
-export using ::memmove;
-
-//--- test.cc
-import a;
-
-void test() {
-  int a, b;
-  unsigned c = 0;
-  memmove(&a, &b, c);
-}
-
-// CHECK-NOT: memmove



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


[clang] 531233d - Revert "add support for riscv64"

2023-10-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-10-06T14:56:16-07:00
New Revision: 531233d4b099835a3b384456c2c22453010f9780

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

LOG: Revert "add support for riscv64"

This reverts commit cd0a8245b0feb951569eb3d396a1ff629daeb55c, which
breaks the build of compiler-rt for riscv64.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
compiler-rt/lib/tsan/rtl/CMakeLists.txt
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
compiler-rt/lib/tsan/rtl/tsan_platform.h
compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/test/tsan/map32bit.cpp
compiler-rt/test/tsan/mmap_large.cpp
compiler-rt/test/tsan/test.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 735af54f114cef2..1ba222bf83b1032 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -801,7 +801,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   IsRISCV64 || IsSystemZ || IsHexagon || IsLoongArch64)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ ||
-  IsLoongArch64 || IsRISCV64)
+  IsLoongArch64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsSystemZ)
 Res |= SanitizerKind::KernelMemory;

diff  --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 416777171d2ca75..e8ab660c1d83c0c 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -66,7 +66,7 @@ set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} 
${ARM64} ${PPC32} ${PPC
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
 ${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
-${LOONGARCH64} ${RISCV64})
+${LOONGARCH64})
 set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
 ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
 ${LOONGARCH64})

diff  --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt 
b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
index 791c0596f65abf7..7b18d379e919776 100644
--- a/compiler-rt/lib/tsan/rtl/CMakeLists.txt
+++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
@@ -220,10 +220,6 @@ else()
   set(TSAN_ASM_SOURCES
 tsan_rtl_mips64.S
 )
-elseif(arch MATCHES "riscv64")
-  set(TSAN_ASM_SOURCES
-tsan_rtl_riscv64.S
-)
 elseif(arch MATCHES "s390x")
   set(TSAN_ASM_SOURCES
 tsan_rtl_s390x.S

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index bb10b607278f91a..5add97ccd17a3ad 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -81,8 +81,6 @@ struct ucontext_t {
 #define PTHREAD_ABI_BASE  "GLIBC_2.17"
 #elif SANITIZER_LOONGARCH64
 #define PTHREAD_ABI_BASE  "GLIBC_2.36"
-#elif SANITIZER_RISCV64
-#define PTHREAD_ABI_BASE  "GLIBC_2.27"
 #endif
 
 extern "C" int pthread_attr_init(void *attr);

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h 
b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 43822020c0b4b30..f0cdaf48eaa3102 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -377,71 +377,6 @@ struct MappingPPC64_47 {
   static const uptr kMidAppMemEnd = 0;
 };
 
-/*
-C/C++ on linux/riscv64 (39-bit VMA)
- 0010 00 - 0200  00: main binary  ( 8 GB)
-0200  00 - 1000  00: -
-1000  00 - 4000  00: shadow memory(64 GB)
-4000  00 - 4800  00: metainfo (16 GB)
-4800  00 - 5500  00: -
-5500  00 - 5a00  00: main binary (PIE)(~8 GB)
-5600  00 - 7c00  00: -
-7d00  00 - 7fff  ff: libraries and main thread stack  ( 8 GB)
-
-mmap by default allocates from top downwards
-VDSO sits below loader and above dynamic libraries, within HiApp region.
-Heap starts after program region whose position depends on pie or non-pie.
-Disable tracking them since their locations are not fixed.
-*/
-struct MappingRiscv64_39 {
-  static const uptr kLoAppMemBeg   = 0x001000ull;
-  static const uptr kLoAppMemEnd   = 0x02ull;
-  static const uptr kShadowBeg = 0x10ull;
-  static const uptr kShadowEnd = 0x20ull;
-  static const uptr kMetaShadowBeg = 0x20ull;
-  static const uptr kMetaShadowEnd = 0x24ull;
-  static const uptr kMidAp

[clang] fa872aa - [Fuchsia] Enable libcxx filesystem on Windows build.

2023-06-27 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-06-27T16:57:58-07:00
New Revision: fa872aa221e2c632048517e5580b059ce7fc6900

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

LOG: [Fuchsia] Enable libcxx filesystem on Windows build.

This patch enables the libcxx filesystem when building runtimes for
Windows.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 763a79eee9cea..42d7f36df3f93 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -119,7 +119,6 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
-  set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")



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


[clang] bb39889 - [Fuchsia] Add llvm-strings to Fuchsia clang build.

2023-06-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-06-06T16:27:35-07:00
New Revision: bb398898dad98e001f8b665a37ab6fb8cef70814

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

LOG: [Fuchsia] Add llvm-strings to Fuchsia clang build.

This patch adds 'llvm-strings' to Fuchsia clang build.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index b4bc8cb4eb64e..9bacd27d31eaa 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -321,6 +321,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-readelf
   llvm-readobj
   llvm-size
+  llvm-strings
   llvm-strip
   llvm-symbolizer
   llvm-undname



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


[clang] 82b5a93 - Revert "[Fuchsia] Add llvm-debuginfod to toolchain"

2023-06-01 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-06-01T10:20:17-07:00
New Revision: 82b5a934b8e535d531b204af13775a820010c9be

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

LOG: Revert "[Fuchsia] Add llvm-debuginfod to toolchain"

This reverts commit 731f9ac6e53611dabb51c52bfc8011c2aab7790b.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 78c123f191305..8f5aa21be6fb8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -296,7 +296,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-ar
   llvm-cov
   llvm-cxxfilt
-  llvm-debuginfod
   llvm-debuginfod-find
   llvm-dlltool
   ${LLVM_DRIVER_TARGET}



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


[clang] e38cdc5 - Disable compiler launcher on external projects and multi stage clang

2023-04-24 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-04-24T12:15:44-07:00
New Revision: e38cdc5933b026cd25cf70c06f690a431c608d63

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

LOG: Disable compiler launcher on external projects and multi stage clang

When using compiler caching program like ccache, there is no point to
use them on external projects or multi-stage clang builds. As these
builds uses fresh from source code toolchain and will pollute the build
cache. If a compiler launcher is still required, a user can explicity
define `CMAKE_C_COMPILER_LAUNCHER` and `CMAKE_CXX_COMPILER_LAUNCHER` in
`CLANG_BOOTSTRAP_PASSTHROUGH` and `LLVM_EXTERNAL_PROJECT_PASSTHROUGH`
flags to enable compiler launcher in these builds.

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

Added: 


Modified: 
clang/CMakeLists.txt
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 4508ea4c77aa5..fd8558a16f81d 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -660,8 +660,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
 LLVM_VERSION_SUFFIX
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
-CMAKE_C_COMPILER_LAUNCHER
-CMAKE_CXX_COMPILER_LAUNCHER
 CMAKE_MAKE_PROGRAM
 CMAKE_OSX_ARCHITECTURES
 CMAKE_BUILD_TYPE

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 73910b4b083a1..44af6c1462bde 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -165,6 +165,19 @@ function(llvm_ExternalProject_Add name source_dir)
 endforeach()
   endforeach()
 
+  # Populate the non-project-specific passthrough variables
+  foreach(variableName ${LLVM_EXTERNAL_PROJECT_PASSTHROUGH})
+if(DEFINED ${variableName})
+  if("${${variableName}}" STREQUAL "")
+set(value "")
+  else()
+string(REPLACE ";" "|" value "${${variableName}}")
+  endif()
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${variableName}=${value})
+endif()
+  endforeach()
+
   if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
 if(CLANG_IN_TOOLCHAIN)
   if(is_msvc_target)
@@ -327,8 +340,6 @@ function(llvm_ExternalProject_Add name source_dir)
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
-   -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}



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


[clang] 43825d1 - Revert "[Assignment Tracking] Enable by default"

2023-03-31 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-03-31T11:27:18-07:00
New Revision: 43825d19318695be48abe6f042369da00fbb808b

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

LOG: Revert "[Assignment Tracking] Enable by default"

This reverts commit aa32490bfe0b957c4f5583e14304f5e34b2b9bce, which
breaks llvm runtimes builds on armv7 linux.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/CodeGen/assignment-tracking/flag.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 11007c99aa691..0cc7052b67105 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5800,7 +5800,7 @@ def experimental_assignment_tracking_EQ : Joined<["-"], 
"fexperimental-assignmen
   Group, CodeGenOpts<"EnableAssignmentTracking">,
   NormalizedValuesScope<"CodeGenOptions::AssignmentTrackingOpts">,
   Values<"disabled,enabled,forced">, 
NormalizedValues<["Disabled","Enabled","Forced"]>,
-  MarshallingInfoEnum, "Enabled">;
+  MarshallingInfoEnum, "Disabled">;
 
 } // let Flags = [CC1Option, NoDriverOption]
 

diff  --git a/clang/test/CodeGen/assignment-tracking/flag.cpp 
b/clang/test/CodeGen/assignment-tracking/flag.cpp
index 3bd974fe07c6c..aa1f054dae4d7 100644
--- a/clang/test/CodeGen/assignment-tracking/flag.cpp
+++ b/clang/test/CodeGen/assignment-tracking/flag.cpp
@@ -8,10 +8,10 @@
 // RUN: -emit-llvm  %s -o - -fexperimental-assignment-tracking=disabled 
-O1\
 // RUN: | FileCheck %s --check-prefixes=DISABLE
 
- Enabled by default:
+ Disabled by default:
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\
 // RUN: -emit-llvm  %s -o - -O1
\
-// RUN: | FileCheck %s --check-prefixes=ENABLE
+// RUN: | FileCheck %s --check-prefixes=DISABLE
 
  Disabled at O0 unless forced.
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\



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


[clang] a7bb9a3 - [Fuchsia] Enable LLVM_USE_RELATIVE_PATHS_IN_FILES in bootstrap

2023-02-28 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-28T15:19:23-08:00
New Revision: a7bb9a363923a6bfcc58a60b0442af8326422324

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

LOG: [Fuchsia] Enable LLVM_USE_RELATIVE_PATHS_IN_FILES in bootstrap

This patch enables LLVM_USE_RELATIVE_PATHS_IN_FILES when building the
bootstrap toolchain for 2 stages build.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index a993a786d2534..d9b34dd757e9a 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -16,6 +16,7 @@ set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 
 # Passthrough stage1 flags to stage1.
 set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH



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


[clang] ac835ec - [Fuchsia] Set /winsysroot in Windows runtimes linker flags

2023-02-14 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-14T13:31:48-08:00
New Revision: ac835ecb5feacdbf3fd9fcfc72fd2972067c26b4

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

LOG: [Fuchsia] Set /winsysroot in Windows runtimes linker flags

This patch sets '/winsysroot' flag when building Windows runtimes so we
don't have to explicitly set Windows library search paths.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5a9681a7cbae0..5a7cf6cf2c887 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -88,14 +88,13 @@ if(WIN32 OR LLVM_WINSYSROOT)
   ${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
 set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
-# so we have to manually set the libpath. We use clang-cl driver if we 
can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+  # TODO: lld-link has a bug that it cannot infer the machine type
+  # correctly when /winsysroot is set while Windows libraries search paths
+  # are not explicitly defined.
+  # Explicitly set the machine type for now.
+  /machine:X64
+  /vfsoverlay:${LLVM_VFSOVERLAY}
+  /winsysroot:${LLVM_WINSYSROOT})
 string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
   endif()
 



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


[clang] 14ca2e6 - Revert "[Fuchsia] Simplify Fuchsia stage2 toolchain setup"

2023-02-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-06T15:00:59-08:00
New Revision: 14ca2e68ff4c8cb03bd8f937ef792a2b638d0258

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

LOG: Revert "[Fuchsia] Simplify Fuchsia stage2 toolchain setup"

This reverts commit f9ff49882a65ab26ab347f4df8f2a58368d37185.
Accidentally landed a draft patch.

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index e0638a0b3c21..a993a786d253 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -169,8 +169,6 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_EXTRA_DEPS
   builtins
   runtimes
-  llvm-rc
-  llvm-mt
   CACHE STRING "")
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
   ${EXTRA_ARGS}



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


[clang] 5fcdab0 - [Fuchsia] Build windows runtimes using cross compilation on Linux

2023-02-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-06T14:58:53-08:00
New Revision: 5fcdab04c25039b5acb988568e08da9fc65c40fc

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

LOG: [Fuchsia] Build windows runtimes using cross compilation on Linux

This patch provides initial support of building Clang runtimes for
Windows when using Fuchsia Clang toolchains under Linux.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 3d9c1ef01e0ce..4d2be0b47d1f1 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@ if(APPLE)
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+  endif()
   set(target "x86_64-pc-windows-msvc")
 
+  if (LLVM_WINSYSROOT)
+set(WINDOWS_COMPILER_FLAGS
+  -Xclang
+  -ivfsoverlay
+  -Xclang
+  ${LLVM_VFSOVERLAY}
+  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
+  # but it current has a bug that prevents it from working under cross
+  # compilation. Set this flag manually for now.
+  /winsysroot
+  ${LLVM_WINSYSROOT})
+string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+set(WINDOWS_LINK_FLAGS
+/vfsoverlay:${LLVM_VFSOVERLAY}
+# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
+# so we have to manually set the libpath. We use clang-cl driver if we 
can
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+  endif()
+
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -84,6 +116,11 @@ if(WIN32)
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)

diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 987c9ce75ccfd..e0638a0b3c219 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -34,6 +34,8 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
   CMAKE_MODULE_LINKER_FLAGS
   CMAKE_SHARED_LINKER_FLAGS
   CMAKE_EXE_LINKER_FLAGS
+  LLVM_WINSYSROOT
+  LLVM_VFSOVERLAY
 )
 
 foreach(variable ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH})

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 9eef4eb7e35d2..750838875cd0e 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1315,6 +1315,10 @@ if(NOT LLVM_TOOLCHAIN_TOOLS)
 strings
 strip
 )
+  # Build llvm-mt if libxml2 is enabled. Can be used by runtimes.
+  if (LLVM_ENABLE_LIBXML2)
+

[clang] f9ff498 - [Fuchsia] Simplify Fuchsia stage2 toolchain setup

2023-02-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-06T14:58:53-08:00
New Revision: f9ff49882a65ab26ab347f4df8f2a58368d37185

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

LOG: [Fuchsia] Simplify Fuchsia stage2 toolchain setup

WIP

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 0536ede83657f..987c9ce75ccfd 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -167,6 +167,8 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_EXTRA_DEPS
   builtins
   runtimes
+  llvm-rc
+  llvm-mt
   CACHE STRING "")
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
   ${EXTRA_ARGS}



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


[clang] dc1c891 - [Clang] Add llvm-mt and llvm-rc to Clang bootstrap dependency

2023-02-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-06T11:36:27-08:00
New Revision: dc1c8917afd3f2b306797890a56be66087feb832

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

LOG: [Clang] Add llvm-mt and llvm-rc to Clang bootstrap dependency

This patch adds llvm-mt and llvm-rc to the Clang bootstrap
dependency when building the Clang under Windows.

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index b2cd30b9c788..be59c199f05f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -595,6 +595,14 @@ if (CLANG_ENABLE_BOOTSTRAP)
 add_dependencies(clang-bootstrap-deps lld)
   endif()
 
+  if (WIN32)
+# Build llvm-rc and llvm-mt which are needed by the Windows build.
+add_dependencies(clang-bootstrap-deps llvm-rc)
+if(LLVM_ENABLE_LIBXML2)
+  add_dependencies(clang-bootstrap-deps llvm-mt)
+endif()
+  endif()
+
   # If the next stage is LTO we need to depend on LTO and possibly lld or 
LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
 if(APPLE)



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


[clang] 630266a - [Fuchsia] Simplified the stage2 build setup

2023-02-06 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-02-06T10:46:31-08:00
New Revision: 630266aed342797d6413a69b8792567fc6263501

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

LOG: [Fuchsia] Simplified the stage2 build setup

This patch simplified the BOOTSTRAP_ flags, allowing them to be
pass through from regular flags.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 7537bf8a3ee2b..0536ede83657f 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -17,6 +17,34 @@ set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 
+# Passthrough stage1 flags to stage1.
+set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
+  LLVM_ENABLE_ZLIB
+  ZLIB_INCLUDE_DIR
+  ZLIB_LIBRARY
+  LLVM_ENABLE_ZSTD
+  zstd_DIR
+  LLVM_ENABLE_LIBXML2
+  LibXml2_ROOT
+  LLVM_ENABLE_CURL
+  CURL_ROOT
+  OpenSSL_ROOT
+  CMAKE_FIND_PACKAGE_PREFER_CONFIG
+  CMAKE_SYSROOT
+  CMAKE_MODULE_LINKER_FLAGS
+  CMAKE_SHARED_LINKER_FLAGS
+  CMAKE_EXE_LINKER_FLAGS
+)
+
+foreach(variable ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH})
+  get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
+  if(${is_value_set})
+get_property(value CACHE ${variable} PROPERTY VALUE)
+get_property(type CACHE ${variable} PROPERTY TYPE)
+set(BOOTSTRAP_${variable} "${value}" CACHE ${type} "")
+  endif()
+endforeach()
+
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
 endif()
@@ -105,12 +133,6 @@ if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
   endif()
 endif()
 
-if(UNIX)
-  set(BOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-endif()
-
 set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 



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


[clang] f2b58eb - Revert "[Fuchsia] Build windows runtimes using cross compilation on Linux"

2023-01-23 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-01-23T18:43:23-08:00
New Revision: f2b58eb4ad840f33caf970d6cf2906486647086b

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

LOG: Revert "[Fuchsia] Build windows runtimes using cross compilation on Linux"

This reverts commit 20bb7658f53b0b8db165ff4d404ede3f9b34862d.
It breaks Fuchsia stage2 builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 73fa55668957..9694a0f59856 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,44 +69,12 @@ if(APPLE)
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32 OR LLVM_WINSYSROOT)
-  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
-message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
-  endif()
+if(WIN32)
   set(target "x86_64-pc-windows-msvc")
 
-  if (LLVM_WINSYSROOT)
-set(WINDOWS_COMPILER_FLAGS
-  -Xclang
-  -ivfsoverlay
-  -Xclang
-  ${LLVM_VFSOVERLAY}
-  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
-  # but it current has a bug that prevents it from working under cross
-  # compilation. Set this flag manually for now.
-  /winsysroot
-  ${LLVM_WINSYSROOT})
-string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
-set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
-# so we have to manually set the libpath. We use clang-cl driver if we 
can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
-string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
-  endif()
-
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
-  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -116,11 +84,6 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
-  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
-  set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 05bfd70fe54c..d760eee07958 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@ function(llvm_ExternalProject_Add name source_dir)
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -212,12 +212,6 @@ function(llvm_ExternalProject_Add name source_dir)
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(APPEND compiler_args 
-DCMAKE_READELF=${LLVM_RUNTIME_OUT

[clang] 20bb765 - [Fuchsia] Build windows runtimes using cross compilation on Linux

2023-01-23 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-01-23T14:09:31-08:00
New Revision: 20bb7658f53b0b8db165ff4d404ede3f9b34862d

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

LOG: [Fuchsia] Build windows runtimes using cross compilation on Linux

This patch provides initial support of building Clang runtimes for
Windows when using Fuchsia Clang toolchains under Linux.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9694a0f59856..73fa55668957 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@ if(APPLE)
   set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" 
CACHE STRING "")
 endif()
 
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+  endif()
   set(target "x86_64-pc-windows-msvc")
 
+  if (LLVM_WINSYSROOT)
+set(WINDOWS_COMPILER_FLAGS
+  -Xclang
+  -ivfsoverlay
+  -Xclang
+  ${LLVM_VFSOVERLAY}
+  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake 
automatically
+  # but it current has a bug that prevents it from working under cross
+  # compilation. Set this flag manually for now.
+  /winsysroot
+  ${LLVM_WINSYSROOT})
+string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+set(WINDOWS_LINK_FLAGS
+/vfsoverlay:${LLVM_VFSOVERLAY}
+# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
+# so we have to manually set the libpath. We use clang-cl driver if we 
can
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+  endif()
+
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -84,6 +116,11 @@ if(WIN32)
   set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING 
"")
+  set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
+  set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index bf61d6dbc497..ff6cb11f7d1b 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@ function(llvm_ExternalProject_Add name source_dir)
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -213,6 +213,12 @@ function(llvm_ExternalProject_Add name source_dir)
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(

[clang] bc3edb6 - [CMake][Fuchsia] Include llvm-ml in Fuchsia toolchain

2023-01-11 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-01-11T11:02:58-08:00
New Revision: bc3edb6272010320e601e7cf7153db617e4d616f

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

LOG: [CMake][Fuchsia] Include llvm-ml in Fuchsia toolchain

This change includes llvm-ml tool in Fuchsia toolchain.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 7a09e4798309e..9694a0f598565 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -265,6 +265,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-lib
   llvm-libtool-darwin
   llvm-lipo
+  llvm-ml
   llvm-mt
   llvm-nm
   llvm-objcopy



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


[clang] a903ecb - [vfs] Allow root paths relative to the vfsoverlay YAML file

2022-12-16 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2022-12-16T11:45:36-08:00
New Revision: a903ecb4a26d8cf9a2e9e8369105682fd98f3982

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

LOG: [vfs] Allow root paths relative to the vfsoverlay YAML file

This change adds 'root-relative' option in vfsoverlay YAML file format
so the root patchs can be relative to the YAML file directory instead of
the current working directory.

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

Added: 
clang/test/VFS/Inputs/root-relative-overlay.yaml

Modified: 
clang/test/VFS/relative-path.c
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/test/VFS/Inputs/root-relative-overlay.yaml 
b/clang/test/VFS/Inputs/root-relative-overlay.yaml
new file mode 100644
index 0..931c1b4b73c55
--- /dev/null
+++ b/clang/test/VFS/Inputs/root-relative-overlay.yaml
@@ -0,0 +1,11 @@
+{
+  'version': 0,
+  'case-sensitive': false,
+  'overlay-relative': OVERLAY_DIR,
+  'root-relative': 'overlay-dir',
+  'roots': [
+{ 'name': 'not_real.h', 'type': 'file',
+  'external-contents': 'EXTERNAL_DIR/actual_header.h'
+},
+  ]
+}

diff  --git a/clang/test/VFS/relative-path.c b/clang/test/VFS/relative-path.c
index ab207d096848b..ba5451136a0c1 100644
--- a/clang/test/VFS/relative-path.c
+++ b/clang/test/VFS/relative-path.c
@@ -3,6 +3,13 @@
 // RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsoverlay.yaml > %t.yaml
 // RUN: %clang_cc1 -Werror -I . -ivfsoverlay %t.yaml -fsyntax-only %s
 
+// RUN: cp %S/Inputs/actual_header.h %t/actual_header.h
+// RUN: sed -e "s@OVERLAY_DIR@true@g" -e "s@EXTERNAL_DIR@.@g" 
%S/Inputs/root-relative-overlay.yaml > %t/root-relative-overlay.yaml
+// RUN: %clang_cc1 -Werror -I %t -ivfsoverlay %t/root-relative-overlay.yaml 
-fsyntax-only %s
+
+// RUN: sed -e "s@OVERLAY_DIR@false@g" -e 
"s@EXTERNAL_DIR@%{/t:regex_replacement}@g" %S/Inputs/root-relative-overlay.yaml 
> %t/root-relative-overlay2.yaml
+// RUN: %clang_cc1 -Werror -I %t -ivfsoverlay %t/root-relative-overlay2.yaml 
-fsyntax-only %s
+
 #include "not_real.h"
 
 void foo(void) {

diff  --git a/llvm/include/llvm/Support/VirtualFileSystem.h 
b/llvm/include/llvm/Support/VirtualFileSystem.h
index 295ed63def9be..71dbc80edf9a5 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -653,17 +653,28 @@ class RedirectingFileSystemParser;
 /// \endverbatim
 ///
 /// The roots may be absolute or relative. If relative they will be made
-/// absolute against the current working directory.
+/// absolute against either current working directory or the directory where
+/// the Overlay YAML file is located, depending on the 'root-relative'
+/// configuration.
 ///
 /// All configuration options are optional.
 ///   'case-sensitive': 
 ///   'use-external-names': 
+///   'root-relative': 
 ///   'overlay-relative': 
 ///   'fallthrough': 
 ///   'redirecting-with': 
 ///
+/// To clarify, 'root-relative' option will prepend the current working
+/// directory, or the overlay directory to the 'roots->name' field only if
+/// 'roots->name' is a relative path. On the other hand, when 
'overlay-relative'
+/// is set to 'true', external paths will always be prepended with the overlay
+/// directory, even if external paths are not relative paths. The
+/// 'root-relative' option has no interaction with the 'overlay-relative'
+/// option.
+///
 /// Virtual directories that list their contents are represented as
 /// \verbatim
 /// {
@@ -747,6 +758,15 @@ class RedirectingFileSystem : public vfs::FileSystem {
 RedirectOnly
   };
 
+  /// The type of relative path used by Roots.
+  enum class RootRelativeKind {
+/// The roots are relative to the current working directory.
+CWD,
+/// The roots are relative to the directory where the Overlay YAML file
+// locates.
+OverlayDir
+  };
+
   /// A single file or directory in the VFS.
   class Entry {
 EntryKind Kind;
@@ -892,6 +912,21 @@ class RedirectingFileSystem : public vfs::FileSystem {
   ErrorOr getExternalStatus(const Twine &CanonicalPath,
 const Twine &OriginalPath) const;
 
+  /// Make \a Path an absolute path.
+  ///
+  /// Makes \a Path absolute using the \a WorkingDir if it is not already.
+  ///
+  /// /absolute/path   => /absolute/path
+  /// relative/../path => /relative/../path
+  ///
+  /// \param WorkingDir  A path that will be used as the base Dir if \a Path
+  ///is not already absolute.
+  /// \param Path A path that is modified to be an absolute path.
+  /// \returns success if \a pat

[libunwind] a353909 - Revert "[runtimes] Always define cxx_shared, cxx_static & other targets"

2022-10-12 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2022-10-12T12:54:48-07:00
New Revision: a3539090884c9159893c0b2b4c1dc34f23510707

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

LOG: Revert "[runtimes] Always define cxx_shared, cxx_static & other targets"

This reverts commit 79ee0342dbf025bc70f237bdfe9ccb4e10a592ce which
breaks the LLVM TSan bots.

Added: 


Modified: 
libcxx/cmake/caches/AIX.cmake
libcxx/src/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake
index d4eb9ac42743a..76cf177913011 100644
--- a/libcxx/cmake/caches/AIX.cmake
+++ b/libcxx/cmake/caches/AIX.cmake
@@ -17,10 +17,3 @@ set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
 set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(LIBUNWIND_ENABLE_SHARED ON CACHE BOOL "")
 set(LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
-
-# On AIX, both shared and static libraries are archived. As a result, both the 
static and the shared targets end
-# up with a `.a` suffix, which conflict. To workaround that, we set a 
diff erent output name for the static
-# libraries, which we never actually build anyway. For more information, see 
https://gitlab.kitware.com/cmake/cmake/-/issues/19494.
-set(LIBCXX_STATIC_OUTPUT_NAME "c++-static" CACHE STRING "")
-set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi-static" CACHE STRING "")
-set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind-static" CACHE STRING "")

diff  --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index f2ae81e88cf76..9ff2a62e93946 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -147,6 +147,10 @@ if (LIBCXX_CONFIGURE_IDE)
   endif()
 endif()
 
+if(NOT LIBCXX_INSTALL_LIBRARY)
+  set(exclude_from_all EXCLUDE_FROM_ALL)
+endif()
+
 if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
   find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
 endif()
@@ -191,146 +195,139 @@ endfunction()
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-#
 # Build the shared library.
-#
-add_library(cxx_shared SHARED 
$<$>:EXCLUDE_FROM_ALL> ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
-target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-target_link_libraries(cxx_shared PUBLIC cxx-headers
- PRIVATE ${LIBCXX_LIBRARIES})
-set_target_properties(cxx_shared
-  PROPERTIES
-COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
-VERSION   "${LIBCXX_LIBRARY_VERSION}"
-SOVERSION "${LIBCXX_ABI_VERSION}"
-DEFINE_SYMBOL ""
-)
-cxx_add_common_build_flags(cxx_shared)
-cxx_set_common_defines(cxx_shared)
-
-if(ZOS)
-  add_custom_command(TARGET cxx_shared POST_BUILD
-COMMAND
-  ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
-  $ $ 
"${LIBCXX_DLL_NAME}"
-COMMENT "Rename dll name inside the side deck file"
-WORKING_DIRECTORY $
+if (LIBCXX_ENABLE_SHARED)
+  add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
+  target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+  target_link_libraries(cxx_shared PUBLIC cxx-headers
+   PRIVATE ${LIBCXX_LIBRARIES})
+  set_target_properties(cxx_shared
+PROPERTIES
+  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+  OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
+  VERSION   "${LIBCXX_LIBRARY_VERSION}"
+  SOVERSION "${LIBCXX_ABI_VERSION}"
+  DEFINE_SYMBOL ""
   )
-endif()
+  cxx_add_common_build_flags(cxx_shared)
+  cxx_set_common_defines(cxx_shared)
+
+  if(ZOS)
+add_custom_command(TARGET cxx_shared POST_BUILD
+  COMMAND
+${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
+$ $ 
"${LIBCXX_DLL_NAME}"
+  COMMENT "Rename dll name inside the side deck file"
+  WORKING_DIRECTORY $
+)
+  endif()
 
-# Link against libc++abi
-if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-  target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-else()
-  target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-endif()
+  # Link against libc++abi
+  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
+  else()
+target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
+  endif()
 
-# Maybe re-export symbols from libc++abi
-# In particular, we don't re-export the symbols if libc++abi is merged 
statically
-# into libc++ because in that case there's no dylib to re-export from.
-if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
-  AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
-  A

[clang-tools-extra] a759477 - Revert "[clang-doc] Add typedef/using information."

2022-09-27 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2022-09-27T18:35:34-07:00
New Revision: a7594772225b59ad75cd270aa261b49695985444

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

LOG: Revert "[clang-doc] Add typedef/using information."

This reverts commit eed22583fd78d4d657fb70b99e62fbdc1f83b8f9, which
breaks clang build with -Werror.

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/BitcodeWriter.h
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/clang-doc/Mapper.h
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-doc/Serialize.h
clang-tools-extra/clang-doc/YAMLGenerator.cpp
clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.h
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MergeTest.cpp
clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 8e1db35532a05..027272691d038 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -24,6 +24,12 @@ llvm::Error decodeRecord(const Record &R, 
llvm::SmallVectorImpl &Field,
   return llvm::Error::success();
 }
 
+llvm::Error decodeRecord(const Record &R, std::string &Field,
+ llvm::StringRef Blob) {
+  Field.assign(Blob.begin(), Blob.end());
+  return llvm::Error::success();
+}
+
 llvm::Error decodeRecord(const Record &R, SymbolID &Field,
  llvm::StringRef Blob) {
   if (R[0] != BitCodeConstants::USRHashSize)
@@ -98,7 +104,6 @@ llvm::Error decodeRecord(const Record &R, InfoType &Field,
   case InfoType::IT_function:
   case InfoType::IT_default:
   case InfoType::IT_enum:
-  case InfoType::IT_typedef:
 Field = IT;
 return llvm::Error::success();
   }
@@ -228,23 +233,6 @@ llvm::Error parseRecord(const Record &R, unsigned ID, 
llvm::StringRef Blob,
   }
 }
 
-llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
-TypedefInfo *I) {
-  switch (ID) {
-  case TYPEDEF_USR:
-return decodeRecord(R, I->USR, Blob);
-  case TYPEDEF_NAME:
-return decodeRecord(R, I->Name, Blob);
-  case TYPEDEF_DEFLOCATION:
-return decodeRecord(R, I->DefLoc, Blob);
-  case TYPEDEF_IS_USING:
-return decodeRecord(R, I->IsUsing, Blob);
-  default:
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "invalid field for TypedefInfo");
-  }
-}
-
 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
 EnumValueInfo *I) {
   switch (ID) {
@@ -436,11 +424,6 @@ template <> llvm::Error addTypeInfo(EnumInfo *I, TypeInfo 
&&T) {
   return llvm::Error::success();
 }
 
-template <> llvm::Error addTypeInfo(TypedefInfo *I, TypeInfo &&T) {
-  I->Underlying = std::move(T);
-  return llvm::Error::success();
-}
-
 template  llvm::Error addReference(T I, Reference &&R, FieldId F) {
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "invalid type cannot contain Reference");
@@ -492,17 +475,6 @@ template <> llvm::Error addReference(EnumInfo *I, 
Reference &&R, FieldId F) {
   }
 }
 
-template <> llvm::Error addReference(TypedefInfo *I, Reference &&R, FieldId F) 
{
-  switch (F) {
-  case FieldId::F_namespace:
-I->Namespace.emplace_back(std::move(R));
-return llvm::Error::success();
-  default:
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "invalid type cannot contain Reference");
-  }
-}
-
 template <>
 llvm::Error addReference(NamespaceInfo *I, Reference &&R, FieldId F) {
   switch (F) {
@@ -510,10 +482,10 @@ llvm::Error addReference(NamespaceInfo *I, Reference &&R, 
FieldId F) {
 I->Namespace.emplace_back(std::move(R));
 return llvm::Error::success();
   case FieldId::F_child_namespace:
-I->Children.Namespaces.emplace_back(std::move(R));
+I->ChildNamespaces.emplace_back(std::move(R));
 return llvm::Error::success();
   case FieldId::F_child_record:
-I->Children.Records.emplace_back(std::move(R));
+I->ChildRecords.emplace_back(std::move(R)

Re: [PATCH] D134235: [clang-doc] Clean up *Info constructors.

2022-09-26 Thread Haowei Wu via cfe-commits
Please avoid directly replying to the email as they won't be logged in the
phabricator.

This boolean is logged into YAML output, while I don't have data, I could
bet there will be users depending on it even if it looks so unlikely. We
don't own the tool in the first place, in that case, I felt if there is a
bug in its constructor, we should fix the bug instead of abruptly deleting
it, even if it looks so easy to be derived from other values.

On Mon, Sep 26, 2022 at 3:14 PM Brett Wilson  wrote:

> On Mon, Sep 26, 2022 at 1:42 PM Haowei Wu via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> haowei added a comment.
>>
>> @brettw Thanks for the clarification. I was oncall for buildgardener last
>> week and got quite busy due to breakages.
>>
>> Thanks for your clarification, that is really helpful to understand the
>> your intent. While I still don't see the way these constructors are
>> implemented is an issue. I don't have a strong opinions on this and OK with
>> your refactors.
>>
>> "semantically equivalent" means these test code should have same
>> input/output, performance same routines of task and use same amount of
>> memory. Before your change, these typeinfo's symbolID in the test are
>> always pointing to a constant EmptySID, after your change, some of these
>> typeinfo points to an empty symbol ID in allocated in memory when typeinfo
>> is created. While the output is the same, they are not equivalent. For
>> refactor changes, I would prefer to avoid introducing such changes.
>>
>> I have one question about deleting the IsInGlobalNamespace. I understand
>> it is not well implemented and has a bug in its constructor, but I don't
>> think we should simply delete it just because it is buggy and not well
>> used. It is part of C++ and commonly used. Do you have any plan to add it
>> back after all the refactor work finishes?
>>
>
> I guess I'll ask you: what does this boolean mean and why do we need it?
> This flag was only ever derived from the "path" which is just a member in
> the same class. Users already have the full namespace information as far as
> I can tell.
>
> Brett
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7fae15f - Revert "[Driver] Improve linking options for target AVR"

2022-06-14 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2022-06-14T17:53:46-07:00
New Revision: 7fae15f9251d3b392058e2fc84898b53619d36ad

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

LOG: Revert "[Driver] Improve linking options for target AVR"

This reverts commit 3b6e166999bb83197c8b70468c2d371c58cf0c25 which
causes Clang Driver test failures on Fuchsia builders.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/avr-toolchain.c

Removed: 
clang/test/Driver/Inputs/basic_avr_tree/usr/bin/ld.lld



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 96219f83b0a5..0ef6b0a7e086 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -36,6 +36,10 @@ def warn_drv_avr_mcu_not_specified : Warning<
   "no target microcontroller specified on command line, cannot "
   "link standard libraries, please pass -mmcu=">,
   InGroup;
+def warn_drv_avr_gcc_not_found: Warning<
+  "no avr-gcc installation can be found on the system, "
+  "cannot link standard libraries">,
+  InGroup;
 def warn_drv_avr_libc_not_found: Warning<
   "no avr-libc installation can be found on the system, "
   "cannot link standard libraries">,

diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 0bdbd5c09a5f..466fc3b20569 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -375,7 +375,8 @@ AVRToolChain::AVRToolChain(const Driver &D, const 
llvm::Triple &Triple,
 
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs) && GCCInstallation.isValid()) {
+  !Args.hasArg(options::OPT_nodefaultlibs) &&
+  GCCInstallation.isValid()) {
 GCCInstallPath = GCCInstallation.getInstallPath();
 std::string GCCParentPath(GCCInstallation.getParentLibPath());
 getProgramPaths().push_back(GCCParentPath + "/../bin");
@@ -428,12 +429,9 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // Compute information about the target AVR.
   std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
   llvm::Optional FamilyName = GetMCUFamilyName(CPU);
-  llvm::Optional AVRLibcRoot = TC.findAVRLibcInstallation();
   llvm::Optional SectionAddressData = GetMCUSectionAddressData(CPU);
 
-  // Compute the linker program path, and use GNU "avr-ld" as default.
-  std::string Linker = getToolChain().GetLinkerPath(nullptr);
-
+  std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
@@ -452,11 +450,17 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
 if (!CPU.empty()) {
+Optional FamilyName = GetMCUFamilyName(CPU);
+Optional AVRLibcRoot = TC.findAVRLibcInstallation();
+
   if (!FamilyName) {
 // We do not have an entry for this CPU in the family
 // mapping table yet.
 D.Diag(diag::warn_drv_avr_family_linking_stdlibs_not_implemented)
 << CPU;
+  } else if (TC.getGCCInstallPath().empty()) {
+// We can not link since there is no avr-ld.
+D.Diag(diag::warn_drv_avr_gcc_not_found);
   } else if (!AVRLibcRoot) {
 // No avr-libc found and so no runtime linked.
 D.Diag(diag::warn_drv_avr_libc_not_found);
@@ -469,6 +473,7 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 LinkStdlib = true;
   }
 }
+
 if (!LinkStdlib)
   D.Diag(diag::warn_drv_avr_stdlib_not_linked);
   }
@@ -503,15 +508,11 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
 CmdArgs.push_back("--end-group");
 
-// Add user specified linker script.
-Args.AddAllArgs(CmdArgs, options::OPT_T);
-
 // Specify the family name as the emulation mode to use.
 // This is almost always required because otherwise avr-ld
 // will assume 'avr2' and warn about the program being larger
 // than the bare minimum supports.
-if (Linker.find("avr-ld") != std::string::npos)
-  CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName));
+CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName));
   }
 
   C.addCommand(std::make_unique(

diff  --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/bin/ld.lld 
b/clang/test/Driver/Inputs/basic_avr_tree/usr/bin/ld.lld
deleted file mode 100755
index e69de29bb2d1..

diff  --git a/cla

[clang] 07bed3a - [clang][Fuchsia] Add additional unit test for availability attr

2021-10-25 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-10-25T15:40:30-07:00
New Revision: 07bed3ae52b0a94d9de7f12ca5f2a92589c6c4b6

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

LOG: [clang][Fuchsia] Add additional unit test for availability attr

This change adds additional unit tests for availability attribute
support for Fuchsia platform.

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

Added: 


Modified: 
clang/test/Sema/attr-availability-fuchsia.c

Removed: 




diff  --git a/clang/test/Sema/attr-availability-fuchsia.c 
b/clang/test/Sema/attr-availability-fuchsia.c
index 6b273fe2ae5f6..53bea9a7db3a1 100644
--- a/clang/test/Sema/attr-availability-fuchsia.c
+++ b/clang/test/Sema/attr-availability-fuchsia.c
@@ -11,17 +11,19 @@
 void f0(int) __attribute__((availability(fuchsia, introduced = 14, deprecated 
= 19)));
 void f1(int) __attribute__((availability(fuchsia, introduced = 16)));
 void f2(int) __attribute__((availability(fuchsia, introduced = 14, deprecated 
= 16))); // expected-note {{'f2' has been explicitly marked deprecated here}}
-void f3(int) __attribute__((availability(fuchsia, introduced = 19)));
+void f3(int) __attribute__((availability(fuchsia, introduced = 19, strict))); 
// expected-note {{'f3' has been explicitly marked unavailable here}}
 void f4(int) __attribute__((availability(fuchsia, introduced = 9, deprecated = 
11, obsoleted = 16), availability(ios, introduced = 2.0, deprecated = 3.0))); 
// expected-note{{explicitly marked unavailable}}
 void f5(int) __attribute__((availability(ios, introduced = 3.2), 
availability(fuchsia, unavailable)));   
// expected-note{{'f5' has been explicitly marked unavailable here}}
 void f6(int) __attribute__((availability(fuchsia, introduced = 16.0)));
  
// expected-warning {{Fuchsia API Level prohibits specifying a minor or 
sub-minor version}}
 void f7(int) __attribute__((availability(fuchsia, introduced = 16.1))); // 
expected-warning {{Fuchsia API Level prohibits specifying a minor or sub-minor 
version}}
+void f8(int) __attribute__((availability(fuchsia, introduced = 19))); // 
nothing will happen as 'strict' is not specified.
 
 void test() {
   f0(0);
   f1(0);
   f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Fuchsia 
16}}
-  f3(0);
+  f3(0); // expected-error{{'f3' is unavailable: introduced in Fuchsia 19}}
   f4(0); // expected-error{{f4' is unavailable: obsoleted in Fuchsia 16}}
   f5(0); // expected-error{{'f5' is unavailable: not available on Fuchsia}}
+  f8(0);
 }



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


[clang] 998e067 - Reland "[clang][Fuchsia] Support availability attr on Fuchsia"

2021-10-11 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-10-11T18:41:29-07:00
New Revision: 998e067a0a579bd483c2a2d411385e58494ffbca

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

LOG: Reland "[clang][Fuchsia] Support availability attr on Fuchsia"

This reland commit 1131b1eb3509b47d30a36ea9b42367ab1d7373a2, which
adds support to __attribute__((availability)) annotation for Fuchsia
platform. This patch also adds '-ffuchsia-api-level' to allow specify
Fuchsia API level from the command line.

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

Added: 
clang/test/Driver/attr-availability-fuchsia.c
clang/test/Sema/attr-availability-fuchsia.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 22669650b4413..c39657e6c8351 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -848,6 +848,7 @@ def Availability : InheritableAttr {
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
  .Case("android", "Android")
+ .Case("fuchsia", "Fuchsia")
  .Case("ios", "iOS")
  .Case("macos", "macOS")
  .Case("tvos", "tvOS")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 128ad047072e8..c5b3f2c5cca64 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3554,6 +3554,9 @@ def warn_availability_swift_unavailable_deprecated_only : 
Warning<
   InGroup;
 def note_protocol_method : Note<
   "protocol method is here">;
+def warn_availability_fuchsia_unavailable_minor : Warning<
+  "Fuchsia API Level prohibits specifying a minor or sub-minor version">,
+  InGroup;
 
 def warn_unguarded_availability :
   Warning<"%0 is only available on %1 %2 or newer">,

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index e21d2fcea621e..912fd0ec18961 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -431,6 +431,8 @@ ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, 
ExtendArgsKind::ExtendTo32,
  "Controls how scalar integer arguments are extended in calls "
  "to unprototyped and varargs functions")
 
+VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9b0d0dfb7628c..4d422abd03a0e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3173,6 +3173,9 @@ def mlinker_version_EQ : Joined<["-"], 
"mlinker-version=">,
 def mllvm : Separate<["-"], "mllvm">, 
Flags<[CC1Option,CC1AsOption,CoreOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
+  Group, Flags<[CC1Option]>, HelpText<"Set Fuchsia API level">,
+  MarshallingInfoInt>;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
 def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 02a0957be5b93..220290c1bacf5 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -890,6 +890,9 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public 
OSTargetInfo {
 // Required by the libc++ locale support.
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
+Builder.defineMacro("__Fuchsia_API_level__", Twine(Opts.FuchsiaAPILevel));
+this->PlatformName = "fuchsia";
+this->PlatformMinVersion = VersionTuple(Opts.FuchsiaAPILevel);
   }
 
 public:

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f1771d4fa35d2..7ce6aa289e095 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5481,6 +5481,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
   options::OPT_fno_experimental_relative_cxx_abi_vtables);
 
+  if (Arg *A = Args.getLastArg(o

[clang] b5e8348 - Revert "[clang][Fuchsia] Support availability attr on Fuchsia"

2021-10-11 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-10-11T17:32:38-07:00
New Revision: b5e8348bf2ded134e45dab879a13d26f5b9c5815

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

LOG: Revert "[clang][Fuchsia] Support availability attr on Fuchsia"

This reverts commit 1131b1eb3509b47d30a36ea9b42367ab1d7373a2, which
breaks several llvm bots.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 
clang/test/Driver/attr-availability-fuchsia.c
clang/test/Sema/attr-availability-fuchsia.c



diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index c39657e6c8351..22669650b4413 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -848,7 +848,6 @@ def Availability : InheritableAttr {
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
  .Case("android", "Android")
- .Case("fuchsia", "Fuchsia")
  .Case("ios", "iOS")
  .Case("macos", "macOS")
  .Case("tvos", "tvOS")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c5b3f2c5cca64..128ad047072e8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3554,9 +3554,6 @@ def warn_availability_swift_unavailable_deprecated_only : 
Warning<
   InGroup;
 def note_protocol_method : Note<
   "protocol method is here">;
-def warn_availability_fuchsia_unavailable_minor : Warning<
-  "Fuchsia API Level prohibits specifying a minor or sub-minor version">,
-  InGroup;
 
 def warn_unguarded_availability :
   Warning<"%0 is only available on %1 %2 or newer">,

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 912fd0ec18961..e21d2fcea621e 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -431,8 +431,6 @@ ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, 
ExtendArgsKind::ExtendTo32,
  "Controls how scalar integer arguments are extended in calls "
  "to unprototyped and varargs functions")
 
-VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
-
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4d422abd03a0e..9b0d0dfb7628c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3173,9 +3173,6 @@ def mlinker_version_EQ : Joined<["-"], 
"mlinker-version=">,
 def mllvm : Separate<["-"], "mllvm">, 
Flags<[CC1Option,CC1AsOption,CoreOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
-def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
-  Group, Flags<[CC1Option]>, HelpText<"Set Fuchsia API level">,
-  MarshallingInfoInt>;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
 def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 220290c1bacf5..02a0957be5b93 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -890,9 +890,6 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public 
OSTargetInfo {
 // Required by the libc++ locale support.
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
-Builder.defineMacro("__Fuchsia_API_level__", Twine(Opts.FuchsiaAPILevel));
-this->PlatformName = "fuchsia";
-this->PlatformMinVersion = VersionTuple(Opts.FuchsiaAPILevel);
   }
 
 public:

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7ce6aa289e095..f1771d4fa35d2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5481,9 +5481,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
   options::OPT_fno_experimental_relative_cxx_abi_vtables);
 
-  if (Arg *A = Args.getLastArg(options::OPT_ffuchsia_api_level_EQ))
-A->render(Args, CmdArgs);
-
   // Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi}
   // (-ansi is equivalent to -std=c89 or -std=c++98).
   //

diff  --g

[clang] 1131b1e - [clang][Fuchsia] Support availability attr on Fuchsia

2021-10-11 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-10-11T15:33:04-07:00
New Revision: 1131b1eb3509b47d30a36ea9b42367ab1d7373a2

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

LOG: [clang][Fuchsia] Support availability attr on Fuchsia

This patch adds support to __attribute__((availability)) annotation for
Fuchsia platform. This patch also adds '-ffuchsia-api-level' to allow
specify Fuchsia API level from the command line.

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

Added: 
clang/test/Driver/attr-availability-fuchsia.c
clang/test/Sema/attr-availability-fuchsia.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ec7c1bd60ed4c..bd6510677fac0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -848,6 +848,7 @@ def Availability : InheritableAttr {
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
  .Case("android", "Android")
+ .Case("fuchsia", "Fuchsia")
  .Case("ios", "iOS")
  .Case("macos", "macOS")
  .Case("tvos", "tvOS")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 128ad047072e8..c5b3f2c5cca64 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3554,6 +3554,9 @@ def warn_availability_swift_unavailable_deprecated_only : 
Warning<
   InGroup;
 def note_protocol_method : Note<
   "protocol method is here">;
+def warn_availability_fuchsia_unavailable_minor : Warning<
+  "Fuchsia API Level prohibits specifying a minor or sub-minor version">,
+  InGroup;
 
 def warn_unguarded_availability :
   Warning<"%0 is only available on %1 %2 or newer">,

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index e21d2fcea621e..912fd0ec18961 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -431,6 +431,8 @@ ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, 
ExtendArgsKind::ExtendTo32,
  "Controls how scalar integer arguments are extended in calls "
  "to unprototyped and varargs functions")
 
+VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9b0d0dfb7628c..4d422abd03a0e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3173,6 +3173,9 @@ def mlinker_version_EQ : Joined<["-"], 
"mlinker-version=">,
 def mllvm : Separate<["-"], "mllvm">, 
Flags<[CC1Option,CC1AsOption,CoreOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
+  Group, Flags<[CC1Option]>, HelpText<"Set Fuchsia API level">,
+  MarshallingInfoInt>;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
 def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 02a0957be5b93..220290c1bacf5 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -890,6 +890,9 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public 
OSTargetInfo {
 // Required by the libc++ locale support.
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
+Builder.defineMacro("__Fuchsia_API_level__", Twine(Opts.FuchsiaAPILevel));
+this->PlatformName = "fuchsia";
+this->PlatformMinVersion = VersionTuple(Opts.FuchsiaAPILevel);
   }
 
 public:

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f1771d4fa35d2..7ce6aa289e095 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5481,6 +5481,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
   options::OPT_fno_experimental_relative_cxx_abi_vtables);
 
+  if (Arg *A = Args.getLastArg(options::OPT_ffuchsia_api_level_EQ))
+A->render(Args, CmdArgs)

[clang] 38a5bd4 - [clang_format] Add fallback-style flag to clang-format-diff.py

2021-09-09 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-09-09T16:36:39-07:00
New Revision: 38a5bd4115afbe022a99334c7880f30a8ffd7c4a

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

LOG: [clang_format] Add fallback-style flag to clang-format-diff.py

This change adds fallback-style flag to clang-format-diff.py

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

Added: 


Modified: 
clang/tools/clang-format/clang-format-diff.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index ea483f59e96b4..ecad0155d9bef 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -58,6 +58,11 @@ def main():
   parser.add_argument('-style',
   help='formatting style to apply (LLVM, GNU, Google, 
Chromium, '
   'Microsoft, Mozilla, WebKit)')
+  parser.add_argument('-fallback-style',
+  help='The name of the predefined style used as a'
+  'fallback in case clang-format is invoked with'
+  '-style=file, but can not find the .clang-format'
+  'file to use.')
   parser.add_argument('-binary', default='clang-format',
   help='location of binary to use for clang-format')
   args = parser.parse_args()
@@ -103,6 +108,8 @@ def main():
 command.extend(lines)
 if args.style:
   command.extend(['-style', args.style])
+if args.fallback_style:
+  command.extend(['-fallback-style', args.fallback_style])
 
 try:
   p = subprocess.Popen(command,



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


[clang] 6103fdf - [ifs][elfabi] Merge llvm-ifs/elfabi tools

2021-07-19 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-07-19T11:23:19-07:00
New Revision: 6103fdfab4e2c051c070e2994db8b696fc440048

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

LOG: [ifs][elfabi] Merge llvm-ifs/elfabi tools

This change merges llvm-elfabi and llvm-ifs tools.

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

Added: 
llvm/tools/llvm-ifs/ErrorCollector.cpp
llvm/tools/llvm-ifs/ErrorCollector.h

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/InterfaceStubs.cpp
clang/test/InterfaceStubs/driver-test.c
llvm/include/llvm/InterfaceStub/ELFObjHandler.h
llvm/include/llvm/InterfaceStub/IFSHandler.h
llvm/include/llvm/InterfaceStub/IFSStub.h
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/InterfaceStub/IFSHandler.cpp
llvm/lib/InterfaceStub/IFSStub.cpp
llvm/test/CMakeLists.txt
llvm/test/tools/llvm-ifs/binary-read-add-soname.test
llvm/test/tools/llvm-ifs/binary-read-arch.test
llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
llvm/test/tools/llvm-ifs/binary-read-soname.test
llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
llvm/test/tools/llvm-ifs/conflict-header-version.ifs
llvm/test/tools/llvm-ifs/conflict-size.ifs
llvm/test/tools/llvm-ifs/conflict-type.ifs
llvm/test/tools/llvm-ifs/conflict-weak.ifs
llvm/test/tools/llvm-ifs/default-empty.ifs
llvm/test/tools/llvm-ifs/empty1.ifs
llvm/test/tools/llvm-ifs/empty2.ifs
llvm/test/tools/llvm-ifs/fail-file-open.test
llvm/test/tools/llvm-ifs/fail-file-write-windows.test
llvm/test/tools/llvm-ifs/fail-file-write.test
llvm/test/tools/llvm-ifs/func.ifs
llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
llvm/test/tools/llvm-ifs/ifs-read-basic.test
llvm/test/tools/llvm-ifs/ios-tbd.ifs
llvm/test/tools/llvm-ifs/macos-tbd.ifs
llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
llvm/test/tools/llvm-ifs/object.ifs
llvm/test/tools/llvm-ifs/output-target-error.test
llvm/test/tools/llvm-ifs/preserve-dates-ifs.test
llvm/test/tools/llvm-ifs/preserve-dates-stub.test
llvm/test/tools/llvm-ifs/read-elf-dynsym.test
llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
llvm/test/tools/llvm-ifs/read-unsupported-file.test
llvm/test/tools/llvm-ifs/strip-target.test
llvm/test/tools/llvm-ifs/strong.ifs
llvm/test/tools/llvm-ifs/tvos-tbd.ifs
llvm/test/tools/llvm-ifs/version-ok.ifs
llvm/test/tools/llvm-ifs/watchos-tbd.ifs
llvm/test/tools/llvm-ifs/weak-mismatch.ifs
llvm/test/tools/llvm-ifs/weak.ifs
llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
llvm/test/tools/llvm-ifs/write-stub.test
llvm/tools/llvm-ifs/CMakeLists.txt
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 
llvm/tools/llvm-elfabi/CMakeLists.txt
llvm/tools/llvm-elfabi/ErrorCollector.cpp
llvm/tools/llvm-elfabi/ErrorCollector.h
llvm/tools/llvm-elfabi/llvm-elfabi.cpp
llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn



diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index c031465002cca..aa45c1549340b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -246,7 +246,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
-  llvm-elfabi
+  llvm-ifs
   llvm-gsymutil
   llvm-lib
   llvm-lipo

diff  --git a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp 
b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
index 57acf338df5c4..05a13db8d0cff 100644
--- a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
+++ b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
@@ -20,10 +20,11 @@ void Merger::ConstructJob(Compilation &C, const JobAction 
&JA,
   const llvm::opt::ArgList &Args,
   const char *LinkingOutput) const {
   std::string Merger = getToolChain().GetProgramPa

[clang] 0ce58c5 - [Fuchsia][CMake] Add missing include path.

2021-05-26 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2021-05-26T19:59:53-07:00
New Revision: 0ce58c52d50bd2edd09df7c7ef3dd4dc85b05992

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

LOG: [Fuchsia][CMake] Add missing include path.

This patch adds include path for missing header files from "sync".
This patch also fixes the build failures caused by scudo.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 2cc25ba1fda8..db1631f7f143 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -145,7 +145,7 @@ if(FUCHSIA_SDK)
   set(FUCHSIA_x86_64-unknown-fuchsia_NAME x64)
   set(FUCHSIA_riscv64-unknown-fuchsia_NAME riscv64)
   foreach(target 
i386-unknown-fuchsia;x86_64-unknown-fuchsia;aarch64-unknown-fuchsia;riscv64-unknown-fuchsia)
-set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target} 
-I${FUCHSIA_SDK}/pkg/fdio/include")
+set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target} 
-I${FUCHSIA_SDK}/pkg/sync/include -I${FUCHSIA_SDK}/pkg/fdio/include")
 set(FUCHSIA_${target}_LINKER_FLAGS 
"-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib")
 set(FUCHSIA_${target}_SYSROOT 
"${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot")
   endforeach()



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


[clang] 2407eb0 - [analyzer] Update static analyzer to be support sarif-html

2021-02-10 Thread Haowei Wu via cfe-commits

Author: Daniel Hwang
Date: 2021-02-10T18:34:53-08:00
New Revision: 2407eb08a5748bc2613e95fa449fc1cae6f4ff8f

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

LOG: [analyzer] Update static analyzer to be support sarif-html

Updates static analyzer to be able to generate both sarif and html
output in a single run similar to plist-html.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/StaticAnalyzer/Core/Analyses.def
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e767d4238f0f..e2a955ea0243 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3667,7 +3667,7 @@ def _CLASSPATH : Separate<["--"], "CLASSPATH">, 
Alias;
 def _all_warnings : Flag<["--"], "all-warnings">, Alias;
 def _analyzer_no_default_checks : Flag<["--"], "analyzer-no-default-checks">, 
Flags<[NoXarchOption]>;
 def _analyzer_output : JoinedOrSeparate<["--"], "analyzer-output">, 
Flags<[NoXarchOption]>,
-  HelpText<"Static analyzer report output format 
(html|plist|plist-multi-file|plist-html|sarif|text).">;
+  HelpText<"Static analyzer report output format 
(html|plist|plist-multi-file|plist-html|sarif|sarif-html|text).">;
 def _analyze : Flag<["--"], "analyze">, Flags<[NoXarchOption, CoreOption]>,
   HelpText<"Run the static analyzer">;
 def _assemble : Flag<["--"], "assemble">, Alias;

diff  --git a/clang/include/clang/StaticAnalyzer/Core/Analyses.def 
b/clang/include/clang/StaticAnalyzer/Core/Analyses.def
index c4e5f5be6fd7..88c375ce0925 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Analyses.def
+++ b/clang/include/clang/StaticAnalyzer/Core/Analyses.def
@@ -52,9 +52,14 @@ ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html",
  "Output analysis results using HTML wrapped with Plists",
  createPlistHTMLDiagnosticConsumer)
 
-ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file",
+ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results using SARIF",
  createSarifDiagnosticConsumer)
 
+ANALYSIS_DIAGNOSTICS(SARIF_HTML, "sarif-html",
+ "Output analysis results using both SARIF and HTML "
+ "output files",
+ createSarifHTMLDiagnosticConsumer)
+
 ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr",
  createTextPathDiagnosticConsumer)
 

diff  --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 149459cf986a..46e533d9680e 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -176,6 +176,16 @@ void ento::createPlistHTMLDiagnosticConsumer(
   CTU);
 }
 
+void ento::createSarifHTMLDiagnosticConsumer(
+  PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers &C,
+const std::string &sarif_file, const Preprocessor &PP,
+const cross_tu::CrossTranslationUnitContext &CTU) {
+  createHTMLDiagnosticConsumer(DiagOpts, C, 
std::string(llvm::sys::path::parent_path(sarif_file)), PP, CTU);
+  createSarifDiagnosticConsumer(DiagOpts, C, sarif_file, PP, CTU);
+  createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, sarif_file, 
PP,
+  CTU);
+}
+
 
//===--===//
 // Report processing.
 
//===--===//



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


[clang] d72859f - [scan-build-py] Update scan-build-py to allow outputing as SARIF

2021-02-07 Thread Haowei Wu via cfe-commits

Author: Daniel Hwang
Date: 2021-02-07T18:25:50-08:00
New Revision: d72859ffa237bbb82c1ef7302f2d99534183f8ca

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

LOG: [scan-build-py] Update scan-build-py to allow outputing as SARIF

clang static analysis reports can be generated in html, plist, or sarif
format. This updates scan-build-py to be able to specify SARIF as the
desired output format, as previously it only support plist and html
formats.

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

Added: 


Modified: 
clang/tools/scan-build-py/libscanbuild/analyze.py
clang/tools/scan-build-py/libscanbuild/arguments.py
clang/tools/scan-build-py/libscanbuild/report.py
clang/tools/scan-build-py/tests/unit/test_analyze.py
clang/tools/scan-build-py/tests/unit/test_report.py

Removed: 




diff  --git a/clang/tools/scan-build-py/libscanbuild/analyze.py 
b/clang/tools/scan-build-py/libscanbuild/analyze.py
index a4bb499f86c9..dbe08be9b24a 100644
--- a/clang/tools/scan-build-py/libscanbuild/analyze.py
+++ b/clang/tools/scan-build-py/libscanbuild/analyze.py
@@ -52,7 +52,8 @@ def scan_build():
 
 args = parse_args_for_scan_build()
 # will re-assign the report directory as new output
-with report_directory(args.output, args.keep_empty) as args.output:
+with report_directory(
+args.output, args.keep_empty, args.output_format) as args.output:
 # Run against a build command. there are cases, when analyzer run
 # is not required. But we need to set up everything for the
 # wrappers, because 'configure' needs to capture the CC/CXX values
@@ -79,7 +80,7 @@ def analyze_build():
 
 args = parse_args_for_analyze_build()
 # will re-assign the report directory as new output
-with report_directory(args.output, args.keep_empty) as args.output:
+with report_directory(args.output, args.keep_empty, args.output_format) as 
args.output:
 # Run the analyzer against a compilation db.
 govern_analyzer_runs(args)
 # Cover report generation and bug counting.
@@ -336,7 +337,7 @@ def analyze_compiler_wrapper_impl(result, execution):
 
 
 @contextlib.contextmanager
-def report_directory(hint, keep):
+def report_directory(hint, keep, output_format):
 """ Responsible for the report directory.
 
 hint -- could specify the parent directory of the output directory.
@@ -355,7 +356,11 @@ def report_directory(hint, keep):
 yield name
 finally:
 if os.listdir(name):
-msg = "Run 'scan-view %s' to examine bug reports."
+if output_format != 'sarif':
+# 'scan-view' currently does not support sarif format.
+msg = "Run 'scan-view %s' to examine bug reports."
+else:
+msg = "View result at %s/results-merged.sarif."
 keep = True
 else:
 if keep:
@@ -433,7 +438,7 @@ def wrapper(*args, **kwargs):
   'direct_args',  # arguments from command line
   'force_debug',  # kill non debug macros
   'output_dir',  # where generated report files shall go
-  'output_format',  # it's 'plist', 'html', both or plist-multi-file
+  'output_format',  # it's 'plist', 'html', 'plist-html', 
'plist-multi-file', or 'sarif'
   'output_failures',  # generate crash reports or not
   'ctu'])  # ctu control options
 def run(opts):
@@ -537,6 +542,12 @@ def target():
   dir=opts['output_dir'])
 os.close(handle)
 return name
+elif opts['output_format'] == 'sarif':
+(handle, name) = tempfile.mkstemp(prefix='result-',
+  suffix='.sarif',
+  dir=opts['output_dir'])
+os.close(handle)
+return name
 return opts['output_dir']
 
 try:

diff  --git a/clang/tools/scan-build-py/libscanbuild/arguments.py 
b/clang/tools/scan-build-py/libscanbuild/arguments.py
index e258a4100331..e1d654b331cb 100644
--- a/clang/tools/scan-build-py/libscanbuild/arguments.py
+++ b/clang/tools/scan-build-py/libscanbuild/arguments.py
@@ -244,6 +244,14 @@ def create_analyze_parser(from_build_command):
 action='store_const',
 help="""Cause the results as a set of .plist files with extra
 information on related files.""")
+format_group.add_argument(
+'--sarif',
+'-sarif',
+dest='output_format',
+const='sarif',
+default='html',
+action='store_const',
+help="""Cause the results as a result.sarif file.""")
 
 advanced = parser.add_argument_group('advanced options')
 advanced.add_argument(

diff  --git 

[clang] 8deaec1 - [analyzer] Update Fuchsia checker to catch releasing unowned handles.

2021-01-06 Thread Haowei Wu via cfe-commits

Author: Daniel Hwang
Date: 2021-01-06T16:23:49-08:00
New Revision: 8deaec122ec68746c53ec2afb893873124053d8d

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

LOG: [analyzer] Update Fuchsia checker to catch releasing unowned handles.

Certain Fuchsia functions may return handles that are not owned by the
current closure. This adds a check in order to determine when these
handles are released.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/test/Analysis/fuchsia_handle.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
index c246a8db3067..e3f4be0726c8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -20,29 +20,39 @@
 // Art:
 //
 //
-//  +-+-v-+ ++
-//   acquire_func succeeded | | Escape  ||
-//+->  Allocated  +->  Escaped   <--+
-//| | | ||  |
-//| +-+--++ ++  |
-//|   |  |  |
-//| release_func  |  +--+   |
-//|   | | handle  ++|
-//|   | | dies|||
-//|  +v-+   +-> Leaked ||
-//|  |  | |(REPORT)||
-// +--+--+   | Released | Escape  ++|
-// | |   |  +---+
-// | Not tracked <--+++---+-+
-// | |  | |   |As argument by value
-// +--+--+  |release_func |   +--+ in function call
-//| | |  | or by reference in
-//| | |  | use_func call
-//+-++v-+| +---+
-//acquire_func failed| Double   |+-> Use after |
-//   | released |  | released  |
-//   | (REPORT) |  | (REPORT)  |
-//   +--+  +---+
+// +-+ ++
+//  acquire_func succeeded | | Escape  ||
+//   +->  Allocated  +->  Escaped   <--+
+//   | | | ||  |
+//   | +-+--++ ++  |
+//   |   |  |  |
+// acquire_func  | release_func  |  +--+   |
+//failed |   | | handle  ++|
+// +-+   |   | | dies|||
+// | |   |  +v-+   +-> Leaked ||
+// | |   |  |  | |(REPORT)||
+// |  +--+--+   | Released | Escape  ++|
+// |  | |   |  +---+
+// +--> Not tracked |   ++---+-+
+//| ||   |As argument by value
+//+--+--+   release_func |   +--+ in function call
+//   |   |  | or by reference in
+//   |   |  | use_func call
+//unowned|  +v-+| +---+
+//  acquire_func |  | Double   |+-> Use after |
+//   succeeded   |  | released |  | released  |
+//   |  | (REPORT) |  | (REPORT)  |
+//+---+ +--+  +---+
+//| Allocated |
+//| Unowned   |  release_func
+//|   +-+
+//+---+ |
+//  |
+//+-v--+
+//| Release of |
+//| unowned handle |
+//| (REPORT)   |
+//++
 //
 // acquire_func represents the 

[clang] 7c0e3a7 - [clang][IR] Add support for leaf attribute

2020-12-14 Thread Haowei Wu via cfe-commits

Author: Gulfem Savrun Yeniceri
Date: 2020-12-14T14:48:17-08:00
New Revision: 7c0e3a77bc43a9c4d05f68ffd4e84d0f75efbd91

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

LOG: [clang][IR] Add support for leaf attribute

This patch adds support for leaf attribute as an optimization hint
in Clang/LLVM.

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

Added: 
clang/test/CodeGen/attr-leaf.c
clang/test/Sema/attr-leaf.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Bitcode/attributes.ll

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 79902c8f5b89..61eb86ac81a1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1448,6 +1448,13 @@ def LayoutVersion : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [LayoutVersionDocs];
 }
 
+def Leaf : InheritableAttr {
+  let Spellings = [GCC<"leaf">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [LeafDocs];
+  let SimpleHandler = 1;
+}
+
 def LifetimeBound : DeclOrTypeAttr {
   let Spellings = [Clang<"lifetimebound", 0>];
   let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 28f35cf2c0c7..e70596b5ac28 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3976,6 +3976,22 @@ are used to instantiate the specialization.
   }];
 }
 
+def LeafDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+
+The ``leaf`` attribute is used as a compiler hint to improve dataflow analysis
+in library functions. Functions marked with the ``leaf`` attribute are not 
allowed
+to jump back into the caller's translation unit, whether through invoking a
+callback function, an external function call, use of ``longjmp``, or other 
means.
+Therefore, they cannot use or modify any data that does not escape the caller 
function's
+compilation unit.
+
+For more information see
+`gcc documentation 
`
+}];
+}
+
 def NoStackProtectorDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 5db34b693bf3..73194be922dd 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1989,6 +1989,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute("no_caller_saved_registers");
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
 
 HasOptnone = TargetDecl->hasAttr();
 if (auto *AllocSize = TargetDecl->getAttr()) {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 15094854300d..395d0ef57945 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7715,6 +7715,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
   case ParsedAttr::AT_AnyX86NoCfCheck:
 handleNoCfCheckAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_Leaf:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_NoThrow:
 if (!AL.isUsedAsTypeAttr())
   handleSimpleAttribute(S, D, AL);

diff  --git a/clang/test/CodeGen/attr-leaf.c b/clang/test/CodeGen/attr-leaf.c
new file mode 100644
index ..2b2bacf5e725
--- /dev/null
+++ b/clang/test/CodeGen/attr-leaf.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -Oz -o - %s | FileCheck 
%s
+
+// CHECK: define void @f() local_unnamed_addr [[ATTRS:#[0-9]+]] {
+void f() __attribute__((leaf));
+
+void f()
+{
+}
+
+// CHECK: attributes [[ATTRS]] = { {{.*}}nocallback{{.*}} }

diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 0ba6769a1a8a..cb1e48217a81 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -68,6 +

[clang] 3ce78f5 - [analyzer] Ignore annotations if func is inlined.

2020-12-07 Thread Haowei Wu via cfe-commits

Author: Yu Shan
Date: 2020-12-07T11:28:11-08:00
New Revision: 3ce78f54edcfc881377a9e567715caf2f0be2abc

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

LOG: [analyzer] Ignore annotations if func is inlined.

When we annotating a function header so that it could be used by other
TU, we also need to make sure the function is parsed correctly within
the same TU. So if we can find the function's implementation,
ignore the annotations, otherwise, false positive would occur.
Move the escape by value case to post call and do not escape the handle
if the function is inlined and we have analyzed the handle.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/test/Analysis/fuchsia_handle.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
index d4901eb0abbb..c246a8db3067 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -331,11 +331,6 @@ void FuchsiaHandleChecker::checkPreCall(const CallEvent 
&Call,
   return;
 }
   }
-  if (!hasFuchsiaAttr(PVD) &&
-  PVD->getType()->isIntegerType()) {
-// Working around integer by-value escapes.
-State = State->set(Handle, HandleState::getEscaped());
-  }
 }
   }
   C.addTransition(State);
@@ -347,6 +342,10 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
   if (!FuncDecl)
 return;
 
+  // If we analyzed the function body, then ignore the annotations.
+  if (C.wasInlined)
+return;
+
   ProgramStateRef State = C.getState();
 
   std::vector> Notes;
@@ -417,6 +416,14 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent 
&Call,
 });
 State = State->set(
 Handle, HandleState::getMaybeAllocated(ResultSymbol));
+  } else if (!hasFuchsiaAttr(PVD) &&
+ PVD->getType()->isIntegerType()) {
+// Working around integer by-value escapes.
+// The by-value escape would not be captured in checkPointerEscape.
+// If the function was not analyzed (otherwise wasInlined should be
+// true) and there is no annotation on the handle, we assume the handle
+// is escaped.
+State = State->set(Handle, HandleState::getEscaped());
   }
 }
   }

diff  --git a/clang/test/Analysis/fuchsia_handle.cpp 
b/clang/test/Analysis/fuchsia_handle.cpp
index 911ab7adaaa9..99f0449a4902 100644
--- a/clang/test/Analysis/fuchsia_handle.cpp
+++ b/clang/test/Analysis/fuchsia_handle.cpp
@@ -315,6 +315,45 @@ void checkHandlePtrInStructureLeak() {
   // expected-note@-1 {{Potential leak of handle}}
 }
 
+// Assume this function's declaration that has the release annotation is in one
+// header file while its implementation is in another file. We have to annotate
+// the declaration because it might be used outside the TU.
+// We also want to make sure it is okay to call the function within the same 
TU.
+zx_status_t test_release_handle(zx_handle_t handle ZX_HANDLE_RELEASE) {
+  return zx_handle_close(handle);
+}
+
+void checkReleaseImplementedFunc() {
+  zx_handle_t a, b;
+  zx_channel_create(0, &a, &b);
+  zx_handle_close(a);
+  test_release_handle(b);
+}
+
+void use_handle(zx_handle_t handle) {
+  // Do nothing.
+}
+
+void test_call_by_value() {
+  zx_handle_t a, b;
+  zx_channel_create(0, &a, &b);
+  zx_handle_close(a);
+  use_handle(b);
+  zx_handle_close(b);
+}
+
+void test_call_by_value_leak() {
+  zx_handle_t a, b;
+  zx_channel_create(0, &a, &b); // expected-note {{Handle allocated through 
3rd parameter}}
+  zx_handle_close(a);
+  // Here we are passing handle b as integer value to a function that could be
+  // analyzed by the analyzer, thus the handle should not be considered 
escaped.
+  // After the function 'use_handle', handle b is still tracked and should be
+  // reported leaked.
+  use_handle(b);
+} // expected-warning {{Potential leak of handle}}
+// expected-note@-1 {{Potential leak of handle}}
+
 // RAII
 
 template 



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


[clang] 914f6c4 - [StaticAnalyzer] Support struct annotations in FuchsiaHandleChecker

2020-11-21 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2020-11-21T19:59:51-08:00
New Revision: 914f6c4ff8a42d384cad0bbb07de4dd1a96c78d4

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

LOG: [StaticAnalyzer] Support struct annotations in FuchsiaHandleChecker

Support adding handle annotations to sturucture that contains
handles. All the handles referenced by the structure (direct
value or ptr) would be treated as containing the
release/use/acquire annotations directly.

Patch by Yu Shan

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/test/Analysis/fuchsia_handle.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
index b2822e5307f3..d4901eb0abbb 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -53,7 +53,7 @@
 //
 // Note that, the analyzer does not always know for sure if a function failed
 // or succeeded. In those cases we use the state MaybeAllocated.
-// Thus, the diagramm above captures the intent, not implementation details.
+// Thus, the diagram above captures the intent, not implementation details.
 //
 // Due to the fact that the number of handle related syscalls in Fuchsia
 // is large, we adopt the annotation attributes to descript syscalls'
@@ -226,32 +226,70 @@ static const ExplodedNode *getAcquireSite(const 
ExplodedNode *N, SymbolRef Sym,
   return nullptr;
 }
 
-/// Returns the symbols extracted from the argument or null if it cannot be
-/// found.
-static SymbolRef getFuchsiaHandleSymbol(QualType QT, SVal Arg,
-ProgramStateRef State) {
+namespace {
+class FuchsiaHandleSymbolVisitor final : public SymbolVisitor {
+public:
+  FuchsiaHandleSymbolVisitor(ProgramStateRef State) : State(std::move(State)) 
{}
+  ProgramStateRef getState() const { return State; }
+
+  bool VisitSymbol(SymbolRef S) override {
+if (const auto *HandleType = S->getType()->getAs())
+  if (HandleType->getDecl()->getName() == HandleTypeName)
+Symbols.push_back(S);
+return true;
+  }
+
+  SmallVector GetSymbols() { return Symbols; }
+
+private:
+  SmallVector Symbols;
+  ProgramStateRef State;
+};
+} // end anonymous namespace
+
+/// Returns the symbols extracted from the argument or empty vector if it 
cannot
+/// be found. It is unlikely to have over 1024 symbols in one argument.
+static SmallVector
+getFuchsiaHandleSymbols(QualType QT, SVal Arg, ProgramStateRef State) {
   int PtrToHandleLevel = 0;
   while (QT->isAnyPointerType() || QT->isReferenceType()) {
 ++PtrToHandleLevel;
 QT = QT->getPointeeType();
   }
+  if (QT->isStructureType()) {
+// If we see a structure, see if there is any handle referenced by the
+// structure.
+FuchsiaHandleSymbolVisitor Visitor(State);
+State->scanReachableSymbols(Arg, Visitor);
+return Visitor.GetSymbols();
+  }
   if (const auto *HandleType = QT->getAs()) {
 if (HandleType->getDecl()->getName() != HandleTypeName)
-  return nullptr;
-if (PtrToHandleLevel > 1) {
+  return {};
+if (PtrToHandleLevel > 1)
   // Not supported yet.
-  return nullptr;
-}
+  return {};
 
 if (PtrToHandleLevel == 0) {
-  return Arg.getAsSymbol();
+  SymbolRef Sym = Arg.getAsSymbol();
+  if (Sym) {
+return {Sym};
+  } else {
+return {};
+  }
 } else {
   assert(PtrToHandleLevel == 1);
-  if (Optional ArgLoc = Arg.getAs())
-return State->getSVal(*ArgLoc).getAsSymbol();
+  if (Optional ArgLoc = Arg.getAs()) {
+SymbolRef Sym = State->getSVal(*ArgLoc).getAsSymbol();
+if (Sym) {
+  return {Sym};
+} else {
+  return {};
+}
+  }
 }
   }
-  return nullptr;
+  return {};
 }
 
 void FuchsiaHandleChecker::checkPreCall(const CallEvent &Call,
@@ -273,30 +311,31 @@ void FuchsiaHandleChecker::checkPreCall(const CallEvent 
&Call,
 if (Arg >= FuncDecl->getNumParams())
   break;
 const ParmVarDecl *PVD = FuncDecl->getParamDecl(Arg);
-SymbolRef Handle =
-getFuchsiaHandleSymbol(PVD->getType(), Call.getArgSVal(Arg), State);
-if (!Handle)
-  continue;
+SmallVector Handles =
+getFuchsiaHandleSymbols(PVD->getType(), Call.getArgSVal(Arg), State);
 
 // Handled in checkPostCall.
 if (hasFuchsiaAttr(PVD) ||
 hasFuchsiaAttr(PVD))
   continue;
 
-const HandleState *HState = State->get(Handle);
-if (!HState || HState->isEscaped())
-  continue;
+for (SymbolRef Handle : Handles) {
+  const HandleState *HState = State->get(Handle);
+  

[clang] d93287c - [scan-build] Supprot relative 'file' in cdb.

2020-11-09 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2020-11-09T20:06:20-08:00
New Revision: d93287cac89fd50a105ac4a59c079884b8e53e49

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

LOG: [scan-build] Supprot relative 'file' in cdb.

Excluded folders in scan build is turned to absolute path before
comapre to 'file' in cdb. 'file' in cdb might be a path relative
to 'directory', so we need to turn it to absolute path before
comparison.

Patch by Yu Shan

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

Added: 


Modified: 
clang/tools/scan-build-py/libscanbuild/analyze.py

Removed: 




diff  --git a/clang/tools/scan-build-py/libscanbuild/analyze.py 
b/clang/tools/scan-build-py/libscanbuild/analyze.py
index ffdf7f7c7d61..a4bb499f86c9 100644
--- a/clang/tools/scan-build-py/libscanbuild/analyze.py
+++ b/clang/tools/scan-build-py/libscanbuild/analyze.py
@@ -207,10 +207,14 @@ def write_global_map(arch, mangled_ast_pairs):
 def run_analyzer_parallel(args):
 """ Runs the analyzer against the given compilation database. """
 
-def exclude(filename):
+def exclude(filename, directory):
 """ Return true when any excluded directory prefix the filename. """
-return any(re.match(r'^' + directory, filename)
-   for directory in args.excludes)
+if not os.path.isabs(filename):
+# filename is either absolute or relative to directory. Need to 
turn
+# it to absolute since 'args.excludes' are absolute paths.
+filename = os.path.normpath(os.path.join(directory, filename))
+return any(re.match(r'^' + exclude_directory, filename)
+   for exclude_directory in args.excludes)
 
 consts = {
 'clang': args.clang,
@@ -225,7 +229,8 @@ def exclude(filename):
 logging.debug('run analyzer against compilation database')
 with open(args.cdb, 'r') as handle:
 generator = (dict(cmd, **consts)
- for cmd in json.load(handle) if not exclude(cmd['file']))
+ for cmd in json.load(handle) if not exclude(
+cmd['file'], cmd['directory']))
 # when verbose output requested execute sequentially
 pool = multiprocessing.Pool(1 if args.verbose > 2 else None)
 for current in pool.imap_unordered(run, generator):



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