[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-08-31 Thread Vassil Vassilev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG319ce9801174: [clang-repl] Re-implement clang-interpreter as 
a test case. (authored by v.g.vassilev).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D107049?vs=369729=369845#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107049

Files:
  clang/docs/ClangFormattedStatus.rst
  clang/examples/CMakeLists.txt
  clang/examples/clang-interpreter/CMakeLists.txt
  clang/examples/clang-interpreter/README.txt
  clang/examples/clang-interpreter/Test.cxx
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Misc/interpreter.c
  clang/test/lit.cfg.py
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,8 +17,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 
-#include "llvm/ADT/ArrayRef.h"
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -0,0 +1,121 @@
+//===- unittests/Interpreter/InterpreterExceptionTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for Clang's Interpreter library.
+//
+//===--===//
+
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/Support/TargetSelect.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace {
+using Args = std::vector;
+static std::unique_ptr
+createInterpreter(const Args  = {},
+  DiagnosticConsumer *Client = nullptr) {
+  Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
+  ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
+  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  if (Client)
+CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+// This function isn't referenced outside its translation unit, but it
+// can't use the "static" keyword because its address is used for
+// GetMainExecutable (since some platforms don't support taking the
+// address of main, and some platforms can't implement GetMainExecutable
+// without being given the address of a function in the main executable).
+std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
+  return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
+}
+
+static std::string MakeResourcesPath() {
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  void *MainAddr = (void *)(intptr_t)GetExecutablePath;
+  std::string BinaryPath = GetExecutablePath(/*Argv0=*/nullptr, MainAddr);
+
+  // build/tools/clang/unittests/Interpreter/Executable -> build/
+  llvm::StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  SmallString<128> P(Dir);
+  llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+  CLANG_VERSION_STRING);
+
+  return std::string(P.str());
+}
+
+TEST(InterpreterTest, CatchException) {
+  llvm::InitializeNativeTarget();
+  llvm::InitializeNativeTargetAsmPrinter();
+
+  {
+auto J = llvm::orc::LLJITBuilder().create();
+if (!J) {
+  // The platform does not support JITs.
+  // We can't use llvm::consumeError as it needs typeinfo for 

[clang] 319ce98 - [clang-repl] Re-implement clang-interpreter as a test case.

2021-08-31 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-09-01T05:23:21Z
New Revision: 319ce98011742141dad8dd95a2f9de9c0449be5c

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

LOG: [clang-repl] Re-implement clang-interpreter as a test case.

The current infrastructure in lib/Interpreter has a tool, clang-repl, very
similar to clang-interpreter which also allows incremental compilation.

This patch moves clang-interpreter as a test case and drops it as conditionally
built example as we already have clang-repl in place.

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

Added: 
clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Modified: 
clang/docs/ClangFormattedStatus.rst
clang/examples/CMakeLists.txt
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp
clang/test/CMakeLists.txt
clang/test/lit.cfg.py
clang/unittests/Interpreter/CMakeLists.txt
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 
clang/examples/clang-interpreter/CMakeLists.txt
clang/examples/clang-interpreter/README.txt
clang/examples/clang-interpreter/Test.cxx
clang/test/Misc/interpreter.c



diff  --git a/clang/docs/ClangFormattedStatus.rst 
b/clang/docs/ClangFormattedStatus.rst
index beca555ebc016..77320cd2b6550 100644
--- a/clang/docs/ClangFormattedStatus.rst
+++ b/clang/docs/ClangFormattedStatus.rst
@@ -59,11 +59,6 @@ tree in terms of conformance to :doc:`ClangFormat` as of: 
June 04, 2021 13:01:37
  - `1`
  - `0`
  - :good:`100%`
-   * - clang/examples/clang-interpreter
- - `1`
- - `0`
- - `1`
- - :none:`0%`
* - clang/examples/PrintFunctionNames
  - `1`
  - `0`

diff  --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt
index 300d8d795c674..8a4139f5d8c11 100644
--- a/clang/examples/CMakeLists.txt
+++ b/clang/examples/CMakeLists.txt
@@ -3,7 +3,6 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
 add_subdirectory(Attribute)

diff  --git a/clang/examples/clang-interpreter/CMakeLists.txt 
b/clang/examples/clang-interpreter/CMakeLists.txt
deleted file mode 100644
index 11056aa379ae8..0
--- a/clang/examples/clang-interpreter/CMakeLists.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-set(LLVM_LINK_COMPONENTS
-  Core
-  ExecutionEngine
-  MC
-  MCJIT
-  Object
-  OrcJit
-  Option
-  RuntimeDyld
-  Support
-  native
-  )
-
-add_clang_executable(clang-interpreter
-  main.cpp
-  )
-
-add_dependencies(clang-interpreter
-  clang-resource-headers
-  )
-
-clang_target_link_libraries(clang-interpreter
-  PRIVATE
-  clangBasic
-  clangCodeGen
-  clangDriver
-  clangFrontend
-  clangSerialization
-  )
-
-export_executable_symbols(clang-interpreter)
-
-if (MSVC)
-  # Is this a CMake bug that even with export_executable_symbols, Windows
-  # needs to explictly export the type_info vtable
-  set_property(TARGET clang-interpreter
-   APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:??_7type_info@@6B@")
-endif()
-
-function(clang_enable_exceptions TARGET)
-  # Really have to jump through hoops to enable exception handling independent
-  # of how LLVM is being built.
-  if (NOT LLVM_REQUIRES_EH AND NOT LLVM_REQUIRES_RTTI)
-if (MSVC)
-  # /EHs to allow throwing from extern "C"
-  set(excptnExceptions_ON "/D _HAS_EXCEPTIONS=1 /EHs /wd4714")
-  set(excptnExceptions_OFF "/D _HAS_EXCEPTIONS=0 /EHs-c-")
-  set(excptnRTTI_ON "/GR")
-  set(excptnRTTI_OFF "/GR-")
-  set(excptnEHRTTIRegEx "(/EHs(-c-?)|_HAS_EXCEPTIONS=(0|1))")
-else()
-  set(excptnExceptions_ON "-fexceptions")
-  set(excptnExceptions_OFF "-fno-exceptions")
-  set(excptnRTTI_ON "-frtti")
-  set(excptnRTTI_OFF "-fno-rtti")
-  set(excptnEHRTTIRegEx "-f(exceptions|no-exceptions)")
-endif()
-if (LLVM_REQUIRES_EH)
-  set(excptnExceptions_DFLT ${excptnExceptions_ON})
-else()
-  set(excptnExceptions_DFLT ${excptnExceptions_OFF})
-endif()
-if (LLVM_REQUIRES_RTTI)
-  set(excptnRTTI_DFLT ${excptnRTTI_ON})
-else()
-  set(excptnRTTI_DFLT ${excptnRTTI_OFF})
-endif()
-
-# Strip the exception & rtti flags from the target
-get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_FLAGS)
-string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
-string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
-set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS "${editedFlags}")
-
-get_property(addedFlags TARGET 

[PATCH] D108794: Fully qualify template template parameters when printing

2021-08-31 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

It looks like a strict improvement on printing and most callers using the 
default args won't need to be updated.

There's one more function call that should be updated:
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/DumpAST.cpp#L298

Fixing that and the comment and this should be good to go in.




Comment at: clang/include/clang/AST/TemplateName.h:318-320
   /// \param SuppressNNS if true, don't print the
   /// nested-name-specifier that precedes the template name (if it has
   /// one).

Update this comment to reflect the enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108794

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-08-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yes, that's right.  OVE allows us to logically place a single expression in 
multiple positions in the expression hierarchy.  This can be useful for either 
source or semantic fidelity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-08-31 Thread Jason Rice via Phabricator via cfe-commits
ricejasonf updated this revision to Diff 369828.
ricejasonf added a comment.

I think I found a simple solution that bypasses transforming the OVE. The 
ArrayInitLoop always has an OVE in it so I strip it along with it in 
TransformInitializer.

I looked around in CodeGen and might have a better understanding of the purpose 
of OVEs now. The same pointer to the OVE appears twice inside the AIL. CodeGen 
keeps a mapping of the result of the source expression to the OVE so it emits 
the same result both times it encounters the OVE. Does that sound right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/pr45964-decomp-transform.cpp


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* 
[[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], 
%[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 
[[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, 
i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr* OVE = cast(AIL->getCommonExpr());
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* [[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], %[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 [[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr* OVE = cast(AIL->getCommonExpr());
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99487: [CodeGen] Port basic block sections from ELF to COFF

2021-08-31 Thread TaoPan via Phabricator via cfe-commits
TaoPan added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99487

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


[PATCH] D109023: libclang: Document the soname change in the release notes

2021-08-31 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.

LGTM, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109023

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


[PATCH] D108905: [ItaniumCXXABI] Make __cxa_end_catch calls unconditionally nounwind

2021-08-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D108905#2975712 , @rsmith wrote:

> No decision as yet, but so far it looks very likely that we'll settle on the 
> rule that exceptions cannot have potentially-throwing destructors, and that 
> we should reject `throw`s of such types. I don't think that should be applied 
> retroactively to C++98, though, because destructors were not implicitly 
> non-throwing back then.

Is the committee comfortable with implementations causing potentially-throwing 
exception destructors to trigger `std::terminate`?  I understand that this is a 
weird question because it implies the use of / interoperation with an old 
language standard, but we do need to know how to compile in C++98 mode, and we 
may need to demote this to a warning pre-C++23.  If it's not an error in old 
modes, but the committee doesn't approve of calling `std::terminate` if it 
happens, then we still need to compile `catch (...)` as throwing in case we're 
interoperating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108905

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


[PATCH] D104386: [PowerPC][Builtins] Added a number of builtins for compatibility with XL.

2021-08-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Just encountered another similar error, apparently introduced in 
rGc8937b6cb9751807de1e69f0f0f70a9a58f8f5dc 
 (as more 
additions to the `defineXLCompatMacros` function, by @lei):

  In file included from /home/dim/src/llvm-13-update/lib/msun/powerpc/fenv.c:32:
  /home/dim/src/llvm-13-update/lib/msun/powerpc/fenv.h:114:9: error: '__mtfsf' 
macro redefined [-Werror,-Wmacro-redefined]
  #define __mtfsf(__env) \
  ^
  :375:9: note: previous definition is here
  #define __mtfsf __builtin_ppc_mtfsf
  ^
  1 error generated.

To unblock my builds, I'm just going to use `-U` to undef these macros manually 
for now...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104386

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


[PATCH] D108905: [ItaniumCXXABI] Make __cxa_end_catch calls unconditionally nounwind

2021-08-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

No decision as yet, but so far it looks very likely that we'll settle on the 
rule that exceptions cannot have potentially-throwing destructors, and that we 
should reject `throw`s of such types. I don't think that should be applied 
retroactively to C++98, though, because destructors were not implicitly 
non-throwing back then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108905

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


[PATCH] D109023: libclang: Document the soname change in the release notes

2021-08-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:311
 
-- ...
+- Make libclang SONAME independent from LLVM version. It will be updated only 
when
+  needed.

MaskRay wrote:
> While here, mention the exact CMake variable.
Also link to https://lists.llvm.org/pipermail/cfe-dev/2021-June/068423.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109023

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


[PATCH] D109023: libclang: Document the soname change in the release notes

2021-08-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/docs/ReleaseNotes.rst:311
 
-- ...
+- Make libclang SONAME independent from LLVM version. It will be updated only 
when
+  needed.

While here, mention the exact CMake variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109023

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


[PATCH] D108479: [Clang] Add __builtin_addressof_nocfi

2021-08-31 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added inline comments.



Comment at: clang/test/CodeGen/builtin-addressof-nocfi.c:18
+  // CHECK: call void @c(void ()* no_cfi @a)
+  c(__builtin_addressof_nocfi(a));
+  e();

nickdesaulniers wrote:
> do we ever need the builtin address of a global that's NOT a function?
> 
> If so, we should add a test for that. If not, perhaps we don't need to waste 
> space in every APValue?
> do we ever need the builtin address of a global that's NOT a function?

I don't think so. This version does accept any global because it was modelled 
after `__builtin_addressof()`, but we could look into limiting this only for 
functions. Perhaps the built-in name should also be changed in that case?

> If so, we should add a test for that. If not, perhaps we don't need to waste 
> space in every APValue?

What would be a better place for the flag? I think in Clang, changing this to 
support only functions would probably just need some additional Sema checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108479

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


[PATCH] D108479: [Clang] Add __builtin_addressof_nocfi

2021-08-31 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen updated this revision to Diff 369795.
samitolvanen marked 2 inline comments as done.
samitolvanen added a comment.

Fixed clang-tidy warnings, dropped an unnecessary auto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108479

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/APValue.h
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/CodeGen/builtin-addressof-nocfi.c
  clang/test/SemaCXX/builtins.cpp

Index: clang/test/SemaCXX/builtins.cpp
===
--- clang/test/SemaCXX/builtins.cpp
+++ clang/test/SemaCXX/builtins.cpp
@@ -39,6 +39,14 @@
   S *ptmp = __builtin_addressof(S{}); // expected-error {{taking the address of a temporary}}
 }
 
+namespace addressof_nocfi {
+  void a(void) {}
+  static_assert(__builtin_addressof_nocfi(a) == a, "");
+
+  struct S {} s;
+  static_assert(__builtin_addressof_nocfi(s) == , "");
+}
+
 void no_ms_builtins() {
   __assume(1); // expected-error {{use of undeclared}}
   __noop(1); // expected-error {{use of undeclared}}
Index: clang/test/CodeGen/builtin-addressof-nocfi.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-addressof-nocfi.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=cfi-icall -o - %s | FileCheck %s
+
+void a(void) {}
+void b(void) {}
+void c(void (*p)(void)) {
+  p();
+}
+
+// CHECK: @e = constant void ()* no_cfi @a
+void (*const e)(void) = __builtin_addressof_nocfi(a);
+// CHECK: @f = global [2 x void ()*] [void ()* @b, void ()* no_cfi @b]
+void (*f[])(void) = {b, __builtin_addressof_nocfi(b)};
+
+void d(void) {
+  // CHECK: store void ()* no_cfi @b, void ()** %g
+  void (*g)(void) = __builtin_addressof_nocfi(b);
+  // CHECK: call void @c(void ()* no_cfi @a)
+  c(__builtin_addressof_nocfi(a));
+  e();
+  f[1]();
+  g();
+}
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -66,7 +66,8 @@
   case Builtin::BI__builtin_expect:
   case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
-  case Builtin::BI__builtin_addressof: {
+  case Builtin::BI__builtin_addressof:
+  case Builtin::BI__builtin_addressof_nocfi: {
 // For __builtin_unpredictable, __builtin_expect,
 // __builtin_expect_with_probability and __builtin_assume_aligned,
 // just return the value of the subexpression.
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1749,6 +1749,7 @@
   return ExprError();
 break;
   case Builtin::BI__builtin_addressof:
+  case Builtin::BI__builtin_addressof_nocfi:
 if (SemaBuiltinAddressof(*this, TheCall))
   return ExprError();
 break;
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1887,8 +1887,12 @@
 if (D->hasAttr())
   return CGM.GetWeakRefReference(D).getPointer();
 
-if (auto FD = dyn_cast(D))
-  return CGM.GetAddrOfFunction(FD);
+if (const auto *FD = dyn_cast(D)) {
+  llvm::Constant *C = CGM.GetAddrOfFunction(FD);
+  if (base.isNoCFIValue())
+return llvm::NoCFIValue::get(cast(C));
+  return C;
+}
 
 if (auto VD = dyn_cast(D)) {
   // We can never refer to a variable with local storage.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -4375,6 +4375,9 @@
   }
   case Builtin::BI__builtin_addressof:
 return RValue::get(EmitLValue(E->getArg(0)).getPointer(*this));
+  case Builtin::BI__builtin_addressof_nocfi:
+return RValue::get(llvm::NoCFIValue::get(
+cast(EmitLValue(E->getArg(0)).getPointer(*this;
   case Builtin::BI__builtin_operator_new:
 return EmitBuiltinNewDeleteCall(
 E->getCallee()->getType()->castAs(), E, false);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -8980,6 +8980,11 @@
   switch (BuiltinOp) {
   case Builtin::BI__builtin_addressof:
 return evaluateLValue(E->getArg(0), Result);
+  case Builtin::BI__builtin_addressof_nocfi:

[PATCH] D102943: [modules] Use `HashBuilder` and `MD5` for the module hash.

2021-08-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 369794.
arames marked an inline comment as done.
arames added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102943

Files:
  clang/include/clang/Basic/ObjCRuntime.h
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/include/clang/Serialization/ModuleFileExtension.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/TestModuleFileExtension.cpp
  clang/lib/Frontend/TestModuleFileExtension.h
  clang/lib/Serialization/ModuleFileExtension.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Support/VersionTuple.h

Index: llvm/include/llvm/Support/VersionTuple.h
===
--- llvm/include/llvm/Support/VersionTuple.h
+++ llvm/include/llvm/Support/VersionTuple.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/HashBuilder.h"
 #include 
 #include 
 
@@ -164,6 +165,12 @@
 return llvm::hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build);
   }
 
+  template 
+  friend void addHash(HashBuilderImpl ,
+  const VersionTuple ) {
+HBuilder.add(VT.Major, VT.Minor, VT.Subminor, VT.Build);
+  }
+
   /// Retrieve a string representation of the version number.
   std::string getAsString() const;
 
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -860,9 +860,7 @@
 return {};
   };
 
-  llvm::hash_code hashExtension(llvm::hash_code Code) const override {
-return {};
-  }
+  void hashExtension(ExtensionHashBuilder ) const override {}
 
   std::unique_ptr
   createExtensionWriter(ASTWriter ) override {
Index: clang/lib/Serialization/ModuleFileExtension.cpp
===
--- clang/lib/Serialization/ModuleFileExtension.cpp
+++ clang/lib/Serialization/ModuleFileExtension.cpp
@@ -11,12 +11,10 @@
 
 char ModuleFileExtension::ID = 0;
 
-ModuleFileExtension::~ModuleFileExtension() { }
+ModuleFileExtension::~ModuleFileExtension() {}
 
-llvm::hash_code ModuleFileExtension::hashExtension(llvm::hash_code Code) const {
-  return Code;
-}
+void ModuleFileExtension::hashExtension(ExtensionHashBuilder ) const {}
 
-ModuleFileExtensionWriter::~ModuleFileExtensionWriter() { }
+ModuleFileExtensionWriter::~ModuleFileExtensionWriter() {}
 
-ModuleFileExtensionReader::~ModuleFileExtensionReader() { }
+ModuleFileExtensionReader::~ModuleFileExtensionReader() {}
Index: clang/lib/Frontend/TestModuleFileExtension.h
===
--- clang/lib/Frontend/TestModuleFileExtension.h
+++ clang/lib/Frontend/TestModuleFileExtension.h
@@ -55,7 +55,7 @@
 
   ModuleFileExtensionMetadata getExtensionMetadata() const override;
 
-  llvm::hash_code hashExtension(llvm::hash_code Code) const override;
+  void hashExtension(ExtensionHashBuilder ) const override;
 
   std::unique_ptr
   createExtensionWriter(ASTWriter ) override;
Index: clang/lib/Frontend/TestModuleFileExtension.cpp
===
--- clang/lib/Frontend/TestModuleFileExtension.cpp
+++ clang/lib/Frontend/TestModuleFileExtension.cpp
@@ -93,16 +93,14 @@
   return { BlockName, MajorVersion, MinorVersion, UserInfo };
 }
 
-llvm::hash_code TestModuleFileExtension::hashExtension(
-  llvm::hash_code Code) const {
+void TestModuleFileExtension::hashExtension(
+ExtensionHashBuilder ) const {
   if (Hashed) {
-Code = llvm::hash_combine(Code, BlockName);
-Code = llvm::hash_combine(Code, MajorVersion);
-Code = llvm::hash_combine(Code, MinorVersion);
-Code = llvm::hash_combine(Code, UserInfo);
+HBuilder.add(BlockName);
+HBuilder.add(MajorVersion);
+HBuilder.add(MinorVersion);
+HBuilder.add(UserInfo);
   }
-
-  return Code;
 }
 
 std::unique_ptr
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -78,6 +78,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/HashBuilder.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -4469,116 +4470,99 @@
 }
 
 std::string CompilerInvocation::getModuleHash() const {
+  // FIXME: Consider using SHA1 instead of MD5.
+  llvm::HashBuilder HBuilder;
+
   // Note: For QoI reasons, the things we use as a hash here should all be
   // dumped via the 

[PATCH] D102943: [modules] Use `HashBuilder` and `MD5` for the module hash.

2021-08-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames marked 2 inline comments as done.
arames added inline comments.



Comment at: clang/include/clang/Basic/ObjCRuntime.h:486
+  template 
+  friend void addHash(llvm::HashBuilderImpl ,
+  const ObjCRuntime ) {

dexonsmith wrote:
> arames wrote:
> > I have added these in the same line as existing `hash_value` functions. The 
> > idea being others may also need to hash those objects.
> > Let me know if you would rather move some/all of these locally in 
> > `CompilerInvocation.cpp`.
> Seems reasonable to me.
> 
> An option to consider (maybe in a separate commit?) would be to add:
> ```
> lang=c++
> class HashCodeHasher {
> public:
>   void update(ArrayRef Bytes) {
> llvm::hash_code BytesCode = llvm::hash_value(Bytes);
> Code = Code ? BytesCode : llvm::hash_combine(*Code, BytesCode);
>   }
>   Optional Code;
> };
> templatestd::enable_if_t::value, bool> = true>
> llvm::hash_code hash_value(const T ) {
>   HashBuilder Builder;
>   Builder.add(Value);
>   return *Builder.Code;
> }
> ```
> Then objects that support HashBuilder also support `llvm::hash_value` without 
> extra code...
I created https://reviews.llvm.org/D109024 for this.
If we decide to go for that mechanism, whichever PR lands first, I can update 
the other to use the new mechanism.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4473-4475
+  // FIXME: We want to use something cryptographically sound. This was
+  // initially using CityHash (via `llvm::hash_code`). We moved to `llvm::MD5`.
+  // Is thie appropriate ?

dexonsmith wrote:
> I'd simplify:
> ```
> lang=c++
> // FIXME: Consider using SHA1 instead of MD5.
> ```
Do you think we should switch to `SHA1` now ?
I picked MD5 at random amongst the available hashes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102943

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


[PATCH] D109023: libclang: Document the soname change in the release notes

2021-08-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added reviewers: MaskRay, tstellar.
sylvestre.ledru requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109023

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -308,7 +308,8 @@
 libclang
 
 
-- ...
+- Make libclang SONAME independent from LLVM version. It will be updated only 
when
+  needed.
 
 Static Analyzer
 ---


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -308,7 +308,8 @@
 libclang
 
 
-- ...
+- Make libclang SONAME independent from LLVM version. It will be updated only when
+  needed.
 
 Static Analyzer
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-08-31 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@ldionne update?


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

https://reviews.llvm.org/D107717

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


[PATCH] D108886: Add RISC-V sifive-s51 cpu

2021-08-31 Thread Alexander Pivovarov via Phabricator via cfe-commits
apivovarov updated this revision to Diff 369745.
apivovarov added a comment.

Add `sifive-s51` to test `target-invalid-cpu-note.c` error messages match string


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108886

Files:
  clang/test/Driver/riscv-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/lib/Target/RISCV/RISCV.td


Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -254,6 +254,11 @@
  FeatureStdExtA,
  FeatureStdExtC]>;
 
+def : ProcessorModel<"sifive-s51", RocketModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtC]>;
+
 def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit,
  FeatureStdExtM,
  FeatureStdExtA,
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- llvm/include/llvm/Support/RISCVTargetParser.def
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -20,6 +20,7 @@
 PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""})
 PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""})
 PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
+PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
 PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -196,7 +196,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-7-rv64, sifive-u54, sifive-u74
+// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-7-rv64, sifive-s51, sifive-u54, sifive-u74
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -204,4 +204,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-7-rv64, sifive-u54, sifive-u74, generic, rocket, sifive-7-series
+// TUNE-RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-7-rv64, sifive-s51, sifive-u54, sifive-u74, generic, rocket, 
sifive-7-series
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -45,6 +45,13 @@
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=sifive-7-series | 
FileCheck -check-prefix=MTUNE-SIFIVE7-SERIES-64 %s
 // MTUNE-SIFIVE7-SERIES-64: "-tune-cpu" "sifive-7-rv64"
 
+// mcpu with mabi option
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-s51 -mabi=lp64 | 
FileCheck -check-prefix=MCPU-ABI-SIFIVE-S51 %s
+// MCPU-ABI-SIFIVE-S51: "-nostdsysteminc" "-target-cpu" "sifive-s51"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+c" "-target-feature" "+64bit"
+// MCPU-ABI-SIFIVE-S51: "-target-abi" "lp64"
+
 // mcpu with default march
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck 
-check-prefix=MCPU-SIFIVE-U54 %s
 // MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54"


Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -254,6 +254,11 @@
  FeatureStdExtA,
  FeatureStdExtC]>;
 
+def : ProcessorModel<"sifive-s51", RocketModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtC]>;
+
 def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit,
  FeatureStdExtM,

[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-08-31 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: 
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp:101-105
+  // FIXME: Somehow when we build this test in release mode argc is not 0.
+  // printf("%d\n", argc);
+  // for (int I = 0; I < argc; ++I)
+  //   printf("arg[%d]='%s'\n", I, argv[I]);
+

rsmith wrote:
> Isn't this because you're passing no arguments to `main` when you call it 
> later in the test? You're not passing any arguments on line 123/124.
Ah, indeed. Thanks!



Comment at: 
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp:123-124
+  testing::internal::CaptureStdout();
+  auto Main = (int (*)(...))llvm::cantFail(Interp->getSymbolAddress("main"));
+  EXPECT_THROW(Main(), std::exception);
+  std::string CapturedStdOut = testing::internal::GetCapturedStdout();

rsmith wrote:
> I think this should probably be cast to `int(*)(int, const char**)` instead. 
> But the name `main` is special, and might not have its declared type, so 
> selecting a different function name would have less risk of weird behavior. 
> I'd also suggest you remove the parameters if you're not going to use them.
Fixed. The past intent was to keep it as close as possible to the original 
example.


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

https://reviews.llvm.org/D107049

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


[PATCH] D102943: [modules] Use `HashBuilder` and `MD5` for the module hash.

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

A couple of suggestions inline, but this basically LGTM.

@jansvoboda11 @Bigcheese : can you take a look as well and confirm this looks 
reasonable from your perspectives?




Comment at: clang/include/clang/Basic/ObjCRuntime.h:486
+  template 
+  friend void addHash(llvm::HashBuilderImpl ,
+  const ObjCRuntime ) {

arames wrote:
> I have added these in the same line as existing `hash_value` functions. The 
> idea being others may also need to hash those objects.
> Let me know if you would rather move some/all of these locally in 
> `CompilerInvocation.cpp`.
Seems reasonable to me.

An option to consider (maybe in a separate commit?) would be to add:
```
lang=c++
class HashCodeHasher {
public:
  void update(ArrayRef Bytes) {
llvm::hash_code BytesCode = llvm::hash_value(Bytes);
Code = Code ? BytesCode : llvm::hash_combine(*Code, BytesCode);
  }
  Optional Code;
};
template ::value, bool> = true>
llvm::hash_code hash_value(const T ) {
  HashBuilder Builder;
  Builder.add(Value);
  return *Builder.Code;
}
```
Then objects that support HashBuilder also support `llvm::hash_value` without 
extra code...



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4473-4475
+  // FIXME: We want to use something cryptographically sound. This was
+  // initially using CityHash (via `llvm::hash_code`). We moved to `llvm::MD5`.
+  // Is thie appropriate ?

I'd simplify:
```
lang=c++
// FIXME: Consider using SHA1 instead of MD5.
```



Comment at: llvm/include/llvm/Support/HashBuilder.h:167
   /// template 
-  /// void addHash(HashBuilder ,
+  /// void addHash(HashBuilderImpl ,
   ///  const UserDefinedStruct );

Please fix in a separate commit (no need for a review IMO).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102943

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


[PATCH] D108917: [PowerPC] Define __powerpc and __PPC macros

2021-08-31 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In D108917#2974490 , @cebowleratibm 
wrote:

> I'd like to see the rationale for adding these forms of the macros in the 
> review and also in the extended commit message.  These forms are being added 
> primarily because the AIX XL compiler documented and defined them.  The patch 
> itself looks fine.

If XL only defines this on AIX, so should Clang. They only go into this 
location if XL defines them on both Linux and AIX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108917

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


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-08-31 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 369729.
v.g.vassilev marked 3 inline comments as done.
v.g.vassilev added a comment.

Address comments.


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

https://reviews.llvm.org/D107049

Files:
  clang/docs/ClangFormattedStatus.rst
  clang/examples/CMakeLists.txt
  clang/examples/clang-interpreter/CMakeLists.txt
  clang/examples/clang-interpreter/README.txt
  clang/examples/clang-interpreter/Test.cxx
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Misc/interpreter.c
  clang/test/lit.cfg.py
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,8 +17,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 
-#include "llvm/ADT/ArrayRef.h"
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -0,0 +1,121 @@
+//===- unittests/Interpreter/InterpreterExceptionTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for Clang's Interpreter library.
+//
+//===--===//
+
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/Support/TargetSelect.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace {
+using Args = std::vector;
+static std::unique_ptr
+createInterpreter(const Args  = {},
+  DiagnosticConsumer *Client = nullptr) {
+  Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
+  ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
+  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  if (Client)
+CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+// This function isn't referenced outside its translation unit, but it
+// can't use the "static" keyword because its address is used for
+// GetMainExecutable (since some platforms don't support taking the
+// address of main, and some platforms can't implement GetMainExecutable
+// without being given the address of a function in the main executable).
+std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
+  return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
+}
+
+static std::string MakeResourcesPath() {
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  void *MainAddr = (void *)(intptr_t)GetExecutablePath;
+  std::string BinaryPath = GetExecutablePath(/*Argv0=*/nullptr, MainAddr);
+
+  // build/tools/clang/unittests/Interpreter/Executable -> build/
+  llvm::StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  Dir = llvm::sys::path::parent_path(Dir);
+  SmallString<128> P(Dir);
+  llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+  CLANG_VERSION_STRING);
+
+  return std::string(P.str());
+}
+
+TEST(InterpreterTest, CatchException) {
+  llvm::InitializeNativeTarget();
+  llvm::InitializeNativeTargetAsmPrinter();
+
+  {
+auto J = llvm::orc::LLJITBuilder().create();
+if (!J) {
+  // The platform does not support JITs.
+  // We can't use llvm::consumeError as it needs typeinfo for ErrorInfoBase.
+  auto E = J.takeError();
+  (void)E;
+  return;
+}
+  }
+  const char ExceptionCode[] =
+  R"(
+#include 
+#include 
+
+static void ThrowerAnError(const char* Name) {
+  throw std::runtime_error(Name);
+}
+
+extern "C" 

[PATCH] D108291: [clang-nvlink-wrapper] Wrapper around nvlink for archive files

2021-08-31 Thread Ye Luo via Phabricator via cfe-commits
ye-luo accepted this revision.
ye-luo added a comment.
This revision is now accepted and ready to land.

Documentation is much improved. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108291

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


[PATCH] D109003: Ensure field-annotations on pointers properly match the AS of the field.

2021-08-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: Tyker, aaron.ballman.
Herald added subscribers: Naghasan, Anastasia.
erichkeane requested review of this revision.

Discovered in SYCL, the field annotations were always cast to an i8*,
which is an invalid bitcast for a pointer type with an address space.
This patch makes sure that we create an intrinsic that takes a pointer
to the correct address-space and properly do our casts.


Repository:
  rC Clang

https://reviews.llvm.org/D109003

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenSYCL/field-annotate-addr-space.cpp


Index: clang/test/CodeGenSYCL/field-annotate-addr-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/field-annotate-addr-space.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes 
-emit-llvm %s -o - | FileCheck %s
+
+// CHECK: [[ANNOT:.+]] = private unnamed_addr constant 
{{.*}}c"my_annotation\00"
+
+struct HasField {
+  // This caused an assertion on creating a bitcast here,
+  // since the address space didn't match.
+  [[clang::annotate("my_annotation")]]
+  int *a;
+};
+
+void foo(int *b) {
+  struct HasField f;
+  // CHECK: %[[A:.+]] = getelementptr inbounds %struct.HasField, 
%struct.HasField addrspace(4)* %{{.+}}
+  // CHECK: %[[BITCAST:.+]] = bitcast i32 addrspace(4)* addrspace(4)* %[[A]] 
to i8 addrspace(4)*
+  // CHECK: %[[CALL:.+]] = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 
addrspace(4)* %[[BITCAST]], i8* getelementptr inbounds ([14 x i8], [14 x i8]* 
[[ANNOT]]
+  // CHECK: bitcast i8 addrspace(4)* %[[CALL]] to i32 addrspace(4)* 
addrspace(4)*
+  f.a = b;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2405,15 +2405,19 @@
   assert(D->hasAttr() && "no annotate attribute");
   llvm::Value *V = Addr.getPointer();
   llvm::Type *VTy = V->getType();
-  llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
-CGM.Int8PtrTy);
+  llvm::PointerType *PTy = dyn_cast(VTy);
+  unsigned AS = PTy ? PTy->getAddressSpace() : 0;
+  llvm::PointerType *IntrinTy =
+  llvm::PointerType::getWithSamePointeeType(CGM.Int8PtrTy, AS);
+  llvm::Function *F =
+  CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation, IntrinTy);
 
   for (const auto *I : D->specific_attrs()) {
 // FIXME Always emit the cast inst so we can differentiate between
 // annotation on the first field of a struct and annotation on the struct
 // itself.
-if (VTy != CGM.Int8PtrTy)
-  V = Builder.CreateBitCast(V, CGM.Int8PtrTy);
+if (VTy != IntrinTy)
+  V = Builder.CreateBitCast(V, IntrinTy);
 V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation(), I);
 V = Builder.CreateBitCast(V, VTy);
   }


Index: clang/test/CodeGenSYCL/field-annotate-addr-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/field-annotate-addr-space.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: [[ANNOT:.+]] = private unnamed_addr constant {{.*}}c"my_annotation\00"
+
+struct HasField {
+  // This caused an assertion on creating a bitcast here,
+  // since the address space didn't match.
+  [[clang::annotate("my_annotation")]]
+  int *a;
+};
+
+void foo(int *b) {
+  struct HasField f;
+  // CHECK: %[[A:.+]] = getelementptr inbounds %struct.HasField, %struct.HasField addrspace(4)* %{{.+}}
+  // CHECK: %[[BITCAST:.+]] = bitcast i32 addrspace(4)* addrspace(4)* %[[A]] to i8 addrspace(4)*
+  // CHECK: %[[CALL:.+]] = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %[[BITCAST]], i8* getelementptr inbounds ([14 x i8], [14 x i8]* [[ANNOT]]
+  // CHECK: bitcast i8 addrspace(4)* %[[CALL]] to i32 addrspace(4)* addrspace(4)*
+  f.a = b;
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2405,15 +2405,19 @@
   assert(D->hasAttr() && "no annotate attribute");
   llvm::Value *V = Addr.getPointer();
   llvm::Type *VTy = V->getType();
-  llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
-CGM.Int8PtrTy);
+  llvm::PointerType *PTy = dyn_cast(VTy);
+  unsigned AS = PTy ? PTy->getAddressSpace() : 0;
+  llvm::PointerType *IntrinTy =
+  llvm::PointerType::getWithSamePointeeType(CGM.Int8PtrTy, AS);
+  llvm::Function *F =
+  CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation, IntrinTy);
 
   for (const auto *I : D->specific_attrs()) {
 // FIXME Always emit the cast inst so we can differentiate between
 // annotation on the first field of a struct 

[PATCH] D107430: [OMPIRBuilder] Add ordered directive to OMPIRBuilder

2021-08-31 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

Accepting patch since no reaction from @fghanim


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

https://reviews.llvm.org/D107430

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-08-31 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The error state of the stream can store these combinations:

|   | FERROR flag | FEOF flag | file position indeterminate |
| 1 | false   | false | false   | No error (single 
state)  
   |
| 2 | true| false | false   | should never 
happen unless the "indeterminate" is cleared with a debug function  
   |
| 3 | false   | true  | false   | FEOF flag set 
(single state)  
  |
| 4 | false   | false | true| only 
indeterminate position but no error flags (single state), can occur after 
`fseek` or `clearerr`|
| 5 | true| true  | false   | should never 
occur   
   |
| 6 | true| false | true| FERROR set, 
always together with indeterminate position (single state)  
|
| 7 | false   | true  | true| FEOF set, 
indeterminate position should be ignored here (single state), same as case 3
  |
| 8 | true| true  | true| the single 
combined ("Schrödinger") state: cases 3 and 6, this means delay of the state 
split until the exact error is revealed |
|


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D109000: [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

2021-08-31 Thread Yaron Keren via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10d78a06baa2: [llvm-lit] unbreak clang-only builds by not 
assuming llvm-lit in build dir (authored by yaron.keren).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109000

Files:
  clang/test/utils/update_cc_test_checks/lit.local.cfg


Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -21,8 +21,10 @@
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)
 # Windows: llvm-lit.py, Linux: llvm-lit
-llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
-lit = config.llvm_external_lit if config.llvm_external_lit else 
shell_quote(llvm_lit)
+if config.llvm_external_lit:
+lit = config.llvm_external_lit
+else:
+lit = shell_quote(glob.glob(os.path.join(config.llvm_tools_dir, 
'llvm-lit*'))[0])
 python = shell_quote(config.python_executable)
 config.substitutions.append(
 ('%update_cc_test_checks', "%s %s %s" % (


Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -21,8 +21,10 @@
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)
 # Windows: llvm-lit.py, Linux: llvm-lit
-llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
-lit = config.llvm_external_lit if config.llvm_external_lit else shell_quote(llvm_lit)
+if config.llvm_external_lit:
+lit = config.llvm_external_lit
+else:
+lit = shell_quote(glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0])
 python = shell_quote(config.python_executable)
 config.substitutions.append(
 ('%update_cc_test_checks', "%s %s %s" % (
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 10d78a0 - [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

2021-08-31 Thread Yaron Keren via cfe-commits

Author: Yaron Keren
Date: 2021-08-31T18:57:47+03:00
New Revision: 10d78a06baa217b8a4b853eff962e9ae719a8a45

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

LOG: [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

Reviewed By: tstellar

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

Added: 


Modified: 
clang/test/utils/update_cc_test_checks/lit.local.cfg

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg 
b/clang/test/utils/update_cc_test_checks/lit.local.cfg
index 6b4f5cfc62ed3..d57fa6832d425 100644
--- a/clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -21,8 +21,10 @@ script_path = os.path.join(config.llvm_src_root, 'utils',
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)
 # Windows: llvm-lit.py, Linux: llvm-lit
-llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
-lit = config.llvm_external_lit if config.llvm_external_lit else 
shell_quote(llvm_lit)
+if config.llvm_external_lit:
+lit = config.llvm_external_lit
+else:
+lit = shell_quote(glob.glob(os.path.join(config.llvm_tools_dir, 
'llvm-lit*'))[0])
 python = shell_quote(config.python_executable)
 config.substitutions.append(
 ('%update_cc_test_checks', "%s %s %s" % (



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


[PATCH] D109000: [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

2021-08-31 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109000

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


[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_images` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1726,6 +1726,7 @@
   if (S.getLangOpts().OpenCL) {
 const auto  = S.getOpenCLOptions();
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1735,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Comp &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1726,6 +1726,7 @@
   if (S.getLangOpts().OpenCL) {
 const auto  = S.getOpenCLOptions();
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1735,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Comp &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), 

[clang] b8debab - [clang] Remove redundant calls to c_str() (NFC)

2021-08-31 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-08-31T08:53:51-07:00
New Revision: b8debabb775b6d9eec5aa16f1b0c3428cc076bcb

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

LOG: [clang] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5718546b3bb67..f99ad6a50de1e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1448,8 +1448,8 @@ llvm::Value 
*CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction ,
 const char *FileName = PLoc.getFilename();
 unsigned Line = PLoc.getLine();
 unsigned Column = PLoc.getColumn();
-SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FunctionName.c_str(), FileName,
-Line, Column);
+SrcLocStr =
+OMPBuilder.getOrCreateSrcLocStr(FunctionName, FileName, Line, Column);
   }
   unsigned Reserved2Flags = getDefaultLocationReserved2Flags();
   return OMPBuilder.getOrCreateIdent(SrcLocStr, llvm::omp::IdentFlag(Flags),

diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index 0144d808cf124..67d941c6c2ab9 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -174,7 +174,7 @@ int Compilation::ExecuteCommand(const Command ,
 !getDriver().CCPrintOptionsFilename.empty()) {
   std::error_code EC;
   OwnedStream.reset(new llvm::raw_fd_ostream(
-  getDriver().CCPrintOptionsFilename.c_str(), EC,
+  getDriver().CCPrintOptionsFilename, EC,
   llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF));
   if (EC) {
 getDriver().Diag(diag::err_drv_cc_print_options_failure)

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cdd8ee4ca378e..9dab045b1c9f1 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4124,7 +4124,7 @@ void Driver::BuildJobs(Compilation ) const {
 << '\n';
 Out.flush();
 std::error_code EC;
-llvm::raw_fd_ostream OS(CCPrintStatReportFilename.c_str(), EC,
+llvm::raw_fd_ostream OS(CCPrintStatReportFilename, EC,
 llvm::sys::fs::OF_Append |
 llvm::sys::fs::OF_Text);
 if (EC)

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 4a7413112b55d..a29ed0bdc6b4c 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -754,7 +754,7 @@ AMDGPUToolChain::detectSystemGPUs(const ArgList ,
 
   std::string ErrorMessage;
   if (int Result = llvm::sys::ExecuteAndWait(
-  Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
+  Program, {}, {}, Redirects, /* SecondsToWait */ 0,
   /*MemoryLimit*/ 0, )) {
 if (Result > 0) {
   ErrorMessage = "Exited with error code " + std::to_string(Result);

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5fcf3c504633c..343a5d5f4cf78 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -661,7 +661,7 @@ void tools::addArchSpecificRPath(const ToolChain , const 
ArgList ,
   std::string CandidateRPath = TC.getArchSpecificLibPath();
   if (TC.getVFS().exists(CandidateRPath)) {
 CmdArgs.push_back("-rpath");
-CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
   }
 }
 

diff  --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 1ce5a2a203c24..570c1bcabd696 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -261,8 +261,7 @@ void netbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   const SanitizerArgs  = ToolChain.getSanitizerArgs();
   if (SanArgs.needsSharedRt()) {
 CmdArgs.push_back("-rpath");
-CmdArgs.push_back(Args.MakeArgString(
-ToolChain.getCompilerRTPath().c_str()));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.getCompilerRTPath()));
   }
 
   unsigned Major, Minor, Micro;

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 0f9bd70efc73e..8de2e75388bed 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp

[PATCH] D108998: [SystemZ][z/OS] Create html report file with text flag

2021-08-31 Thread Fanbo Meng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae206db2d653: [SystemZ][z/OS] Create html report file with 
text flag (authored by fanbo-meng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108998

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -344,7 +344,7 @@
 
   if (std::error_code EC = llvm::sys::fs::openFileForReadWrite(
   ResultPath, FD, llvm::sys::fs::CD_CreateNew,
-  llvm::sys::fs::OF_None)) {
+  llvm::sys::fs::OF_Text)) {
 // Existence of the file corresponds to the situation where a different
 // Clang instance has emitted a bug report with the same issue hash.
 // This is an entirely normal situation that does not deserve a warning,


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -344,7 +344,7 @@
 
   if (std::error_code EC = llvm::sys::fs::openFileForReadWrite(
   ResultPath, FD, llvm::sys::fs::CD_CreateNew,
-  llvm::sys::fs::OF_None)) {
+  llvm::sys::fs::OF_Text)) {
 // Existence of the file corresponds to the situation where a different
 // Clang instance has emitted a bug report with the same issue hash.
 // This is an entirely normal situation that does not deserve a warning,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ae206db - [SystemZ][z/OS] Create html report file with text flag

2021-08-31 Thread Fanbo Meng via cfe-commits

Author: Fanbo Meng
Date: 2021-08-31T11:52:04-04:00
New Revision: ae206db2d653cfeb1021e4e8f5783de797e521a5

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

LOG: [SystemZ][z/OS] Create html report file with text flag

Change OF_None to OF_Text flag in file creation, same reasoning as 
https://reviews.llvm.org/D97785

Reviewed By: abhina.sreeskantharajan

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index e7df9a70839de..9db3b140f21e5 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -344,7 +344,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
 
   if (std::error_code EC = llvm::sys::fs::openFileForReadWrite(
   ResultPath, FD, llvm::sys::fs::CD_CreateNew,
-  llvm::sys::fs::OF_None)) {
+  llvm::sys::fs::OF_Text)) {
 // Existence of the file corresponds to the situation where a 
diff erent
 // Clang instance has emitted a bug report with the same issue hash.
 // This is an entirely normal situation that does not deserve a warning,



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


[PATCH] D108974: [clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/ClangScanDeps/strip_diag_serialize.cpp:1-3
+// FIXME: Make this pass again.
+// XFAIL: *
+

Can you clarify why a temporary regression is necessary? Is there a way of 
reordering patches to avoid it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108974

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


[PATCH] D108918: [clang] NFC: Extract DiagnosticOptions parsing

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

A few comments inline, but LGTM once you fix those.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2259-2260
 
+DiagnosticOptions *clang::CreateAndPopulateDiagOpts(ArrayRef 
Argv,
+bool *UseNewCC1Process) {
+  auto *DiagOpts = new DiagnosticOptions;

Please return `std::unique_ptr()` instead of `new`.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2270-2274
+  if (UseNewCC1Process)
+*UseNewCC1Process =
+Args.hasFlag(clang::driver::options::OPT_fno_integrated_cc1,
+ clang::driver::options::OPT_fintegrated_cc1,
+ /*Default=*/CLANG_SPAWN_CC1);

I don't think `-fintegrated-cc1` is related to diagnostic options. I suggest 
leaving it behind in the driver code and using:
```
lang=c++
std::unique_ptr
clang::createAndPopulateDiagOpts(ArrayRef Argv) {
  return createAndPopulateDiagOptsImpl(Argv);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108918

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


[PATCH] D108919: [clan-repl] Install clang-repl

2021-08-31 Thread Vassil Vassilev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9948e9254fb: [clang-repl] Install clang-repl (authored by 
v.g.vassilev).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108919

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -7,7 +7,7 @@
   Support
   )
 
-add_clang_executable(clang-repl
+add_clang_tool(clang-repl
   ClangRepl.cpp
   )
 


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -7,7 +7,7 @@
   Support
   )
 
-add_clang_executable(clang-repl
+add_clang_tool(clang-repl
   ClangRepl.cpp
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c9948e9 - [clang-repl] Install clang-repl

2021-08-31 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-08-31T15:20:15Z
New Revision: c9948e9254fbb6ea00f66c7b4542311d21e060be

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

LOG: [clang-repl] Install clang-repl

This is essentially what D106813 was supposed to do but did not.

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

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index c2576d7c564d9..060c62aa419c7 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -7,7 +7,7 @@ set( LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_executable(clang-repl
+add_clang_tool(clang-repl
   ClangRepl.cpp
   )
 



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


[PATCH] D109000: [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

2021-08-31 Thread Yaron Keren via Phabricator via cfe-commits
yaron.keren added a comment.

Addressing comment in https://reviews.llvm.org/D108085


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109000

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


[PATCH] D108085: Use installed llvm-lit.py instead of lit.py PR-51072

2021-08-31 Thread Yaron Keren via Phabricator via cfe-commits
yaron.keren marked an inline comment as done.
yaron.keren added inline comments.



Comment at: clang/test/utils/update_cc_test_checks/lit.local.cfg:24
+# Windows: llvm-lit.py, Linux: llvm-lit
+llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
+lit = config.llvm_external_lit if config.llvm_external_lit else 
shell_quote(llvm_lit)

tstellar wrote:
> This patch breaks stand-alone clang builds, because it assumes llvm-lit* will 
> be present in the build directory.   This line should be guarded by if not 
> config.llvm_external_lit.
Continued in https://reviews.llvm.org/D109000


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108085

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


[PATCH] D109000: [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir

2021-08-31 Thread Yaron Keren via Phabricator via cfe-commits
yaron.keren created this revision.
yaron.keren added a reviewer: tstellar.
yaron.keren requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109000

Files:
  clang/test/utils/update_cc_test_checks/lit.local.cfg


Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -21,8 +21,10 @@
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)
 # Windows: llvm-lit.py, Linux: llvm-lit
-llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
-lit = config.llvm_external_lit if config.llvm_external_lit else 
shell_quote(llvm_lit)
+if config.llvm_external_lit:
+lit = config.llvm_external_lit
+else:
+lit = shell_quote(glob.glob(os.path.join(config.llvm_tools_dir, 
'llvm-lit*'))[0])
 python = shell_quote(config.python_executable)
 config.substitutions.append(
 ('%update_cc_test_checks', "%s %s %s" % (


Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -21,8 +21,10 @@
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)
 # Windows: llvm-lit.py, Linux: llvm-lit
-llvm_lit = glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0]
-lit = config.llvm_external_lit if config.llvm_external_lit else shell_quote(llvm_lit)
+if config.llvm_external_lit:
+lit = config.llvm_external_lit
+else:
+lit = shell_quote(glob.glob(os.path.join(config.llvm_tools_dir, 'llvm-lit*'))[0])
 python = shell_quote(config.python_executable)
 config.substitutions.append(
 ('%update_cc_test_checks', "%s %s %s" % (
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108979: [clang][deps] NFC: Stop going through ClangTool

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D108979#2974642 , @dexonsmith 
wrote:

> I'm approving as-is, since this is a step forward, but I'm curious if you can 
> clarify what ToolInvocation is providing, and whether that's worth it or if 
> it'd make sense (eventually) to go a step further.

(To be concrete, I feel any libclang API is likely to accept command-lines as 
something directly representable as `ArrayRef`. Having to 
repackage that as `std::vector` seems a bit unfortunate since the 
CompilerInvocation will want it repackaged again as `ArrayRef`. 
But maybe ToolInvocation is doing something valuable, and certainly we could 
change that later.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108979

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


[PATCH] D108998: [SystemZ][z/OS] Create html report file with text flag

2021-08-31 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108998

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


[PATCH] D108981: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningTool API

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108981

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


[PATCH] D108980: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningWorker API

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108980

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


[PATCH] D108982: [clang][deps] Avoid creating diagnostic serialization file, add test

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Code changes LGTM, just a comment on the test.




Comment at: clang/test/ClangScanDeps/diagnostics.c:8
+
+// CHECK-NOT: error: invalid iOS deployment version

Should this just be:
```
CHECK-NOT: error:
```
?


Also, is there a positive CHECK or two you could add? And possibly a comment to 
explain what the test is for? (It's not obvious to me from the name 
"diagnostics".)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108982

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


[PATCH] D108998: [SystemZ][z/OS] Create html report file with text flag

2021-08-31 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
Herald added a subscriber: martong.
fanbo-meng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Change OF_None to OF_Text flag in file creation, same reasoning as 
https://reviews.llvm.org/D97785


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108998

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -344,7 +344,7 @@
 
   if (std::error_code EC = llvm::sys::fs::openFileForReadWrite(
   ResultPath, FD, llvm::sys::fs::CD_CreateNew,
-  llvm::sys::fs::OF_None)) {
+  llvm::sys::fs::OF_Text)) {
 // Existence of the file corresponds to the situation where a different
 // Clang instance has emitted a bug report with the same issue hash.
 // This is an entirely normal situation that does not deserve a warning,


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -344,7 +344,7 @@
 
   if (std::error_code EC = llvm::sys::fs::openFileForReadWrite(
   ResultPath, FD, llvm::sys::fs::CD_CreateNew,
-  llvm::sys::fs::OF_None)) {
+  llvm::sys::fs::OF_Text)) {
 // Existence of the file corresponds to the situation where a different
 // Clang instance has emitted a bug report with the same issue hash.
 // This is an entirely normal situation that does not deserve a warning,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108979: [clang][deps] NFC: Stop going through ClangTool

2021-08-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM. I've independently been wondering for a while whether ClangTool was doing 
more harm than good for the scanning usecase.

I'm approving as-is, since this is a step forward, but I'm curious if you can 
clarify what ToolInvocation is providing, and whether that's worth it or if 
it'd make sense (eventually) to go a step further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108979

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


[PATCH] D107290: [PoC][RISCV] Add support for the vscale_range attribute

2021-08-31 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp:101
+  } else {
+RVVBitsMin = RVVVectorBitsMinOpt;
+RVVBitsMax = RVVVectorBitsMaxOpt;

craig.topper wrote:
> If clang always emits the attribute, are these options effectively dead for 
> clang codegen?
Yes, that's a good point - I'd missed that. I'm not sure the best way of 
keeping that ability apart from moving the options up to clang and dealing with 
the fallout from that. Which I'm not even sure we //can// deal with yet?

Unless we make the options override the attribute, though that might be its own 
can of worms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107290

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-08-31 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

We had a meeting outside phabricator, here is the gist of it:

- It'd be better to have your initially proposed schrödinger-like `NoteTag`s.
- The intent is to emit a warning for each of the error states in 
`StreamState`. It seems to me that this is not what we're doing now, but, 
similarly to adding warnings fro FERROR and being able to clear the 
indeterminate file position indicator state, would truly display how `NoteTag`s 
might change their message depending on the `BugType`.
- There are numerous discussions to be had on how to handle `fseek`, how much 
do FERROR and the file position indicator imply one another, but for this 
patch, adding debug functions such as `void 
StreamCheckerTest_remove_indeterminate_file_pos_tag(FILE *)` or `void 
StreamCheckerTest_warn_if_in_ferror(FILE *)` would allow as to test the 
functionality added by this patch, and land it.

As such, I'd like if you implemented the above mentioned functions with their 
expected functionality. I'd like to test cases where the very same function 
call gets a different note message depending on the `BugType`:

  void fseek_caused_feof() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET); // expected-note {{Stream reaches end-of-file here}} 
<= (*)
if (ferror(F)) // expected-note {{Assuming the error flag is not set on the 
stream}}
   // expected-note@-1 {{Taking false branch}}
  return;
StreamCheckerTest_remove_indeterminate_file_pos_tag(F);
fread(Buf, 1, 1, F); // expected-warning{{Read function called when stream 
is in EOF state. Function has no effect}}
// expected-note@-1{{Read function called when stream is in EOF state. 
Function has no effect}}
fclose(F);
  }
  
  void fseek_caused_ferror() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET); // expected-note {{Stream has its error flag set}} 
<= (*)
if (feof(F)) // expected-note {{Assuming the end-of-file flag is not set on 
the stream}}
 // expected-note@-1 {{Taking false branch}}
  return;
StreamCheckerTest_remove_indeterminate_file_pos_tag(F);
StreamCheckerTest_warn_if_in_ferror(F); // expected-warning{{Read function 
called when stream is in FERROR state.}}
// expected-note@-1{Read function called when stream is in FERROR state.}
fclose(F);
  }
  
  void fseek_caused_indeterminate_file_pos() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET); // expected-note {{Stream operation leaves the file 
position indicator indeterminate}} <= (*)
clearerr(F);
fread(Buf, 1, 1, F); // expected-warning{{File position of the stream might 
be 'indeterminate' after a failed operation. Can cause undefined behavior}}
// expected-note@-1{{File position of the stream might be 'indeterminate' 
after a failed operation. Can cause undefined behavior}}
fclose(F);
  }

Maybe some others in the spirit of these 3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D108917: [AIX] Define __powerpc and __PPC macros

2021-08-31 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm requested changes to this revision.
cebowleratibm added a comment.
This revision now requires changes to proceed.

I'd like to see the rationale for adding these forms of the macros in the 
review and also in the extended commit message.  These forms are being added 
primarily because the AIX XL compiler documented and defined them.  The patch 
itself looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108917

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


[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-31 Thread gehry via Phabricator via cfe-commits
Sockke marked an inline comment as not done.
Sockke added a comment.

Thanks for your review, I greatly appreciate it. @whisperity
There is no wrong case in the original test file, which is why we did not catch 
the bug in the test suite. From this, I added some new cases. 
I tested the functions with multi-parameters, there is no problem, I will add 
them to the test file.

In D107450#2968708 , @whisperity 
wrote:

> I'm a bit confused about this, but it has been a while since I read this 
> patch. Am I right to think that the code in the patch and the original 
> submission (the patch summary) diverged since the review started? I do not 
> see anything "removed" from the test files, only a new addition. Or did you 
> accidentally upload a wrong diff somewhere? The original intention of the 
> patch was to remove bogus printouts.
>
> In general: the test file ends without any testing for functions with 
> multiple parameters. Are they out-of-scope by design?






Comment at: 
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:131-145
 auto Diag = diag(FileMoveRange.getBegin(),
  "std::move of the %select{|const }0"
- "%select{expression|variable %4}1 "
- "%select{|of the trivially-copyable type %5 }2"
- "has no effect; remove std::move()"
- "%select{| or make the variable non-const}3")
+ "%select{expression|variable %5}1 "
+ "%select{|of the trivially-copyable type %6 }2"
+ "has no effect%select{; remove std::move()||; consider "
+ "changing %7's parameter from %8 to 'const %9 &'}3"
+ "%select{| or make the variable non-const}4")

whisperity wrote:
> 
> 





Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:139
 << IsConstArg << IsVariable << IsTriviallyCopyable
-<< (IsConstArg && IsVariable && !IsTriviallyCopyable) << Var
-<< Arg->getType();
+<< (IsRValueReferenceArg + (IsRValueReferenceArg &&
+IsTriviallyCopyable &&

whisperity wrote:
> **`+`**? Shouldn't this be `||`? I know they're equivalent over Z_2, but if 
> we're using `&&` instead of `*` then let's adhere to the style.
> **`+`**? Shouldn't this be `||`? I know they're equivalent over Z_2, but if 
> we're using `&&` instead of `*` then let's adhere to the style.

The reason for this is that the maximum capacity of diag is 10.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:267-270
+void showTmp(Tmp &&) {}
+void testTmp() {
+  Tmp t;
+  showTmp(std::move(t));

whisperity wrote:
> Is there a test case covering if there are separate invocations of the 
> function? Just to make sure that the //consider changing the parameter// 
> suggestion won't become an annoyance either, and result in conflicts with 
> other parts of the code.
The warning will only be given when calling this function and passing in the 
parameters wrapped with std::move. Is my understanding correct?




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:271
+  showTmp(std::move(t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 't' 
of the trivially-copyable type 'Tmp' has no effect; consider changing showTmp's 
parameter from 'Tmp &&' to 'const Tmp &'
+}

whisperity wrote:
> We could ensure that the symbol name is printed the same way as the other 
> placeholder-injected named decls.
Yes,  this is a better implementation.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; consider changing showInt's 
parameter from 'int'&& to 'int'&
+  return std::move(a);

whisperity wrote:
> MTC wrote:
> > Change **'int'&&**  -> **'int&&'** and **'int&'** -> **int**. 
> > 
> > Make `consider changing showInt's parameter from 'int'&& to 'int'&` as a 
> > note instead of a warning. And I don't have a strong preference for the 
> > position of the note, but I personally want to put it in the source 
> > location of the function definition. and 
> >>! In D107450#2936824, @MTC wrote:
> > but I personally want to put it in the source location of the function 
> > definition
> 
> (I think you submitted the comment too early, @MTC, as there's an 
> unterminated sentence there.)
> 
> But I agree with this. It should be put there when we're talking about the 
> function's signature. The reason being the developer reading the warning 
> could dismiss a potential 

[PATCH] D108989: [OpenCL] Supports optional 64-bit floating point types in C++ for OpenCL 2021

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_fp64` in C++ for OpenCL
2021 enabling a respective optional core feature from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108989

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenOpenCL/printf.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/fp64-fp16-options.cl

Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -6,6 +6,7 @@
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
@@ -20,6 +21,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
@@ -29,6 +33,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 
 // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
 // disables all extensions by default, but supported core extensions for a
@@ -36,7 +43,7 @@
 // enabled by default with -cl-std=CL2.0).
 //
 // RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 #ifdef _OPENCL_H_
 // expected-no-diagnostics
@@ -46,7 +53,7 @@
 // expected-no-diagnostics
 #endif
 
-#ifdef __OPENCL_CPP_VERSION__
+#if __OPENCL_CPP_VERSION__ == 100
 // expected-no-diagnostics
 #endif
 
@@ -92,7 +99,7 @@
 void f2(void) {
   double d;
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || __OPENCL_CPP_VERSION__ >= 202100)
 // expected-error@-3{{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}}
 #else
 // expected-error@-5{{use of type 'double' requires cl_khr_fp64 support}}
@@ -102,7 +109,7 @@
   typedef double double4 __attribute__((ext_vector_type(4)));
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-31 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108291: [clang-nvlink-wrapper] Wrapper around nvlink for archive files

2021-08-31 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked an inline comment as done.
saiislam added a comment.

Ping. Any more suggestions/questions?
I will update requested changes/documentation for D105191 
 once this gets through.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108291

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


[PATCH] D104344: [modules] Track how headers are included by different modules.

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

I see, thanks for the explanation. This LGTM provided the failing clangd test 
gets fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104344

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-08-31 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D106262#2939532 , @balazske wrote:

> Really I still not understand why the previous `BugType` dependent `NoteTag` 
> functions were bad design (except that it could make the code difficult to 
> understand). If we would have the BugType available in the NoteTag, we could 
> make the decision about what to display and no "or"s are needed in the 
> message. We do not need a "Stream either reaches end-of-file, or fails and 
> has its file position indicator left indeterminate and the error flag set." 
> message if the information is available about what the exact problem was 
> (from the BugType) and we can build a "Stream reaches end-of-file." if the 
> bug was end-of-file related, and so on. (Really instead of the bug type other 
> information could be used that is passed from the bug report to the note tag, 
> but there is no way for this to do?)

My strongest arguments **for** the the notes I suggested is that this would 
give the complete picture. Suppose I see the note "stream has its error flag 
set", and fix the FERROR case (add an `ferror()` check with an early return), 
only to stumble across the very same bug an hour later, but now with an EOF in 
the note message. I could have added an early return about EOF as well, but I 
didn't know that function was modeled with EOF set as well. While my suggested 
note is long, I think this is about the shortest that would give users the 
complete picture, and I don't think that a longer note is something to avoid 
(CodeChecker users in particular have to deal with lot longer macro expansions 
already, and they are still useful IMO).

While I really believe that this would be the better option of the two, I don't 
strongly insist on it, especially if others see it a subpar option as well.

> Otherwise just the user has to find out the same thing by looking at later 
> functions and notes.

I believe the general advice for users is to read bug reports not from top to 
bottom, but from the error report up (as its likely that the essence of the bug 
can be summarized far before we get to the notes around where the analysis 
started). I think the long note version would be better in that case, it'd more 
clearly display how the analyzer reached the conclusion.

> So I want to wait for the opinion of another reviewer(s) before proceeding.

Another set of eyes could never hurt, indeed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D104386: [PowerPC][Builtins] Added a number of builtins for compatibility with XL.

2021-08-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added subscribers: adalava, jhibbits.
dim added a comment.

In D104386#2973372 , @nemanjai wrote:

> In D104386#2973245 , @dim wrote:
>
>> Note that this unexpectedly broke FreeBSD's powerpc64 builds, as we've long 
>> used the following in our `lib/libc/powerpc64/string/bcopy.S`:

...

>> However, I think I can make do with adding `-U__bcopy` to the clang command 
>> line. It would have been nice if these aliases were behind some 
>> `--xl-compat` flag... :)
>
> I am really sorry that we broke you. Would it help if we defined this macro 
> only if compiling for Linux/AIX? If so, are there any others (or perhaps all 
> of them) that you'd like us to conditionally define only on AIX/Linux?

Well, it seems that `defineXLCompatMacros` was rather small in the beginning 
(when it was introduced in rG62b5df7fe2b3fda1772befeda15598fbef96a614 
) so there 
were not so many chances for collisions. This is probably why we've not noticed 
these definitions, and also because they're not there for clang <= 12. :)

That said, if you think there is a use case for sometimes compiling with the XL 
compiler on systems *other* than Linux/AIX, then your suggested workaround 
might not be adequate. @jhibbits @adalava did you ever use the XL compiler on 
FreeBSD?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104386

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


[PATCH] D108765: [docs] Fix documentation of clang-format BasedOnStyle type

2021-08-31 Thread Ludovic Jozeau via Phabricator via cfe-commits
FederAndInk added a comment.

In D108765#2974153 , @MyDeveloperDay 
wrote:

>   error: pathspec './plurals.txt' did not match any file(s) known to git
>   Traceback (most recent call last):
> File "./dump_format_style.py", line 18, in 
>   subprocess.check_call(['git', 'checkout', '--', PLURAL_FILE])
> File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
>   raise CalledProcessError(retcode, cmd)
>   subprocess.CalledProcessError: Command '['git', 'checkout', '--', 
> './plurals.txt']' returned non-zero exit status 1.

This is expected if `plurals.txt` is not in git yet, there is `call` that will 
do nothing on errors, but I use `check_call` to report errors from `git 
checkout -- plurals.txt`. To test, you can either replace temporarily the 
`check_call` by a `call` in clang/docs/tools/dump_format_style.py:18 or get the 
commit/create a temporary commit with plurals.txt

Maybe to simplify the testing/review procedure, I'll change `check_call` by 
`call` and if it is accepted, change it back to the checked version.




Comment at: clang/docs/tools/dump_format_style.py:9
 import re
+import inspect
+import subprocess

MyDeveloperDay wrote:
> FederAndInk wrote:
> > HazardyKnusperkeks wrote:
> > > I think these should be sorted.
> > ok, it will be done
> are these standard imports or are we going to have to pip install something?
These are all standard imports, no worries :) 
(https://docs.python.org/3/library/subprocess.html)

otherwise, I would have directly used python inflect/or any other package to 
solve the plural problem



Comment at: clang/docs/tools/dump_format_style.py:18
+PLURAL_FILE = os.path.join(os.path.dirname(__file__), 'plurals.txt')
+subprocess.check_call(['git', 'checkout', '--', PLURAL_FILE])
+plurals = set(open(PLURAL_FILE).read().splitlines())

MyDeveloperDay wrote:
> FederAndInk wrote:
> > HazardyKnusperkeks wrote:
> > > So you would add a plurals.txt in git and make the change visible through 
> > > git diff? What about just reordering? I.e. `Strings` is on line 2, but 
> > > after a change in line 1. Maybe sort the output?
> > > 
> > > I'm not against this procedure, but also not in favor. :)
> > This line is used to restore the version of plurals.txt to HEAD, so when 
> > calling the script multiple times, it keeps showing new plurals until 
> > plurals.txt gets committed.
> > 
> > > So you would add a plurals.txt in git and make the change visible through 
> > > git diff?
> > 
> > yes, that's it
> > 
> > > What about just reordering?
> > 
> > I don't think we want ordering, it is ordered from first plural generated 
> > to last/new one, so git diff will only show new plurals
> I'm personally not in favour of this script calling back to git
Well, I was inspired by other python scripts in the llvm-project repo that use 
`subprocess` to call `git`, it just touches the plurals.txt files to allow the 
user calling the script multiple times and be warned of the new plurals each 
time until it is committed. We could do without it, but we would lose a part of 
automation and the user of the script would have to partly manage the 
plurals.txt file.

A semi-solution I see is to at least tell the user to use `git checkout -- 
plurals.txt` if they want to clean up plurals/regenerate them and see which 
ones are new and/or call `git diff -- plurals.txt` to show new plurals which 
may be less "problematic" than `git checkout -- plurals.txt`. What do you think?

Tl;dr of solutions:

1. reconsider as this technic is in use in other scripts in llvm-project
2. call `git diff` instead of `git checkout` leading to less consistent and 
precise messages
3. just tell the user what are their options (printing 'you can use `git 
checkout -- plurals.txt` or `git diff -- plurals.txt`'...)
4. other ideas?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108765

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


[PATCH] D108982: [clang][deps] Avoid creating diagnostic serialization file, add test

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Inject custom diagnostic options into `ToolInvocation` with stripped diagnostic 
serialization file to make test pass again. Also add test that confirms the 
driver -> cc1 command-line transformation/parsing respects `-Wno-error=...`.

Depends on D108981 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108982

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
  clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
  clang/test/ClangScanDeps/diagnostics.c
  clang/test/ClangScanDeps/strip_diag_serialize.cpp

Index: clang/test/ClangScanDeps/strip_diag_serialize.cpp
===
--- clang/test/ClangScanDeps/strip_diag_serialize.cpp
+++ clang/test/ClangScanDeps/strip_diag_serialize.cpp
@@ -1,6 +1,3 @@
-// FIXME: Make this pass again.
-// XFAIL: *
-
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
Index: clang/test/ClangScanDeps/diagnostics.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/diagnostics.c
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/diagnostics/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/diagnostics/cdb.json.template > %t/cdb.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir %t/build 2>&1 | FileCheck %s
+
+// CHECK-NOT: error: invalid iOS deployment version
Index: clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -c DIR/tu.c -target i386-apple-ios14.0-simulator -Wno-error=invalid-ios-deployment-target -o DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -269,8 +269,6 @@
 DependencyScanningWorker::DependencyScanningWorker(
 DependencyScanningService )
 : Format(Service.getFormat()) {
-  DiagOpts = new DiagnosticOptions();
-
   PCHContainerOps = std::make_shared();
   PCHContainerOps->registerReader(
   std::make_unique());
@@ -290,16 +288,20 @@
 Files = new FileManager(FileSystemOptions(), RealFS);
 }
 
-static llvm::Error runWithDiags(
-DiagnosticOptions *DiagOpts,
-llvm::function_ref BodyShouldSucceed) {
+static llvm::Error
+runWithDiags(DiagnosticOptions *DiagOpts,
+ llvm::function_ref
+ BodyShouldSucceed) {
+  // Avoid serializing diagnostics.
+  DiagOpts->DiagnosticSerializationFile.clear();
+
   // Capture the emitted diagnostics and report them to the client
   // in the case of a failure.
   std::string DiagnosticOutput;
   llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
   TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, DiagOpts);
 
-  if (BodyShouldSucceed(DiagPrinter))
+  if (BodyShouldSucceed(DiagPrinter, *DiagOpts))
 return llvm::Error::success();
   return llvm::make_error(DiagnosticsOS.str(),
  llvm::inconvertibleErrorCode());
@@ -313,15 +315,22 @@
   llvm::IntrusiveRefCntPtr CurrentFiles =
   Files ? Files : new FileManager(FileSystemOptions(), RealFS);
 
-  return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer ) {
-DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
-PPSkipMappings.get(), Format);
-// Create an invocation that uses the underlying file system to ensure that
-// any file system requests that are made by the driver do not go through
-// the dependency scanning filesystem.
-ToolInvocation Invocation(CommandLine, , CurrentFiles.get(),
-  PCHContainerOps);
-Invocation.setDiagnosticConsumer();
-return Invocation.run();
-  });
+  std::vector CCommandLine(CommandLine.size(), nullptr);
+  llvm::transform(CommandLine, CCommandLine.begin(),
+  [](const std::string ) { return Str.c_str(); });
+
+  return runWithDiags(
+  CreateAndPopulateDiagOpts(CCommandLine),
+  [&](DiagnosticConsumer , DiagnosticOptions ) {
+DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
+PPSkipMappings.get(), 

[PATCH] D108981: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningTool API

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch simplifies the dependency scanner API. Made possibly by D108979 
.

Depends on D108980 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108981

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -508,10 +508,8 @@
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I)
 WorkerTools.push_back(std::make_unique(Service));
 
-  std::vector Inputs;
-  for (tooling::CompileCommand Cmd :
-   AdjustingCompilations->getAllCompileCommands())
-Inputs.emplace_back(Cmd);
+  std::vector Inputs =
+  AdjustingCompilations->getAllCompileCommands();
 
   std::atomic HadErrors(false);
   FullDeps FD;
@@ -527,7 +525,7 @@
 , ]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
-const SingleCommandCompilationDatabase *Input;
+const tooling::CompileCommand *Input;
 std::string Filename;
 std::string CWD;
 size_t LocalIndex;
@@ -538,19 +536,19 @@
 return;
   LocalIndex = Index;
   Input = [Index++];
-  tooling::CompileCommand Cmd = Input->getAllCompileCommands()[0];
-  Filename = std::move(Cmd.Filename);
-  CWD = std::move(Cmd.Directory);
+  Filename = std::move(Input->Filename);
+  CWD = std::move(Input->Directory);
 }
 // Run the tool on it.
 if (Format == ScanningOutputFormat::Make) {
-  auto MaybeFile = WorkerTools[I]->getDependencyFile(*Input, CWD);
+  auto MaybeFile =
+  WorkerTools[I]->getDependencyFile(Input->CommandLine, CWD);
   if (handleMakeDependencyToolResult(Filename, MaybeFile, DependencyOS,
  Errs))
 HadErrors = true;
 } else {
   auto MaybeFullDeps = WorkerTools[I]->getFullDependencies(
-  *Input, CWD, AlreadySeenModules);
+  Input->CommandLine, CWD, AlreadySeenModules);
   if (handleFullDependencyToolResult(Filename, MaybeFullDeps, FD,
  LocalIndex, DependencyOS, Errs))
 HadErrors = true;
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -50,7 +50,7 @@
 : Worker(Service) {}
 
 llvm::Expected DependencyScanningTool::getDependencyFile(
-const tooling::CompilationDatabase , StringRef CWD) {
+const std::vector , StringRef CWD) {
   /// Prints out all of the gathered dependencies into a string.
   class MakeDependencyPrinterConsumer : public DependencyConsumer {
   public:
@@ -102,17 +102,6 @@
 std::vector Dependencies;
   };
 
-  // We expect a single command here because if a source file occurs multiple
-  // times in the original CDB, then `computeDependencies` would run the
-  // `DependencyScanningAction` once for every time the input occured in the
-  // CDB. Instead we split up the CDB into single command chunks to avoid this
-  // behavior.
-  assert(Compilations.getAllCompileCommands().size() == 1 &&
- "Expected a compilation database with a single command!");
-  // FIXME: Avoid this copy.
-  std::vector CommandLine =
-  Compilations.getAllCompileCommands().front().CommandLine;
-
   MakeDependencyPrinterConsumer Consumer;
   auto Result = Worker.computeDependencies(CWD, CommandLine, Consumer);
   if (Result)
@@ -124,7 +113,7 @@
 
 llvm::Expected
 DependencyScanningTool::getFullDependencies(
-const tooling::CompilationDatabase , StringRef CWD,
+const std::vector , StringRef CWD,
 const llvm::StringSet<> ) {
   class FullDependencyPrinterConsumer : public DependencyConsumer {
   public:
@@ -188,17 +177,6 @@
 const llvm::StringSet<> 
   };
 
-  // We expect a single command here because if a source file occurs multiple
-  // times in the original CDB, then `computeDependencies` would run the
-  // `DependencyScanningAction` once for every time the input occured in the
-  // CDB. Instead we split up the CDB into single command chunks to avoid this
-  // behavior.
-  assert(Compilations.getAllCompileCommands().size() == 1 &&

[PATCH] D108980: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningWorker API

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch simplifies the dependency scanner API. Made possibly by D108979 
.

Depends on D108979 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108980

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -306,18 +306,13 @@
 }
 
 llvm::Error DependencyScanningWorker::computeDependencies(
-const std::string , StringRef WorkingDirectory,
-const CompilationDatabase , DependencyConsumer ) {
+StringRef WorkingDirectory, const std::vector ,
+DependencyConsumer ) {
   RealFS->setCurrentWorkingDirectory(WorkingDirectory);
 
   llvm::IntrusiveRefCntPtr CurrentFiles =
   Files ? Files : new FileManager(FileSystemOptions(), RealFS);
 
-  // FIXME: Avoid this copy.
-  std::vector CompileCommands = CDB.getCompileCommands(Input);
-  const std::vector  =
-  CompileCommands.front().CommandLine;
-
   return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer ) {
 DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
 PPSkipMappings.get(), Format);
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -109,10 +109,12 @@
   // behavior.
   assert(Compilations.getAllCompileCommands().size() == 1 &&
  "Expected a compilation database with a single command!");
-  std::string Input = Compilations.getAllCompileCommands().front().Filename;
+  // FIXME: Avoid this copy.
+  std::vector CommandLine =
+  Compilations.getAllCompileCommands().front().CommandLine;
 
   MakeDependencyPrinterConsumer Consumer;
-  auto Result = Worker.computeDependencies(Input, CWD, Compilations, Consumer);
+  auto Result = Worker.computeDependencies(CWD, CommandLine, Consumer);
   if (Result)
 return std::move(Result);
   std::string Output;
@@ -193,11 +195,12 @@
   // behavior.
   assert(Compilations.getAllCompileCommands().size() == 1 &&
  "Expected a compilation database with a single command!");
-  std::string Input = Compilations.getAllCompileCommands().front().Filename;
+  // FIXME: Avoid this copy.
+  std::vector CommandLine =
+  Compilations.getAllCompileCommands().front().CommandLine;
 
   FullDependencyPrinterConsumer Consumer(AlreadySeen);
-  llvm::Error Result =
-  Worker.computeDependencies(Input, CWD, Compilations, Consumer);
+  llvm::Error Result = Worker.computeDependencies(CWD, CommandLine, Consumer);
   if (Result)
 return std::move(Result);
   return Consumer.getFullDependencies();
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -80,9 +80,8 @@
   ///
   /// \returns A \c StringError with the diagnostic output if clang errors
   /// occurred, success otherwise.
-  llvm::Error computeDependencies(const std::string ,
-  StringRef WorkingDirectory,
-  const CompilationDatabase ,
+  llvm::Error computeDependencies(StringRef WorkingDirectory,
+  const std::vector ,
   DependencyConsumer );
 
 private:


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -306,18 +306,13 @@
 }
 
 llvm::Error DependencyScanningWorker::computeDependencies(
-const std::string , StringRef WorkingDirectory,
-const CompilationDatabase , DependencyConsumer ) {
+StringRef WorkingDirectory, const std::vector ,
+DependencyConsumer ) {
   RealFS->setCurrentWorkingDirectory(WorkingDirectory);
 
   llvm::IntrusiveRefCntPtr CurrentFiles =
   Files ? Files : new FileManager(FileSystemOptions(), RealFS);
 
-  // FIXME: Avoid this copy.
-  std::vector CompileCommands = 

[PATCH] D108979: [clang][deps] NFC: Stop going through ClangTool

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The dependency scanner currently uses `ClangTool` to invoke the dependency 
scanning action.

However, `ClangTool` seems to be the wrong level of abstraction. It's intended 
to be run over a collection of compile commands, which we actively avoid via 
`SingleCommandCompilationDatabase`. It automatically injects `-fsyntax-only` 
and other flags, which we avoid by calling `clearArgumentsAdjusters()`. It 
deduces the resource directory based on the current executable path, which we'd 
like to change to deducing from `argv[0]`.

Internally, `ClangTool` uses `ToolInvocation` which seems to be more in line 
with what the dependency scanner tries to achieve. This patch switches to 
directly using `ToolInvocation` instead. NFC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108979

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -309,17 +309,24 @@
 const std::string , StringRef WorkingDirectory,
 const CompilationDatabase , DependencyConsumer ) {
   RealFS->setCurrentWorkingDirectory(WorkingDirectory);
+
+  llvm::IntrusiveRefCntPtr CurrentFiles =
+  Files ? Files : new FileManager(FileSystemOptions(), RealFS);
+
+  // FIXME: Avoid this copy.
+  std::vector CompileCommands = CDB.getCompileCommands(Input);
+  const std::vector  =
+  CompileCommands.front().CommandLine;
+
   return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer ) {
-/// Create the tool that uses the underlying file system to ensure that any
-/// file system requests that are made by the driver do not go through the
-/// dependency scanning filesystem.
-tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS, Files);
-Tool.clearArgumentsAdjusters();
-Tool.setRestoreWorkingDir(false);
-Tool.setPrintErrorMessage(false);
-Tool.setDiagnosticConsumer();
 DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
 PPSkipMappings.get(), Format);
-return !Tool.run();
+// Create an invocation that uses the underlying file system to ensure that
+// any file system requests that are made by the driver do not go through
+// the dependency scanning filesystem.
+ToolInvocation Invocation(CommandLine, , CurrentFiles.get(),
+  PCHContainerOps);
+Invocation.setDiagnosticConsumer();
+return Invocation.run();
   });
 }


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -309,17 +309,24 @@
 const std::string , StringRef WorkingDirectory,
 const CompilationDatabase , DependencyConsumer ) {
   RealFS->setCurrentWorkingDirectory(WorkingDirectory);
+
+  llvm::IntrusiveRefCntPtr CurrentFiles =
+  Files ? Files : new FileManager(FileSystemOptions(), RealFS);
+
+  // FIXME: Avoid this copy.
+  std::vector CompileCommands = CDB.getCompileCommands(Input);
+  const std::vector  =
+  CompileCommands.front().CommandLine;
+
   return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer ) {
-/// Create the tool that uses the underlying file system to ensure that any
-/// file system requests that are made by the driver do not go through the
-/// dependency scanning filesystem.
-tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS, Files);
-Tool.clearArgumentsAdjusters();
-Tool.setRestoreWorkingDir(false);
-Tool.setPrintErrorMessage(false);
-Tool.setDiagnosticConsumer();
 DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
 PPSkipMappings.get(), Format);
-return !Tool.run();
+// Create an invocation that uses the underlying file system to ensure that
+// any file system requests that are made by the driver do not go through
+// the dependency scanning filesystem.
+ToolInvocation Invocation(CommandLine, , CurrentFiles.get(),
+  PCHContainerOps);
+Invocation.setDiagnosticConsumer();
+return Invocation.run();
   });
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97699: [analyzer] Add InvalidPtrChecker

2021-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.

I think it looks good, I don't have much objection to this.
I've also participated in the offline-review of this patch, so the current 
shape of this reflects my intentions, thus I resign.
At the same time, I'm requesting others to have a look at this, I genuinely 
think it has great value!
@Szelethus @martong @NoQ

Note: I'd like to highlight that on not modeled functions it behaves slightly 
differently than expected.


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

https://reviews.llvm.org/D97699

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


[clang] f9bc1b3 - [OpenCL] Defines helper function for kernel language compatible OpenCL version

2021-08-31 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-08-31T10:08:38+01:00
New Revision: f9bc1b3bee557de5735c745f9558c47ca568bd96

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

LOG: [OpenCL] Defines helper function for kernel language compatible OpenCL 
version

This change defines a helper function getOpenCLCompatibleVersion()
inside LangOptions class. The function contains mapping between
C++ for OpenCL versions and their corresponding compatible OpenCL
versions. This mapping function should be updated each time a new
C++ for OpenCL language version is introduced. The helper function
is expected to simplify conditions on OpenCL C and C++ for OpenCL
versions inside compiler code.

Code refactoring performed.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/OpenCLOptions.h
clang/lib/Basic/Builtins.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index ea6a792f0598..43e33c7029b8 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -444,6 +444,9 @@ class LangOptions : public LangOptionsBase {
   /// Return the OpenCL C or C++ version as a VersionTuple.
   VersionTuple getOpenCLVersionTuple() const;
 
+  /// Return the OpenCL version that kernel language is compatible with
+  unsigned getOpenCLCompatibleVersion() const;
+
   /// Return the OpenCL C or C++ for OpenCL language name and version
   /// as a string.
   std::string getOpenCLVersionString() const;

diff  --git a/clang/include/clang/Basic/OpenCLOptions.h 
b/clang/include/clang/Basic/OpenCLOptions.h
index 1a035626fade..4bc568802584 100644
--- a/clang/include/clang/Basic/OpenCLOptions.h
+++ b/clang/include/clang/Basic/OpenCLOptions.h
@@ -58,7 +58,7 @@ static inline OpenCLVersionID encodeOpenCLVersion(unsigned 
OpenCLVersion) {
 // mask.
 static inline bool isOpenCLVersionContainedInMask(const LangOptions ,
   unsigned Mask) {
-  auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
+  auto CLVer = LO.getOpenCLCompatibleVersion();
   OpenCLVersionID Code = encodeOpenCLVersion(CLVer);
   return Mask & Code;
 }
@@ -79,7 +79,7 @@ class OpenCLOptions {
   // the __opencl_c_program_scope_global_variables feature is supported
   // C++ for OpenCL inherits rule from OpenCL C v2.0.
   bool areProgramScopeVariablesSupported(const LangOptions ) const {
-return Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200 ||
+return Opts.getOpenCLCompatibleVersion() == 200 ||
(Opts.OpenCLVersion == 300 &&
 isSupported("__opencl_c_program_scope_global_variables", Opts));
   }
@@ -115,8 +115,7 @@ class OpenCLOptions {
 // Is option available in OpenCL version \p LO.
 bool isAvailableIn(const LangOptions ) const {
   // In C++ mode all extensions should work at least as in v2.0.
-  auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-  return CLVer >= Avail;
+  return LO.getOpenCLCompatibleVersion() >= Avail;
 }
 
 // Is core option in OpenCL version \p LO.

diff  --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index 7118aa9dc210..2b0f4071662c 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -72,7 +72,7 @@ bool Builtin::Context::builtinIsSupported(const Builtin::Info 
,
   bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
   (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) ==  
OCLC1X_LANG;
   bool OclC2Unsupported =
-  (LangOpts.OpenCLVersion != 200 && !LangOpts.OpenCLCPlusPlus) &&
+  (LangOpts.getOpenCLCompatibleVersion() != 200) &&
   (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG;
   bool OclCUnsupported = !LangOpts.OpenCL &&
  (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);

diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 3e3e7fe3dc15..b6dc73d66304 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -52,6 +52,16 @@ VersionTuple LangOptions::getOpenCLVersionTuple() const {
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 
+unsigned LangOptions::getOpenCLCompatibleVersion() const {
+  if (!OpenCLCPlusPlus)
+return OpenCLVersion;
+  if 

[PATCH] D108693: [OpenCL] Defines helper function for kernel language compatible OpenCL version

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9bc1b3bee55: [OpenCL] Defines helper function for kernel 
language compatible OpenCL version (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108693

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1369,8 +1369,7 @@
 // value being declared, poison it as invalid so we don't get chains of
 // errors.
 declarator.setInvalidType(true);
-  } else if ((S.getLangOpts().OpenCLVersion >= 200 ||
-  S.getLangOpts().OpenCLCPlusPlus) &&
+  } else if (S.getLangOpts().getOpenCLCompatibleVersion() >= 200 &&
  DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
   << DS.getSourceRange();
@@ -5093,7 +5092,7 @@
 "__cl_clang_variadic_functions", S.getLangOpts()) &&
 !(D.getIdentifier() &&
   ((D.getIdentifier()->getName() == "printf" &&
-(LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) ||
+LangOpts.getOpenCLCompatibleVersion() >= 120) ||
D.getIdentifier()->getName().startswith("__" {
   S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function);
   D.setInvalidType(true);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12263,7 +12263,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
+  if (getLangOpts().getOpenCLCompatibleVersion() >= 200) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
@@ -12522,8 +12522,9 @@
/*AllowBoolConversions*/false);
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
-  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
+  if (getLangOpts().OpenCL &&
+  getLangOpts().getOpenCLCompatibleVersion() < 120 &&
+  vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -14974,8 +14975,7 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120 &&
-  !Context.getLangOpts().OpenCLCPlusPlus) {
+  Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->castAs()->getElementType();
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7519,7 +7519,7 @@
 }
 
 static void handleOpenCLNoSVMAttr(Sema , Decl *D, const ParsedAttr ) {
-  if (S.LangOpts.OpenCLVersion < 200 && !S.LangOpts.OpenCLCPlusPlusVersion)
+  if (S.LangOpts.getOpenCLCompatibleVersion() < 200)
 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
 << AL << "2.0" << 1;
   else
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8834,8 +8834,7 @@
 // OpenCL v3.0 s6.11.a:
 // A kernel function argument cannot be declared as a pointer to a pointer
 // type. [...] This restriction only applies to OpenCL C 1.2 or below.
-if (S.getLangOpts().OpenCLVersion <= 120 &&
-!S.getLangOpts().OpenCLCPlusPlus) {
+if (S.getLangOpts().getOpenCLCompatibleVersion() <= 120) {
   S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
   D.setInvalidType();
   return;
@@ -10017,7 +10016,7 @@
 
 // OpenCL 2.0 pipe restrictions forbids pipe packet types to be non-value
 // types.
-if (getLangOpts().OpenCLVersion >= 200 || 

[PATCH] D108976: [clang][tooling] Allow providing custom diagnostic options to ToolInvocation

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 369658.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -265,6 +265,41 @@
   EXPECT_EQ(Consumer.NumErrorsSeen, 0u);
 }
 
+TEST(ToolInvocation, CustomDiagnosticOptionsOverwriteParsedOnes) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+
+  std::vector Args;
+  Args.push_back("tool-executable");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer();
+
+  auto DiagOpts = llvm::makeIntrusiveRefCnt();
+  Invocation.setDiagnosticOptions(&*DiagOpts);
+
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` didn't downgrade the
+  // error into a warning due to being overwritten by custom diagnostic options.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 1u);
+}
+
 struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
   bool SawSourceManager;
 
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,10 +343,17 @@
   for (const std::string  : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Argv);
-  TextDiagnosticPrinter DiagnosticPrinter(
-  llvm::errs(), &*DiagOpts);
+
+  // Parse diagnostic options from the driver command-line only if none were
+  // explicitly set.
+  IntrusiveRefCntPtr ParsedDiagOpts;
+  DiagnosticOptions *DiagOpts = this->DiagOpts;
+  if (!DiagOpts) {
+ParsedDiagOpts = CreateAndPopulateDiagOpts(Argv);
+DiagOpts = &*ParsedDiagOpts;
+  }
+
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
   IntrusiveRefCntPtr Diagnostics =
   CompilerInstance::createDiagnostics(
   &*DiagOpts, DiagConsumer ? DiagConsumer : , false);
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -268,11 +268,17 @@
 
   ~ToolInvocation();
 
-  /// Set a \c DiagnosticConsumer to use during parsing.
+  /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
+  /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
 this->DiagConsumer = DiagConsumer;
   }
 
+  /// Set a \c DiagnosticOptions to use during driver command-line parsing.
+  void setDiagnosticOptions(DiagnosticOptions *DiagOpts) {
+this->DiagOpts = DiagOpts;
+  }
+
   /// Run the clang invocation.
   ///
   /// \returns True if there were no errors during execution.
@@ -290,6 +296,7 @@
   FileManager *Files;
   std::shared_ptr PCHContainerOps;
   DiagnosticConsumer *DiagConsumer = nullptr;
+  DiagnosticOptions *DiagOpts = nullptr;
 };
 
 /// Utility to run a FrontendAction over a set of files.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108974: [clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 369657.
jansvoboda11 added a comment.

XFAIL clang-scan-deps test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108974

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/test/ClangScanDeps/strip_diag_serialize.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -224,6 +224,47 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct ErrorCountingDiagnosticConsumer : public DiagnosticConsumer {
+  ErrorCountingDiagnosticConsumer() : NumErrorsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+if (DiagLevel == DiagnosticsEngine::Level::Error)
+  ++NumErrorsSeen;
+  }
+  unsigned NumErrorsSeen;
+};
+
+TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+
+  std::vector Args;
+  Args.push_back("tool-executable");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer();
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` downgraded the error
+  // into a warning.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 0u);
+}
+
 struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
   bool SawSourceManager;
 
Index: clang/test/ClangScanDeps/strip_diag_serialize.cpp
===
--- clang/test/ClangScanDeps/strip_diag_serialize.cpp
+++ clang/test/ClangScanDeps/strip_diag_serialize.cpp
@@ -1,3 +1,6 @@
+// FIXME: Make this pass again.
+// XFAIL: *
+
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -347,16 +347,16 @@
   CreateAndPopulateDiagOpts(Argv);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
-  DiagnosticsEngine Diagnostics(
-  IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
-  DiagConsumer ? DiagConsumer : , false);
+  IntrusiveRefCntPtr Diagnostics =
+  CompilerInstance::createDiagnostics(
+  &*DiagOpts, DiagConsumer ? DiagConsumer : , false);
   // Although `Diagnostics` are used only for command-line parsing, the custom
   // `DiagConsumer` might expect a `SourceManager` to be present.
-  SourceManager SrcMgr(Diagnostics, *Files);
-  Diagnostics.setSourceManager();
+  SourceManager SrcMgr(*Diagnostics, *Files);
+  Diagnostics->setSourceManager();
 
   const std::unique_ptr Driver(
-  newDriver(, BinaryName, >getVirtualFileSystem()));
+  newDriver(&*Diagnostics, BinaryName, >getVirtualFileSystem()));
   // The "input file not found" diagnostics from the driver are useful.
   // The driver is only aware of the VFS working directory, but some clients
   // change this at the FileManager level instead.
@@ -368,11 +368,11 @@
   if (!Compilation)
 return false;
   const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
-  , Compilation.get());
+  &*Diagnostics, Compilation.get());
   if (!CC1Args)
 return false;
   std::unique_ptr Invocation(
-  newInvocation(, *CC1Args, BinaryName));
+  newInvocation(&*Diagnostics, *CC1Args, BinaryName));
   return runInvocation(BinaryName, Compilation.get(), std::move(Invocation),
std::move(PCHContainerOps));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108976: [clang][tooling] Allow providing custom diagnostic options to ToolInvocation

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch allows the clients of `ToolInvocation` to provide custom diagnostic 
options to be used during driver -> cc1 command-line transformation and parsing.

Depends on D108974 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108976

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -265,6 +265,41 @@
   EXPECT_EQ(Consumer.NumErrorsSeen, 0u);
 }
 
+TEST(ToolInvocation, CustomDiagnosticOptionsOverwriteParsedOnes) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+
+  std::vector Args;
+  Args.push_back("tool-executable");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer();
+
+  auto DiagOpts = llvm::makeIntrusiveRefCnt();
+  Invocation.setDiagnosticOptions(&*DiagOpts);
+
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` didn't downgrade the
+  // error into a warning due to being overwritten by custom diagnostic options.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 1u);
+}
+
 struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
   bool SawSourceManager;
 
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,10 +343,17 @@
   for (const std::string  : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Argv);
-  TextDiagnosticPrinter DiagnosticPrinter(
-  llvm::errs(), &*DiagOpts);
+
+  // Parse diagnostic options from the driver command-line only if none were
+  // explicitly set.
+  IntrusiveRefCntPtr ParsedDiagOpts;
+  DiagnosticOptions *DiagOpts = this->DiagOpts;
+  if (!DiagOpts) {
+ParsedDiagOpts = CreateAndPopulateDiagOpts(Argv);
+DiagOpts = &*ParsedDiagOpts;
+  }
+
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
   IntrusiveRefCntPtr Diagnostics =
   CompilerInstance::createDiagnostics(
   &*DiagOpts, DiagConsumer ? DiagConsumer : , false);
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -268,11 +268,17 @@
 
   ~ToolInvocation();
 
-  /// Set a \c DiagnosticConsumer to use during parsing.
+  /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
+  /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
 this->DiagConsumer = DiagConsumer;
   }
 
+  /// Set a \c DiagnosticOptions to use during driver command-line parsing.
+  void setDiagnosticOptions(DiagnosticOptions *DiagOpts) {
+this->DiagOpts = DiagOpts;
+  }
+
   /// Run the clang invocation.
   ///
   /// \returns True if there were no errors during execution.
@@ -290,6 +296,7 @@
   FileManager *Files;
   std::shared_ptr PCHContainerOps;
   DiagnosticConsumer *DiagConsumer = nullptr;
+  DiagnosticOptions *DiagOpts = nullptr;
 };
 
 /// Utility to run a FrontendAction over a set of files.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108975: [clangd] Omit default template arguments from type hints

2021-08-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108975

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -602,6 +602,16 @@
   )cpp");
 }
 
+TEST(TypeHints, DefaultTemplateArgs) {
+  assertTypeHints(R"cpp(
+template 
+struct A {};
+A foo();
+auto $var[[var]] = foo();
+  )cpp",
+  ExpectedHint{": A", "var"});
+}
+
 // FIXME: Low-hanging fruit where we could omit a type hint:
 //  - auto x = TypeName(...);
 //  - auto x = (TypeName) (...);
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -24,7 +24,8 @@
   : Results(Results), AST(AST.getASTContext()),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()),
+StructuredBindingPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, );
@@ -33,14 +34,16 @@
 TypeHintPolicy.SuppressScope = true; // keep type names short
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
-// Print canonical types. Otherwise, SuppressScope would result in
-// things like "metafunction::type" being shorted to just "type",
-// which is useless. This is particularly important for structured
-// bindings that use the tuple_element protocol, where the non-canonical
-// types would be "tuple_element::type".
-// Note, for "auto", we would often prefer sugared types, but the AST
-// doesn't currently retain them in DeducedType anyways.
-TypeHintPolicy.PrintCanonicalTypes = true;
+
+// For structured bindings, print canonical types. This is important 
because
+// for bindings that use the tuple_element protocol, the non-canonical 
types
+// would be "tuple_element::type".
+// For "auto", we often prefer sugared types, but the AST doesn't currently
+// retain them in DeducedType. However, not setting PrintCanonicalTypes for
+// "auto" at least allows SuppressDefaultTemplateArgs (set by default) to
+// have an effect.
+StructuredBindingPolicy = TypeHintPolicy;
+StructuredBindingPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@@ -98,7 +101,8 @@
 // but show hints for the individual bindings.
 if (auto *DD = dyn_cast(D)) {
   for (auto *Binding : DD->bindings()) {
-addTypeHint(Binding->getLocation(), Binding->getType(), ": ");
+addTypeHint(Binding->getLocation(), Binding->getType(), ": ",
+StructuredBindingPolicy);
   }
   return true;
 }
@@ -327,11 +331,16 @@
   }
 
   void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
+addTypeHint(R, T, Prefix, TypeHintPolicy);
+  }
+
+  void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
+   const PrintingPolicy ) {
 // Do not print useless "NULL TYPE" hint.
 if (!T.getTypePtrOrNull())
   return;
 
-std::string TypeName = T.getAsString(TypeHintPolicy);
+std::string TypeName = T.getAsString(Policy);
 if (TypeName.length() < TypeNameLimit)
   addInlayHint(R, InlayHintKind::TypeHint, std::string(Prefix) + TypeName);
   }
