[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 278658.
jdenny added a comment.

Rebased onto latest D83922 .

Implemented rejection of `present` if not OpenMP >= 5.1.

Cleaned up tests some.


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

https://reviews.llvm.org/D83061

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_ast_print.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp

Index: clang/test/OpenMP/target_teams_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_map_messages.cpp
+++ clang/test/OpenMP/target_teams_map_messages.cpp
@@ -468,7 +468,7 @@
 
 #pragma omp target data map(always, tofrom: x)
 #pragma omp target data map(always: x) // expected-error {{missing map type}}
-#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   foo();
@@ -543,7 +543,7 @@
 
 #pragma omp target data map(always, tofrom: x)
 #pragma omp target data map(always: x) // expected-error {{missing map type}}
-#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   foo();
Index: clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
@@ -175,7 +175,7 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always: x) // expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always, tofrom: always, tofrom, x)
   for (i = 0; i < argc; ++i) foo();
@@ -287,7 +287,7 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always: x) // expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always, tofrom: always, tofrom, x)
   for (i = 0; i < argc; ++i) foo();
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
+++ 

[PATCH] D83999: [CMake][Fuchsia] Include additional tools in the toolchain

2020-07-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: leonardchan.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

These are needed on Windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83999

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -233,14 +233,17 @@
   llvm-ar
   llvm-cov
   llvm-cxxfilt
+  llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
   llvm-gsymutil
   llvm-lib
+  llvm-mt
   llvm-nm
   llvm-objcopy
   llvm-objdump
   llvm-profdata
+  llvm-rc
   llvm-ranlib
   llvm-readelf
   llvm-readobj


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -233,14 +233,17 @@
   llvm-ar
   llvm-cov
   llvm-cxxfilt
+  llvm-dlltool
   llvm-dwarfdump
   llvm-dwp
   llvm-gsymutil
   llvm-lib
+  llvm-mt
   llvm-nm
   llvm-objcopy
   llvm-objdump
   llvm-profdata
+  llvm-rc
   llvm-ranlib
   llvm-readelf
   llvm-readobj
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83997: [os_log] Improve the way we extend the lifetime of objects passed to __builtin_os_log_format

2020-07-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous, martong.
Herald added a reviewer: shafik.

This patch fixes several shortcomings of the way we currently extend the 
lifetime of objects passed to calls to __builtin_os_log_format:

- Sema doesn't diagnose code that jumps into or out of the scope of a 
lifetime-extended object.
- Lifetime of objects in comma operators or expressions for ObjC property 
access isn't extended.
- We extend the lifetime of an object by emitting an extra pair of retain and 
release calls instead of delaying the release call.
- Calls to clang.arc.use are emitted on exception paths even though they are 
needed only on normal paths.

rdar://problem/62610583


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83997

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-objc-arc-json.m
  clang/test/AST/ast-dump-stmt.m
  clang/test/CodeGenObjC/os_log.m
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/PCH/Inputs/arc.h
  clang/test/PCH/arc.m
  clang/test/SemaObjC/format-strings-oslog.m

Index: clang/test/SemaObjC/format-strings-oslog.m
===
--- clang/test/SemaObjC/format-strings-oslog.m
+++ clang/test/SemaObjC/format-strings-oslog.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
 
 #include 
 #include 
@@ -6,6 +6,7 @@
 #include  // For wint_t and wchar_t
 
 int printf(const char *restrict, ...);
+id getObj(void);
 
 @interface NSString
 @end
@@ -67,3 +68,38 @@
   MyOSLog("%d");// expected-warning {{more '%' conversions than data arguments}}
   MyOSLog("%P", p); // expected-warning {{using '%P' format specifier without precision}}
 }
+
+void test_arc_extended_lifetime0(int cond, void *buf) {
+  switch (cond) {
+  case 0:
+__builtin_os_log_format(buf, @"%@", getObj()); // expected-note {{jump enters lifetime of an object}}
+break;
+  default: // expected-error {{cannot jump from switch statement to this case label}}
+break;
+  }
+}
+
+void test_arc_extended_lifetime1(int cond, void *buf, id a) {
+  switch (cond) {
+  case 0:
+__builtin_os_log_format(buf, @"%@", a);
+break;
+  default:
+break;
+  }
+}
+
+void test_arc_extended_lifetime2(int cond, void *buf) {
+  static void *ips[] = {&};
+L0: // expected-note {{possible target of indirect goto}}
+;
+  __builtin_os_log_format(buf, @"%@", getObj()); // expected-note {{jump exits lifetime of an object}}
+  goto *ips; // expected-error {{cannot jump}}
+}
+
+void test_arc_extended_lifetime3(int cond, void *buf, id a) {
+  static void *ips[] = {&};
+L0:;
+  __builtin_os_log_format(buf, @"%@", a);
+  goto *ips;
+}
Index: clang/test/PCH/arc.m
===
--- clang/test/PCH/arc.m
+++ clang/test/PCH/arc.m
@@ -4,7 +4,7 @@
 
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -x objective-c-header -o %t %S/Inputs/arc.h
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s 
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -emit-llvm -o - %s | FileCheck %s
 
 // Test error when pch's -fobjc-arc state is different.
 // RUN: not %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=CHECK-ERR1 %s 
@@ -16,3 +16,15 @@
 
 // CHECK-ERR1: Objective-C automated reference counting was enabled in PCH file but is currently disabled
 // CHECK-ERR2: Objective-C automated reference counting was disabled in PCH file but is currently enabled
+
+// CHECK: define internal void @callBuiltinOSLogFormat(
+// CHECK: %[[CALL:.*]] = call i8* @getObj()
+// CHECK: %[[V1:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[CALL]])
+// CHECK: %[[V2:.*]] = ptrtoint i8* %[[V1]] to i64
+// CHECK: call void @__os_log_helper_1_2_1_8_64(i8* %{{.*}}, i64 %[[V2]])
+// CHECK: call void @os_log_pack_send(
+// CHECK: call void @llvm.objc.release(i8* %[[V1]])
+
+void testBuiltinOSLogFormat(void) {
+  callBuiltinOSLogFormat(0);
+}
Index: 

[clang] 8ef9e2b - Revert "[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked."

2020-07-16 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-16T18:06:37-07:00
New Revision: 8ef9e2bf355d05bc81d8b0fe1e5333eec59a0a91

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

LOG: Revert "[libFuzzer] Link libFuzzer's own interceptors when other compiler 
runtimes are not linked."

This causes binaries linked with this runtime to crash on startup if
dlsym uses any of the intercepted functions. (For example, that happens
when using tcmalloc as the allocator: dlsym attempts to allocate memory
with malloc, and tcmalloc uses strncmp within its implementation.)

Also revert dependent commit "[libFuzzer] Disable implicit builtin knowledge 
about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

This reverts commit f78d9fceea736d431e9e3cbca291e3909e3aa46d and 
12d1124c49beec0fb79d36944960e5bf0f236d4c.

Added: 


Modified: 
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
compiler-rt/lib/fuzzer/CMakeLists.txt
compiler-rt/test/fuzzer/memcmp.test
compiler-rt/test/fuzzer/memcmp64.test
compiler-rt/test/fuzzer/strcmp.test
compiler-rt/test/fuzzer/strncmp.test
compiler-rt/test/fuzzer/strstr.test

Removed: 
compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp



diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index 563d6c3ff9de..934dab808e82 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -74,7 +74,6 @@ class SanitizerArgs {
!Sanitizers.has(SanitizerKind::Address) &&
!Sanitizers.has(SanitizerKind::HWAddress);
   }
-  bool needsFuzzerInterceptors() const;
   bool needsUbsanRt() const;
   bool requiresMinimalRuntime() const { return MinimalRuntime; }
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 4af24662ca91..bcc9ffc7ff8f 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -240,10 +240,6 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver ,
   return TrappingKinds;
 }
 
-bool SanitizerArgs::needsFuzzerInterceptors() const {
-  return needsFuzzer() && !needsAsanRt() && !needsTsanRt() && !needsMsanRt();
-}
-
 bool SanitizerArgs::needsUbsanRt() const {
   // All of these include ubsan.
   if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() ||
@@ -1088,22 +1084,6 @@ void SanitizerArgs::addArgs(const ToolChain , const 
llvm::opt::ArgList ,
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
-  // libFuzzer wants to intercept calls to certain library functions, so the
-  // following -fno-builtin-* flags force the compiler to emit interposable
-  // libcalls to these functions. Other sanitizers effectively do the same 
thing
-  // by marking all library call sites with NoBuiltin attribute in their LLVM
-  // pass. (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
-  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
-CmdArgs.push_back("-fno-builtin-memcmp");
-CmdArgs.push_back("-fno-builtin-strncmp");
-CmdArgs.push_back("-fno-builtin-strcmp");
-CmdArgs.push_back("-fno-builtin-strncasecmp");
-CmdArgs.push_back("-fno-builtin-strcasecmp");
-CmdArgs.push_back("-fno-builtin-strstr");
-CmdArgs.push_back("-fno-builtin-strcasestr");
-CmdArgs.push_back("-fno-builtin-memmem");
-  }
-
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.
   if (Sanitizers.hasOneOf(CFIClasses) && !TC.getTriple().isOSWindows() &&

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index acde6d9e2111..6b6e276b8ce7 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -784,9 +784,6 @@ bool tools::addSanitizerRuntimes(const ToolChain , const 
ArgList ,
   !Args.hasArg(options::OPT_shared)) {
 
 addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
-if (SanArgs.needsFuzzerInterceptors())
-  addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer_interceptors", false,
-  true);
 if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   }

diff  --git a/compiler-rt/lib/fuzzer/CMakeLists.txt 
b/compiler-rt/lib/fuzzer/CMakeLists.txt
index 02be89cb70a5..b5be6b89452e 100644
--- a/compiler-rt/lib/fuzzer/CMakeLists.txt
+++ b/compiler-rt/lib/fuzzer/CMakeLists.txt
@@ -99,13 +99,6 @@ add_compiler_rt_object_libraries(RTfuzzer_main
   CFLAGS ${LIBFUZZER_CFLAGS}
   DEPS ${LIBFUZZER_DEPS})
 

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-16 Thread walter erquinigo via Phabricator via cfe-commits
wallace added a comment.

@clayborg, the tests will fail on linux because the Makefile is expecting a 
.dsym file. I think it's okay if she does it just for Darwin and then I update 
the test to cover also linux, as I have my linux already well set up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-16 Thread Greg Clayton via Phabricator via cfe-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So you should revert any clang format changes that are not in modified lines of 
source, mostly revert a lot of lines in lldb-vscode.cpp.




Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:19
 
-
-@skipIfWindows
-@skipUnlessDarwin
-@skipIfRemote
-def test_modules_event(self):
-program_basename = "a.out.stripped"
+def get_modules(self, program_basename):
 program= self.getBuildArtifact(program_basename)

Name should be more descriptive. Maybe "setup_test_common" is a better name



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:19
 
-
-@skipIfWindows
-@skipUnlessDarwin
-@skipIfRemote
-def test_modules_event(self):
-program_basename = "a.out.stripped"
+def get_modules(self, program_basename):
 program= self.getBuildArtifact(program_basename)

clayborg wrote:
> Name should be more descriptive. Maybe "setup_test_common" is a better name
So all of these tests can re-use this function if we switch it up a bit. Here 
is what I was thinking:

```
def run_test(self, symbol_basename, expect_debug_info_size):
program_basename = "a.out.stripped"
program = self.getBuildArtifact(program_basename)
self.build_and_launch(program)
functions = ['foo']
breakpoint_ids = self.set_function_breakpoints(functions)
self.assertEquals(len(breakpoint_ids), len(functions), 'expect one 
breakpoint')
self.continue_to_breakpoints(breakpoint_ids)
active_modules = self.vscode.get_active_modules()
program_module = active_modules[program_basename]
self.assertIn(program_basename, active_modules, '%s module is in active 
modules' % (program_basename))
self.assertIn('name', program_module, 'make sure name is in module')
self.assertEqual(program_basename, program_module['name'])
self.assertIn('path', program_module, 'make sure path is in module')
self.assertEqual(program, program_module['path'])
self.assertTrue('symbolFilePath' not in program_module, 'Make sure 
a.out.stripped has no debug info')
self.assertEqual('Symbols not found.', program_module['symbolStatus'])
symbols_path = self.getBuildArtifact(symbol_basename)
self.vscode.request_evaluate('`%s' % ('target symbols add -s "%s" "%s"' % 
(program, symbols_path)))

def checkSymbolsLoaded():
active_modules = self.vscode.get_active_modules()
program_module = active_modules[program_basename]
return 'Symbols loaded.' == program_module['symbolStatus']

def checkSymbolsLoadedWithSize():
active_modules = self.vscode.get_active_modules()
program_module = active_modules[program_basename]
symbolsStatus = program_module['symbolStatus']
symbol_regex = re.compile(r"Symbols loaded. 
\([0-9]+(\.[0-9]*)?[KMG]?B\)")
return symbol_regex.match(program_module['symbolStatus'])

if expect_debug_info_size:
self.waitUntil(checkSymbolsLoadedWithSize)
else:
self.waitUntil(checkSymbolsLoaded)
```

Then your tests would be:
```
@skipIfWindows
@skipIfRemote
def test_module_event(self):
# Mac or linux.

# On mac, if we load a.out as our symbol file, we will use DWARF with .o 
files and we will
# have debug symbols, but we won't see any debug info size because all of 
the DWARF
# sections are in .o files.

# On other platforms, we expect a.out to have debug info, so we will expect 
a size.
expect_debug_info_size = platform.system() != 'Darwin'
return run_test("a.out", expect_debug_info_size)

@skipIfWindows
@skipUnlessDarwin
@skipIfRemote
def test_module_event_dsym(self):
# Darwin only test with dSYM file.

# On mac, if we load a.out.dSYM as our symbol file, we will have debug 
symbols and we
# will have DWARF sections added to the module, so we will expect a size.
return run_test("a.out.dSYM", True)
```
This should cover both mac and non windows correctly.



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:20
+def get_modules(self, program_basename):
 program= self.getBuildArtifact(program_basename)
 self.build_and_launch(program)

add a space after program:

```
program = self.getBuildArtifact(program_basename)
```



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:32
+@skipIfWindows
+@skipUnlessDarwin
+@skipIfRemote

Remove @skipUnlessDarwin here. This should work on linux.



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:59
+# it will end up using the executable and the .o files as the debug 
info.
+# We won't see any debug information size for this case since all of 
the debug info 

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-16 Thread walter erquinigo via Phabricator via cfe-commits
wallace added inline comments.



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:333-335
+  if (section_name.startswith(".debug") || section_name.startswith("__debug"))
+debug_info_size += section.GetFileByteSize();
+  if (section_name.startswith(".apple") || section_name.startswith("__apple"))

you can merge these two ifs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-16 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 278631.
aelitashen added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The tests added are only for macOS, Walter will help me write tests on Linux. 
This update optimize the code and apply git clang format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -343,7 +343,7 @@
   char buffer[1024];
   size_t count;
   while ((count = process.GetSTDOUT(buffer, sizeof(buffer))) > 0)
-  g_vsc.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count));
+g_vsc.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count));
   while ((count = process.GetSTDERR(buffer, sizeof(buffer))) > 0)
 g_vsc.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count));
 }
@@ -448,10 +448,10 @@
 if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
   body.try_emplace("reason", "new");
 } else if (event_mask &
-lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+   lldb::SBTarget::eBroadcastBitModulesUnloaded) {
   body.try_emplace("reason", "removed");
 } else if (event_mask &
-lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+   lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
   body.try_emplace("reason", "changed");
 }
 body.try_emplace("module", module_value);
@@ -873,7 +873,9 @@
 // "CompletionsRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
-// "description": "Returns a list of possible completions for a given caret position and text.\nThe CompletionsRequest may only be called if the 'supportsCompletionsRequest' capability exists and is true.",
+// "description": "Returns a list of possible completions for a given caret
+// position and text.\nThe CompletionsRequest may only be called if the
+// 'supportsCompletionsRequest' capability exists and is true.",
 // "properties": {
 //   "command": {
 // "type": "string",
@@ -892,19 +894,23 @@
 //   "properties": {
 // "frameId": {
 //   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope."
+//   "description": "Returns completions in the scope of this stack frame.
+//   If not specified, the completions are returned for the global scope."
 // },
 // "text": {
 //   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion."
+//   "description": "One or more source lines. Typically this is the text a
+//   user has typed into the debug console before he asked for completion."
 // },
 // "column": {
 //   "type": "integer",
-//   "description": "The character position for which to determine the completion proposals."
+//   "description": "The character position for which to determine the
+//   completion proposals."
 // },
 // "line": {
 //   "type": "integer",
-//   "description": "An optional line for which to determine the completion proposals. If missing the first line of the text is assumed."
+//   "description": "An optional line for which to determine the completion
+//   proposals. If missing the first line of the text is assumed."
 // }
 //   },
 //   "required": [ "text", "column" ]
@@ -933,39 +939,51 @@
 // },
 // "CompletionItem": {
 //   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the CompletionsRequest.",
-//   "properties": {
+//   "description": "CompletionItems are the suggestions returned from the
+//   CompletionsRequest.", "properties": {
 // "label": {
 //   "type": "string",
-//   "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion."
+//   "description": "The label of this completion item. By default this is
+//   also the text that is inserted when selecting this completion."
 // },
 // "text": {
 //   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of the label."
+//   "description": "If text is not falsy 

[PATCH] D83992: [ASTImporter] Add Visitor for TypedefNameDecl's

2020-07-16 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 278630.
vabridgers added a comment.

Fix lint pre-merge check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83992

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -22,6 +22,20 @@
 struct Builder : RecursiveASTVisitor {
   ASTImporterLookupTable 
   Builder(ASTImporterLookupTable ) : LT(LT) {}
+
+  bool VisitTypedefNameDecl(TypedefNameDecl *D) {
+QualType Ty = D->getUnderlyingType();
+Ty = Ty.getCanonicalType();
+if (const auto *RTy = dyn_cast(Ty)) {
+  LT.add(RTy->getAsRecordDecl());
+  // iterate over the field decls, adding them
+  for (auto *it : RTy->getAsRecordDecl()->fields()) {
+LT.add(it);
+  }
+}
+return true;
+  }
+
   bool VisitNamedDecl(NamedDecl *D) {
 LT.add(D);
 return true;


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -22,6 +22,20 @@
 struct Builder : RecursiveASTVisitor {
   ASTImporterLookupTable 
   Builder(ASTImporterLookupTable ) : LT(LT) {}
+
+  bool VisitTypedefNameDecl(TypedefNameDecl *D) {
+QualType Ty = D->getUnderlyingType();
+Ty = Ty.getCanonicalType();
+if (const auto *RTy = dyn_cast(Ty)) {
+  LT.add(RTy->getAsRecordDecl());
+  // iterate over the field decls, adding them
+  for (auto *it : RTy->getAsRecordDecl()->fields()) {
+LT.add(it);
+  }
+}
+return true;
+  }
+
   bool VisitNamedDecl(NamedDecl *D) {
 LT.add(D);
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83836: [Analyzer] Add checkRegionChanges for SmartPtrModeling

2020-07-16 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar marked 2 inline comments as done.
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:97
 
+// If a region is removed all of the subregions needs to be removed too.
+static ProgramStateRef removeTrackedRegions(ProgramStateRef State,

vsavchenko wrote:
> nit: *need to be removed
fixed



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:98
+// If a region is removed all of the subregions needs to be removed too.
+static ProgramStateRef removeTrackedRegions(ProgramStateRef State,
+const MemRegion *Region) {

vsavchenko wrote:
> Maybe `Subregions` would fit better in this name then?
Changed to Subregions



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:186
+  for (const auto *Region : Regions)
+State = removeTrackedRegions(State, Region->getBaseRegion());
+  return State;

vsavchenko wrote:
> It is not critical, but potentially we can allocate/deallocate a whole bunch 
> of states here.  We can do the same sort of operation with the map itself 
> (`State->get()`), which still have similar problem but to a 
> lesser degree.  Additionally, this `get` method is not 
> compile-time, it searches for the corresponding map in runtime (also in a 
> map), so you repeat that as many times as you have `Regions`.
> 
> And super-duper over-optimization note on my part: making the loop over 
> `Regions` to be the inner-most is more cache-friendly.  It is not really 
> critical here, but it is overall good to have an eye for things like that.
Updated `removeTrackedSubregions` for passing `TrackedRegionMap`



Comment at: clang/test/Analysis/Inputs/system-header-simulator-cxx.h:962
+  operator bool() const;
+  unique_ptr =(unique_ptr &);
+};

xazax.hun wrote:
> vrnithinkumar wrote:
> > added this to support  use case like `Q = std::move(P)`
> This operation should be `noexcept`: 
> https://en.cppreference.com/w/cpp/memory/unique_ptr/operator%3D
> 
> While it makes little difference for the analyzer at this point we should try 
> to be as close to the standard as possible. If you have some time feel free 
> to add `noexcept` to other methods that miss it :)
Added `noexcept` for all applicable methods



Comment at: clang/test/Analysis/smart-ptr.cpp:190
+/*
+// TODO: Enable this test after '=' operator overloading modeling.
+void derefAfterAssignment() {

vsavchenko wrote:
> Usually we simply add the test with expectations matching current state of 
> things, but add a TODO over those particular lines. This way when you fix the 
> issue the test will start failing and you won't forget to uncomment it.
Enabled the test and added the todo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83836



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


[PATCH] D83836: [Analyzer] Add checkRegionChanges for SmartPtrModeling

2020-07-16 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 278628.
vrnithinkumar marked 8 inline comments as done.
vrnithinkumar added a comment.

- Adding a missed todo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83836

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -67,14 +67,14 @@
   std::unique_ptr P(new A());
   P.release();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterReset() {
   std::unique_ptr P(new A());
   P.reset();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterResetWithNull() {
@@ -101,3 +101,103 @@
   A *AP = P.release();
   AP->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
 }
+
+void pass_smart_ptr_by_ref(std::unique_ptr );
+void pass_smart_ptr_by_const_ref(const std::unique_ptr );
+void pass_smart_ptr_by_rvalue_ref(std::unique_ptr &);
+void pass_smart_ptr_by_const_rvalue_ref(const std::unique_ptr &);
+void pass_smart_ptr_by_ptr(std::unique_ptr *a);
+void pass_smart_ptr_by_const_ptr(const std::unique_ptr *a);
+
+void regioninvalidationTest() {
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_ref(P);
+P->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_ref(P);
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_rvalue_ref(std::move(P));
+P->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_rvalue_ref(std::move(P));
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_ptr();
+P->foo();
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_ptr();
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+}
+
+struct StructWithSmartPtr {
+  std::unique_ptr P;
+};
+
+void pass_struct_with_smart_ptr_by_ref(StructWithSmartPtr );
+void pass_struct_with_smart_ptr_by_const_ref(const StructWithSmartPtr );
+void pass_struct_with_smart_ptr_by_rvalue_ref(StructWithSmartPtr &);
+void pass_struct_with_smart_ptr_by_const_rvalue_ref(const StructWithSmartPtr &);
+void pass_struct_with_smart_ptr_by_ptr(StructWithSmartPtr *a);
+void pass_struct_with_smart_ptr_by_const_ptr(const StructWithSmartPtr *a);
+
+void regioninvalidationTestWithinStruct() {
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_ref(S);
+S.P->foo(); // no-warning
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_ref(S);
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_rvalue_ref(std::move(S));
+S.P->foo(); // no-warning
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_rvalue_ref(std::move(S));
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_ptr();
+S.P->foo();
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_ptr();
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+}
+
+void derefAfterAssignment() {
+  {
+std::unique_ptr P(new A());
+std::unique_ptr Q;
+Q = std::move(P);
+Q->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+std::unique_ptr Q;
+Q = std::move(P);
+// TODO: Fix test with expecting warning after '=' operator overloading modeling.
+Q->foo(); // no-warning
+  }
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -943,24 +943,25 @@
 
 #if __cplusplus >= 201103L
 namespace std {
-  template  // TODO: Implement the stub for deleter.
-  class unique_ptr {
-  public:
-unique_ptr() {}
-unique_ptr(T *) {}
-

[PATCH] D83836: [Analyzer] Add checkRegionChanges for SmartPtrModeling

2020-07-16 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 278622.
vrnithinkumar marked an inline comment as done.
vrnithinkumar added a comment.

- Addressing review comments
- Enabling commented out tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83836

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -67,14 +67,14 @@
   std::unique_ptr P(new A());
   P.release();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterReset() {
   std::unique_ptr P(new A());
   P.reset();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterResetWithNull() {
@@ -101,3 +101,102 @@
   A *AP = P.release();
   AP->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
 }
+
+void pass_smart_ptr_by_ref(std::unique_ptr );
+void pass_smart_ptr_by_const_ref(const std::unique_ptr );
+void pass_smart_ptr_by_rvalue_ref(std::unique_ptr &);
+void pass_smart_ptr_by_const_rvalue_ref(const std::unique_ptr &);
+void pass_smart_ptr_by_ptr(std::unique_ptr *a);
+void pass_smart_ptr_by_const_ptr(const std::unique_ptr *a);
+
+void regioninvalidationTest() {
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_ref(P);
+P->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_ref(P);
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_rvalue_ref(std::move(P));
+P->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_rvalue_ref(std::move(P));
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_ptr();
+P->foo();
+  }
+  {
+std::unique_ptr P;
+pass_smart_ptr_by_const_ptr();
+P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+}
+
+struct StructWithSmartPtr {
+  std::unique_ptr P;
+};
+
+void pass_struct_with_smart_ptr_by_ref(StructWithSmartPtr );
+void pass_struct_with_smart_ptr_by_const_ref(const StructWithSmartPtr );
+void pass_struct_with_smart_ptr_by_rvalue_ref(StructWithSmartPtr &);
+void pass_struct_with_smart_ptr_by_const_rvalue_ref(const StructWithSmartPtr &);
+void pass_struct_with_smart_ptr_by_ptr(StructWithSmartPtr *a);
+void pass_struct_with_smart_ptr_by_const_ptr(const StructWithSmartPtr *a);
+
+void regioninvalidationTestWithinStruct() {
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_ref(S);
+S.P->foo(); // no-warning
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_ref(S);
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_rvalue_ref(std::move(S));
+S.P->foo(); // no-warning
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_rvalue_ref(std::move(S));
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_ptr();
+S.P->foo();
+  }
+  {
+StructWithSmartPtr S;
+pass_struct_with_smart_ptr_by_const_ptr();
+S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  }
+}
+
+void derefAfterAssignment() {
+  {
+std::unique_ptr P(new A());
+std::unique_ptr Q;
+Q = std::move(P);
+Q->foo(); // no-warning
+  }
+  {
+std::unique_ptr P;
+std::unique_ptr Q;
+Q = std::move(P);
+Q->foo(); // no-warning
+  }
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -943,24 +943,25 @@
 
 #if __cplusplus >= 201103L
 namespace std {
-  template  // TODO: Implement the stub for deleter.
-  class unique_ptr {
-  public:
-unique_ptr() {}
-unique_ptr(T *) {}
-unique_ptr(const unique_ptr &) = delete;
-

[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7043-7044
 OMP_MAP_CLOSE = 0x400,
+/// Produce a runtime error if the data is not already allocated.
+OMP_MAP_PRESENT = 0x800,
 /// The 16 MSBs of the flags indicate whether the entry is member of some

ABataev wrote:
> Better to use thу next value to avoid compatibility issues with XLC. 
You mean 0x1000?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83061



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


[PATCH] D83992: [ASTImporter] Add Visitor for TypedefNameDecl's

2020-07-16 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added a reviewer: martong.
Herald added subscribers: cfe-commits, teemperor, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

We found a case where Typedef Name Declarations were not being added
correctly when importing builtin types. This exposed the need for a
TypedefNameDecl visitor so these types can be added by RecordDecl and
fields.

This code is covered by the ASTImporterTest cases that use the implicit
struct __NSConstantString_tag definitions.

Thanks to @martong for the debugging assist!

Depends on D83970 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83992

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -22,6 +22,20 @@
 struct Builder : RecursiveASTVisitor {
   ASTImporterLookupTable 
   Builder(ASTImporterLookupTable ) : LT(LT) {}
+
+  bool VisitTypedefNameDecl(TypedefNameDecl *D) {
+QualType Ty = D->getUnderlyingType();
+Ty = Ty.getCanonicalType();
+if (const auto *RTy = dyn_cast(Ty)) {
+  LT.add(RTy->getAsRecordDecl());
+  // iterate over the field decls, adding them
+  for (auto it : RTy->getAsRecordDecl()->fields()) {
+LT.add(it);
+  }
+}
+return true;
+  }
+
   bool VisitNamedDecl(NamedDecl *D) {
 LT.add(D);
 return true;


Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -22,6 +22,20 @@
 struct Builder : RecursiveASTVisitor {
   ASTImporterLookupTable 
   Builder(ASTImporterLookupTable ) : LT(LT) {}
+
+  bool VisitTypedefNameDecl(TypedefNameDecl *D) {
+QualType Ty = D->getUnderlyingType();
+Ty = Ty.getCanonicalType();
+if (const auto *RTy = dyn_cast(Ty)) {
+  LT.add(RTy->getAsRecordDecl());
+  // iterate over the field decls, adding them
+  for (auto it : RTy->getAsRecordDecl()->fields()) {
+LT.add(it);
+  }
+}
+return true;
+  }
+
   bool VisitNamedDecl(NamedDecl *D) {
 LT.add(D);
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12d1124c49be: [libFuzzer] Disable implicit builtin knowledge 
about memcmp-like functions when… (authored by dokyungs).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test


Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp 
-o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o 
%t-NoAsanStrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp 
%S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o 
%t-NoAsanStrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp 
-o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o 
%t-NoAsanStrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp 
%S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o 
%t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,22 @@
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags force the compiler to emit interposable
+  // libcalls to these functions. Other sanitizers effectively do the same 
thing
+  // by marking all library call sites with NoBuiltin attribute in their LLVM
+  // pass. (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+CmdArgs.push_back("-fno-builtin-strcasestr");
+

[clang] 12d1124 - [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via cfe-commits

Author: Dokyung Song
Date: 2020-07-16T22:53:54Z
New Revision: 12d1124c49beec0fb79d36944960e5bf0f236d4c

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

LOG: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions 
when -fsanitize=fuzzer-no-link is given.

Summary: This patch disables implicit builtin knowledge about memcmp-like 
functions when compiling the program for fuzzing, i.e., when 
-fsanitize=fuzzer(-no-link) is given. This allows libFuzzer to always intercept 
memcmp-like functions as it effectively disables optimizing calls to such 
functions into different forms. This is done by adding a set of flags 
(-fno-builtin-memcmp and others) in the clang driver. Individual -fno-builtin-* 
flags previously used in several libFuzzer tests are now removed, as it is now 
done automatically in the clang driver.

Reviewers: morehouse, hctim

Subscribers: cfe-commits, #sanitizers

Tags: #clang, #sanitizers

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

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp
compiler-rt/test/fuzzer/memcmp.test
compiler-rt/test/fuzzer/memcmp64.test
compiler-rt/test/fuzzer/strcmp.test
compiler-rt/test/fuzzer/strncmp.test
compiler-rt/test/fuzzer/strstr.test

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index e4fda752c041..4af24662ca91 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,22 @@ void SanitizerArgs::addArgs(const ToolChain , const 
llvm::opt::ArgList ,
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags force the compiler to emit interposable
+  // libcalls to these functions. Other sanitizers effectively do the same 
thing
+  // by marking all library call sites with NoBuiltin attribute in their LLVM
+  // pass. (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+CmdArgs.push_back("-fno-builtin-strcasestr");
+CmdArgs.push_back("-fno-builtin-memmem");
+  }
+
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.
   if (Sanitizers.hasOneOf(CFIClasses) && !TC.getTriple().isOSWindows() &&

diff  --git a/compiler-rt/test/fuzzer/memcmp.test 
b/compiler-rt/test/fuzzer/memcmp.test
index 8859afbe8a97..fa995a22c68a 100644
--- a/compiler-rt/test/fuzzer/memcmp.test
+++ b/compiler-rt/test/fuzzer/memcmp.test
@@ -2,7 +2,7 @@ UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO

diff  --git a/compiler-rt/test/fuzzer/memcmp64.test 
b/compiler-rt/test/fuzzer/memcmp64.test
index fc9d02324373..ca8c8fe8206f 100644
--- a/compiler-rt/test/fuzzer/memcmp64.test
+++ b/compiler-rt/test/fuzzer/memcmp64.test
@@ -2,7 +2,7 @@ UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp 
%S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o 
%t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
 CHECK: BINGO

diff  --git a/compiler-rt/test/fuzzer/strcmp.test 
b/compiler-rt/test/fuzzer/strcmp.test
index eebcf8ef5c70..61065de6fa94 100644
--- a/compiler-rt/test/fuzzer/strcmp.test
+++ b/compiler-rt/test/fuzzer/strcmp.test
@@ -2,7 +2,7 @@ UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp 
-o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o 
%t-NoAsanStrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 

[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Mitch Phillips via Phabricator via cfe-commits
hctim accepted this revision.
hctim added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-16 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D83592#2157130 , @vsk wrote:

> > ! In D83592#2156758 , @zequanwu 
> > wrote:
> >  One way I could think is probably when we visit decl in 
> > `CounterCoverageMappingBuilder`, check for if there is `SkippedRegion` in 
> > the same line and then mark the decl range as `CodeRegion`. For the 
> > example, we will have 3 more `CodeRegion` which covers the ranges of `int x 
> > = 0`, `int y = 0` and `int z = 0`.
>
> I don't think that will work well, because a decl can span multiple lines 
> (which in turn can include comments).
>
> The key issue seems to be that -- even having SourceRanges for all comments 
> -- we don't know whether a line has non-whitespace, non-comment tokens. If it 
> does, the line should have an execution count (and we don't even need to 
> bother with emitting a skipped region covering the line). It sounds like we 
> need a different hook in the preprocessor that reports SourceRanges for lines 
> with no non-comment, non-whitespace tokens. Practically, I think this can be 
> wired up just like a CommentHandler (maybe it could be called 
> WhitespaceHandler?). One side-benefit of introducing a new hook like this is 
> that coverage will handle whitespace-only lines the same way as comment-only 
> lines.
>
> There's probably more than one way to approach this. One thing to be aware 
> of: llvm's LineCoverageStats class is the one responsible for determining 
> whether a line is "mapped" (i.e. whether it has an execution count). It 
> assumes that when a line begins with a skipped region, the subsequent portion 
> of the line must also be skipped. If we only emit skipped regions for fully 
> whitespace-like lines, that's fine. If not, depending on how C-style comments 
> are handled, that may need updating.


Thanks for the reply. I will work on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83592



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


[PATCH] D83516: [PowerPC][Power10] 128-bit Binary Integer Operation instruction definitions and MC Tests

2020-07-16 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2735635523d: [PowerPC][Power10] Add 128-bit Binary Integer 
Operation instruction definitions… (authored by Conanap, committed by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D83516?vs=277442=278615#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83516

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -429,3 +429,84 @@
 # CHECK-BE: stxvrdx 35, 3, 1  # encoding: [0x7c,0x63,0x09,0xdb]
 # CHECK-LE: stxvrdx 35, 3, 1  # encoding: [0xdb,0x09,0x63,0x7c]
 stxvrdx 35, 3, 1
+# CHECK-BE: vmulesd 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xc8]
+# CHECK-LE: vmulesd 1, 2, 3   # encoding: [0xc8,0x1b,0x22,0x10]
+vmulesd 1, 2, 3
+# CHECK-BE: vmulosd 1, 2, 3   # encoding: [0x10,0x22,0x19,0xc8]
+# CHECK-LE: vmulosd 1, 2, 3   # encoding: [0xc8,0x19,0x22,0x10]
+vmulosd 1, 2, 3
+# CHECK-BE: vmuleud 1, 2, 3   # encoding: [0x10,0x22,0x1a,0xc8]
+# CHECK-LE: vmuleud 1, 2, 3   # encoding: [0xc8,0x1a,0x22,0x10]
+vmuleud 1, 2, 3
+# CHECK-BE: vmuloud 1, 2, 3   # encoding: [0x10,0x22,0x18,0xc8]
+# CHECK-LE: vmuloud 1, 2, 3   # encoding: [0xc8,0x18,0x22,0x10]
+vmuloud 1, 2, 3
+# CHECK-BE: vmsumcud 1, 2, 3, 4   # encoding: [0x10,0x22,0x19,0x17]
+# CHECK-LE: vmsumcud 1, 2, 3, 4   # encoding: [0x17,0x19,0x22,0x10]
+vmsumcud 1, 2, 3, 4
+# CHECK-BE: vdivsq 3, 4, 5# encoding: [0x10,0x64,0x29,0x0b]
+# CHECK-LE: vdivsq 3, 4, 5# encoding: [0x0b,0x29,0x64,0x10]
+vdivsq 3, 4, 5
+# CHECK-BE: vdivuq 3, 4, 5# encoding: [0x10,0x64,0x28,0x0b]
+# CHECK-LE: vdivuq 3, 4, 5# encoding: [0x0b,0x28,0x64,0x10]
+vdivuq 3, 4, 5
+# CHECK-BE: vdivesq 3, 4, 5   # encoding: [0x10,0x64,0x2b,0x0b]
+# CHECK-LE: vdivesq 3, 4, 5   # encoding: [0x0b,0x2b,0x64,0x10]
+vdivesq 3, 4, 5
+# CHECK-BE: vdiveuq 3, 4, 5   # encoding: [0x10,0x64,0x2a,0x0b]
+# CHECK-LE: vdiveuq 3, 4, 5   # encoding: [0x0b,0x2a,0x64,0x10]
+vdiveuq 3, 4, 5
+# CHECK-BE: vcmpequq 4, 5, 6  # encoding: [0x10,0x85,0x31,0xc7]
+# CHECK-LE: vcmpequq 4, 5, 6  # encoding: [0xc7,0x31,0x85,0x10]
+vcmpequq 4, 5, 6
+# CHECK-BE: vcmpequq. 4, 5, 6 # encoding: [0x10,0x85,0x35,0xc7]
+# CHECK-LE: vcmpequq. 4, 5, 6 # encoding: [0xc7,0x35,0x85,0x10]
+vcmpequq. 4, 5, 6
+# CHECK-BE: vcmpgtsq 4, 5, 6  # encoding: [0x10,0x85,0x33,0x87]
+# CHECK-LE: vcmpgtsq 4, 5, 6  # encoding: [0x87,0x33,0x85,0x10]
+vcmpgtsq 4, 5, 6
+# CHECK-BE: vcmpgtsq. 4, 5, 6 # encoding: [0x10,0x85,0x37,0x87]
+# CHECK-LE: vcmpgtsq. 4, 5, 6 # encoding: [0x87,0x37,0x85,0x10]
+vcmpgtsq. 4, 5, 6
+# CHECK-BE: vcmpgtuq 4, 5, 6  # encoding: [0x10,0x85,0x32,0x87]
+# CHECK-LE: vcmpgtuq 4, 5, 6  # encoding: [0x87,0x32,0x85,0x10]
+vcmpgtuq 4, 5, 6
+# CHECK-BE: vcmpgtuq. 4, 5, 6 # encoding: [0x10,0x85,0x36,0x87]
+# CHECK-LE: vcmpgtuq. 4, 5, 6 # encoding: [0x87,0x36,0x85,0x10]
+vcmpgtuq. 4, 5, 6
+# CHECK-BE: vmoduq 3, 4, 5# encoding: [0x10,0x64,0x2e,0x0b]
+# CHECK-LE: vmoduq 3, 4, 5# encoding: [0x0b,0x2e,0x64,0x10]
+vmoduq 3, 4, 5
+# CHECK-BE: vextsd2q 20, 25   # encoding: [0x12,0x9b,0xce,0x02]
+# CHECK-LE: vextsd2q 20, 25   # encoding: [0x02,0xce,0x9b,0x12]
+vextsd2q 20, 25
+# CHECK-BE: vrlq 4, 5, 6  # encoding: [0x10,0x85,0x30,0x05]
+# CHECK-LE: vrlq 4, 5, 6  # encoding: [0x05,0x30,0x85,0x10]
+vrlq 4, 5, 6
+# CHECK-BE: vrlqnm 4, 5, 6# encoding: [0x10,0x85,0x31,0x45]
+# CHECK-LE: vrlqnm 4, 5, 6# encoding: [0x45,0x31,0x85,0x10]
+vrlqnm 4, 5, 6
+# CHECK-BE: vrlqmi 4, 5, 6# encoding: [0x10,0x85,0x30,0x45]
+# CHECK-LE: vrlqmi 4, 5, 6# encoding: 

[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

> ! In D83592#2156758 , @zequanwu 
> wrote:
>  One way I could think is probably when we visit decl in 
> `CounterCoverageMappingBuilder`, check for if there is `SkippedRegion` in the 
> same line and then mark the decl range as `CodeRegion`. For the example, we 
> will have 3 more `CodeRegion` which covers the ranges of `int x = 0`, `int y 
> = 0` and `int z = 0`.

I don't think that will work well, because a decl can span multiple lines 
(which in turn can include comments).

The key issue seems to be that -- even having SourceRanges for all comments -- 
we don't know whether a line has non-whitespace, non-comment tokens. If it 
does, the line should have an execution count (and we don't even need to bother 
with emitting a skipped region covering the line). It sounds like we need a 
different hook in the preprocessor that reports SourceRanges for lines with no 
non-comment, non-whitespace tokens. Practically, I think this can be wired up 
just like a CommentHandler (maybe it could be called WhitespaceHandler?). One 
side-benefit of introducing a new hook like this is that coverage will handle 
whitespace-only lines the same way as comment-only lines.

There's probably more than one way to approach this. One thing to be aware of: 
llvm's LineCoverageStats class is the one responsible for determining whether a 
line is "mapped" (i.e. whether it has an execution count). It assumes that when 
a line begins with a skipped region, the subsequent portion of the line must 
also be skipped. If we only emit skipped regions for fully whitespace-like 
lines, that's fine. If not, depending on how C-style comments are handled, that 
may need updating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83592



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278613.
dokyungs added a comment.

Adjusted the comment as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test


Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp 
-o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o 
%t-NoAsanStrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp 
%S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o 
%t-NoAsanStrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp 
-o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o 
%t-NoAsanStrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp 
%S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o 
%t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,22 @@
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags force the compiler to emit interposable
+  // libcalls to these functions. Other sanitizers effectively do the same 
thing
+  // by marking all library call sites with NoBuiltin attribute in their LLVM
+  // pass. (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+CmdArgs.push_back("-fno-builtin-strcasestr");
+CmdArgs.push_back("-fno-builtin-memmem");
+  }
+
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   

[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added inline comments.



Comment at: clang/lib/Driver/SanitizerArgs.cpp:1092
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags disable implicit builtin knowledge about
+  // those functions. Other sanitizers effectively do the same thing by marking

I'd say "the following -fno-builtin-* flags force the compiler to emit 
interposable libcalls to these functions"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-16 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 278611.
asoffer marked an inline comment as done.
asoffer added a comment.

Typo fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult ) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration(0, varDecl(hasInitializer(
+  integerLiteral().bind("int")
+  .bind("decl"),
+  withMetadata(remove(statement(std::string("decl"))), makeMetadata)),
   consumer());
   T.registerMatchers();
   auto Factory = newFrontendActionFactory();
@@ -459,7 +468,7 @@
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any  = Changes[0].getMetadata();
   ASSERT_TRUE(llvm::any_isa(Metadata));
-  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+  EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 
 TEST_F(TransformerTest, MultiChange) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be required to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable
+// types would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult ) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83893: [CUDA][HIP] Always defer diagnostics for wrong-sided reference

2020-07-16 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D83893



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs marked an inline comment as done.
dokyungs added a comment.

Thanks Mitch for the comment! Added a comment that explains that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278610.
dokyungs added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test


Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp 
-o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o 
%t-NoAsanStrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp 
%S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o 
%t-NoAsanStrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp 
-o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o 
%t-NoAsanStrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp 
%S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o 
%t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,22 @@
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags disable implicit builtin knowledge about
+  // those functions. Other sanitizers effectively do the same thing by marking
+  // all library call sites with NoBuiltin attribute in their LLVM pass.
+  // (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+CmdArgs.push_back("-fno-builtin-strcasestr");
+CmdArgs.push_back("-fno-builtin-memmem");
+  }
+
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.
   if 

[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Mitch Phillips via Phabricator via cfe-commits
hctim accepted this revision.
hctim added a comment.
This revision is now accepted and ready to land.

LGTM w/ nit




Comment at: clang/lib/Driver/SanitizerArgs.cpp:1091
 
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");

Nit - add a comment here mentioning the libfuzzer interceptors, and that other 
sanitizers normally do this by propagating IR attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D83922#2156567 , @ABataev wrote:

> In D83922#2156510 , @jdenny wrote:
>
> > In D83922#2155749 , @ABataev wrote:
> >
> > > I would add checks for mapping of `declare target to/link` vars and 
> > > checked if they work in runtime.
> >
> >
> > There are existing codegen tests for that, and they don't seem to be 
> > affected by this patch.  This patch only addresses the case where a `map` 
> > clause is specified for an unused variable.  Is there another behavior this 
> > patch might impact?
>
>
> What I mean is the explicit mapping for `declare target to/link` variables. 
> The variable is marked as declare to and then mapped. Do we have the tests 
> for something like this?


I didn't find tests for the case where a variable has a `declare target` and a 
`map` clause.  I can add some to show that this patch doesn't change the 
generated map types.

In D83922#2156606 , @ABataev wrote:

> Check, if it fixed https://bugs.llvm.org/show_bug.cgi?id=46012


This patch doesn't affect the example in that bug report as far as I can tell.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9470-9471
+  MappedVarSet.insert(CI->getCapturedVar()->getCanonicalDecl());
+else
+  MappedVarSet.insert(nullptr);
 if (CurBasePointers.empty())

ABataev wrote:
> jdenny wrote:
> > ABataev wrote:
> > > No need to insert `nullptr` here, it is not used later.
> > Without this `nulltpr` insertion, many tests fail because of duplicate map 
> > entries.  Independently of my patch, `nulltptr` is used to indicate `this` 
> > capture (see the `generateInfoForCapture` implementation) .
> > 
> > For example:
> > 
> > ```
> > struct S {
> >   int i;
> >   void foo() {
> > #pragma omp target map(i)
> > i = 5;
> >   }
> > };
> > ```
> > 
> > We should have:
> > 
> > ```
> > @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 32, i64 
> > 281474976710659]
> > ```
> > 
> > Without the `nullptr` insertion, we have:
> > 
> > ```
> > @.offload_maptypes = private unnamed_addr constant [4 x i64] [i64 32, i64 
> > 281474976710659, i64 32, i64 844424930131971]
> > ```
> This is strange, because you don't check for `nullptr`. You only check for 
> `ValueDecl`s, but not capture of `this`.
I'm not sure what code you're referring to when you say "you check".

Both with and without my patch, my understanding is that `nullptr` is a special 
key that means `this`.  I'm depending on that to avoid generating map entries 
twice for `this`.

My understanding is based on the way `generateInfoForCapture` works.  If 
`Cap->capturesThis()`, then `VD = nullptr`.  That `VD` is then used by 
`C->decl_component_lists(VD)` to find entries for `this` in map clauses.

Unless I'm misreading it, the code that sets `nullptr` for `this` in decl 
components is `checkMappableExpressionList` in SemaOpenMP.cpp.  The last few 
lines of that function have a comment to this effect.  (That comment would 
probably be more useful in a header file somewhere.)


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

https://reviews.llvm.org/D83922



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Apologies for the wait. I think with the comments below this is good to go. If 
you have questions or concerns, let me know. Thanks for these changes!




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:587
+? AttributeSet(EnumAttr(NoUnwind), EnumAttr(WillReturn))
 : AttributeSet(EnumAttr(NoUnwind)))
 

I think (for now) we should even remove willreturn here. I'm not sure we have 
forward progress guarantees for C + OpenMP :(



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:621
+? AttributeSet(EnumAttr(WriteOnly), EnumAttr(NoFree))
+: AttributeSet())
+

Here and above, `nocapture`.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:632
+   EnumAttrInt(DereferenceableOrNull, 8))
+: AttributeSet())
+

I guess this means the attribute is returned, right? If we are sure it is, we 
can add the `returned` attribute. I checked `__kmpc_threadprivate_cached` and I 
wasn't sure the argument is actually returned, maybe I misunderstand what this 
means. We could add a comment here.

We should also not go for alignment or dereferenceability for now.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:729
+__OMP_RTL_ATTRS(__kmpc_end_critical, BarrierAttrs, AttributeSet(),
+ParamAttrs(ReadOnlyPtrAttrs, AttributeSet(), AttributeSet()))
+

I think this will mitigate PR46210, which is good! 



Comment at: llvm/test/Transforms/OpenMP/add_attributes.ll:1542
+; OPTIMISTIC: ; Function Attrs: inaccessiblemem_or_argmemonly nofree nosync 
nounwind willreturn
+; OPTIMISTIC-NEXT: declare void @__kmpc_end_single(%struct.ident_t* nofree 
readonly, i32)
+

the `single` ones should be barrier like



Comment at: llvm/test/Transforms/OpenMP/add_attributes.ll:1551
+; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn
+; OPTIMISTIC-NEXT: declare void @__kmpc_end_taskgroup(%struct.ident_t* nofree 
readonly, i32)
+

barrier like



Comment at: llvm/test/Transforms/OpenMP/add_attributes.ll:1614
+; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn
+; OPTIMISTIC-NEXT: declare void @__kmpc_omp_wait_deps(%struct.ident_t* nofree 
readonly, i32, i32, i8* nofree readonly, i32, i8*)
+

barrier like, probably all `wait` functions



Comment at: llvm/test/Transforms/OpenMP/add_attributes.ll:1653
+; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn
+; OPTIMISTIC-NEXT: declare void @__kmpc_doacross_wait(%struct.ident_t* nofree 
readonly, i32, i64* nofree readonly)
+

this is a barrier like directive. Let's just mark all doacross as such for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs created this revision.
dokyungs added reviewers: morehouse, hctim.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This patch disables implicit builtin knowledge about memcmp-like functions when 
compiling the program for fuzzing, i.e., when -fsanitize=fuzzer(-no-link) is 
given. This allows libFuzzer to always intercept memcmp-like functions as it 
effectively disables optimizing calls to such functions into different forms. 
This is done by adding a set of flags (-fno-builtin-memcmp and others) in the 
clang driver. Individual -fno-builtin-* flags previously used inlibFuzzer tests 
are now removed, as it is now done automatically in the clang driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test


Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp 
-o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o 
%t-NoAsanStrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp 
%S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o 
%t-NoAsanStrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp 
-o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o 
%t-NoAsanStrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp 
%S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o 
%t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -2,7 +2,7 @@
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | 
FileCheck %s
 
 CHECK: BINGO
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,17 @@
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+

[PATCH] D83970: [ASTImporter] Refactor ASTImporter to support custom downstream tests

2020-07-16 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

@shafik, Thanks! I'll wait 'til Gabor gets a chance to review before landing. 
Best!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83970



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


[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-16 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1212
   if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
+if (getContext().getTargetInfo().getTriple().isOSAIX())
+  llvm::report_fatal_error(

This should query if the platform uses sinit/sterm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83974



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


[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

2020-07-16 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:227
 continue;
+  // Ignore tokens in disabled preprocessor sections.
+  if (Buf.expandedTokens(SM.getMacroArgExpandedLocation(T->location()))

sammccall wrote:
> I think this is more work than we'd like to do in this loop (the whole file 
> could be selected!) and it's also not obviously correct - it relies on the 
> assumption that any token that doesn't expand to something by itself, isn't a 
> macro argument or macro name, is part of an ignored region. (That may or may 
> not be correct, but it's a nontrivial assumption to make here).
> 
> I think the API we need is something like `vector 
> TokenBuffer::expansionsOverlapping(ArrayRef Spelled)`.
> This requires a couple of binary searches on the TokenBuffer side to compute, 
> and on this side we can just look at the spelled token ranges for empty 
> expansions and mark them in a bitmap.
> 
> I'm happy to try to put together a TokenBuffer patch if this is too much of a 
> yak-shave, though.
>  it relies on the assumption that any token that doesn't expand to something 
> by itself, isn't a macro argument or macro name, is part of an ignored 
> region. (That may or may not be correct, but it's a nontrivial assumption to 
> make here).

Example `#define FOO BAR`.
Expanded tokens:
Spelled tokens: `#`, `define`, `FOO`, `BAR`