@@ -342,6 +351,7 @@
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
   PrintingPolicy TypeHintPolicy;
+  PrintingPolicy StructuredBindingPolicy;
 
   static const size_t TypeNameLimit = 32;
 };


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -602,6 +602,16 @@
   )cpp");
 }
 
+TEST(TypeHints, DefaultTemplateArgs) {
+  assertTypeHints(R"cpp(
+template 
+struct A {};
+A foo();
+auto $var[[var]] = foo();
+  )cpp",
+  ExpectedHint{": A", "var"});
+}
+
 // FIXME: Low-hanging fruit where we could omit a type hint:
 //  - auto x = TypeName(...);
 //  - auto x = (TypeName) (...);
Index: clang-tools-extra/clangd/InlayHints.cpp

[PATCH] D108974: [clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In `ToolInvocation::run`, the driver -> cc1 command-line transformation uses 
`DiagnosticsEngine` that wasn't completely initialized. This patch ensures 
`ProcessWarningOptions(DiagnosticsEngine&, const DiagnosticOptions &)` is 
called.

Depends on D108918 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108974

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -224,6 +224,47 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct ErrorCountingDiagnosticConsumer : public DiagnosticConsumer {
+  ErrorCountingDiagnosticConsumer() : NumErrorsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+if (DiagLevel == DiagnosticsEngine::Level::Error)
+  ++NumErrorsSeen;
+  }
+  unsigned NumErrorsSeen;
+};
+
+TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+
+  std::vector Args;
+  Args.push_back("tool-executable");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer();
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` downgraded the error
+  // into a warning.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 0u);
+}
+
 struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
   bool SawSourceManager;
 
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -347,16 +347,16 @@
   CreateAndPopulateDiagOpts(Argv);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
-  DiagnosticsEngine Diagnostics(
-  IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
-  DiagConsumer ? DiagConsumer : , false);
+  IntrusiveRefCntPtr Diagnostics =
+  CompilerInstance::createDiagnostics(
+  &*DiagOpts, DiagConsumer ? DiagConsumer : , false);
   // Although `Diagnostics` are used only for command-line parsing, the custom
   // `DiagConsumer` might expect a `SourceManager` to be present.
-  SourceManager SrcMgr(Diagnostics, *Files);
-  Diagnostics.setSourceManager();
+  SourceManager SrcMgr(*Diagnostics, *Files);
+  Diagnostics->setSourceManager();
 
   const std::unique_ptr Driver(
-  newDriver(, BinaryName, >getVirtualFileSystem()));
+  newDriver(&*Diagnostics, BinaryName, >getVirtualFileSystem()));
   // The "input file not found" diagnostics from the driver are useful.
   // The driver is only aware of the VFS working directory, but some clients
   // change this at the FileManager level instead.
@@ -368,11 +368,11 @@
   if (!Compilation)
 return false;
   const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
-  , Compilation.get());
+  &*Diagnostics, Compilation.get());
   if (!CC1Args)
 return false;
   std::unique_ptr Invocation(
-  newInvocation(, *CC1Args, BinaryName));
+  newInvocation(&*Diagnostics, *CC1Args, BinaryName));
   return runInvocation(BinaryName, Compilation.get(), std::move(Invocation),
std::move(PCHContainerOps));
 }


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -224,6 +224,47 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct ErrorCountingDiagnosticConsumer : public DiagnosticConsumer {
+  ErrorCountingDiagnosticConsumer() : NumErrorsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic 

[PATCH] D108765: [docs] Fix documentation of clang-format BasedOnStyle type

2021-08-31 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

  error: pathspec './plurals.txt' did not match any file(s) known to git
  Traceback (most recent call last):
File "./dump_format_style.py", line 18, in 
  subprocess.check_call(['git', 'checkout', '--', PLURAL_FILE])
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
  raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['git', 'checkout', '--', 
'./plurals.txt']' returned non-zero exit status 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108765

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


[PATCH] D108765: [docs] Fix documentation of clang-format BasedOnStyle type

2021-08-31 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:9
 import re
+import inspect
+import subprocess

FederAndInk wrote:
> HazardyKnusperkeks wrote:
> > I think these should be sorted.
> ok, it will be done
are these standard imports or are we going to have to pip install something?



Comment at: clang/docs/tools/dump_format_style.py:18
+PLURAL_FILE = os.path.join(os.path.dirname(__file__), 'plurals.txt')
+subprocess.check_call(['git', 'checkout', '--', PLURAL_FILE])
+plurals = set(open(PLURAL_FILE).read().splitlines())

FederAndInk wrote:
> HazardyKnusperkeks wrote:
> > So you would add a plurals.txt in git and make the change visible through 
> > git diff? What about just reordering? I.e. `Strings` is on line 2, but 
> > after a change in line 1. Maybe sort the output?
> > 
> > I'm not against this procedure, but also not in favor. :)
> This line is used to restore the version of plurals.txt to HEAD, so when 
> calling the script multiple times, it keeps showing new plurals until 
> plurals.txt gets committed.
> 
> > So you would add a plurals.txt in git and make the change visible through 
> > git diff?
> 
> yes, that's it
> 
> > What about just reordering?
> 
> I don't think we want ordering, it is ordered from first plural generated to 
> last/new one, so git diff will only show new plurals
I'm personally not in favour of this script calling back to git


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108765

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


[PATCH] D108818: [clang] Add a -canonical-prefixes option

2021-08-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.

LGTM


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

https://reviews.llvm.org/D108818

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


[PATCH] D108972: [clangd] Omit type hints that are too long

2021-08-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

(The relevant issue is https://github.com/clangd/clangd/issues/824_


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108972

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


[PATCH] D108972: [clangd] Omit type hints that are too long

2021-08-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:346
+
+  static const size_t TypeNameLimit = 32;
 };

I'm open to suggestions for what the length limit should be, here I made a 
fairly arbitrary choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108972

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


[PATCH] D108972: [clangd] Omit type hints that are too long

2021-08-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108972

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -591,6 +591,17 @@
   )cpp");
 }
 
+TEST(TypeHints, LongTypeName) {
+  assertTypeHints(R"cpp(
+template 
+struct A {};
+struct MultipleWords {};
+A foo();
+// Omit type hint past a certain length (currently 32)
+auto var = foo();
+  )cpp");
+}
+
 // FIXME: Low-hanging fruit where we could omit a type hint:
 //  - auto x = TypeName(...);
 //  - auto x = (TypeName) (...);
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -331,8 +331,9 @@
 if (!T.getTypePtrOrNull())
   return;
 
-addInlayHint(R, InlayHintKind::TypeHint,
- std::string(Prefix) + T.getAsString(TypeHintPolicy));
+std::string TypeName = T.getAsString(TypeHintPolicy);
+if (TypeName.length() < TypeNameLimit)
+  addInlayHint(R, InlayHintKind::TypeHint, std::string(Prefix) + TypeName);
   }
 
   std::vector 
@@ -341,6 +342,8 @@
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
   PrintingPolicy TypeHintPolicy;
+
+  static const size_t TypeNameLimit = 32;
 };
 
 std::vector inlayHints(ParsedAST ) {


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -591,6 +591,17 @@
   )cpp");
 }
 
+TEST(TypeHints, LongTypeName) {
+  assertTypeHints(R"cpp(
+template 
+struct A {};
+struct MultipleWords {};
+A foo();
+// Omit type hint past a certain length (currently 32)
+auto var = foo();
+  )cpp");
+}
+
 // FIXME: Low-hanging fruit where we could omit a type hint:
 //  - auto x = TypeName(...);
 //  - auto x = (TypeName) (...);
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -331,8 +331,9 @@
 if (!T.getTypePtrOrNull())
   return;
 
-addInlayHint(R, InlayHintKind::TypeHint,
- std::string(Prefix) + T.getAsString(TypeHintPolicy));
+std::string TypeName = T.getAsString(TypeHintPolicy);
+if (TypeName.length() < TypeNameLimit)
+  addInlayHint(R, InlayHintKind::TypeHint, std::string(Prefix) + TypeName);
   }
 
   std::vector 
@@ -341,6 +342,8 @@
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
   PrintingPolicy TypeHintPolicy;
+
+  static const size_t TypeNameLimit = 32;
 };
 
 std::vector inlayHints(ParsedAST ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77470: [clang] NFC: Fix trivial typo in comments and document

2021-08-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM, Thank!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77470

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


[PATCH] D105269: [X86] AVX512FP16 instructions enabling 6/6

2021-08-31 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:3902
+  case X86::VFCMADDCSHZr:
+  case X86::VFCMADDCSHZrb:
+  case X86::VFCMADDCSHZrbk:

pengfei wrote:
> LuoYuanke wrote:
> > "b" means rounding. Right?
> broadcasting
Sorry, my mistake. Here `b` supposes to represent `EVEX.b` bit in the encoding.
It's used as broadcast control only in memory variants in vector instructions.
When it is used in register variants, it enables rounding control and SAE.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105269

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


[PATCH] D106343: [OpenCL] Support cl_ext_float_atomics

2021-08-31 Thread Yang Haonan via Phabricator via cfe-commits
haonanya added a comment.

Hi, svenvh and Anastasia. If you approve the patch, could you please submit it?
I don't have permission to do it.


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

https://reviews.llvm.org/D106343

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


[PATCH] D98254: Fix typo in two files in Clang

2021-08-31 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe01ac501af20: Fix typo in two files in Clang, patch by 
FusionBolt (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98254

Files:
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Interp.h


Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -38,7 +38,7 @@
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
-/// Convers a value to an APValue.
+/// Convert a value to an APValue.
 template  bool ReturnValue(const T , APValue ) {
   R = V.toAPValue();
   return true;
@@ -50,7 +50,7 @@
 /// Checks if the array is offsetable.
 bool CheckArray(InterpState , CodePtr OpPC, const Pointer );
 
-/// Checks if a pointer is live and accesible.
+/// Checks if a pointer is live and accessible.
 bool CheckLive(InterpState , CodePtr OpPC, const Pointer ,
AccessKinds AK);
 /// Checks if a pointer is null.
Index: clang/lib/AST/Interp/Context.h
===
--- clang/lib/AST/Interp/Context.h
+++ clang/lib/AST/Interp/Context.h
@@ -67,7 +67,7 @@
   /// Runs a function.
   bool Run(State , Function *Func, APValue );
 
-  /// Checks a result fromt the interpreter.
+  /// Checks a result from the interpreter.
   bool Check(State , llvm::Expected &);
 
 private:


Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -38,7 +38,7 @@
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
-/// Convers a value to an APValue.
+/// Convert a value to an APValue.
 template  bool ReturnValue(const T , APValue ) {
   R = V.toAPValue();
   return true;
@@ -50,7 +50,7 @@
 /// Checks if the array is offsetable.
 bool CheckArray(InterpState , CodePtr OpPC, const Pointer );
 
-/// Checks if a pointer is live and accesible.
+/// Checks if a pointer is live and accessible.
 bool CheckLive(InterpState , CodePtr OpPC, const Pointer ,
AccessKinds AK);
 /// Checks if a pointer is null.
Index: clang/lib/AST/Interp/Context.h
===
--- clang/lib/AST/Interp/Context.h
+++ clang/lib/AST/Interp/Context.h
@@ -67,7 +67,7 @@
   /// Runs a function.
   bool Run(State , Function *Func, APValue );
 
-  /// Checks a result fromt the interpreter.
+  /// Checks a result from the interpreter.
   bool Check(State , llvm::Expected &);
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e01ac50 - Fix typo in two files in Clang, patch by FusionBolt

2021-08-31 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2021-08-31T12:33:37+05:30
New Revision: e01ac501af20cdbbc199f4f4ac3e6d705442

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

LOG: Fix typo in two files in Clang, patch by FusionBolt

Reviewed By: xgupta

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

Added: 


Modified: 
clang/lib/AST/Interp/Context.h
clang/lib/AST/Interp/Interp.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Context.h b/clang/lib/AST/Interp/Context.h
index e8238eea716a1..4f25ff977b81d 100644
--- a/clang/lib/AST/Interp/Context.h
+++ b/clang/lib/AST/Interp/Context.h
@@ -67,7 +67,7 @@ class Context {
   /// Runs a function.
   bool Run(State , Function *Func, APValue );
 
-  /// Checks a result fromt the interpreter.
+  /// Checks a result from the interpreter.
   bool Check(State , llvm::Expected &);
 
 private:

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index d7f9653be2e62..a1d90f26ba464 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -38,7 +38,7 @@ namespace interp {
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
-/// Convers a value to an APValue.
+/// Convert a value to an APValue.
 template  bool ReturnValue(const T , APValue ) {
   R = V.toAPValue();
   return true;
@@ -50,7 +50,7 @@ bool CheckExtern(InterpState , CodePtr OpPC, const Pointer 
);
 /// Checks if the array is offsetable.
 bool CheckArray(InterpState , CodePtr OpPC, const Pointer );
 
-/// Checks if a pointer is live and accesible.
+/// Checks if a pointer is live and accessible.
 bool CheckLive(InterpState , CodePtr OpPC, const Pointer ,
AccessKinds AK);
 /// Checks if a pointer is null.



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


[PATCH] D98254: Fix typo in two files in Clang

2021-08-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98254

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


[PATCH] D102836: [clang] Fix Typo in AST Matcher Reference

2021-08-31 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a6d8a11f89b: [clang] Fix Typo in AST Matcher Reference 
(authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102836

Files:
  clang/docs/LibASTMatchersReference.html


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -7463,7 +7463,7 @@
 }
   }
 
-cxxRcordDecl(hasDeclContext(namedDecl(hasName("M" matches the
+cxxRecordDecl(hasDeclContext(namedDecl(hasName("M" matches the
 declaration of class D.
 
 


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -7463,7 +7463,7 @@
 }
   }
 
-cxxRcordDecl(hasDeclContext(namedDecl(hasName("M" matches the
+cxxRecordDecl(hasDeclContext(namedDecl(hasName("M" matches the
 declaration of class D.
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4a6d8a1 - [clang] Fix Typo in AST Matcher Reference

2021-08-31 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2021-08-31T12:21:47+05:30
New Revision: 4a6d8a11f89b9eae984e1b9608c1c010dc6a037b

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

LOG: [clang] Fix Typo in AST Matcher Reference

In [[ https://clang.llvm.org/docs/LibASTMatchersReference.html | AST Matcher 
Reference]], the example of matcher `hasDeclContext` contained a typo.

`cxxRcordDecl` was changed to `cxxRecordDecl`.

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index e2df4f236139b..73b8a4fcafe51 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -7463,7 +7463,7 @@ AST Traversal Matchers
 }
   }
 
-cxxRcordDecl(hasDeclContext(namedDecl(hasName("M" matches the
+cxxRecordDecl(hasDeclContext(namedDecl(hasName("M" matches the
 declaration of class D.
 
 



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


[PATCH] D102836: [clang] Fix Typo in AST Matcher Reference

2021-08-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102836

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2021-08-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@rsmith - would it make sense to disable preferred names use when 
`PrintingPolicy::PrintCanonicalTypes` is used? It's used in `CGDebugInfo`, but 
also in `Sema::findFailedBooleanCondition` - so maybe we need another 
`PrintingPolicy` flag for this so `CGDebugInfo` can use the flag, but 
`Sema::findFailedBooleanCondition` can keep using preferred names?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D108886: Add RISC-V sifive-s51 cpu

2021-08-31 Thread Alexander Pivovarov via Phabricator via cfe-commits
apivovarov updated this revision to Diff 369635.
apivovarov added a comment.

update the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108886

Files:
  clang/test/Driver/riscv-cpus.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/lib/Target/RISCV/RISCV.td


Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -254,6 +254,11 @@
  FeatureStdExtA,
  FeatureStdExtC]>;
 
+def : ProcessorModel<"sifive-s51", RocketModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtC]>;
+
 def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit,
  FeatureStdExtM,
  FeatureStdExtA,
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- llvm/include/llvm/Support/RISCVTargetParser.def
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -20,6 +20,7 @@
 PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""})
 PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""})
 PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
+PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
 PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -45,6 +45,13 @@
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=sifive-7-series | 
FileCheck -check-prefix=MTUNE-SIFIVE7-SERIES-64 %s
 // MTUNE-SIFIVE7-SERIES-64: "-tune-cpu" "sifive-7-rv64"
 
+// mcpu with mabi option
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-s51 -mabi=lp64 | 
FileCheck -check-prefix=MCPU-ABI-SIFIVE-S51 %s
+// MCPU-ABI-SIFIVE-S51: "-nostdsysteminc" "-target-cpu" "sifive-s51"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+c" "-target-feature" "+64bit"
+// MCPU-ABI-SIFIVE-S51: "-target-abi" "lp64"
+
 // mcpu with default march
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck 
-check-prefix=MCPU-SIFIVE-U54 %s
 // MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54"


Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -254,6 +254,11 @@
  FeatureStdExtA,
  FeatureStdExtC]>;
 
+def : ProcessorModel<"sifive-s51", RocketModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtC]>;
+
 def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit,
  FeatureStdExtM,
  FeatureStdExtA,
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- llvm/include/llvm/Support/RISCVTargetParser.def
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -20,6 +20,7 @@
 PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""})
 PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""})
 PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
+PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
 PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -45,6 +45,13 @@
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=sifive-7-series | FileCheck -check-prefix=MTUNE-SIFIVE7-SERIES-64 %s
 // MTUNE-SIFIVE7-SERIES-64: "-tune-cpu" "sifive-7-rv64"
 
+// mcpu with mabi option
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-s51 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-S51 %s
+// MCPU-ABI-SIFIVE-S51: "-nostdsysteminc" "-target-cpu" "sifive-s51"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
+// MCPU-ABI-SIFIVE-S51: "-target-feature" "+c" "-target-feature" "+64bit"
+// MCPU-ABI-SIFIVE-S51: 

[PATCH] D101935: [clang] Search runtimes build tree for openmp runtime

2021-08-31 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield planned changes to this revision.
JonChesterfield added a comment.

Yeah, we probably can't leave the installed program with a search path only 
used for testing. I'm planning to revisit this to use 
libomptarget_amdgcn_bc_path instead of LIBRARY_PATH for testing, then drop the 
LIBRARY_PATH override.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101935

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