I think we could ignore all except `FOO` in this case. Also I found similar 
check in XRefs.cpp `bool tokenSpelledAt(SourceLocation SpellingLoc, const 
syntax::TokenBuffer )`

How to judge should we skip token or not if we do not have expanded tokens for 
it? Do you have any advice here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83508



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


[PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-16 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1541
 
+def ArmSveVectorBits128 : TypeAttr {
+  let Spellings = [];

aaron.ballman wrote:
> c-rhodes wrote:
> > c-rhodes wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > c-rhodes wrote:
> > > > > > sdesmalen wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > sdesmalen wrote:
> > > > > > > > > nit: Can you add a comment saying why these are undocumented 
> > > > > > > > > (and have no spellings)
> > > > > > > > Also, I think these are all missing `let SemaHandler = 0;` and 
> > > > > > > > `let ASTNode = 0;`
> > > > > > > > 
> > > > > > > > Is there a reason why we need N different type attributes 
> > > > > > > > instead of having a single type attribute which encodes the N 
> > > > > > > > as an argument? I think this may simplify the patch somewhat as 
> > > > > > > > you no longer need to switch over N as much.
> > > > > > > > Is there a reason why we need N different type attributes 
> > > > > > > > instead of having a single type attribute which encodes the N 
> > > > > > > > as an argument?
> > > > > > > AIUI this was a workaround for getting the value of N from an 
> > > > > > > AttributedType, because this only has `getAttrKind` to return the 
> > > > > > > attribute kind, but no way to get the corresponding 
> > > > > > > argument/value. This seemed like a simple way to do that without 
> > > > > > > having to create a new subclass for Type and having to support 
> > > > > > > that in various places. Is the latter the approach you were 
> > > > > > > thinking of? (or is there perhaps a simpler way?)
> > > > > > > Also, I think these are all missing let SemaHandler = 0; and let 
> > > > > > > ASTNode = 0;
> > > > > > 
> > > > > > Good to know. In SemaType I'm doing `CurType = 
> > > > > > State.getAttributedType(A, CurType, CurType);` which gives an 
> > > > > > `AttributedType` in the AST, should I still set `let ASTNode = 0;` 
> > > > > > in this case?
> > > > > > 
> > > > > > > Is there a reason why we need N different type attributes instead 
> > > > > > > of having a single type attribute which encodes the N as an 
> > > > > > > argument?
> > > > > > 
> > > > > > As Sander mentioned, it seemed like the easiest solution, 
> > > > > > interested to know if there's a better approach however
> > > > > I was thinking specifically of creating a new `Type` subclass and 
> > > > > supporting it rather than adding 5 new attributes that only vary by a 
> > > > > bit-width (which means there's likely to be a 6th someday). It's not 
> > > > > immediately clear to me whether that's a really big ask for little 
> > > > > gain or not, though.
> > > > Ah, you're right, we may still need `ASTNode` to be kept around for 
> > > > that, good call.
> > > > Also, I think these are all missing let SemaHandler = 0; and let 
> > > > ASTNode = 0;
> > > 
> > > I've added `let SemaHandler = 0;` for the internal types and `let ASTNode 
> > > = 0;` for the user-facing attr.
> > > I was thinking specifically of creating a new Type subclass and 
> > > supporting it rather than adding 5 new attributes that only vary by a 
> > > bit-width (which means there's likely to be a 6th someday).
> > 
> > It would be nice if the `Attr` was accessible from the `AttributedType`, 
> > similar to how it is for `Decl`s, so something like:
> > ```  if (const auto *AT = T->getAs())
> > if (ArmSveVectorBitsAttr *Attr = AT->getAttr())
> >   unsigned Width = Attr->getNumBits();```
> > Although I'm not sure if that makes sense or how easy it is. I do agree 
> > adding 5 new attributes isn't ideal but for an initial implementation it's 
> > nice and simple. Would you be ok with us addressing this in a later patch?
> > It would be nice if the Attr was accessible from the AttributedType, 
> > similar to how it is for Decls, so something like:
> 
> You can do that through an `AttributedTypeLoc` object, which I think should 
> be available from the situations you need to check this through a 
> `TypeSourceInfo *` for the type. Then you can use 
> `AttributedTypeLoc::getAttr()` to get the semantic attribute.
> 
> > Would you be ok with us addressing this in a later patch?
> 
> No and yes. It's a novel design to have a user-facing attribute that is never 
> hooked up in the AST but is instead used to decide which spellingless 
> attribute to use instead, so I'd strongly prefer to find a solution that 
> doesn't use this approach. I also think we'll wind up with cleaner code from 
> this. That said, if it turns out to be awkward to do because there's too much 
> code required to support it, then I can likely hold my nose.
> You can do that through an AttributedTypeLoc object, which I think should be 
> available from the situations you need to check this through a TypeSourceInfo 
> * for the type. Then you can use AttributedTypeLoc::getAttr() to get the 
> semantic attribute.

I've tried your suggestion 

[PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute

2020-07-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.h:138
+  llvm::Type *ConvertTypeForMem(QualType T, bool ForBitField = false,
+bool EnforceFixedLengthSVEAttribute = false);
 

c-rhodes wrote:
> efriedma wrote:
> > The default for EnforceFixedLengthSVEAttribute seems backwards; I would 
> > expect that almost everywhere that calls ConvertTypeForMem actually wants 
> > the fixed-length type.  The scalable type only exists in registers.
> > The default for EnforceFixedLengthSVEAttribute seems backwards; I would 
> > expect that almost everywhere that calls ConvertTypeForMem actually wants 
> > the fixed-length type. The scalable type only exists in registers.
> 
> It has no effect unless `T->isVLST()` so I think it makes sense.
My question is "why is the current default for EnforceFixedLengthSVEAttribute 
correct?" You answer for that is "because VLST types are rare"?  I'm not sure 
how that's related.

Essentially, the issue is that ConvertTypeForMem means "I'm allocating 
something in memory; what is its type?".  Except for a few places where we've 
specifically added handling to make it work, the code assumes scalable types 
don't exist.  So in most places, we want the fixed version.  With the current 
default, I'm afraid we're going to end up with weird failures with various 
constructs you haven't tested.

I guess if there's some large number of places where the current default is 
actually beneficial, the current patch wouldn't make it obvious, but my 
intuition is that are few places like that.


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

https://reviews.llvm.org/D83553



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


[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: llvm/cmake/modules/AddPerfetto.cmake:9
+  ExternalProject_Add(perfetto_git
+  GIT_REPOSITORY https://github.com/google/perfetto.git
+  GIT_TAG releases/v4.x

nickdesaulniers wrote:
> lebedev.ri wrote:
> > I have concerns about this.
> > It really should use system-provided version via `find_package()`
> > At worst, the sources should be bundled into the tree like it's already 
> > done in some rare cases.
> Not that I'm very good with CMake, but this seems to suggest that 
> `ExternalProject_Add` may not compose well with `find_package`: 
> https://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add
What i am saying is that any code that fetches anything from internet during 
cmake/build time is just plain broken.
perfetto should be provided by system package and we should link to it just 
like we link to zlib/etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82994



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


[PATCH] D83984: Explicitly use utf-8 in send_string

2020-07-16 Thread Tom Rix via Phabricator via cfe-commits
trixirt created this revision.
trixirt added reviewers: serge-sans-paille, michaelplatings.
trixirt added a project: clang.
Herald added a subscriber: cfe-commits.

send_patched_file decodes with utf-8.
The default encoder for python 2 is ascii.

So it is necessary to also change send_string to use utf-8.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83984

Files:
  clang/tools/scan-view/share/ScanView.py


Index: clang/tools/scan-view/share/ScanView.py
===
--- clang/tools/scan-view/share/ScanView.py
+++ clang/tools/scan-view/share/ScanView.py
@@ -744,7 +744,7 @@
 return f
 
 def send_string(self, s, ctype='text/html', headers=True, mtime=None):
-encoded_s = s.encode()
+encoded_s = s.encode('utf-8')
 if headers:
 self.send_response(200)
 self.send_header("Content-type", ctype)


Index: clang/tools/scan-view/share/ScanView.py
===
--- clang/tools/scan-view/share/ScanView.py
+++ clang/tools/scan-view/share/ScanView.py
@@ -744,7 +744,7 @@
 return f
 
 def send_string(self, s, ctype='text/html', headers=True, mtime=None):
-encoded_s = s.encode()
+encoded_s = s.encode('utf-8')
 if headers:
 self.send_response(200)
 self.send_header("Content-type", ctype)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.
Herald added a subscriber: dang.



Comment at: clang/lib/Driver/Driver.cpp:3754
 
+  // We don't need to count the assembler as a job since it doesn't
+  // cause the memory issue that requires disabling integrated-cc1.

lebedev.ri wrote:
> This appears unrelated to the patch.
This might be related to the requirement that perfetto trace everything in 
process; though I think this is also a pre-existing bug IMO that can be 
precommitted.



Comment at: llvm/cmake/modules/AddPerfetto.cmake:9
+  ExternalProject_Add(perfetto_git
+  GIT_REPOSITORY https://github.com/google/perfetto.git
+  GIT_TAG releases/v4.x

lebedev.ri wrote:
> I have concerns about this.
> It really should use system-provided version via `find_package()`
> At worst, the sources should be bundled into the tree like it's already done 
> in some rare cases.
Not that I'm very good with CMake, but this seems to suggest that 
`ExternalProject_Add` may not compose well with `find_package`: 
https://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82994



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


[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-16 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM with minor nit.




Comment at: 
clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp:10
+struct T{
+T();
+~T();

nit: fix clang-format warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83974



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf78d9fceea73: [libFuzzer] Link libFuzzers own 
interceptors when other compiler runtimes are… (authored by dokyungs, committed 
by morehouse).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
===
--- /dev/null
+++ compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
@@ -0,0 +1,170 @@
+//===-- FuzzerInterceptors.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
+//
+//===--===//
+// Intercept certain libc functions to aid fuzzing.
+// Linked only when other RTs that define their own interceptors are not linked.
+//===--===//
+
+#include "FuzzerPlatform.h"
+
+#if LIBFUZZER_LINUX
+
+#define GET_CALLER_PC() __builtin_return_address(0)
+
+#define PTR_TO_REAL(x) real_##x
+#define REAL(x) __interception::PTR_TO_REAL(x)
+#define FUNC_TYPE(x) x##_type
+#define DEFINE_REAL(ret_type, func, ...)   \
+  typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);\
+  namespace __interception { 

[clang] f78d9fc - [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Matt Morehouse via cfe-commits

Author: Dokyung Song
Date: 2020-07-16T20:26:35Z
New Revision: f78d9fceea736d431e9e3cbca291e3909e3aa46d

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

LOG: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes 
are not linked.

Summary: libFuzzer intercepts certain library functions such as memcmp/strcmp 
by defining weak hooks. Weak hooks, however, are called only when other 
runtimes such as ASan is linked. This patch defines libFuzzer's own 
interceptors, which is linked into the libFuzzer executable when other runtimes 
are not linked, i.e., when -fsanitize=fuzzer is given, but not others.

Reviewers: kcc, morehouse, hctim

Reviewed By: morehouse, hctim

Subscribers: krytarowski, mgorny, cfe-commits, #sanitizers

Tags: #clang, #sanitizers

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

Added: 
compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp

Modified: 
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
compiler-rt/lib/fuzzer/CMakeLists.txt
compiler-rt/test/fuzzer/memcmp.test
compiler-rt/test/fuzzer/memcmp64.test
compiler-rt/test/fuzzer/strcmp.test
compiler-rt/test/fuzzer/strncmp.test
compiler-rt/test/fuzzer/strstr.test

Removed: 




diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index 934dab808e82..563d6c3ff9de 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -74,6 +74,7 @@ class SanitizerArgs {
!Sanitizers.has(SanitizerKind::Address) &&
!Sanitizers.has(SanitizerKind::HWAddress);
   }
+  bool needsFuzzerInterceptors() const;
   bool needsUbsanRt() const;
   bool requiresMinimalRuntime() const { return MinimalRuntime; }
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index bcc9ffc7ff8f..e4fda752c041 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -240,6 +240,10 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver ,
   return TrappingKinds;
 }
 
+bool SanitizerArgs::needsFuzzerInterceptors() const {
+  return needsFuzzer() && !needsAsanRt() && !needsTsanRt() && !needsMsanRt();
+}
+
 bool SanitizerArgs::needsUbsanRt() const {
   // All of these include ubsan.
   if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() ||

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6b6e276b8ce7..acde6d9e2111 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -784,6 +784,9 @@ bool tools::addSanitizerRuntimes(const ToolChain , const 
ArgList ,
   !Args.hasArg(options::OPT_shared)) {
 
 addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
+if (SanArgs.needsFuzzerInterceptors())
+  addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer_interceptors", false,
+  true);
 if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   }

diff  --git a/compiler-rt/lib/fuzzer/CMakeLists.txt 
b/compiler-rt/lib/fuzzer/CMakeLists.txt
index b5be6b89452e..02be89cb70a5 100644
--- a/compiler-rt/lib/fuzzer/CMakeLists.txt
+++ b/compiler-rt/lib/fuzzer/CMakeLists.txt
@@ -99,6 +99,13 @@ add_compiler_rt_object_libraries(RTfuzzer_main
   CFLAGS ${LIBFUZZER_CFLAGS}
   DEPS ${LIBFUZZER_DEPS})
 
+add_compiler_rt_object_libraries(RTfuzzer_interceptors
+  OS ${FUZZER_SUPPORTED_OS}
+  ARCHS ${FUZZER_SUPPORTED_ARCH}
+  SOURCES FuzzerInterceptors.cpp
+  CFLAGS ${LIBFUZZER_CFLAGS}
+  DEPS ${LIBFUZZER_DEPS})
+
 add_compiler_rt_runtime(clang_rt.fuzzer
   STATIC
   OS ${FUZZER_SUPPORTED_OS}
@@ -115,6 +122,14 @@ add_compiler_rt_runtime(clang_rt.fuzzer_no_main
   CFLAGS ${LIBFUZZER_CFLAGS}
   PARENT_TARGET fuzzer)
 
+add_compiler_rt_runtime(clang_rt.fuzzer_interceptors
+  STATIC
+  OS ${FUZZER_SUPPORTED_OS}
+  ARCHS ${FUZZER_SUPPORTED_ARCH}
+  OBJECT_LIBS RTfuzzer_interceptors
+  CFLAGS ${LIBFUZZER_CFLAGS}
+  PARENT_TARGET fuzzer)
+
 if(OS_NAME MATCHES "Linux|Fuchsia" AND
COMPILER_RT_LIBCXX_PATH AND
COMPILER_RT_LIBCXXABI_PATH)
@@ -148,7 +163,10 @@ if(OS_NAME MATCHES "Linux|Fuchsia" AND
 add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
 target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem 
${LIBCXX_${arch}_PREFIX}/include/c++/v1)
 add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
+target_compile_options(RTfuzzer_interceptors.${arch} PRIVATE -isystem 
${LIBCXX_${arch}_PREFIX}/include/c++/v1)
+

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278589.
dokyungs added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
===
--- /dev/null
+++ compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
@@ -0,0 +1,170 @@
+//===-- FuzzerInterceptors.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
+//
+//===--===//
+// Intercept certain libc functions to aid fuzzing.
+// Linked only when other RTs that define their own interceptors are not linked.
+//===--===//
+
+#include "FuzzerPlatform.h"
+
+#if LIBFUZZER_LINUX
+
+#define GET_CALLER_PC() __builtin_return_address(0)
+
+#define PTR_TO_REAL(x) real_##x
+#define REAL(x) __interception::PTR_TO_REAL(x)
+#define FUNC_TYPE(x) x##_type
+#define DEFINE_REAL(ret_type, func, ...)   \
+  typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);\
+  namespace __interception {   \
+  FUNC_TYPE(func) PTR_TO_REAL(func);   \
+  }
+
+#include 

[PATCH] D83857: Harmonize python shebang

2020-07-16 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG515bc8c1554f: Harmonize Python shebang (authored by 
serge-sans-paille).
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc-project.
Herald added subscribers: libc-commits, openmp-commits, libcxx-commits, 
lldb-commits, Sanitizers, cfe-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83857

Files:
  clang/utils/clangdiag.py
  clang/utils/modfuzz.py
  compiler-rt/lib/sanitizer_common/scripts/litlint_test.py
  compiler-rt/test/sanitizer_common/android_commands/android_compile.py
  compiler-rt/test/sanitizer_common/android_commands/android_run.py
  compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py
  compiler-rt/test/sanitizer_common/ios_commands/iossim_env.py
  compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
  compiler-rt/test/sanitizer_common/ios_commands/iossim_run.py
  debuginfo-tests/dexter/dexter.py
  debuginfo-tests/llgdb-tests/llgdb.py
  libc/AOR_v20.02/math/tools/plot.py
  libcxx/utils/google-benchmark/mingw.py
  lldb/examples/darwin/heap_find/heap.py
  lldb/examples/python/armv7_cortex_m_target_defintion.py
  lldb/examples/python/bsd.py
  lldb/examples/python/cmdtemplate.py
  lldb/examples/python/crashlog.py
  lldb/examples/python/delta.py
  lldb/examples/python/disasm-stress-test.py
  lldb/examples/python/disasm.py
  lldb/examples/python/file_extract.py
  lldb/examples/python/gdbremote.py
  lldb/examples/python/globals.py
  lldb/examples/python/lldb_module_utils.py
  lldb/examples/python/lldbtk.py
  lldb/examples/python/mach_o.py
  lldb/examples/python/memory.py
  lldb/examples/python/operating_system.py
  lldb/examples/python/performance.py
  lldb/examples/python/process_events.py
  lldb/examples/python/sbvalue.py
  lldb/examples/python/shadow.py
  lldb/examples/python/sources.py
  lldb/examples/python/stacks.py
  lldb/examples/python/symbolication.py
  lldb/examples/python/types.py
  lldb/examples/python/x86_64_linux_target_definition.py
  lldb/examples/python/x86_64_qemu_target_definition.py
  lldb/examples/python/x86_64_target_definition.py
  lldb/scripts/analyze-project-deps.py
  lldb/scripts/reproducer-replay.py
  lldb/test/API/functionalities/plugins/python_os_plugin/operating_system.py
  lldb/test/API/functionalities/plugins/python_os_plugin/operating_system2.py
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/operating_system.py
  lldb/test/Shell/helper/build.py
  lldb/third_party/Python/module/progress/progress.py
  llvm/utils/DSAclean.py
  llvm/utils/DSAextract.py
  llvm/utils/benchmark/mingw.py
  llvm/utils/docker/scripts/llvm_checksum/llvm_checksum.py
  llvm/utils/lint/common_lint.py
  llvm/utils/lint/cpp_lint.py
  llvm/utils/lint/generic_lint.py
  llvm/utils/schedcover.py
  llvm/utils/testgen/mc-bundling-x86-gen.py
  openmp/runtime/tools/summarizeStats.py
  polly/test/update_check.py
  polly/utils/jscop2cloog.py
  polly/utils/pyscop/jscop2iscc.py

Index: polly/utils/pyscop/jscop2iscc.py
===
--- polly/utils/pyscop/jscop2iscc.py
+++ polly/utils/pyscop/jscop2iscc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 import argparse, isl, os
 import json
 
Index: polly/utils/jscop2cloog.py
===
--- polly/utils/jscop2cloog.py
+++ polly/utils/jscop2cloog.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 import argparse, os
 import json
 
Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#!/usr/bin/env python3
 # -*- coding: UTF-8 -*-
 
 # Polly/LLVM update_check.py
Index: openmp/runtime/tools/summarizeStats.py
===
--- openmp/runtime/tools/summarizeStats.py
+++ openmp/runtime/tools/summarizeStats.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 import pandas as pd
 import numpy as np
Index: llvm/utils/testgen/mc-bundling-x86-gen.py
===
--- llvm/utils/testgen/mc-bundling-x86-gen.py
+++ llvm/utils/testgen/mc-bundling-x86-gen.py
@@ -1,5 +1,5 @@
 
-#!/usr/bin/python
+#!/usr/bin/env python
 
 # Auto-generates an exhaustive and repetitive test for correct bundle-locked
 # alignment on x86.
Index: llvm/utils/schedcover.py
===
--- llvm/utils/schedcover.py
+++ llvm/utils/schedcover.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 # This creates a CSV file from the output of the debug output of subtarget:
 #   llvm-tblgen --gen-subtarget --debug-only=subtarget-emitter
Index: 

[clang] 4fd91b0 - Remove an unused variable in Clang.

2020-07-16 Thread Nadav Rotem via cfe-commits

Author: Nadav Rotem
Date: 2020-07-16T12:48:48-07:00
New Revision: 4fd91b0f946f49370a3ab33c480a807a3f48b247

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

LOG: Remove an unused variable in Clang.

https://reviews.llvm.org/D83788

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ccae79636f32..8fd0e2892b14 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15543,7 +15543,6 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType 
ConvTy,
   bool CheckInferredResultType = false;
   bool isInvalid = false;
   unsigned DiagKind = 0;
-  FixItHint Hint;
   ConversionFixItGenerator ConvHints;
   bool MayHaveConvFixit = false;
   bool MayHaveFunctionDiff = false;
@@ -15596,10 +15595,9 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType 
ConvTy,
 }
 CheckInferredResultType = DstType->isObjCObjectPointerType() &&
   SrcType->isObjCObjectPointerType();
-if (Hint.isNull() && !CheckInferredResultType) {
+if (!CheckInferredResultType) {
   ConvHints.tryToFixConversion(SrcExpr, SrcType, DstType, *this);
-}
-else if (CheckInferredResultType) {
+} else if (CheckInferredResultType) {
   SrcType = SrcType.getUnqualifiedType();
   DstType = DstType.getUnqualifiedType();
 }
@@ -15768,13 +15766,11 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType 
ConvTy,
 FDiag << FirstType << SecondType << Action << SrcExpr->getSourceRange();
 
   // If we can fix the conversion, suggest the FixIts.
-  assert(ConvHints.isNull() || Hint.isNull());
   if (!ConvHints.isNull()) {
 for (FixItHint  : ConvHints.Hints)
   FDiag << H;
-  } else {
-FDiag << Hint;
   }
+
   if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.Kind); }
 
   if (MayHaveFunctionDiff)



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


[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-16 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D83592#2151773 , @zequanwu wrote:

> In D83592#2151217 , @vsk wrote:
>
> > Could you add an end-to-end llvm-cov test (see e.g. 
> > compiler-rt/test/profile/Linux/coverage_ctors.cpp)? Here are some important 
> > cases I think we should check:
> >
> > - `/* comment at the start of a line */ expr;`
> > - `expr; /* comment at the end of a line */`
> > - `expr; // comment at the end of a line`
> > - `// comment spanning entire line`
> >
> >   In all but the last case, llvm-cov should report an execution count for 
> > the line. Testing multi-line variations of those cases would also be 
> > helpful.
>
>
> llvm-cov doesn't report the execution count for the first 3 liens... I will 
> try to fix that.


The problem is that simply marking comment regions as `SkippedRegion` doesn't 
give enough information for `llvm-cov` about if there is code area before or 
after comments in the same line.

  $ clang++ -fcoverage-mapping -fprofile-instr-generate /tmp/a.cpp -Xclang 
-dump-coverage-mapping && ./a.out && llvm-profdata merge -sparse 
default.profraw -o a.profdata && llvm-cov show ./a.out 
-instr-profile=a.profdata -debug-only="coverage-mapping"
  main:
File 0, 1:12 -> 7:2 = #0
Skipped,File 0, 2:3 -> 2:39 = 0
Skipped,File 0, 3:15 -> 3:49 = 0
Skipped,File 0, 4:15 -> 4:46 = 0
Skipped,File 0, 5:3 -> 5:34 = 0
  Counter in file 0 1:12 -> 7:2, #0
  Counter in file 0 2:3 -> 2:39, 0
  Counter in file 0 3:15 -> 3:49, 0
  Counter in file 0 4:15 -> 4:46, 0
  Counter in file 0 5:3 -> 5:34, 0
  Emitting segments for file: /tmp/a.cpp
  Combined regions:
1:12 -> 7:2 (count=1)
2:3 -> 2:39 (count=0)
3:15 -> 3:49 (count=0)
4:15 -> 4:46 (count=0)
5:3 -> 5:34 (count=0)
  Segment at 1:12 (count = 1), RegionEntry
  Segment at 2:3 (count = 0), RegionEntry, Skipped
  Segment at 2:39 (count = 1)
  Segment at 3:15 (count = 0), RegionEntry, Skipped
  Segment at 3:49 (count = 1)
  Segment at 4:15 (count = 0), RegionEntry, Skipped
  Segment at 4:46 (count = 1)
  Segment at 5:3 (count = 0), RegionEntry, Skipped
  Segment at 5:34 (count = 1)
  Segment at 7:2 (count = 0), Skipped
  1|  1|int main() {
  2|   |  /* comment at the start of a line */ int x = 0;
  3|   |  int y = 0;  /* comment at the end of a line */
  4|   |  int z = 0;  // comment at the end of a line
  5|   |  // comment spanning entire line
  6|  1|  return 0;
  7|  1|}
  8|   |

One way I could think is probably when we visit decl in 
`CounterCoverageMappingBuilder`, check for if there is `SkippedRegion` in the 
same line and then mark the decl range as `CodeRegion`. For the example, we 
will have 3 more `CodeRegion` which covers the ranges of `int x = 0`, `int y = 
0` and `int z = 0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83592



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


[PATCH] D83979: Port LangOpts option flags to new option parsing system

2020-07-16 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, sstefan1, dexonsmith, aheejin, dschuff.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Depends on D83940 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83979

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -269,7 +269,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return Value;
+  return static_cast(Value);
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -285,7 +285,8 @@
   return KeyPath & Value;
 }
 
-static void FixupInvocation(CompilerInvocation ) {
+static void FixupInvocation(CompilerInvocation ,
+DiagnosticsEngine ) {
   LangOptions  = *Invocation.getLangOpts();
   DiagnosticOptions  = Invocation.getDiagnosticOpts();
   CodeGenOptions  = Invocation.getCodeGenOpts();
@@ -296,7 +297,15 @@
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
+  LangOpts.Optimize = CodeGenOpts.OptimizationLevel != 0;
+  LangOpts.OptimizeSize = CodeGenOpts.OptimizeSize != 0;
+  LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
+  LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+
+  if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
+Diags.Report(diag::warn_c_kext);
 }
 
 //===--===//
@@ -2292,9 +2301,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_dllexport_inlines))
-Opts.DllExportInlines = false;
-
   if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
 StringRef Name = A->getValue();
 if (Name == "full" || Name == "branch") {
@@ -2321,7 +2327,6 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
   if (Opts.SYCL) {
 // -sycl-std applies to any SYCL source, not only those containing kernels,
@@ -2339,9 +2344,6 @@
 }
   }
 
-  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
-  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
-
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
@@ -2367,20 +2369,9 @@
 
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
-
-  if (Args.hasArg(OPT_fcuda_is_device))
-Opts.CUDAIsDevice = 1;
-
-  if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
-Opts.CUDAAllowVariadicFunctions = 1;
-
-  if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
-Opts.CUDAHostDeviceConstexpr = 0;
-
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
 Opts.CUDADeviceApproxTranscendentals = 1;
 
-  Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
   if (Args.hasArg(OPT_fgpu_allow_device_init)) {
 if (Opts.HIP)
   Opts.GPUAllowDeviceInit = 1;
@@ -2388,7 +2379,6 @@
   Diags.Report(diag::warn_ignored_hip_only_option)
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
-  Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
   if (Opts.HIP)
 Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
@@ -2408,7 +2398,6 @@
 else if (Args.hasArg(OPT_fobjc_gc))
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
-  Opts.ObjCAutoRefCount = 1;
   if (!Opts.ObjCRuntime.allowsARC())
 Diags.Report(diag::err_arc_unsupported_on_runtime);
 }
@@ -2438,9 +2427,6 @@
   Opts.ObjCWeak = Opts.ObjCWeakRuntime;
 }
 
-if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
-  Opts.ObjCInferRelatedResultType = 0;
-
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
@@ -2469,18 +2455,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (Args.hasArg(OPT_fapple_kext)) {
-if (!Opts.CPlusPlus)
-  Diags.Report(diag::warn_c_kext);
-else
-  Opts.AppleKext = 1;
-  }
-
-  if (Args.hasArg(OPT_print_ivar_layout))
-Opts.ObjCGCBitmapPrint = 1;
-
-  if (Args.hasArg(OPT_fno_constant_cfstrings))
-Opts.NoConstantCFStrings = 1;
   if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
 Opts.CFRuntime =
 llvm::StringSwitch(A->getValue())
@@ -2492,12 +2466,6 @@
 .Case("swift-4.1", 

[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:93
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be requierd to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {

typo: requierd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:93
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {

asoffer wrote:
> ymandel wrote:
> > asoffer wrote:
> > > ymandel wrote:
> > > > nit: typos
> > > > 
> > > > The same applies to `Note`. Since this is a nullable type, can we ask 
> > > > that the user check `Metadata != nullptr`?
> > > I don't think I'm understanding the question. Where/when would users 
> > > check for Metadata != nullptr?
> > > 
> > > Currently in this diff, any library construction of the Metadata field 
> > > will be non-null. Users would have to explicitly pass null in if they 
> > > wanted it to be null which would pretty quickly break when the generator 
> > > is called, so this seems like a not-too-big foot-gun? Does that answer 
> > > the question?
> > Sorry, I meant code that consumes this struct. Mostly that's just 
> > `translateEdits`. I realize now that `Note` is not a great example, since 
> > we totally ignore it. However, it is intended as optional, so if we had the 
> > code, it would be checking it for null first. Conversely, `TargetRange` and 
> > `Replacement` are assumed to never be null, yet we don't set them to 
> > default values here.  So, I think the first step is to decide if this is 
> > optional, and (if not) the second is to consistently handle non-optional 
> > values in this struct.
> > 
> > So, your code below would become something like:
> > ```
> > llvm::Any Metadata;
> > if (E.Metadata != nullptr) {
> >   if (auto M = E.Metadata(Result))
> > Metadata = std::move(*M);
> >   else
> > return M.takeError();
> > }
> > ```
> I don't see any particular reason to allow this field to take on it's null 
> value. A null check could essentially avoid attaching metadata, but that's 
> also what the default lambda would do here (because Any is also a nullable 
> type).
> 
> That being said, sometimes I'm a bit UB-trigger-happy.
Sure. The lack of null check is consistent with the other two fields. so, that 
just leaves it inconsistent with `Note`, which doesn't have as easy an answer 
(since string isn't nullable).  Given that `Note` isn't used (yet), let's punt 
on the consistency issue until we deal with `Note` properly. You're good to go. 
Thanks for talking this through!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D75677: [Analyzer] Only add iterator note tags to the operations of the affected iterators

2020-07-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 278574.
baloghadamsoftware added a comment.

Rebased, no tricks with `LazyCompoundVal`s are used anymore.


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

https://reviews.llvm.org/D75677

Files:
  clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -957,3 +957,4 @@
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
   // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
+
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -116,7 +116,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto j = i++; // expected-note 2{{Iterator 'i' incremented by 1}}
+  auto j = i++; // expected-note{{Iterator 'i' incremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.begin() + 1{{$
// expected-note@-1{{$v.begin() + 1}}
@@ -129,7 +129,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto j = i--; // expected-note 2{{Iterator 'i' decremented by 1}}
+  auto j = i--; // expected-note{{Iterator 'i' decremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.end() - 1{{$
// expected-note@-1{{$v.end() - 1}}
@@ -223,7 +223,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 + 2; // expected-note 4{{Iterator 'i1' incremented by 2}}
+  auto i2 = i1 + 2; // expected-note 2{{Iterator 'i1' incremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == ); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -231,8 +231,6 @@
 // expected-note@-1{{$v.begin()}}
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re{{$v.begin() + 2{{$
 // expected-note@-1{{$v.begin() + 2}}
-  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$v.begin() + 2}}
-// expected-note@-1{{$v.begin() + 2}}
 }
 
 void plus_negative(const std::vector ) {
@@ -240,7 +238,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto i2 = i1 + (-2); // expected-note 3{{Iterator 'i1' decremented by 2}}
+  auto i2 = i1 + (-2); // expected-note 2{{Iterator 'i1' decremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == ); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -255,7 +253,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 + 0; // expected-note 2{{Iterator 'i1' unchanged}}
+  auto i2 = i1 + 0; // expected-note{{Iterator 'i1' unchanged}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == ); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -268,7 +266,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto i2 = i1 - 2;  // expected-note 3{{Iterator 'i1' decremented by 2}}
+  auto i2 = i1 - 2; // expected-note 2{{Iterator 'i1' decremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == ); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -283,7 +281,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 - (-2); // expected-note 3{{Iterator 'i1' incremented by 2}}
+  auto i2 = i1 - (-2); // expected-note 2{{Iterator 'i1' incremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == ); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -298,7 +296,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 - 0; // expected-note 2{{Iterator 'i1' unchanged}}
+  auto i2 = i1 - 0; // expected-note{{Iterator 'i1' unchanged}}
 
   

[PATCH] D74541: [Analyzer] Use note tags to track iterator increments and decrements

2020-07-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/test/Analysis/iterator-modelling.cpp:434
+  //expected-note@-1 0-1{{Calling 'next}}
+  //expected-note@-2 0-1{{Passing the value 1 via 2nd parameter 'n'}}
+  //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Iterator 'it' 
incremented by 1}}

NoQ wrote:
> baloghadamsoftware wrote:
> > Strange, that we do not get this note for `prev`.
> Mmm, why `0-1`?
Because it depends whether `next()` is inlined.


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

https://reviews.llvm.org/D74541



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:51
+static int fuzzerInited = 0;
+static bool fuzzerInitIsRunning;
+

Sorry, one last nit:

If we're preferring LLVM style, let's 
[capitalize](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly)
 variable names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


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

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

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

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

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

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

Added: 


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

Removed: 
clang/unittests/AST/HasSideEffectsTest.cpp



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

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

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



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


[PATCH] D83713: [WebAssembly] Triple::wasm64 related cleanup

2020-07-16 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29f8c9f6c25d: [WebAssembly] Triple::wasm64 related cleanup 
(authored by aardappel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83713

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/InputFiles.cpp
  lld/wasm/SyntheticSections.cpp
  lld/wasm/Writer.cpp
  llvm/include/llvm/Object/Wasm.h
  llvm/lib/Object/WasmObjectFile.cpp

Index: llvm/lib/Object/WasmObjectFile.cpp
===
--- llvm/lib/Object/WasmObjectFile.cpp
+++ llvm/lib/Object/WasmObjectFile.cpp
@@ -957,6 +957,8 @@
   break;
 case wasm::WASM_EXTERNAL_MEMORY:
   Im.Memory = readLimits(Ctx);
+  if (Im.Memory.Flags & wasm::WASM_LIMITS_FLAG_IS_64)
+HasMemory64 = true;
   break;
 case wasm::WASM_EXTERNAL_TABLE:
   Im.Table = readTable(Ctx);
@@ -1019,7 +1021,10 @@
   uint32_t Count = readVaruint32(Ctx);
   Memories.reserve(Count);
   while (Count--) {
-Memories.push_back(readLimits(Ctx));
+auto Limits = readLimits(Ctx);
+if (Limits.Flags & wasm::WASM_LIMITS_FLAG_IS_64)
+  HasMemory64 = true;
+Memories.push_back(Limits);
   }
   if (Ctx.Ptr != Ctx.End)
 return make_error("Memory section ended prematurely",
@@ -1576,11 +1581,15 @@
   return section_iterator(SectionRef(Ref, this));
 }
 
-uint8_t WasmObjectFile::getBytesInAddress() const { return 4; }
+uint8_t WasmObjectFile::getBytesInAddress() const {
+  return HasMemory64 ? 8 : 4;
+}
 
 StringRef WasmObjectFile::getFileFormatName() const { return "WASM"; }
 
-Triple::ArchType WasmObjectFile::getArch() const { return Triple::wasm32; }
+Triple::ArchType WasmObjectFile::getArch() const {
+  return HasMemory64 ? Triple::wasm64 : Triple::wasm32;
+}
 
 SubtargetFeatures WasmObjectFile::getFeatures() const {
   return SubtargetFeatures();
Index: llvm/include/llvm/Object/Wasm.h
===
--- llvm/include/llvm/Object/Wasm.h
+++ llvm/include/llvm/Object/Wasm.h
@@ -282,6 +282,7 @@
   bool HasLinkingSection = false;
   bool HasDylinkSection = false;
   bool SeenCodeSection = false;
+  bool HasMemory64 = false;
   wasm::WasmLinkingData LinkingData;
   uint32_t NumImportedGlobals = 0;
   uint32_t NumImportedFunctions = 0;
Index: lld/wasm/Writer.cpp
===
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -304,7 +304,8 @@
   if (WasmSym::heapBase)
 WasmSym::heapBase->setVirtualAddress(memoryPtr);
 
-  uint64_t maxMemorySetting = 1ULL << (config->is64 ? 48 : 32);
+  uint64_t maxMemorySetting = 1ULL
+  << (config->is64.getValueOr(false) ? 48 : 32);
 
   if (config->initialMemory != 0) {
 if (config->initialMemory != alignTo(config->initialMemory, WasmPageSize))
Index: lld/wasm/SyntheticSections.cpp
===
--- lld/wasm/SyntheticSections.cpp
+++ lld/wasm/SyntheticSections.cpp
@@ -139,7 +139,7 @@
 }
 if (config->sharedMemory)
   import.Memory.Flags |= WASM_LIMITS_FLAG_IS_SHARED;
-if (config->is64)
+if (config->is64.getValueOr(false))
   import.Memory.Flags |= WASM_LIMITS_FLAG_IS_64;
 writeImport(os, import);
   }
@@ -236,7 +236,7 @@
 flags |= WASM_LIMITS_FLAG_HAS_MAX;
   if (config->sharedMemory)
 flags |= WASM_LIMITS_FLAG_IS_SHARED;
-  if (config->is64)
+  if (config->is64.getValueOr(false))
 flags |= WASM_LIMITS_FLAG_IS_64;
   writeUleb128(os, flags, "memory limits flags");
   writeUleb128(os, numMemoryPages, "initial pages");
Index: lld/wasm/InputFiles.cpp
===
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -576,10 +576,16 @@
   obj = check(lto::InputFile::create(MemoryBufferRef(
   mb.getBuffer(), saver.save(archiveName + mb.getBufferIdentifier();
   Triple t(obj->getTargetTriple());
-  if (t.getArch() != Triple::wasm32) {
-error(toString(this) + ": machine type must be wasm32");
+  if (!t.isWasm()) {
+error(toString(this) + ": machine type must be wasm32 or wasm64");
 return;
   }
+  bool is64 = t.getArch() == Triple::wasm64;
+  if (config->is64.hasValue() && *config->is64 != is64) {
+error(toString(this) + ": machine type for all bitcode files must match");
+return;
+  }
+  config->is64 = is64;
   std::vector keptComdats;
   for (StringRef s : obj->getComdatTable())
 keptComdats.push_back(symtab->addComdat(s));
Index: lld/wasm/InputChunks.cpp
===
--- lld/wasm/InputChunks.cpp
+++ lld/wasm/InputChunks.cpp
@@ -335,10 +335,12 @@
   LLVM_DEBUG(dbgs() << "generating runtime relocations: " << getName()
 << " count=" << 

[clang] 29f8c9f - [WebAssembly] Triple::wasm64 related cleanup

2020-07-16 Thread Wouter van Oortmerssen via cfe-commits

Author: Wouter van Oortmerssen
Date: 2020-07-16T12:01:10-07:00
New Revision: 29f8c9f6c25d50fd21e255060ea36eb0025ca2eb

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

LOG: [WebAssembly] Triple::wasm64 related cleanup

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

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
lld/wasm/Config.h
lld/wasm/Driver.cpp
lld/wasm/InputChunks.cpp
lld/wasm/InputFiles.cpp
lld/wasm/SyntheticSections.cpp
lld/wasm/Writer.cpp
llvm/include/llvm/Object/Wasm.h
llvm/lib/Object/WasmObjectFile.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b8c12fc9241a..b7256eb08ac6 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -631,9 +631,7 @@ bool ToolChain::isThreadModelSupported(const StringRef 
Model) const {
 return Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::armeb ||
Triple.getArch() == llvm::Triple::thumb ||
-   Triple.getArch() == llvm::Triple::thumbeb ||
-   Triple.getArch() == llvm::Triple::wasm32 ||
-   Triple.getArch() == llvm::Triple::wasm64;
+   Triple.getArch() == llvm::Triple::thumbeb || Triple.isWasm();
   } else if (Model == "posix")
 return true;
 
@@ -999,9 +997,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().getArch() == llvm::Triple::arm ||
-  getTriple().getArch() == llvm::Triple::wasm32 ||
-  getTriple().getArch() == llvm::Triple::wasm64 || getTriple().isAArch64())
+  getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
+  getTriple().isAArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 || getTriple().isAArch64())
 Res |= SanitizerKind::ShadowCallStack;

diff  --git a/lld/wasm/Config.h b/lld/wasm/Config.h
index cae2852baf86..e8d018f09bf6 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -37,7 +37,7 @@ struct Configuration {
   bool importMemory;
   bool sharedMemory;
   bool importTable;
-  bool is64;
+  llvm::Optional is64;
   bool mergeDataSegments;
   bool pie;
   bool printGcSections;

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index d0805bf3b303..7307aaa3f7be 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -380,7 +380,6 @@ static void readConfigs(opt::InputArgList ) {
   args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, config->shared);
 
   // Parse wasm32/64.
-  config->is64 = false;
   if (auto *arg = args.getLastArg(OPT_m)) {
 StringRef s = arg->getValue();
 if (s == "wasm32")
@@ -528,7 +527,7 @@ createUndefinedGlobal(StringRef name, 
llvm::wasm::WasmGlobalType *type) {
 static GlobalSymbol *createGlobalVariable(StringRef name, bool isMutable,
   int value) {
   llvm::wasm::WasmGlobal wasmGlobal;
-  if (config->is64) {
+  if (config->is64.getValueOr(false)) {
 wasmGlobal.Type = {WASM_TYPE_I64, isMutable};
 wasmGlobal.InitExpr.Value.Int64 = value;
 wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I64_CONST;
@@ -570,16 +569,18 @@ static void createSyntheticSymbols() {
 
 
   if (config->isPic) {
-WasmSym::stackPointer = createUndefinedGlobal(
-"__stack_pointer",
-config->is64 ?  : );
+WasmSym::stackPointer =
+createUndefinedGlobal("__stack_pointer", config->is64.getValueOr(false)
+ ? 
+ : );
 // For PIC code, we import two global variables (__memory_base and
 // __table_base) from the environment and use these as the offset at
 // which to load our static data and function table.
 // See:
 // 
https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
 WasmSym::memoryBase = createUndefinedGlobal(
-"__memory_base", config->is64 ?  : );
+"__memory_base",
+config->is64.getValueOr(false) ?  : );
 WasmSym::tableBase = createUndefinedGlobal("__table_base", );
 WasmSym::memoryBase->markLive();
 WasmSym::tableBase->markLive();
@@ -604,9 +605,9 @@ static void createSyntheticSymbols() {
 WasmSym::tlsAlign = createGlobalVariable("__tls_align", false, 1);
 WasmSym::initTLS = symtab->addSyntheticFunction(
 "__wasm_init_tls", WASM_SYMBOL_VISIBILITY_HIDDEN,
-make(config->is64 ? i64ArgSignature
- : i32ArgSignature,
-

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278565.
dokyungs added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
===
--- /dev/null
+++ compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
@@ -0,0 +1,170 @@
+//===-- FuzzerInterceptors.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
+//
+//===--===//
+// Intercept certain libc functions to aid fuzzing.
+// Linked only when other RTs that define their own interceptors are not linked.
+//===--===//
+
+#include "FuzzerPlatform.h"
+
+#if LIBFUZZER_LINUX
+
+#define GET_CALLER_PC() __builtin_return_address(0)
+
+#define PTR_TO_REAL(x) real_##x
+#define REAL(x) __interception::PTR_TO_REAL(x)
+#define FUNC_TYPE(x) x##_type
+#define DEFINE_REAL(ret_type, func, ...)   \
+  typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);\
+  namespace __interception {   \
+  FUNC_TYPE(func) PTR_TO_REAL(func);   \
+  }
+
+#include 

[PATCH] D83015: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I tweaked the following item in the last revision

> a relative path without a path component separator (/), the value is searched 
> using the -B, COMPILER_PATH, then PATH.

My communication with GCC folks is that they will be happy to adopt something 
like --ld-path. GCC -fuse-ld= searches for all of -B, COMPILER_PATH, then PATH.
This clang patch aligns with my proposed GCC patch 
(https://sourceware.org/pipermail/gcc-patches/2020-July/549386.html I need to 
tweak the option name but Martin said he would be happy with a clang resolution)

@jyknight @phosek  Can I get a bit more approval power? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015



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


[clang] a59d4ae - [Analyzer] Hotfix for various crashes in iterator checkers

2020-07-16 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-07-16T20:49:33+02:00
New Revision: a59d4ae4313c0a961c50d14c0616b49220c5a469

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

LOG: [Analyzer] Hotfix for various crashes in iterator checkers

The patch that introduces handling iterators implemented as pointers may
cause crash in some projects because pointer difference is mistakenly
handled as pointer decrement. (Similair case for iterators implemented
as class instances are already handled correctly.) This patch fixes this
issue.

The second case that causes crash is comparison of an iterator
implemented as pointer and a null-pointer. This patch contains a fix for
this issue as well.

The third case which causes crash is that the checker mistakenly
considers all integers as nonloc::ConcreteInt when handling an increment
or decrement of an iterator implemented as pointers. This patch adds a
fix for this too.

The last case where crashes were detected is when checking for success
of an std::advance() operation. Since the modeling of iterators
implemented as pointers is still incomplete this may result in an
assertion. This patch replaces the assertion with an early exit and
adds a FIXME there.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
clang/test/Analysis/iterator-modeling.cpp
clang/test/Analysis/iterator-range.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
index fd8cbd694b24..632de9e5dc83 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -272,6 +272,8 @@ void IteratorModeling::checkPostStmt(const BinaryOperator 
*BO,
 handleComparison(C, BO, Result, LVal, RVal,
  BinaryOperator::getOverloadedOperator(OK));
   } else if (isRandomIncrOrDecrOperator(OK)) {
+if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+  return;
 handlePtrIncrOrDecr(C, BO->getLHS(),
 BinaryOperator::getOverloadedOperator(OK), RVal);
   }
@@ -461,6 +463,12 @@ void IteratorModeling::handleComparison(CheckerContext , 
const Expr *CE,
 RPos = getIteratorPosition(State, RVal);
   }
 
+  // If the value for which we just tried to set a new iterator position is
+  // an `SVal`for which no iterator position can be set then the setting was
+  // unsuccessful. We cannot handle the comparison in this case.
+  if (!LPos || !RPos)
+return;
+
   // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol
   // instead.
   if (RetVal.isUnknown()) {
@@ -599,6 +607,9 @@ void IteratorModeling::handlePtrIncrOrDecr(CheckerContext 
,
const Expr *Iterator,
OverloadedOperatorKind OK,
SVal Offset) const {
+  if (!Offset.getAs())
+return;
+
   QualType PtrType = Iterator->getType();
   if (!PtrType->isPointerType())
 return;
@@ -612,13 +623,11 @@ void IteratorModeling::handlePtrIncrOrDecr(CheckerContext 
,
 return;
 
   SVal NewVal;
-  if (OK == OO_Plus || OK == OO_PlusEqual)
+  if (OK == OO_Plus || OK == OO_PlusEqual) {
 NewVal = State->getLValue(ElementType, Offset, OldVal);
-  else {
-const llvm::APSInt  =
-  Offset.castAs().getValue();
-auto  = C.getSymbolManager().getBasicVals();
-SVal NegatedOffset = nonloc::ConcreteInt(BVF.getValue(-OffsetInt));
+  } else {
+auto  = C.getSValBuilder();
+SVal NegatedOffset = SVB.evalMinus(Offset.castAs());
 NewVal = State->getLValue(ElementType, NegatedOffset, OldVal);
   }
 
@@ -684,9 +693,14 @@ bool IteratorModeling::noChangeInAdvance(CheckerContext 
, SVal Iter,
 
   const auto StateBefore = N->getState();
   const auto *PosBefore = getIteratorPosition(StateBefore, Iter);
-
-  assert(PosBefore && "`std::advance() should not create new iterator "
- "position but change existing ones");
+  // FIXME: `std::advance()` should not create a new iterator position but
+  //change existing ones. However, in case of iterators implemented as
+  //pointers the handling of parameters in `std::advance()`-like
+  //functions is still incomplete which may result in cases where
+  //the new position is assigned to the wrong pointer. This causes
+  //crash if we use an assertion here.
+  if (!PosBefore)
+return false;
 
   return PosBefore->getOffset() == PosAfter->getOffset();
 }

diff  --git a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp 

[PATCH] D83970: [ASTImporter] Refactor ASTImporter to support custom downstream tests

2020-07-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM but I want @martong to take a look as well and accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83970



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


[PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator checkers

2020-07-16 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa59d4ae4313c: [Analyzer] Hotfix for various crashes in 
iterator checkers (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83295

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -935,3 +935,7 @@
   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
+void ptr_iter_diff(cont_with_ptr_iterator ) {
+  auto i0 = c.begin(), i1 = c.end();
+  ptrdiff_t len = i1 - i0; // no-crash
+}
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1948,6 +1948,13 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}}
 }
 
+void minus_equal_ptr_iterator_variable(const cont_with_ptr_iterator ,
+   int n) {
+  auto i = c.end();
+
+  i -= n; // no-crash
+}
+
 void plus_ptr_iterator(const cont_with_ptr_iterator ) {
   auto i1 = c.begin();
 
@@ -1972,6 +1979,17 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.end() - 2}}
 }
 
+void ptr_iter_diff(cont_with_ptr_iterator ) {
+  auto i0 = c.begin(), i1 = c.end();
+  ptrdiff_t len = i1 - i0; // no-crash
+}
+
+void ptr_iter_cmp_nullptr(cont_with_ptr_iterator ) {
+  auto i0 = c.begin();
+  if (i0 != nullptr) // no-crash
+++i0;
+}
+
 void clang_analyzer_printState();
 
 void print_state(std::vector ) {
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -169,6 +169,8 @@
 verifyDereference(C, LVal);
   } else if (isRandomIncrOrDecrOperator(OK)) {
 SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+  return;
 verifyRandomIncrOrDecr(C, BinaryOperator::getOverloadedOperator(OK), LVal,
RVal);
   }
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -272,6 +272,8 @@
 handleComparison(C, BO, Result, LVal, RVal,
  BinaryOperator::getOverloadedOperator(OK));
   } else if (isRandomIncrOrDecrOperator(OK)) {
+if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+  return;
 handlePtrIncrOrDecr(C, BO->getLHS(),
 BinaryOperator::getOverloadedOperator(OK), RVal);
   }
@@ -461,6 +463,12 @@
 RPos = getIteratorPosition(State, RVal);
   }
 
+  // If the value for which we just tried to set a new iterator position is
+  // an `SVal`for which no iterator position can be set then the setting was
+  // unsuccessful. We cannot handle the comparison in this case.
+  if (!LPos || !RPos)
+return;
+
   // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol
   // instead.
   if (RetVal.isUnknown()) {
@@ -599,6 +607,9 @@
const Expr *Iterator,
OverloadedOperatorKind OK,
SVal Offset) const {
+  if (!Offset.getAs())
+return;
+
   QualType PtrType = Iterator->getType();
   if (!PtrType->isPointerType())
 return;
@@ -612,13 +623,11 @@
 return;
 
   SVal NewVal;
-  if (OK == OO_Plus || OK == OO_PlusEqual)
+  if (OK == OO_Plus || OK == OO_PlusEqual) {
 NewVal = State->getLValue(ElementType, Offset, OldVal);
-  else {
-const llvm::APSInt  =
-  Offset.castAs().getValue();
-auto  = C.getSymbolManager().getBasicVals();
-SVal NegatedOffset = nonloc::ConcreteInt(BVF.getValue(-OffsetInt));
+  } else {
+auto  = C.getSValBuilder();
+SVal NegatedOffset = SVB.evalMinus(Offset.castAs());
 NewVal = State->getLValue(ElementType, NegatedOffset, OldVal);
   }
 
@@ -684,9 +693,14 @@
 
   const auto StateBefore = N->getState();
   const auto *PosBefore = getIteratorPosition(StateBefore, Iter);
-
-  assert(PosBefore && "`std::advance() should not create new iterator "
- "position but change existing ones");
+  // FIXME: `std::advance()` should not create a new iterator 

[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Check, if it fixed https://bugs.llvm.org/show_bug.cgi?id=46012




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9468-9469
  CurSizes, CurMapTypes, PartialStruct);
+if (!CI->capturesThis())
+  MappedVarSet.insert(CI->getCapturedVar()->getCanonicalDecl());
+else

jdenny wrote:
> ABataev wrote:
> > I would check that we capture a variable. We may capture VLA here as well.
> > I would check that we capture a variable. We may capture VLA here as well.
> 
> The `if` on line 9454 above checks for VLAs. This code is in the `else`.
> 
> Similarly, the existing implementation for `generateInfoForCapture`, which is 
> called within this same `else`, doesn't protect against VLAs.  It just checks 
> `capturesThis` as I'm doing there.
> 
> Have I misunderstood?
Ah, yes, here we processed VLAs already. 



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9470-9471
+  MappedVarSet.insert(CI->getCapturedVar()->getCanonicalDecl());
+else
+  MappedVarSet.insert(nullptr);
 if (CurBasePointers.empty())

jdenny wrote:
> ABataev wrote:
> > No need to insert `nullptr` here, it is not used later.
> Without this `nulltpr` insertion, many tests fail because of duplicate map 
> entries.  Independently of my patch, `nulltptr` is used to indicate `this` 
> capture (see the `generateInfoForCapture` implementation) .
> 
> For example:
> 
> ```
> struct S {
>   int i;
>   void foo() {
> #pragma omp target map(i)
> i = 5;
>   }
> };
> ```
> 
> We should have:
> 
> ```
> @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 32, i64 
> 281474976710659]
> ```
> 
> Without the `nullptr` insertion, we have:
> 
> ```
> @.offload_maptypes = private unnamed_addr constant [4 x i64] [i64 32, i64 
> 281474976710659, i64 32, i64 844424930131971]
> ```
This is strange, because you don't check for `nullptr`. You only check for 
`ValueDecl`s, but not capture of `this`.


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

https://reviews.llvm.org/D83922



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


[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-07-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG294d1eae75bf: [RISCV] Add support for -mcpu option. 
(authored by Zakk Chen zakk.c...@sifive.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Driver/riscv-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp
  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
@@ -215,6 +215,16 @@
 
 def : ProcessorModel<"rocket-rv64", Rocket64Model, [Feature64Bit]>;
 
+def : ProcessorModel<"sifive-e31", Rocket32Model, [FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtC]>;
+
+def : ProcessorModel<"sifive-u54", Rocket64Model, [Feature64Bit,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC]>;
 
 //===--===//
 // Define the RISC-V target.
Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -11,11 +11,12 @@
 //
 //===--===//
 
-#include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ARMBuildAttributes.h"
 
 using namespace llvm;
 using namespace AMDGPU;
@@ -208,3 +209,64 @@
   default: return {0, 0, 0};
   }
 }
+
+namespace llvm {
+namespace RISCV {
+
+struct CPUInfo {
+  StringLiteral Name;
+  CPUKind Kind;
+  unsigned Features;
+  StringLiteral DefaultMarch;
+  bool is64Bit() const { return (Features & FK_64BIT); }
+};
+
+constexpr CPUInfo RISCVCPUInfo[] = {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)  \
+  {NAME, CK_##ENUM, FEATURES, DEFAULT_MARCH},
+#include "llvm/Support/RISCVTargetParser.def"
+};
+
+bool checkCPUKind(CPUKind Kind, bool IsRV64) {
+  if (Kind == CK_INVALID)
+return false;
+  return RISCVCPUInfo[static_cast(Kind)].is64Bit() == IsRV64;
+}
+
+CPUKind parseCPUKind(StringRef CPU) {
+  return llvm::StringSwitch(CPU)
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
+#include "llvm/Support/RISCVTargetParser.def"
+  .Default(CK_INVALID);
+}
+
+StringRef getMArchFromMcpu(StringRef CPU) {
+  CPUKind Kind = parseCPUKind(CPU);
+  return RISCVCPUInfo[static_cast(Kind)].DefaultMarch;
+}
+
+void fillValidCPUArchList(SmallVectorImpl , bool IsRV64) {
+  for (const auto  : RISCVCPUInfo) {
+if (C.Kind != CK_INVALID && IsRV64 == C.is64Bit())
+  Values.emplace_back(C.Name);
+  }
+}
+
+// Get all features except standard extension feature
+bool getCPUFeaturesExceptStdExt(CPUKind Kind,
+std::vector ) {
+  unsigned CPUFeatures = RISCVCPUInfo[static_cast(Kind)].Features;
+
+  if (CPUFeatures == FK_INVALID)
+return false;
+
+  if (CPUFeatures & FK_64BIT)
+Features.push_back("+64bit");
+  else
+Features.push_back("-64bit");
+
+  return true;
+}
+
+} // namespace RISCV
+} // namespace llvm
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -130,6 +130,32 @@
 
 } // namespace AMDGPU
 
+namespace RISCV {
+
+enum CPUKind : unsigned {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
+#include "RISCVTargetParser.def"
+};
+
+enum FeatureKind : unsigned {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+  FK_STDEXTM = 1 << 2,
+  FK_STDEXTA = 1 << 3,
+  FK_STDEXTF = 1 << 4,
+  FK_STDEXTD = 1 << 5,
+  FK_STDEXTC = 1 << 6,
+  FK_64BIT = 1 << 7,
+};
+
+bool checkCPUKind(CPUKind Kind, bool IsRV64);
+CPUKind parseCPUKind(StringRef CPU);
+StringRef getMArchFromMcpu(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl , bool IsRV64);
+bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector );
+
+} // namespace RISCV
+
 } // namespace llvm
 
 #endif
Index: 

[clang] 294d1ea - [RISCV] Add support for -mcpu option.

2020-07-16 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2020-07-16T11:46:22-07:00
New Revision: 294d1eae75bf8867821a4491f0d67445227f8470

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

LOG: [RISCV] Add support for -mcpu option.

Summary:
1. gcc uses `-march` and `-mtune` flag to chose arch and
pipeline model, but clang does not have `-mtune` flag,
we uses `-mcpu` to chose both infos.
2. Add SiFive e31 and u54 cpu which have default march
and pipeline model.
3. Specific `-mcpu` with rocket-rv[32|64] would select
pipeline model only, and use the driver's arch choosing
logic to get default arch.

Reviewers: lenary, asb, evandro, HsiangKai

Reviewed By: lenary, asb, evandro

Tags: #llvm, #clang

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

Added: 
clang/test/Driver/riscv-cpus.c
llvm/include/llvm/Support/RISCVTargetParser.def

Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/riscv-arch.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/Support/TargetParser.h
llvm/lib/Support/TargetParser.cpp
llvm/lib/Target/RISCV/RISCV.td

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 522776437cd2..4ba703c8dd1a 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -13,6 +13,7 @@
 #include "RISCV.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/TargetParser.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -166,3 +167,23 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector ,
 
   return true;
 }
+
+bool RISCV32TargetInfo::isValidCPUName(StringRef Name) const {
+  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
+   /*Is64Bit=*/false);
+}
+
+void RISCV32TargetInfo::fillValidCPUList(
+SmallVectorImpl ) const {
+  llvm::RISCV::fillValidCPUArchList(Values, false);
+}
+
+bool RISCV64TargetInfo::isValidCPUName(StringRef Name) const {
+  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
+   /*Is64Bit=*/true);
+}
+
+void RISCV64TargetInfo::fillValidCPUList(
+SmallVectorImpl ) const {
+  llvm::RISCV::fillValidCPUArchList(Values, true);
+}

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 73652b409e9c..6db526da4c59 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -24,7 +24,7 @@ namespace targets {
 // RISC-V Target
 class RISCVTargetInfo : public TargetInfo {
 protected:
-  std::string ABI;
+  std::string ABI, CPU;
   bool HasM;
   bool HasA;
   bool HasF;
@@ -44,6 +44,13 @@ class RISCVTargetInfo : public TargetInfo {
 WIntType = UnsignedInt;
   }
 
+  bool setCPU(const std::string ) override {
+if (!isValidCPUName(Name))
+  return false;
+CPU = Name;
+return true;
+  }
+
   StringRef getABI() const override { return ABI; }
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override;
@@ -97,6 +104,9 @@ class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public 
RISCVTargetInfo {
 return false;
   }
 
+  bool isValidCPUName(StringRef Name) const override;
+  void fillValidCPUList(SmallVectorImpl ) const override;
+
   void setMaxAtomicWidth() override {
 MaxAtomicPromoteWidth = 128;
 
@@ -121,6 +131,9 @@ class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public 
RISCVTargetInfo {
 return false;
   }
 
+  bool isValidCPUName(StringRef Name) const override;
+  void fillValidCPUList(SmallVectorImpl ) const override;
+
   void setMaxAtomicWidth() override {
 MaxAtomicPromoteWidth = 128;
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 80d12e5aa8da..be3f0a07b576 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -446,6 +446,19 @@ static bool getArchFeatures(const Driver , StringRef 
MArch,
   return true;
 }
 
+// Get features except standard extension feature
+void getRISCFeaturesFromMcpu(const Driver , const llvm::Triple ,
+ const llvm::opt::ArgList ,
+ const llvm::opt::Arg *A, StringRef Mcpu,
+ std::vector ) {
+  bool Is64Bit = (Triple.getArch() == llvm::Triple::riscv64);
+  llvm::RISCV::CPUKind CPUKind = llvm::RISCV::parseCPUKind(Mcpu);
+  if (!llvm::RISCV::checkCPUKind(CPUKind, Is64Bit) ||
+  !llvm::RISCV::getCPUFeaturesExceptStdExt(CPUKind, Features)) {
+D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+  }

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-07-16 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \

Do we also need to run for big endian?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467



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


[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-16 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, hubert.reinterpretcast, yusra.syeda.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On AIX, the semantic of global_dtors contains `__sterm` functions associated 
with C++ cleanup actions and user-declared `__attribute__((__destructor__))` 
functions. We will never register `__sterm` with `atexit()`, so currently 
`-fregister_global_dtors_with_atexit` does not work well on AIX. We need to 
figure out a way to handle that when we start supporting user-declared 
__attribute__((__destructor__)) functions.

Currently we `report_fatal_error` on this option temporarily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83974

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
  clang/test/Driver/cxa-atexit.cpp


Index: clang/test/Driver/cxa-atexit.cpp
===
--- clang/test/Driver/cxa-atexit.cpp
+++ clang/test/Driver/cxa-atexit.cpp
@@ -36,6 +36,7 @@
 // RUN: FileCheck --check-prefix=WITHATEXIT %s
 // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit 
-fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 // RUN: %clang -target x86_64-pc-linux-gnu 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
@@ -43,5 +44,18 @@
 // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // WITHATEXIT: -fregister-global-dtors-with-atexit
 // WITHOUTATEXIT-NOT: -fregister-global-dtors-with-atexit
Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+struct T{
+T();
+~T();
+} t;
+
+// CHECK: error in backend: register global dtors with atexit() is not 
supported on AIX yet
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1209,6 +1209,9 @@
 /// when the module is unloaded.
 void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
   if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
+if (getContext().getTargetInfo().getTriple().isOSAIX())
+  llvm::report_fatal_error(
+  "register global dtors with atexit() is not supported on AIX yet");
 DtorsUsingAtExit[Priority].push_back(Dtor);
 return;
   }


Index: clang/test/Driver/cxa-atexit.cpp
===
--- clang/test/Driver/cxa-atexit.cpp
+++ clang/test/Driver/cxa-atexit.cpp
@@ -36,6 +36,7 @@
 // RUN: FileCheck --check-prefix=WITHATEXIT %s
 // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 // RUN: %clang -target x86_64-pc-linux-gnu -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \
@@ -43,5 +44,18 @@
 // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \
 // RUN: FileCheck 

[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D83922#2156510 , @jdenny wrote:

> In D83922#2155749 , @ABataev wrote:
>
> > I would add checks for mapping of `declare target to/link` vars and checked 
> > if they work in runtime.
>
>
> There are existing codegen tests for that, and they don't seem to be affected 
> by this patch.  This patch only addresses the case where a `map` clause is 
> specified for an unused variable.  Is there another behavior this patch might 
> impact?


What I mean is the explicit mapping for `declare target to/link` variables. The 
variable is marked as declare to and then mapped. Do we have the tests for 
something like this?


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

https://reviews.llvm.org/D83922



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5385
+  if (getCodeGenOpts().hasMaybeUnusedDebugInfo() && CRD->hasDefinition())
+DI->completeUnusedClass(*CRD);
+  else if (auto *ES = D->getASTContext().getExternalSource())

dblaikie wrote:
> nickdesaulniers wrote:
> > dblaikie wrote:
> > > I think this might not work as intended if the type trips over the other 
> > > class deduplication optimizations (try manually testing with a type that 
> > > has an external VTable?) - and perhaps this codepath should use the 
> > > EmitAndRetain functionality.
> > completeUnusedClass eventually calls into CGDebugInfo::completeClass which 
> > makes use of the TypeCache.  What does it mean for a class to have "an 
> > external vtable?"  Can you give me an example?
> Here's some sample code that uses a type in the DWARF but due to the vtable 
> being external (an external vtable is one that's guaranteed to be emitted in 
> some other object file - due to the key function optimization in the Itanium 
> ABI - since all virtual functions must be defined if a type is ODR used, the 
> compiler can make a shared assumption that the vtable will only be emitted 
> with a single consistently chosen virtual function (ideally: the first 
> non-inline one) and emit the vtable only in that object and nowhere else) the 
> type is emitted as a declaration (when using "-fno-standalone-debug"):
> 
> ```
> struct t1 {
>   virtual void f1();
> };
> t1 v1;
> ```
Cool, thanks for the example.  For your example:
`clang -g -emit-llvm -S foo.cpp -o -`:
```
...
DIGlobalVariable(name: "v1"
...
DICompositeType(tag: DW_TAG_structure_type, name: "t1"
...
```
`clang -g -fno-eliminate-unused-debug-types -emit-llvm -S foo.cpp -o -`:
```
...
DIGlobalVariable(name: "v1"
...
DICompositeType(tag: DW_TAG_structure_type, name: "t1"
...
DIDerivedType(tag: DW_TAG_member, name: "_vptr$t1"
DIDerivedType(tag: DW_TAG_pointer_type
DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type"
DIBasicType(name: "int"
DISubprogram(name: "f1"
DISubroutineType
DIDerivedType(tag: DW_TAG_pointer_type
...
```
So even though `f1` was not defined, we still emit debug info for it.

Comparing the output of `llvm-dwarfdump` on `$CC -g 
-fno-eliminate-unused-debug-types -c ` for `g++` vs `clang++`; 
we're definitely producing more debug info (the vtable info).



That said, the creation of `v1` technically means that `t1` is no longer an 
"unused type."  If we comment out its creation, then compare `$CC -g 
-fno-eliminate-unused-debug-types -c ` for `g++` vs `clang++`, 
`g++` produces no debug info (That seems like a bug in `g++` to me), while 
`clang++` with this patch produces the debug info for the `CXXRecord`, and 
additional info for the vtable ptr and signature of `f1`.

I'm not sure what's expected in this case (we should at least emit the 
`DW_TAG_structure_type` for `t1`, but I'm not sure about the 
`DW_TAG_subprogram` for `f1`.  I assume that's because we've enabled 
more-than-full-debuginfo behavior? WDYT?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3825-3828
+  if (EmitDwarf &&
+  Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types,
+   options::OPT_feliminate_unused_debug_types, false))
+DebugInfoKind = codegenoptions::UnusedTypeInfo;

dblaikie wrote:
> How does GCC compose this with -gmlt, for instance? I'd suspect that the 
> desired behavior might be for -gmlt to override this -f flag? So maybe this 
> should be predicated on "if (EmitDwarf && DebugInfoKind >= 
> codegenoptions::LimitedDebugInfo && ... "?
> 
> (so if someone wants to use only -gmlt in certain parts of their build that 
> doesn't get upgraded by the presence of this -f flag)
GCC does not yet support `-gmlt`.
https://godbolt.org/z/Wrv6sK

IIUC, `-gmlt` ("minimum line tables") is meant to minimize the amount of debug 
info produced.  I'm not sure what the user expects if they simultaneous ask for 
more debug info (via `-fno-eliminate-unused-types`) and less debug info (via 
`-gmlt`).

The current behavior is that `-fno-eliminate-unused-types` "wins" out over 
`-gmlt`, resulting in the "fullest" amount of debug info being produced.  
(Would you like me to add tests for this behavior to 
clang/test/Driver/debug-options.c for this behavior?)

If we don't want that behavior, we should reconsider whether we want 
`UnusedTypeInfo` to be part of the `DebugInfoKind` "progression."  I also don't 
understand what the suggested added condition to the predicate is supposed to 
do; if `EmitDebugInfo` is set, doesn't the default value of 
`DebugInfoConstructor` (after 227db86a1b7dd6f96f7df14890fcd071bc4fe1f5, rebased 
this patch on top of) mean that we wouldn't use `UnusedTypeInfo` with `-g 
-fno-eliminate-unused-type-info?  Or am I misunderstanding the suggestion?



Comment at: clang/test/CodeGen/debug-info-unused-types.cpp:15-21

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 278557.
nickdesaulniers marked 9 inline comments as done.
nickdesaulniers added a comment.
Herald added a subscriber: dang.

- rebase on 227db86a1b7dd 
, update 
NOT checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=constructor"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class unused_class;
+enum class unused_enum_class;
+
+// NODBG-NOT: name: "unused_
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,55 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "w"
+
+// 

[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-07-16 Thread Simon Cook via Phabricator via cfe-commits
simoncook added a comment.

In D80802#2156221 , @HsiangKai wrote:

> The modification is put in D81213 .


Ah ok, missed that, thanks for pointing it out


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-16 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Overall seems fine to me, but of course, please wait to hear from Amy. 
Just some nits for the test case.




Comment at: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll:9
+; RUN:   FileCheck %s
+
+define dso_local <1 x i128> @test_vec_slq(<1 x i128> %a, <1 x i128> %b) #0 {

nit: please add a description for test purpose. 



Comment at: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll:10
+
+define dso_local <1 x i128> @test_vec_slq(<1 x i128> %a, <1 x i128> %b) #0 {
+; CHECK-LABEL: test_vec_slq:

stefanp wrote:
> nit:
> If you are going to use `#0` you can probably define `attributes #0 = { 
> nounwind }` at the bottom of this file.
nit: The test name and CHECK-LABEL should use `test_vec_vslq`



Comment at: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll:10
+
+define dso_local <1 x i128> @test_vec_slq(<1 x i128> %a, <1 x i128> %b) #0 {
+; CHECK-LABEL: test_vec_slq:

NeHuang wrote:
> stefanp wrote:
> > nit:
> > If you are going to use `#0` you can probably define `attributes #0 = { 
> > nounwind }` at the bottom of this file.
> nit: The test name and CHECK-LABEL should use `test_vec_vslq`
+1, if no specific attributes needed. please remove all the `#0` and `#1` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-16 Thread Andy Soffer via Phabricator via cfe-commits
asoffer marked an inline comment as done.
asoffer added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:93
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {

ymandel wrote:
> asoffer wrote:
> > ymandel wrote:
> > > nit: typos
> > > 
> > > The same applies to `Note`. Since this is a nullable type, can we ask 
> > > that the user check `Metadata != nullptr`?
> > I don't think I'm understanding the question. Where/when would users check 
> > for Metadata != nullptr?
> > 
> > Currently in this diff, any library construction of the Metadata field will 
> > be non-null. Users would have to explicitly pass null in if they wanted it 
> > to be null which would pretty quickly break when the generator is called, 
> > so this seems like a not-too-big foot-gun? Does that answer the question?
> Sorry, I meant code that consumes this struct. Mostly that's just 
> `translateEdits`. I realize now that `Note` is not a great example, since we 
> totally ignore it. However, it is intended as optional, so if we had the 
> code, it would be checking it for null first. Conversely, `TargetRange` and 
> `Replacement` are assumed to never be null, yet we don't set them to default 
> values here.  So, I think the first step is to decide if this is optional, 
> and (if not) the second is to consistently handle non-optional values in this 
> struct.
> 
> So, your code below would become something like:
> ```
> llvm::Any Metadata;
> if (E.Metadata != nullptr) {
>   if (auto M = E.Metadata(Result))
> Metadata = std::move(*M);
>   else
> return M.takeError();
> }
> ```
I don't see any particular reason to allow this field to take on it's null 
value. A null check could essentially avoid attaching metadata, but that's also 
what the default lambda would do here (because Any is also a nullable type).

That being said, sometimes I'm a bit UB-trigger-happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D83015: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 278555.
MaskRay edited the summary of this revision.
MaskRay removed a subscriber: gkm.
MaskRay added a comment.
Herald added subscribers: dang, emaste.

Respect -B and COMPILER_PATH


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/basic_freebsd64_tree/usr/bin/ld.bfd
  clang/test/Driver/fuse-ld.c
  clang/test/Driver/ld-path.c
  clang/test/Misc/warning-flags.c

Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (68):
+CHECK: Warnings without flags (69):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -47,6 +47,7 @@
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
 CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
+CHECK-NEXT:   warn_drv_use_ld_non_word
 CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
Index: clang/test/Driver/ld-path.c
===
--- /dev/null
+++ clang/test/Driver/ld-path.c
@@ -0,0 +1,67 @@
+/// This tests uses the PATH environment variable.
+// UNSUPPORTED: system-windows
+
+// RUN: cd %S
+
+/// If --ld-path= specifies a word (without /), -B and COMPILER_PATH are
+/// consulted to locate the linker.
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd64_tree/usr/bin %clang %s -### \
+// RUN:   -B %S/Inputs/basic_freebsd_tree/usr/bin --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+/// Then PATH is consulted.
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// BFD: Inputs/basic_freebsd_tree/usr/bin/ld.bfd
+
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GOLD
+
+// GOLD: Inputs/basic_freebsd_tree/usr/bin/ld.gold
+
+// RUN: env COMPILER_PATH= PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=not_exist \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NOT_EXIST
+
+// NOT_EXIST: error: invalid linker name in argument '--ld-path=not_exist'
+
+// RUN: %clang %s -### --ld-path= \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=EMPTY
+
+// EMPTY: error: invalid linker name in argument '--ld-path='
+
+/// If --ld-path= contains a slash, PATH is not consulted.
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=./ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NO_BFD
+
+// NO_BFD: error: invalid linker name in argument '--ld-path=./ld.bfd'
+
+/// --ld-path can specify a path.
+// RUN: %clang %s -### --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// RUN: %clang %s -### --ld-path=Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+/// --ld-path= and -fuse-ld= can be used together. --ld-path= takes precedence.
+/// -fuse-ld= can be used to specify the linker flavor.
+// RUN: %clang %s -### -Werror --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd -fuse-ld=gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD --implicit-check-not=error:
+
+/// --ld-path= respects -working-directory.
+// RUN: %clang %s -### --ld-path=usr/bin/ld.bfd -working-directory=%S/Inputs/basic_freebsd_tree \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s 

[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D83922#2155749 , @ABataev wrote:

> I would add checks for mapping of `declare target to/link` vars and checked 
> if they work in runtime.


There are existing codegen tests for that, and they don't seem to be affected 
by this patch.  This patch only addresses the case where a `map` clause is 
specified for an unused variable.  Is there another behavior this patch might 
impact?


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

https://reviews.llvm.org/D83922



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


[clang] 0afe172 - [Driver] Make -B take precedence over COMPILER_PATH

2020-07-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-16T11:27:16-07:00
New Revision: 0afe172e2ee5fb7600fb423a992dbeb884cbebd2

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

LOG: [Driver] Make -B take precedence over COMPILER_PATH

There is currently no COMPILER_PATH test. A subsequent --ld-path patch
will improve the coverage here.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index ece8222dcf24..d2b6268d5fa3 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -978,17 +978,6 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // FIXME: Handle environment options which affect driver behavior, somewhere
   // (client?). GCC_EXEC_PREFIX, LPATH, CC_PRINT_OPTIONS.
 
-  if (Optional CompilerPathValue =
-  llvm::sys::Process::GetEnv("COMPILER_PATH")) {
-StringRef CompilerPath = *CompilerPathValue;
-while (!CompilerPath.empty()) {
-  std::pair Split =
-  CompilerPath.split(llvm::sys::EnvPathSeparator);
-  PrefixDirs.push_back(std::string(Split.first));
-  CompilerPath = Split.second;
-}
-  }
-
   // We look for the driver mode option early, because the mode can affect
   // how other options are parsed.
   ParseDriverMode(ClangExecutable, ArgList.slice(1));
@@ -1106,6 +1095,16 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 A->claim();
 PrefixDirs.push_back(A->getValue(0));
   }
+  if (Optional CompilerPathValue =
+  llvm::sys::Process::GetEnv("COMPILER_PATH")) {
+StringRef CompilerPath = *CompilerPathValue;
+while (!CompilerPath.empty()) {
+  std::pair Split =
+  CompilerPath.split(llvm::sys::EnvPathSeparator);
+  PrefixDirs.push_back(std::string(Split.first));
+  CompilerPath = Split.second;
+}
+  }
   if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
 SysRoot = A->getValue();
   if (const Arg *A = Args.getLastArg(options::OPT__dyld_prefix_EQ))



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-16 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 278552.
asoffer added a comment.

Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult ) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration(0, varDecl(hasInitializer(
+  integerLiteral().bind("int")
+  .bind("decl"),
+  withMetadata(remove(statement(std::string("decl"))), makeMetadata)),
   consumer());
   T.registerMatchers();
   auto Factory = newFrontendActionFactory();
@@ -459,7 +468,7 @@
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any  = Changes[0].getMetadata();
   ASSERT_TRUE(llvm::any_isa(Metadata));
-  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+  EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 
 TEST_F(TransformerTest, MultiChange) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be requierd to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable
+// types would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult ) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83972: Modify ImportDefiniton for ObjCInterfaceDecl so that we always the ImportDeclContext one we start the definition

2020-07-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: teemperor, martong.
Herald added a subscriber: rnkovacs.

Once we start the definition of an `ObjCInterfaceDecl` we won't attempt to 
`ImportDeclContext` later on. Unlike `RecordDecl` case which uses 
`DefinitionCompleter` to force `completeDefinition` we don't seem to have a 
similar mechanism for `ObjCInterfaceDecl`.

This fix was needed due to a bug we see in LLDB expression parsing where an 
initial expression cause an `ObjCInterfaceDecl` to be defined and subsequent 
expressions during import do not call `ImportDeclContext` and we can end up in 
a situation where ivars are imported out of order and not all ivars are 
imported e.g.

  (lldb) expr chb1->hb->field2
  ObjCInterfaceDecl 0x7f9457495fe0 <>  
 HasBitfield1
  |-super ObjCInterface 0x7f9457495e78 'NSObject'
  `-ObjCIvarDecl 0x7f945749d478 <>  field2 
'unsigned int' public
`-IntegerLiteral 0x7f945749d458 <> 'int' 1

We have `field2` which is the second ivar but we are missing `field1`.

In this particular case `ASTContext::lookupFieldBitOffset(...)` assumes we have 
all ivars and they are in order to obtain the index of the ivar and we break 
this assumption. This leads eventually to bad IRGen since it has the wrong 
field offset.


https://reviews.llvm.org/D83972

Files:
  clang/lib/AST/ASTImporter.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/objc/bitfield_ivars/Makefile
  lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
  lldb/test/API/lang/objc/bitfield_ivars/main.m

Index: lldb/test/API/lang/objc/bitfield_ivars/main.m
===
--- lldb/test/API/lang/objc/bitfield_ivars/main.m
+++ lldb/test/API/lang/objc/bitfield_ivars/main.m
@@ -34,10 +34,31 @@
 
 @end
 
+@interface HasBitfield2 : NSObject {
+@public
+  unsigned int x;
+
+  unsigned field1 : 15;
+  unsigned field2 : 4;
+  unsigned field3 : 4;
+}
+@end
+
+@implementation HasBitfield2
+- (id)init {
+  return (self = [super init]);
+}
+@end
+
 int main(int argc, const char * argv[]) {
 ContainsAHasBitfield *chb = [[ContainsAHasBitfield alloc] init];
-printf("%d\n", chb->hb->field2); //% self.expect("expression -- chb->hb->field1", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 0"])
- //% self.expect("expression -- chb->hb->field2", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["= 1"]) # this must happen second
-return 0;
+HasBitfield2 *hb2 = [[HasBitfield2 alloc] init];
+
+hb2->x = 100;
+hb2->field1 = 10;
+hb2->field2 = 3;
+hb2->field3 = 4;
+
+return 0; // break here
 }
 
Index: lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
===
--- lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -1,12 +1,37 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
-
-lldbinline.MakeInlineTest(
-__file__,
-globals(),
-[
-# This is a Darwin-only failure related to incorrect expression-
-# evaluation for single-bit ObjC bitfields.
-decorators.skipUnlessDarwin,
-decorators.expectedFailureAll(
-bugnumber="rdar://problem/17990991")])
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestBitfieldIvars(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+
+@skipUnlessDarwin
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+self.expect_expr("chb->hb->field1", result_type="unsigned int", result_value="0")
+self.expect_expr("chb->hb->field2", result_type="unsigned int", result_value="1")
+
+self.expect_expr("hb2->field1", result_type="unsigned int", result_value="10")
+self.expect_expr("hb2->field2", result_type="unsigned int", result_value="3")
+self.expect_expr("hb2->field3", result_type="unsigned int", result_value="4")
+
+self.expect("frame var *hb2", substrs = [ 'x =', '100',
+ 'field1 =', '10',
+ 'field2 =', '3',
+ 'field3 =', '4'])
+
+@expectedFailureAll()
+def testExprWholeObject(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+## FIXME expression with individual bit-fields obtains correct values but not with the whole object
+self.expect("expr *hb2", substrs = [ 'x =', '100',
+ 'field1 =', '10',
+ 'field2 =', '3',
+ 'field3 =', '4'])
Index: 

[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7948-7949
+   MapFlagsArrayTy ,
+   const llvm::DenseSet  =
+   llvm::DenseSet()) const {
 // We have to process the component lists that relate with the same

ABataev wrote:
> Use `llvm::DenseSet> `.
Thanks for the suggestion.

`CanonicalDeclPtr` appears to be unusable.  The constructor 
(in `Redeclarable.h`) tries to initialize the `const ValueDecl *Ptr` member 
with the `Decl *` returned by `getCanonicalDecl`, producing a type mismatch.

I went with `CanonicalDeclPtr` instead.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9468-9469
  CurSizes, CurMapTypes, PartialStruct);
+if (!CI->capturesThis())
+  MappedVarSet.insert(CI->getCapturedVar()->getCanonicalDecl());
+else

ABataev wrote:
> I would check that we capture a variable. We may capture VLA here as well.
> I would check that we capture a variable. We may capture VLA here as well.

The `if` on line 9454 above checks for VLAs. This code is in the `else`.

Similarly, the existing implementation for `generateInfoForCapture`, which is 
called within this same `else`, doesn't protect against VLAs.  It just checks 
`capturesThis` as I'm doing there.

Have I misunderstood?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9470-9471
+  MappedVarSet.insert(CI->getCapturedVar()->getCanonicalDecl());
+else
+  MappedVarSet.insert(nullptr);
 if (CurBasePointers.empty())

ABataev wrote:
> No need to insert `nullptr` here, it is not used later.
Without this `nulltpr` insertion, many tests fail because of duplicate map 
entries.  Independently of my patch, `nulltptr` is used to indicate `this` 
capture (see the `generateInfoForCapture` implementation) .

For example:

```
struct S {
  int i;
  void foo() {
#pragma omp target map(i)
i = 5;
  }
};
```

We should have:

```
@.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 32, i64 
281474976710659]
```

Without the `nullptr` insertion, we have:

```
@.offload_maptypes = private unnamed_addr constant [4 x i64] [i64 32, i64 
281474976710659, i64 32, i64 844424930131971]
```


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

https://reviews.llvm.org/D83922



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


[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 278546.
jdenny marked 7 inline comments as done.
jdenny edited the summary of this revision.
jdenny added a comment.

Use `CanonicalDeclPtr`, as suggested.


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

https://reviews.llvm.org/D83922

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_teams_map_codegen.cpp

Index: clang/test/OpenMP/target_teams_map_codegen.cpp
===
--- clang/test/OpenMP/target_teams_map_codegen.cpp
+++ clang/test/OpenMP/target_teams_map_codegen.cpp
@@ -20,15 +20,16 @@
 #ifndef HEADER
 #define HEADER
 
+// HOST: @[[MAPTYPES_PRIVATE:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_FIRSTPRIVATE:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_REDUCTION:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_FROM:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 34]
 // HOST: @[[MAPTYPES_TO:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 33]
 // HOST: @[[MAPTYPES_ALLOC:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 32]
-// HOST: @[[MAPTYPES_ARRAY_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
-// HOST: @[[MAPTYPES_ARRAY_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 33, i64 33]
-// HOST-INT128: @[[MAPTYPES_INT128_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
-// HOST-INT128: @[[MAPTYPES_INT128_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 34, i64 34]
+// HOST: @[[MAPTYPES_ARRAY_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 35, i64 35, i64 35]
+// HOST: @[[MAPTYPES_ARRAY_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 33, i64 33, i64 33]
+// HOST-INT128: @[[MAPTYPES_INT128_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 35, i64 35, i64 35]
+// HOST-INT128: @[[MAPTYPES_INT128_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 34, i64 34, i64 34]
 //
 // CHECK: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_PRIVATE:__omp_offloading_[^"\\]*mapWithPrivate[^"\\]*]]\00"
 // CHECK: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_FIRSTPRIVATE:__omp_offloading_[^"\\]*mapWithFirstprivate[^"\\]*]]\00"
@@ -42,9 +43,7 @@
 // INT128: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_INT128_R1:__omp_offloading_[^"\\]*mapInt128[^"\\]*]]\00"
 
 // HOST: define {{.*}}mapWithPrivate
-// HOST: call {{.*}} @.[[OFFLOAD_PRIVATE]].region_id
-// HOST-NOT: offload_maptypes
-// HOST-SAME: {{$}}
+// HOST: call {{.*}} @.[[OFFLOAD_PRIVATE]].region_id{{.*}} @[[MAPTYPES_PRIVATE]]
 //
 // CHECK: define {{.*}} void @[[OFFLOAD_PRIVATE]]()
 // CHECK: call void ({{.*}}@[[OUTLINE_PRIVATE:.omp_outlined.[.0-9]*]]
Index: clang/test/OpenMP/target_map_codegen.cpp
===
--- clang/test/OpenMP/target_map_codegen.cpp
+++ clang/test/OpenMP/target_map_codegen.cpp
@@ -1307,12 +1307,26 @@
 
 #endif
 ///==///
-// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DUSE -DCK19 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefixes=CK19,CK19-64,CK19-USE
+// RUN: %clang_cc1 -DUSE -DCK19 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -DUSE -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefixes=CK19,CK19-64,CK19-USE
+// RUN: %clang_cc1 -DUSE -DCK19 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefixes=CK19,CK19-32,CK19-USE
+// RUN: %clang_cc1 -DUSE -DCK19 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -DUSE -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefixes=CK19,CK19-32,CK19-USE
+
+// RUN: %clang_cc1 -DUSE -DCK19 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 

[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-07-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev removed a reviewer: aaron.ballman.
v.g.vassilev added a comment.



>> Also, I would like to add that the current test present in this diff does 
>> not fail in the existing system but it was the best I and Vassil could come 
>> up with to replicate our problem.
> 
> Is there a way to run something like creduce to come up with a test case that 
> does replicate the issue? I'd like to ensure we have a test case that fails 
> without the patch applied so that we can be sure we don't regress the 
> behavior.

Not easily. That bug comes from internal infrastructure which uses clang's API 
and happens when calling directly the mangler. Running creduce would require 
failure to be reproducible with bare clang. I was hoping @rsmith had something 
up his sleeve.


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

https://reviews.llvm.org/D83174



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


[PATCH] D83959: Fix compiling warnings in OpenMP declare mapper codegen

2020-07-16 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

Thanks George!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83959



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


[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-16 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14156
+
+  // This transformation is only valid if the we are loading either a byte,
+  // halfword, word, or doubleword.

nit: if we are loading either a byte



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:29
+   [SDNPHasChain, SDNPMayLoad]>;
+
+

nit: one space is enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502



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


[PATCH] D83970: [ASTImporter] Refactor ASTImporter to support custom downstream tests

2020-07-16 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added a reviewer: martong.
Herald added subscribers: cfe-commits, teemperor, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

The purpose of this change is to do a small refactoring of code in
ASTImporterTest.cpp by moving it to ASTImporterFixtures.h in order to
support tests of downstream custom types and minimize the "living
downstream burden" of frequent integrations from community to a
downstream repo that implements custom AST import tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83970

Files:
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -18,7 +18,6 @@
 #include "gtest/gtest.h"
 
 #include "ASTImporterFixtures.h"
-#include "MatchVerifier.h"
 
 namespace clang {
 namespace ast_matchers {
@@ -27,230 +26,6 @@
 using internal::BindableMatcher;
 using llvm::StringMap;
 
-// Base class for those tests which use the family of `testImport` functions.
-class TestImportBase
-: public CompilerOptionSpecificTest,
-  public ::testing::WithParamInterface> {
-
-  template 
-  llvm::Expected importNode(ASTUnit *From, ASTUnit *To,
-  ASTImporter , NodeType Node) {
-ASTContext  = To->getASTContext();
-
-// Add 'From' file to virtual file system so importer can 'find' it
-// while importing SourceLocations. It is safe to add same file multiple
-// times - it just isn't replaced.
-StringRef FromFileName = From->getMainFileName();
-createVirtualFileIfNeeded(To, FromFileName,
-  From->getBufferForFile(FromFileName));
-
-auto Imported = Importer.Import(Node);
-
-if (Imported) {
-  // This should dump source locations and assert if some source locations
-  // were not imported.
-  SmallString<1024> ImportChecker;
-  llvm::raw_svector_ostream ToNothing(ImportChecker);
-  ToCtx.getTranslationUnitDecl()->print(ToNothing);
-
-  // This traverses the AST to catch certain bugs like poorly or not
-  // implemented subtrees.
-  (*Imported)->dump(ToNothing);
-}
-
-return Imported;
-  }
-
-  template 
-  testing::AssertionResult
-  testImport(const std::string ,
- const std::vector ,
- const std::string , const std::vector ,
- MatchVerifier ,
- const BindableMatcher ,
- const BindableMatcher ) {
-const char *const InputFileName = "input.cc";
-const char *const OutputFileName = "output.cc";
-
-std::unique_ptr FromAST = tooling::buildASTFromCodeWithArgs(
- FromCode, FromArgs, InputFileName),
- ToAST = tooling::buildASTFromCodeWithArgs(
- ToCode, ToArgs, OutputFileName);
-
-ASTContext  = FromAST->getASTContext(),
-= ToAST->getASTContext();
-
-ASTImporter Importer(ToCtx, ToAST->getFileManager(), FromCtx,
- FromAST->getFileManager(), false);
-
-auto FoundNodes = match(SearchMatcher, FromCtx);
-if (FoundNodes.size() != 1)
-  return testing::AssertionFailure()
- << "Multiple potential nodes were found!";
-
-auto ToImport = selectFirst(DeclToImportID, FoundNodes);
-if (!ToImport)
-  return testing::AssertionFailure() << "Node type mismatch!";
-
-// Sanity check: the node being imported should match in the same way as
-// the result node.
-BindableMatcher WrapperMatcher(VerificationMatcher);
-EXPECT_TRUE(Verifier.match(ToImport, WrapperMatcher));
-
-auto Imported = importNode(FromAST.get(), ToAST.get(), Importer, ToImport);
-if (!Imported) {
-  std::string ErrorText;
-  handleAllErrors(
-  Imported.takeError(),
-  [](const ImportError ) { ErrorText = Err.message(); });
-  return testing::AssertionFailure()
- << "Import failed, error: \"" << ErrorText << "\"!";
-}
-
-return Verifier.match(*Imported, WrapperMatcher);
-  }
-
-  template 
-  testing::AssertionResult
-  testImport(const std::string ,
- const std::vector ,
- const std::string , const std::vector ,
- MatchVerifier ,
- const BindableMatcher ) {
-return testImport(
-FromCode, FromArgs, ToCode, ToArgs, Verifier,
-translationUnitDecl(
-has(namedDecl(hasName(DeclToImportID)).bind(DeclToImportID))),
-VerificationMatcher);
-  }
-
-protected:
-  std::vector getExtraArgs() const override { return GetParam(); }
-
-public:
-
-  /// Test how AST node named "declToImport" located in the translation unit
-  /// of "FromCode" virtual file is imported to "ToCode" virtual file.
-  

[PATCH] D83959: Fix compiling warnings in OpenMP declare mapper codegen

2020-07-16 Thread George Rokos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc47c0e0a6a2: [clang] Fix compilation warnings in OpenMP 
declare mapper codegen. (authored by grokos).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83959

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8008,12 +8008,12 @@
 C->isImplicit(), std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_to, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), 
std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_from, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), 
std::get<2>(L));
   }
@@ -8029,7 +8029,7 @@
 
 for (const auto *C :
  CurExecDir->getClausesOfKind()) {
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 OMPClauseMappableExprCommon::MappableExprComponentListRef Components =
 std::get<1>(L);
 assert(!Components.empty() &&


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8008,12 +8008,12 @@
 C->isImplicit(), std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_to, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_from, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), std::get<2>(L));
   }
@@ -8029,7 +8029,7 @@
 
 for (const auto *C :
  CurExecDir->getClausesOfKind()) {
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 OMPClauseMappableExprCommon::MappableExprComponentListRef Components =
 std::get<1>(L);
 assert(!Components.empty() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fc47c0e - [clang] Fix compilation warnings in OpenMP declare mapper codegen.

2020-07-16 Thread George Rokos via cfe-commits

Author: George Rokos
Date: 2020-07-16T11:04:12-07:00
New Revision: fc47c0e0a6a2681154efa9d31b8605fc91a62daa

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

LOG: [clang] Fix compilation warnings in OpenMP declare mapper codegen.

This patch fixes the compilation warnings that L is not a reference.
Thanks to Lingda Li for providing the patch.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 4fecd89d2bc5..89f403f2c82f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8008,12 +8008,12 @@ class MappableExprsHandler {
 C->isImplicit(), std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_to, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), 
std::get<2>(L));
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_from, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit(), 
std::get<2>(L));
   }
@@ -8029,7 +8029,7 @@ class MappableExprsHandler {
 
 for (const auto *C :
  CurExecDir->getClausesOfKind()) {
-  for (const auto  : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 OMPClauseMappableExprCommon::MappableExprComponentListRef Components =
 std::get<1>(L);
 assert(!Components.empty() &&



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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-16 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

The description includes `... however it is more preferable to use bitcast`. It 
is not a question of preference but of correctness. The fp to int conversions 
truncate while bitcasts don't. The semantics of the builtins require that no 
truncation happen.

Also, please include checks in SemaChecking for:

- Third argument being constant
- Third argument being within range
- Second argument having the same type as the element type of the first




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14275
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI &&
+   "Third Arg to vinsw/vinsd intrinsic must be a constant integer!");

Where is the code that ensures this? There does not appear to be a Sema check 
to emit a meaningful message for this. We also need a test with a non-constant 
argument to show the message.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14278
+llvm::Type *ResultType = ConvertType(E->getType());
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_altivec_vinsw);
+int64_t ConstArg = ArgCI->getSExtValue();

I don't think we should be creating the declaration if we may not use it. Just 
initialize this to `nullptr` here and set it for each case.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14307
+  // Perform additional handling if the second argument is a double.
+  if (Ops[1]->getType()->isDoubleTy()) {
+Ops[0] = Builder.CreateBitCast(Ops[0],

Please change this to a negative condition (i.e. if the type is **not** `i64`). 
Similarly in other similar conditions.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14319
+  }
+  case PPC::BI__builtin_altivec_vec_replace_unaligned: {
+// The third argument of vec_replace_unaligned must be a compile time

Can we reorganize this as something like:
```
case PPC::BI__builtin_altivec_vec_replace_elt:
case PPC::BI__builtin_altivec_vec_replace_unaligned: {
  // Define variables that are needed
  unsigned ArgWidth = Ops[1]->getType()->getPrimitiveSizeInBits();
  if (BuiltinID == PPC::BI__builtin_altivec_vec_replace_elt)
ConstArg *= ArgWidth / 8;
  assert((ArgWidth == 32 || ArgWidth == 64) && "Invalid argument width");
  if (ArgWidth == 32) {
// set up what is needed for vinsw
  } else {
// set up what is needed for vinsd
  }
  // Emit the call
  if (BuiltinID == PPC::BI__builtin_altivec_vec_replace_elt)
// add the bitcast of the result
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500



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


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-07-16 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:433
 
-  Builder.SetInsertPoint(OuterFn->getEntryBlock().getFirstNonPHI());
-  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
-  AllocaInst *ZeroAddr = Builder.CreateAlloca(Int32, nullptr, "zero.addr");
+  IRBuilder<> AllocaBuilder(AllocaIP.getBlock(), AllocaIP.getPoint());
+

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > fghanim wrote:
> > > > Here and elsewhere: You seem to have forgotten to undo the changes 
> > > > introduced by using a separate `AllocaBuilder`?
> > > > 
> > > > Also, Nit: before using `AllocaIP`, either add an assert that it is not 
> > > > empty, or alternatively, add logic to just set it to entry block of 
> > > > `outerfn` if it is
> > > > Here and elsewhere: You seem to have forgotten to undo the changes 
> > > > introduced by using a separate AllocaBuilder?
> > > 
> > > I don't get this. These changes are on purpose. 
> > Oh, my bad. I assumed that since we now pass `allocaip` to communicate 
> > where is the insertion point, using `builder` the way we used to is 
> > sufficient, and this was leftover code. So now what purpose does 
> > `AllocaBuilder` serve?
> 1) No switching the IP back and forth in one builder all the time.
> 2) Showing by the name of the builder directly where the instructions will be 
> created.
>No switching the IP back and forth in one builder all the time.
- Is this about something you expect in the future? because unless I am missing 
something, and looking at it side by side, I don't see any less setting 
/reseting of IPs going on, except in the new version we to set the debug info 
IP in `allocabuilder` in addition to in `builder`.
- we don't use either `AllocaIP` after returning from `bodyCB`
- Even if we did, both `bodyCB`, and `FiniCB` have IPGuards inside them.
- Also, since IRBuilders do `insertbefore` an IP, both `AllocaIP` should be 
up-to-date except if the iterator for an IP gets invalidated, the risk of which 
is sort of proportional to increase in number of IRbuilders.

>Showing by the name of the builder directly where the instructions will be 
>created.
Wouldn't a comment be better? 
Personally, I find it confusing when something called `AllocaBuilder`, is being 
used to emit loads and stores.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

2020-07-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/StmtPrinter.cpp:1159
+  case BuiltinType::UInt128:
+OS << "Ui128";
+break;

davidstone wrote:
> aaron.ballman wrote:
> > riccibruno wrote:
> > > riccibruno wrote:
> > > > davidstone wrote:
> > > > > riccibruno wrote:
> > > > > > `i128` and `Ui128` are not valid integer literal suffix. The output 
> > > > > > of `StmtPrinter` is intended to be valid C++. Unfortunately here I 
> > > > > > think that your only choice is to print the high and low parts 
> > > > > > separately. 
> > > > > I'm confused. i8, Ui8, i16, and Ui16 are also not valid C++ suffixes, 
> > > > > but just a few lines up we use those. What am I missing here?
> > > > The literal suffixes `[u]i8, [u]i16, [u]i32, and [u]i64` are an MSVC 
> > > > extension (see `NumericLiteralParser::NumericLiteralParser` in 
> > > > `Lex/LiteralSupport.cpp`).
> > > > 
> > > > This does not explain why they are used even in non-ms compatibility 
> > > > mode
> > > > but at least there is some reason for their existence.
> > > > 
> > > > However I don't think that MSVC supports 128-bits integers (?), and 
> > > > clang certainly
> > > > does not support `[u]i128` so there is no reason to use them.
> > > > 
> > > > @aaron.ballman Do you know why are these suffixes used outside of 
> > > > ms-compatibility mode?
> > > > This does not explain why they are used even in non-ms compatibility 
> > > > mode
> > > > but at least there is some reason for their existence.
> > > 
> > > Let's just ask the author @majnemer 
> > > @aaron.ballman Do you know why are these suffixes used outside of 
> > > ms-compatibility mode?
> > 
> > Our pretty printing is *supposed* to generate valid code, but we get it 
> > wrong fairly often and I don't think we've ever promised (let alone tested) 
> > that you can use this output to compile code (and get the same results). I 
> > think that's more of a stretch goal. That said, the pretty printer should 
> > probably be looking at the language options to decide whether it wants to 
> > output those suffixes or not.
> > 
> > As for historical context, I think the thread starting here is relevant: 
> > http://lists.llvm.org/pipermail/cfe-dev/2012-September/024423.html
> So what is the next step for this patch?
> So what is the next step for this patch?

I don't think we should print any suffix for these, similar to how we handle 
`int`. There is no 128-bit suffix we support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82880



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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-07-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D83174#2155143 , @gargvaibhav64 
wrote:

> The tests weren't failing for me. So, we are possibly missing test coverage. 
> I have made the change now.


Thanks for making the change.

> Also, I would like to add that the current test present in this diff does not 
> fail in the existing system but it was the best I and Vassil could come up 
> with to replicate our problem.

Is there a way to run something like creduce to come up with a test case that 
does replicate the issue? I'd like to ensure we have a test case that fails 
without the patch applied so that we can be sure we don't regress the behavior.


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

https://reviews.llvm.org/D83174



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


[PATCH] D83915: [PowerPC] Remove QPX/A2Q BGQ/BGP support

2020-07-16 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D83915#2155650 , 
@hubert.reinterpretcast wrote:

> Should we indicate planned removal in the Release Notes for version 11 and 
> actual removal in those for version 12?


Good suggestion. https://reviews.llvm.org/D83968 for adding the section in 
master, will add conent in v11 branch if approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83915



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


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-16 Thread David Van Cleve via Phabricator via cfe-commits
davidvancleve added a comment.

Super! Once we pull in that version (unsure of the latency; this is my first 
time reporting an issue with clangd), I'll be sure to come back and confirm 
that the fix is working for me. Thank you again for the quick turnaround!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

https://bugs.llvm.org/show_bug.cgi?id=46754 to get the fixed merged


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83099#2155900 , @davidvancleve 
wrote:

> Yes, these two are exactly the case!
>
> > - you'd be using an editor/plugin that sends compile commands over LSP 
> > (such as YCM + ycm_extra_conf). What are you using?
> > - there should be relatively few *.idx files inside the extra directories 
> > (the ones not near your compilation database), corresponding to files 
> > you've had open rather than the whole project


Well, that's a relief :-)
46c921003c2ce5f1cdc4de9ef613eb001980780c 
 should 
fix this then, and we'll get it cherrypicked to the release branch.
Please let us know if you see this again after that commit!

> I'm using YCM. We only had /.clangd/ in our gitignore, which AIUI would have 
> only been ignoring a clangd at the level of the project root; I certainly 
> never noticed any .clangd folders in subdirectories.

Yeah, the leading slash shoud do that... I'm stumped then, but I'm also fairly 
confident this is fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83942: [analyzer][tests] Add a notion of project sizes

2020-07-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> Sizes assigned to the projects in this commit, do not directly
>  correspond to the number of lines or files in the project.

Maybe `QUICK`/`NORMAL`/`SLOW` then? Or by purpose: 
`BENCHMARK`/`DAILY`/`PARANOID`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83942



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


[PATCH] D83961: [Analyzer] Fix bug report source locations in minimal output.

2020-07-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> These will be updated if the code change looks good.

Hard to tell; this entire code is too convoluted, i'd rather look at the 
changes. Can you update at least some tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83961



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


[PATCH] D83966: Enable the test for hasArraySize() in all language modes

2020-07-16 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In C++11 and later Clang generates an implicit conversion from int to
size_t in the AST.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83966

Files:
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -3219,13 +3219,13 @@
 }
 
 TEST_P(ASTMatchersTest, HasArraySize) {
-  if (GetParam().Language != Lang_CXX03) {
-// FIXME: Fix this test to work in all C++ language modes.
+  if (!GetParam().isCXX()) {
 return;
   }
 
   EXPECT_TRUE(matches("struct MyClass {}; MyClass *p1 = new MyClass[10];",
-  cxxNewExpr(hasArraySize(integerLiteral(equals(10));
+  cxxNewExpr(hasArraySize(
+  
ignoringParenImpCasts(integerLiteral(equals(10)));
 }
 
 TEST_P(ASTMatchersTest, HasDefinition_MatchesStructDefinition) {


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -3219,13 +3219,13 @@
 }
 
 TEST_P(ASTMatchersTest, HasArraySize) {
-  if (GetParam().Language != Lang_CXX03) {
-// FIXME: Fix this test to work in all C++ language modes.
+  if (!GetParam().isCXX()) {
 return;
   }
 
   EXPECT_TRUE(matches("struct MyClass {}; MyClass *p1 = new MyClass[10];",
-  cxxNewExpr(hasArraySize(integerLiteral(equals(10));
+  cxxNewExpr(hasArraySize(
+  ignoringParenImpCasts(integerLiteral(equals(10)));
 }
 
 TEST_P(ASTMatchersTest, HasDefinition_MatchesStructDefinition) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:17
+
+#define GET_CALLER_PC() __builtin_return_address(0)
+

Nit: Let's move this down with the other defines.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:30
+
+#include  // for dlsym()
+

Nit:  Can we move the other includes down by this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-07-16 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D80802#2155432 , @simoncook wrote:

> Since this patch replaces 0.8 support with 0.9, it should include an update 
> to the version check in `clang/lib/Driver/ToolChains/Arch/RISCV.cpp` to match.


The modification is put in D81213 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-16 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:53
+int fuzzer_inited = 0;
+bool fuzzer_init_is_running;
+

These are in the global namespace, and have C mangling, which is unnecessary.  
Please either put them in a namespace or make them static.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:55
+
+static void __fuzzer_init();
+

This also doesn't need C mangling.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:63
+}  
\
+  } while (0)
+

Let's prefer a function rather than a macro for this.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:143
+return;
+  fuzzer_init_is_running = 1;
+

Let's use true/false rather than 1/0 for bools.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D83868: Use TestClangConfig in AST Matchers tests and run them in more configurations

2020-07-16 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f244c4b42b0: Use TestClangConfig in AST Matchers tests and 
run them in more configurations (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83868

Files:
  clang/include/clang/Testing/TestClangConfig.h
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h

Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -183,11 +183,6 @@
   "input.c");
 }
 
-template 
-testing::AssertionResult notMatchesC(const Twine , const T ) {
-  return matchesConditionally(Code, AMatcher, false, {Lang_C89});
-}
-
 template 
 testing::AssertionResult notMatchesObjC(const Twine , const T ) {
   return matchesObjC(Code, AMatcher, false);
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -18,7 +18,7 @@
 namespace clang {
 namespace ast_matchers {
 
-TEST(IsExpandedFromMacro, ShouldMatchInFile) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesInFile) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 void Test() { MY_MACRO(4); }
@@ -26,7 +26,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchNested) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesNested) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define WRAPPER(a) MY_MACRO(a)
@@ -35,7 +35,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesIntermediate) {
   StringRef input = R"cc(
 #define IMPL(a) (4 + (a))
 #define MY_MACRO(a) IMPL(a)
@@ -45,7 +45,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesTransitive) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define WRAPPER(a) MY_MACRO(a)
@@ -54,7 +54,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("WRAPPER";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchArgument) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesArgument) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 void Test() {
@@ -65,9 +65,9 @@
   EXPECT_TRUE(matches(input, declRefExpr(isExpandedFromMacro("MY_MACRO";
 }
 
-// Like IsExpandedFromMacroShouldMatchArgumentMacro, but the argument is itself
-// a macro.
-TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
+// Like IsExpandedFromMacro_MatchesArgument, but the argument is itself a
+// macro.
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesArgumentMacroExpansion) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define IDENTITY(a) (a)
@@ -78,7 +78,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("IDENTITY";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesWhenInArgument) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define IDENTITY(a) (a)
@@ -89,7 +89,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesObjectMacro) {
   StringRef input = R"cc(
 #define PLUS (2 + 2)
 void Test() {
@@ -99,7 +99,7 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+TEST(IsExpandedFromMacro, MatchesFromCommandLine) {
   StringRef input = R"cc(
 void Test() { FOUR_PLUS_FOUR; }
   )cc";
@@ -108,7 +108,7 @@
   {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
 }
 
-TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_NotMatchesBeginOnly) {
   StringRef input = R"cc(
 #define ONE_PLUS 1+
   void Test() { ONE_PLUS 4; }
@@ -117,7 +117,7 @@
   notMatches(input, binaryOperator(isExpandedFromMacro("ONE_PLUS";
 }
 
-TEST(IsExpandedFromMacro, ShouldNotMatchEndOnly) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_NotMatchesEndOnly) {
   StringRef input = R"cc(
 #define PLUS_ONE +1
   void Test() { 4 PLUS_ONE; }
@@ -126,7 +126,7 @@
   notMatches(input, binaryOperator(isExpandedFromMacro("PLUS_ONE";
 }
 
-TEST(IsExpandedFromMacro, ShouldNotMatchDifferentMacro) {
+TEST_P(ASTMatchersTest, 

[clang] 4f244c4 - Use TestClangConfig in AST Matchers tests and run them in more configurations

2020-07-16 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-16T18:36:53+02:00
New Revision: 4f244c4b42b096a55f2e7f719e1101c6fd26c034

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

LOG: Use TestClangConfig in AST Matchers tests and run them in more 
configurations

Summary:
I am changing tests for AST Matchers to run in multiple language standards
versions, and under multiple triples that have different behavior with regards
to templates. This change is similar to https://reviews.llvm.org/D82179.

To keep the size of the patch manageable, in this patch I'm only migrating one
file to get the process started and get feedback on this approach.

Reviewers: ymandel

Reviewed By: ymandel

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Testing/TestClangConfig.h
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h

Removed: 




diff  --git a/clang/include/clang/Testing/TestClangConfig.h 
b/clang/include/clang/Testing/TestClangConfig.h
index eefa36dc2ebb..5d6be4f65d0a 100644
--- a/clang/include/clang/Testing/TestClangConfig.h
+++ b/clang/include/clang/Testing/TestClangConfig.h
@@ -51,6 +51,8 @@ struct TestClangConfig {
 return Language == Lang_CXX17 || Language == Lang_CXX20;
   }
 
+  bool isCXX20OrLater() const { return Language == Lang_CXX20; }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index c249410201ba..36e92c632c03 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -18,7 +18,7 @@
 namespace clang {
 namespace ast_matchers {
 
-TEST(IsExpandedFromMacro, ShouldMatchInFile) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesInFile) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 void Test() { MY_MACRO(4); }
@@ -26,7 +26,7 @@ TEST(IsExpandedFromMacro, ShouldMatchInFile) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchNested) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesNested) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define WRAPPER(a) MY_MACRO(a)
@@ -35,7 +35,7 @@ TEST(IsExpandedFromMacro, ShouldMatchNested) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesIntermediate) {
   StringRef input = R"cc(
 #define IMPL(a) (4 + (a))
 #define MY_MACRO(a) IMPL(a)
@@ -45,7 +45,7 @@ TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesTransitive) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define WRAPPER(a) MY_MACRO(a)
@@ -54,7 +54,7 @@ TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("WRAPPER";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchArgument) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesArgument) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 void Test() {
@@ -65,9 +65,9 @@ TEST(IsExpandedFromMacro, ShouldMatchArgument) {
   EXPECT_TRUE(matches(input, declRefExpr(isExpandedFromMacro("MY_MACRO";
 }
 
-// Like IsExpandedFromMacroShouldMatchArgumentMacro, but the argument is itself
-// a macro.
-TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
+// Like IsExpandedFromMacro_MatchesArgument, but the argument is itself a
+// macro.
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesArgumentMacroExpansion) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define IDENTITY(a) (a)
@@ -78,7 +78,7 @@ TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("IDENTITY";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesWhenInArgument) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
 #define IDENTITY(a) (a)
@@ -89,7 +89,7 @@ TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
 }
 
-TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
+TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesObjectMacro) {
   StringRef input = 

  1   2   >